]> git.saurik.com Git - wxWidgets.git/blob - src/msw/popupwin.cpp
final sweep over docs - replace & with \&
[wxWidgets.git] / src / msw / popupwin.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/popupwin.cpp
3 // Purpose: implements wxPopupWindow for MSW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 08.05.02
7 // RCS-ID: $Id$
8 // Copyright: (c) 2002 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "popup.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/defs.h"
33 #endif //WX_PRECOMP
34
35 #if wxUSE_POPUPWIN
36
37 #include "wx/popupwin.h"
38
39 #include "wx/msw/private.h" // for GetDesktopWindow()
40
41 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
42
43 // ============================================================================
44 // implementation
45 // ============================================================================
46
47 bool wxPopupWindow::Create(wxWindow *parent, int flags)
48 {
49 // popup windows are created hidden by default
50 Hide();
51
52 return wxPopupWindowBase::Create(parent) &&
53 wxWindow::Create(parent, wxID_ANY,
54 wxDefaultPosition, wxDefaultSize,
55 flags | wxPOPUP_WINDOW);
56 }
57
58 void wxPopupWindow::DoGetPosition(int *x, int *y) const
59 {
60 // the position of a "top level" window such as this should be in
61 // screen coordinates, not in the client ones which MSW gives us
62 // (because we are a child window)
63 wxPopupWindowBase::DoGetPosition(x, y);
64
65 GetParent()->ClientToScreen(x, y);
66 }
67
68 WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const
69 {
70 // we only honour the border flags, the others don't make sense for us
71 WXDWORD style = wxWindow::MSWGetStyle(flags & wxBORDER_MASK, exstyle);
72
73 if ( exstyle )
74 {
75 // a popup window floats on top of everything
76 *exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
77 }
78
79 return style;
80 }
81
82 WXHWND wxPopupWindow::MSWGetParent() const
83 {
84 // we must be a child of the desktop to be able to extend beyond the parent
85 // window client area (like the comboboxes drop downs do)
86 //
87 // NB: alternative implementation would be to use WS_POPUP instead of
88 // WS_CHILD but then showing a popup would deactivate the parent which
89 // is ugly and working around this, although possible, is even more
90 // ugly
91 // GetDesktopWindow() is not always supported on WinCE, and if
92 // it is, it often returns NULL.
93 #ifdef __WXWINCE__
94 return 0;
95 #else
96 return (WXHWND)::GetDesktopWindow();
97 #endif
98 }
99
100 bool wxPopupWindow::Show(bool show)
101 {
102 if ( !wxWindowMSW::Show(show) )
103 return false;
104
105 if ( show )
106 {
107 // raise to top of z order
108 if (!::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
109 {
110 wxLogLastError(_T("SetWindowPos"));
111 }
112 }
113
114 return true;
115 }
116
117 #endif // #if wxUSE_POPUPWIN
118