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