]> git.saurik.com Git - wxWidgets.git/blame - src/msw/popupwin.cpp
Changed CanApplyParentThemeBackground to ApplyParentThemeBackground
[wxWidgets.git] / src / msw / popupwin.cpp
CommitLineData
e49d97e6
VZ
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>
6c9a19aa 9// License: wxWindows licence
e49d97e6
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
14f355c2 20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e49d97e6
VZ
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
37d729ed 32#include "wx/defs.h"
e49d97e6
VZ
33#endif //WX_PRECOMP
34
3080bf59
VZ
35#if wxUSE_POPUPWIN
36
e49d97e6
VZ
37#include "wx/popupwin.h"
38
24b3cc2c 39#include "wx/msw/private.h" // for GetDesktopWindow()
220c6d43 40
24b3cc2c 41IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
7e25f59e 42
e49d97e6
VZ
43// ============================================================================
44// implementation
45// ============================================================================
46
47bool wxPopupWindow::Create(wxWindow *parent, int flags)
48{
49 return wxPopupWindowBase::Create(parent) &&
50 wxWindow::Create(parent, -1,
51 wxDefaultPosition, wxDefaultSize,
52 flags | wxPOPUP_WINDOW);
53}
54
55void wxPopupWindow::DoGetPosition(int *x, int *y) const
56{
57 // the position of a "top level" window such as this should be in
58 // screen coordinates, not in the client ones which MSW gives us
59 // (because we are a child window)
60 wxPopupWindowBase::DoGetPosition(x, y);
61
62 GetParent()->ClientToScreen(x, y);
63}
64
65WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const
66{
24b3cc2c 67 // we only honour the border flags, the others don't make sense for us
e49d97e6
VZ
68 WXDWORD style = wxWindow::MSWGetStyle(flags & wxBORDER_MASK, exstyle);
69
e49d97e6
VZ
70 if ( exstyle )
71 {
72 // a popup window floats on top of everything
73 *exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
74 }
75
76 return style;
77}
78
24b3cc2c 79WXHWND wxPopupWindow::MSWGetParent() const
7e25f59e 80{
24b3cc2c
VZ
81 // we must be a child of the desktop to be able to extend beyond the parent
82 // window client area (like the comboboxes drop downs do)
83 //
84 // NB: alternative implementation would be to use WS_POPUP instead of
85 // WS_CHILD but then showing a popup would deactivate the parent which
86 // is ugly and working around this, although possible, is even more
87 // ugly
4676948b
JS
88 // GetDesktopWindow() is not always supported on WinCE, and if
89 // it is, it often returns NULL.
90#ifdef __WXWINCE__
91 return 0;
92#else
24b3cc2c 93 return (WXHWND)::GetDesktopWindow();
4676948b 94#endif
7e25f59e
VZ
95}
96
25b1b442
JS
97bool wxPopupWindow::Show(bool show)
98{
c649a6ab 99 if ( !wxWindowMSW::Show(show) )
25b1b442
JS
100 return FALSE;
101
25b1b442
JS
102 if ( show )
103 {
104 // raise to top of z order
c649a6ab 105 if (!::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
25b1b442
JS
106 {
107 wxLogLastError(_T("SetWindowPos"));
108 }
109 }
110
111 return TRUE;
112}
113
3080bf59 114#endif // #if wxUSE_POPUPWIN
25b1b442 115