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