1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _HELPPOPUPWINDOW_HXX_
21 #define _HELPPOPUPWINDOW_HXX_
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
25 #include <osl/mutex.hxx>
27 #define WIN32_LEAN_AND_MEAN
29 #pragma warning(push, 1)
36 //---------------------------------------------
38 //---------------------------------------------
41 A simple popup window similary to the one the
42 windows help (using WinHelp) creates when called
43 with the option HELP_CONTEXTPOPUP.
45 The interface is very simple but necessary for our
47 The window automaticaly calculates the necessary
48 dimensions of the window and a appropriate show
49 position based on the position the client provides.
50 When the user click any mouse button or hits any key
51 the window closes itself and disappears.
54 class CHelpPopupWindow
59 The client may set some parameter of the window.
60 When the client omits to set one or more values
61 a default value will be taken.
62 The values are in pixel.
74 The client may set the text the window is showing
77 void SAL_CALL
setText( const OUString
& aHelpText
);
80 Shows the window with the text that was last set.
81 The posistion is the prefered position. The window
82 may itself show at a slightly different position
83 if it fits not at the prefered position.
85 void SAL_CALL
show( sal_Int32 x
, sal_Int32 y
);
87 HWND SAL_CALL
setParent( HWND hwndNewParent
);
90 void SAL_CALL
onPaint( HWND
, HDC
);
91 void SAL_CALL
onNcDestroy();
92 void SAL_CALL
onCreate( HWND
);
94 POINT SAL_CALL
calcUpperLeftCorner( );
95 void SAL_CALL
calcWindowRect( LPRECT lprect
);
97 void SAL_CALL
adjustWindowSize( sal_Int32
*, sal_Int32
* );
98 void SAL_CALL
adjustWindowPos( sal_Int32 x
, sal_Int32 y
, sal_Int32 cx
, sal_Int32 cy
);
100 ATOM SAL_CALL
RegisterWindowClass( );
101 void SAL_CALL
UnregisterWindowClass( );
103 static LRESULT CALLBACK
WndProc( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
106 sal_Int32 m_hMargins
;
107 sal_Int32 m_vMargins
;
108 sal_Int32 m_avCharWidth
;
109 sal_Int32 m_avCharHeight
;
112 HINSTANCE m_hInstance
;
113 sal_Bool m_bWndClassRegistered
;
115 HBITMAP m_hBitmapShadow
;
116 HBRUSH m_hBrushShadow
;
118 // the window class has to be registered only
119 // once per process, so multiple instance of this class
120 // share the registered window class
121 static ATOM s_ClassAtom
;
122 static osl::Mutex s_Mutex
;
123 static sal_Int32 s_RegisterWndClassCount
;
125 // prevent copy and assignment
127 CHelpPopupWindow( const CHelpPopupWindow
& );
128 CHelpPopupWindow
& operator=( const CHelpPopupWindow
& );
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */