]> git.saurik.com Git - wxWidgets.git/blame - src/os2/popupwin.cpp
Moved wxCharhookEvent so that it sends the same
[wxWidgets.git] / src / os2 / popupwin.cpp
CommitLineData
63ebec23
DW
1///////////////////////////////////////////////////////////////////////////////
2// Name: os2/popupwin.cpp
3// Purpose: implements wxPopupWindow for OS2
4// Author: Dave Webster
5// Modified by:
6// Created: 13.05.02
7// RCS-ID: $Id$
8// Copyright: (c) 2002 Dave Webster <dwebster@bhmi.com>
9// License: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation "popup.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27
28#ifndef WX_PRECOMP
29#endif //WX_PRECOMP
30
31#include "wx/popupwin.h"
32
6ed98c6a
DW
33wxWindowList wxPopupWindow::m_svShownPopups;
34
63ebec23
DW
35// ============================================================================
36// implementation
37// ============================================================================
38
39bool wxPopupWindow::Create(
40 wxWindow* pParent
41, int nFlags
42)
43{
44 return wxPopupWindowBase::Create(pParent) &&
45 wxWindow::Create( pParent
46 ,-1
47 ,wxDefaultPosition
48 ,wxDefaultSize
49 ,nFlags | wxPOPUP_WINDOW
50 );
51} // end of wxPopupWindow::Create
52
53void wxPopupWindow::DoGetPosition(
54 int* pnX
55, int* pnY
56) const
57{
58 //
59 // The position of a "top level" window such as this should be in
60 // screen coordinates, not in the client ones which MSW gives us
61 // (because we are a child window)
62 //
63 wxPopupWindowBase::DoGetPosition(pnX, pnY);
64 GetParent()->ClientToScreen(pnX, pnY);
65} // end of wxPopupWindow::DoGetPosition
66
67WXDWORD wxPopupWindow::OS2GetStyle(
68 long lFlags
69, WXDWORD* dwExstyle
70) const
71{
72 WXDWORD dwStyle = wxWindow::OS2GetStyle( lFlags & wxBORDER_MASK
73 ,dwExstyle
74 );
75
76 return dwStyle;
77} // end of wxPopupWindow::OS2GetStyle
78
6ed98c6a
DW
79bool wxPopupWindow::Show(
80 bool bShow
81)
82{
83 SWP vSwp;
84 //
85 // Skip wxWindow::Show() which calls wxBringWindowToTop(): this results in
86 // activating the popup window and stealing the atcivation from our parent
87 // which means that the parent frame becomes deactivated when opening a
88 // combobox, for example -- definitely not what we want
89 //
90 if (!wxWindowBase::Show(bShow))
91 return FALSE;
92
93 if (bShow)
94 {
95 m_svShownPopups.Append(this);
96 }
97 else // remove from the shown list
98 {
99 m_svShownPopups.DeleteObject(this);
100 }
101 ::WinQueryWindowPos(GetHwnd(), &vSwp);
102
103 if (bShow)
104 {
105 ::WinSetWindowPos( GetHwnd()
106 ,HWND_TOP
107 ,vSwp.x
108 ,vSwp.y
109 ,vSwp.cx
110 ,vSwp.cy
111 ,SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER
112 );
113 }
114 else
115 {
116 ::WinSetWindowPos( GetHwnd()
117 ,HWND_BOTTOM
118 ,vSwp.x
119 ,vSwp.y
120 ,vSwp.cx
121 ,vSwp.cy
122 ,SWP_HIDE | SWP_ZORDER
123 );
124 }
125 return TRUE;
126} // end of wxPopupWindow::Show
127
128/* static */
129wxPopupWindow* wxPopupWindow::FindPopupFor(
130 wxWindow* pWinParent
131)
132{
133 //
134 // Find a popup with the given parent in the linked list of all shown
135 // popups
136 //
137 for ( wxWindowList::Node *node = m_svShownPopups.GetFirst();
138 node;
139 node = node->GetNext() )
140 {
141 wxWindow* pWin = node->GetData();
142
143 if (pWin->GetParent() == pWinParent )
144 return (wxPopupWindow *)pWin;
145 }
146 return NULL;
147} // end of wxPopupWindow::FindPopupFor
148