]> git.saurik.com Git - wxWidgets.git/blame - include/wx/popupwin.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / popupwin.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/popupwin.h
3// Purpose: wxPopupWindow interface declaration
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 06.01.01
1e6feb95 7// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
526954c5 8// Licence: wxWindows licence
1e6feb95
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_POPUPWIN_H_BASE_
12#define _WX_POPUPWIN_H_BASE_
13
2ecf902b 14#include "wx/defs.h"
1e6feb95
VZ
15
16#if wxUSE_POPUPWIN
2ecf902b 17
42b0d8b9 18#include "wx/nonownedwnd.h"
2ecf902b 19
1e6feb95
VZ
20// ----------------------------------------------------------------------------
21// wxPopupWindow: a special kind of top level window used for popup menus,
22// combobox popups and such.
23// ----------------------------------------------------------------------------
24
53a2db12 25class WXDLLIMPEXP_CORE wxPopupWindowBase : public wxNonOwnedWindow
1e6feb95
VZ
26{
27public:
28 wxPopupWindowBase() { }
799ea011 29 virtual ~wxPopupWindowBase();
1e6feb95
VZ
30
31 // create the popup window
32 //
33 // style may only contain border flags
34 bool Create(wxWindow *parent, int style = wxBORDER_NONE);
35
36 // move the popup window to the right position, i.e. such that it is
37 // entirely visible
38 //
39 // the popup is positioned at ptOrigin + size if it opens below and to the
40 // right (default), at ptOrigin - sizePopup if it opens above and to the
41 // left &c
42 //
43 // the point must be given in screen coordinates!
44 virtual void Position(const wxPoint& ptOrigin,
45 const wxSize& size);
fc7a2a60 46
7e548f6b 47 virtual bool IsTopLevel() const { return true; }
bd507486 48
c0c133e1 49 wxDECLARE_NO_COPY_CLASS(wxPopupWindowBase);
1e6feb95
VZ
50};
51
19193a2c 52
1e6feb95 53// include the real class declaration
0872eaf9 54#if defined(__WXMSW__)
1e6feb95 55 #include "wx/msw/popupwin.h"
0872eaf9 56#elif defined(__WXPM__)
19193a2c 57 #include "wx/os2/popupwin.h"
1be7a35c 58#elif defined(__WXGTK20__)
9f41d601 59 #include "wx/gtk/popupwin.h"
1be7a35c
MR
60#elif defined(__WXGTK__)
61 #include "wx/gtk1/popupwin.h"
0872eaf9 62#elif defined(__WXX11__)
83df96d6 63 #include "wx/x11/popupwin.h"
0872eaf9 64#elif defined(__WXMOTIF__)
833a51f6 65 #include "wx/motif/popupwin.h"
42b0d8b9
VS
66#elif defined(__WXDFB__)
67 #include "wx/dfb/popupwin.h"
e4346967 68#elif defined(__WXMAC__)
ef0e9220 69 #include "wx/osx/popupwin.h"
1e6feb95
VZ
70#else
71 #error "wxPopupWindow is not supported under this platform."
72#endif
73
74// ----------------------------------------------------------------------------
75// wxPopupTransientWindow: a wxPopupWindow which disappears automatically
76// when the user clicks mouse outside it or if it loses focus in any other way
77// ----------------------------------------------------------------------------
78
b5dbe15d
VS
79class WXDLLIMPEXP_FWD_CORE wxPopupWindowHandler;
80class WXDLLIMPEXP_FWD_CORE wxPopupFocusHandler;
fbfb3fb3 81
53a2db12 82class WXDLLIMPEXP_CORE wxPopupTransientWindow : public wxPopupWindow
1e6feb95
VZ
83{
84public:
85 // ctors
86 wxPopupTransientWindow() { Init(); }
758bce95 87 wxPopupTransientWindow(wxWindow *parent, int style = wxBORDER_NONE);
1e6feb95
VZ
88
89 virtual ~wxPopupTransientWindow();
90
91 // popup the window (this will show it too) and keep focus at winFocus
92 // (or itself if it's NULL), dismiss the popup if we lose focus
93 virtual void Popup(wxWindow *focus = NULL);
94
95 // hide the window
96 virtual void Dismiss();
ea1ad04b 97
7e25f59e
VZ
98 // can the window be dismissed now?
99 //
100 // VZ: where is this used??
ea1ad04b 101 virtual bool CanDismiss()
7e548f6b 102 { return true; }
1e6feb95 103
7e548f6b 104 // called when a mouse is pressed while the popup is shown: return true
1e6feb95 105 // from here to prevent its normal processing by the popup (which consists
6d090da1 106 // in dismissing it if the mouse is clicked outside it)
1e6feb95
VZ
107 virtual bool ProcessLeftDown(wxMouseEvent& event);
108
537a0880
RR
109 // Overridden to grab the input on some plaforms
110 virtual bool Show( bool show = true );
2ecf902b 111
f9e19204
VZ
112 // Override to implement delayed destruction of this window.
113 virtual bool Destroy();
114
1e6feb95
VZ
115protected:
116 // common part of all ctors
117 void Init();
118
119 // this is called when the popup is disappeared because of anything
120 // else but direct call to Dismiss()
121 virtual void OnDismiss();
122
123 // dismiss and notify the derived class
124 void DismissAndNotify();
125
126 // remove our event handlers
127 void PopHandlers();
128
276612f7
RD
129 // get alerted when child gets deleted from under us
130 void OnDestroy(wxWindowDestroyEvent& event);
131
c34cd96a 132#if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON)
25fe875d
VZ
133 // Check if the mouse needs to be captured or released: we must release
134 // when it's inside our window if we want the embedded controls to work.
414f2513
RD
135 void OnIdle(wxIdleEvent& event);
136#endif
0872eaf9 137
1e6feb95
VZ
138 // the child of this popup if any
139 wxWindow *m_child;
140
141 // the window which has the focus while we're shown
142 wxWindow *m_focus;
143
d7cff34d 144 // these classes may call our DismissAndNotify()
1e6feb95
VZ
145 friend class wxPopupWindowHandler;
146 friend class wxPopupFocusHandler;
6c3422e9 147
d7cff34d
VZ
148 // the handlers we created, may be NULL (if not, must be deleted)
149 wxPopupWindowHandler *m_handlerPopup;
150 wxPopupFocusHandler *m_handlerFocus;
151
414f2513 152 DECLARE_EVENT_TABLE()
6c3422e9 153 DECLARE_DYNAMIC_CLASS(wxPopupTransientWindow)
c0c133e1 154 wxDECLARE_NO_COPY_CLASS(wxPopupTransientWindow);
1e6feb95
VZ
155};
156
c9cdd31d 157#if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
1e6feb95
VZ
158
159// ----------------------------------------------------------------------------
160// wxPopupComboWindow: wxPopupTransientWindow used by wxComboBox
161// ----------------------------------------------------------------------------
162
b5dbe15d
VS
163class WXDLLIMPEXP_FWD_CORE wxComboBox;
164class WXDLLIMPEXP_FWD_CORE wxComboCtrl;
1e6feb95 165
53a2db12 166class WXDLLIMPEXP_CORE wxPopupComboWindow : public wxPopupTransientWindow
1e6feb95
VZ
167{
168public:
6b598e05 169 wxPopupComboWindow() { m_combo = NULL; }
a57d600f 170 wxPopupComboWindow(wxComboCtrl *parent);
1e6feb95 171
a57d600f 172 bool Create(wxComboCtrl *parent);
1e6feb95
VZ
173
174 // position the window correctly relatively to the combo
175 void PositionNearCombo();
176
177protected:
178 // notify the combo here
179 virtual void OnDismiss();
180
e0c83227
VZ
181 // forward the key presses to the combobox
182 void OnKeyDown(wxKeyEvent& event);
183
1e6feb95 184 // the parent combobox
a57d600f 185 wxComboCtrl *m_combo;
6c3422e9 186
e0c83227 187 DECLARE_EVENT_TABLE()
6c3422e9 188 DECLARE_DYNAMIC_CLASS(wxPopupComboWindow)
1e6feb95
VZ
189};
190
c9cdd31d 191#endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
1e6feb95
VZ
192
193#endif // wxUSE_POPUPWIN
194
195#endif // _WX_POPUPWIN_H_BASE_