1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _HELPPOPUPWINDOW_HXX_ 29*cdf0e10cSrcweir #define _HELPPOPUPWINDOW_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //------------------------------------------------------------------------ 32*cdf0e10cSrcweir // includes 33*cdf0e10cSrcweir //------------------------------------------------------------------------ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <sal/types.h> 36*cdf0e10cSrcweir #include <rtl/ustring.hxx> 37*cdf0e10cSrcweir #include <osl/mutex.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #define WIN32_LEAN_AND_MEAN 40*cdf0e10cSrcweir #if defined _MSC_VER 41*cdf0e10cSrcweir #pragma warning(push, 1) 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #include <windows.h> 44*cdf0e10cSrcweir #if defined _MSC_VER 45*cdf0e10cSrcweir #pragma warning(pop) 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir //--------------------------------------------- 49*cdf0e10cSrcweir // declaration 50*cdf0e10cSrcweir //--------------------------------------------- 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir /* 53*cdf0e10cSrcweir A simple popup window similary to the one the 54*cdf0e10cSrcweir windows help (using WinHelp) creates when called 55*cdf0e10cSrcweir with the option HELP_CONTEXTPOPUP. 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir The interface is very simple but necessary for our 58*cdf0e10cSrcweir needs. 59*cdf0e10cSrcweir The window automaticaly calculates the necessary 60*cdf0e10cSrcweir dimensions of the window and a appropriate show 61*cdf0e10cSrcweir position based on the position the client provides. 62*cdf0e10cSrcweir When the user click any mouse button or hits any key 63*cdf0e10cSrcweir the window closes itself and disappears. 64*cdf0e10cSrcweir */ 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir class CHelpPopupWindow 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir public: 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir /* 71*cdf0e10cSrcweir The client may set some parameter of the window. 72*cdf0e10cSrcweir When the client omits to set one or more values 73*cdf0e10cSrcweir a default value will be taken. 74*cdf0e10cSrcweir The values are in pixel. 75*cdf0e10cSrcweir */ 76*cdf0e10cSrcweir CHelpPopupWindow( 77*cdf0e10cSrcweir HINSTANCE hInstance, 78*cdf0e10cSrcweir HWND hwndParent ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir /* 81*cdf0e10cSrcweir dtor 82*cdf0e10cSrcweir */ 83*cdf0e10cSrcweir ~CHelpPopupWindow( ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir /* 86*cdf0e10cSrcweir The client may set the text the window is showing 87*cdf0e10cSrcweir on next activation. 88*cdf0e10cSrcweir */ 89*cdf0e10cSrcweir void SAL_CALL setText( const rtl::OUString& aHelpText ); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /* 92*cdf0e10cSrcweir Shows the window with the text that was last set. 93*cdf0e10cSrcweir The posistion is the prefered position. The window 94*cdf0e10cSrcweir may itself show at a slightly different position 95*cdf0e10cSrcweir if it fits not at the prefered position. 96*cdf0e10cSrcweir */ 97*cdf0e10cSrcweir void SAL_CALL show( sal_Int32 x, sal_Int32 y ); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir HWND SAL_CALL setParent( HWND hwndNewParent ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir private: 102*cdf0e10cSrcweir void SAL_CALL onPaint( HWND, HDC ); 103*cdf0e10cSrcweir void SAL_CALL onNcDestroy(); 104*cdf0e10cSrcweir void SAL_CALL onCreate( HWND ); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir POINT SAL_CALL calcUpperLeftCorner( ); 107*cdf0e10cSrcweir void SAL_CALL calcWindowRect( LPRECT lprect ); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir void SAL_CALL adjustWindowSize( sal_Int32*, sal_Int32* ); 110*cdf0e10cSrcweir void SAL_CALL adjustWindowPos( sal_Int32 x, sal_Int32 y, sal_Int32 cx, sal_Int32 cy ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir ATOM SAL_CALL RegisterWindowClass( ); 113*cdf0e10cSrcweir void SAL_CALL UnregisterWindowClass( ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir private: 118*cdf0e10cSrcweir sal_Int32 m_hMargins; 119*cdf0e10cSrcweir sal_Int32 m_vMargins; 120*cdf0e10cSrcweir sal_Int32 m_avCharWidth; 121*cdf0e10cSrcweir sal_Int32 m_avCharHeight; 122*cdf0e10cSrcweir HWND m_hwnd; 123*cdf0e10cSrcweir HWND m_hwndParent; 124*cdf0e10cSrcweir HINSTANCE m_hInstance; 125*cdf0e10cSrcweir sal_Bool m_bWndClassRegistered; 126*cdf0e10cSrcweir ::rtl::OUString m_HelpText; 127*cdf0e10cSrcweir HBITMAP m_hBitmapShadow; 128*cdf0e10cSrcweir HBRUSH m_hBrushShadow; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir // the window class has to be registered only 131*cdf0e10cSrcweir // once per process, so multiple instance of this class 132*cdf0e10cSrcweir // share the registered window class 133*cdf0e10cSrcweir static ATOM s_ClassAtom; 134*cdf0e10cSrcweir static osl::Mutex s_Mutex; 135*cdf0e10cSrcweir static sal_Int32 s_RegisterWndClassCount; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // prevent copy and assignment 138*cdf0e10cSrcweir private: 139*cdf0e10cSrcweir CHelpPopupWindow( const CHelpPopupWindow& ); 140*cdf0e10cSrcweir CHelpPopupWindow& operator=( const CHelpPopupWindow& ); 141*cdf0e10cSrcweir }; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir #endif 144