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