1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _HELPPOPUPWINDOW_HXX_ 25*b1cdbd2cSJim Jagielski #define _HELPPOPUPWINDOW_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------ 28*b1cdbd2cSJim Jagielski // includes 29*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------ 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski #include <sal/types.h> 32*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx> 33*b1cdbd2cSJim Jagielski #include <osl/mutex.hxx> 34*b1cdbd2cSJim Jagielski 35*b1cdbd2cSJim Jagielski #define WIN32_LEAN_AND_MEAN 36*b1cdbd2cSJim Jagielski #if defined _MSC_VER 37*b1cdbd2cSJim Jagielski #pragma warning(push, 1) 38*b1cdbd2cSJim Jagielski #endif 39*b1cdbd2cSJim Jagielski #include <windows.h> 40*b1cdbd2cSJim Jagielski #if defined _MSC_VER 41*b1cdbd2cSJim Jagielski #pragma warning(pop) 42*b1cdbd2cSJim Jagielski #endif 43*b1cdbd2cSJim Jagielski 44*b1cdbd2cSJim Jagielski //--------------------------------------------- 45*b1cdbd2cSJim Jagielski // declaration 46*b1cdbd2cSJim Jagielski //--------------------------------------------- 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski /* 49*b1cdbd2cSJim Jagielski A simple popup window similary to the one the 50*b1cdbd2cSJim Jagielski windows help (using WinHelp) creates when called 51*b1cdbd2cSJim Jagielski with the option HELP_CONTEXTPOPUP. 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski The interface is very simple but necessary for our 54*b1cdbd2cSJim Jagielski needs. 55*b1cdbd2cSJim Jagielski The window automaticaly calculates the necessary 56*b1cdbd2cSJim Jagielski dimensions of the window and a appropriate show 57*b1cdbd2cSJim Jagielski position based on the position the client provides. 58*b1cdbd2cSJim Jagielski When the user click any mouse button or hits any key 59*b1cdbd2cSJim Jagielski the window closes itself and disappears. 60*b1cdbd2cSJim Jagielski */ 61*b1cdbd2cSJim Jagielski 62*b1cdbd2cSJim Jagielski class CHelpPopupWindow 63*b1cdbd2cSJim Jagielski { 64*b1cdbd2cSJim Jagielski public: 65*b1cdbd2cSJim Jagielski 66*b1cdbd2cSJim Jagielski /* 67*b1cdbd2cSJim Jagielski The client may set some parameter of the window. 68*b1cdbd2cSJim Jagielski When the client omits to set one or more values 69*b1cdbd2cSJim Jagielski a default value will be taken. 70*b1cdbd2cSJim Jagielski The values are in pixel. 71*b1cdbd2cSJim Jagielski */ 72*b1cdbd2cSJim Jagielski CHelpPopupWindow( 73*b1cdbd2cSJim Jagielski HINSTANCE hInstance, 74*b1cdbd2cSJim Jagielski HWND hwndParent ); 75*b1cdbd2cSJim Jagielski 76*b1cdbd2cSJim Jagielski /* 77*b1cdbd2cSJim Jagielski dtor 78*b1cdbd2cSJim Jagielski */ 79*b1cdbd2cSJim Jagielski ~CHelpPopupWindow( ); 80*b1cdbd2cSJim Jagielski 81*b1cdbd2cSJim Jagielski /* 82*b1cdbd2cSJim Jagielski The client may set the text the window is showing 83*b1cdbd2cSJim Jagielski on next activation. 84*b1cdbd2cSJim Jagielski */ 85*b1cdbd2cSJim Jagielski void SAL_CALL setText( const rtl::OUString& aHelpText ); 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski /* 88*b1cdbd2cSJim Jagielski Shows the window with the text that was last set. 89*b1cdbd2cSJim Jagielski The posistion is the prefered position. The window 90*b1cdbd2cSJim Jagielski may itself show at a slightly different position 91*b1cdbd2cSJim Jagielski if it fits not at the prefered position. 92*b1cdbd2cSJim Jagielski */ 93*b1cdbd2cSJim Jagielski void SAL_CALL show( sal_Int32 x, sal_Int32 y ); 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski HWND SAL_CALL setParent( HWND hwndNewParent ); 96*b1cdbd2cSJim Jagielski 97*b1cdbd2cSJim Jagielski private: 98*b1cdbd2cSJim Jagielski void SAL_CALL onPaint( HWND, HDC ); 99*b1cdbd2cSJim Jagielski void SAL_CALL onNcDestroy(); 100*b1cdbd2cSJim Jagielski void SAL_CALL onCreate( HWND ); 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski POINT SAL_CALL calcUpperLeftCorner( ); 103*b1cdbd2cSJim Jagielski void SAL_CALL calcWindowRect( LPRECT lprect ); 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski void SAL_CALL adjustWindowSize( sal_Int32*, sal_Int32* ); 106*b1cdbd2cSJim Jagielski void SAL_CALL adjustWindowPos( sal_Int32 x, sal_Int32 y, sal_Int32 cx, sal_Int32 cy ); 107*b1cdbd2cSJim Jagielski 108*b1cdbd2cSJim Jagielski ATOM SAL_CALL RegisterWindowClass( ); 109*b1cdbd2cSJim Jagielski void SAL_CALL UnregisterWindowClass( ); 110*b1cdbd2cSJim Jagielski 111*b1cdbd2cSJim Jagielski static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski private: 114*b1cdbd2cSJim Jagielski sal_Int32 m_hMargins; 115*b1cdbd2cSJim Jagielski sal_Int32 m_vMargins; 116*b1cdbd2cSJim Jagielski sal_Int32 m_avCharWidth; 117*b1cdbd2cSJim Jagielski sal_Int32 m_avCharHeight; 118*b1cdbd2cSJim Jagielski HWND m_hwnd; 119*b1cdbd2cSJim Jagielski HWND m_hwndParent; 120*b1cdbd2cSJim Jagielski HINSTANCE m_hInstance; 121*b1cdbd2cSJim Jagielski sal_Bool m_bWndClassRegistered; 122*b1cdbd2cSJim Jagielski ::rtl::OUString m_HelpText; 123*b1cdbd2cSJim Jagielski HBITMAP m_hBitmapShadow; 124*b1cdbd2cSJim Jagielski HBRUSH m_hBrushShadow; 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielski // the window class has to be registered only 127*b1cdbd2cSJim Jagielski // once per process, so multiple instance of this class 128*b1cdbd2cSJim Jagielski // share the registered window class 129*b1cdbd2cSJim Jagielski static ATOM s_ClassAtom; 130*b1cdbd2cSJim Jagielski static osl::Mutex s_Mutex; 131*b1cdbd2cSJim Jagielski static sal_Int32 s_RegisterWndClassCount; 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielski // prevent copy and assignment 134*b1cdbd2cSJim Jagielski private: 135*b1cdbd2cSJim Jagielski CHelpPopupWindow( const CHelpPopupWindow& ); 136*b1cdbd2cSJim Jagielski CHelpPopupWindow& operator=( const CHelpPopupWindow& ); 137*b1cdbd2cSJim Jagielski }; 138*b1cdbd2cSJim Jagielski 139*b1cdbd2cSJim Jagielski #endif 140