]> git.saurik.com Git - wxWidgets.git/blame - src/msw/popupwin.cpp
Take src x, y into account when blitting with alpha
[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>
65571936 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
e49d97e6
VZ
41// ============================================================================
42// implementation
43// ============================================================================
44
45bool wxPopupWindow::Create(wxWindow *parent, int flags)
46{
eefe6d4b
VZ
47 // popup windows are created hidden by default
48 Hide();
49
e49d97e6 50 return wxPopupWindowBase::Create(parent) &&
078cf5cb 51 wxWindow::Create(parent, wxID_ANY,
e49d97e6
VZ
52 wxDefaultPosition, wxDefaultSize,
53 flags | wxPOPUP_WINDOW);
54}
55
56void wxPopupWindow::DoGetPosition(int *x, int *y) const
57{
58 // the position of a "top level" window such as this should be in
59 // screen coordinates, not in the client ones which MSW gives us
60 // (because we are a child window)
61 wxPopupWindowBase::DoGetPosition(x, y);
62
63 GetParent()->ClientToScreen(x, y);
64}
65
66WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const
67{
24b3cc2c 68 // we only honour the border flags, the others don't make sense for us
e49d97e6
VZ
69 WXDWORD style = wxWindow::MSWGetStyle(flags & wxBORDER_MASK, exstyle);
70
e49d97e6
VZ
71 if ( exstyle )
72 {
73 // a popup window floats on top of everything
74 *exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
75 }
76
77 return style;
78}
79
24b3cc2c 80WXHWND wxPopupWindow::MSWGetParent() const
7e25f59e 81{
24b3cc2c
VZ
82 // we must be a child of the desktop to be able to extend beyond the parent
83 // window client area (like the comboboxes drop downs do)
84 //
85 // NB: alternative implementation would be to use WS_POPUP instead of
86 // WS_CHILD but then showing a popup would deactivate the parent which
87 // is ugly and working around this, although possible, is even more
88 // ugly
4676948b
JS
89 // GetDesktopWindow() is not always supported on WinCE, and if
90 // it is, it often returns NULL.
91#ifdef __WXWINCE__
92 return 0;
93#else
24b3cc2c 94 return (WXHWND)::GetDesktopWindow();
4676948b 95#endif
7e25f59e
VZ
96}
97
25b1b442
JS
98bool wxPopupWindow::Show(bool show)
99{
c649a6ab 100 if ( !wxWindowMSW::Show(show) )
078cf5cb 101 return false;
25b1b442 102
25b1b442
JS
103 if ( show )
104 {
105 // raise to top of z order
c649a6ab 106 if (!::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
25b1b442
JS
107 {
108 wxLogLastError(_T("SetWindowPos"));
109 }
82ceade7
RD
110
111 // and set it as the foreground window so the mouse can be captured
112 ::SetForegroundWindow(GetHwnd());
25b1b442
JS
113 }
114
078cf5cb 115 return true;
25b1b442
JS
116}
117
3080bf59 118#endif // #if wxUSE_POPUPWIN
25b1b442 119