1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPopupWindow interface declaration
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_POPUPWIN_H_BASE_
12 #define _WX_POPUPWIN_H_BASE_
18 #include "wx/nonownedwnd.h"
20 // ----------------------------------------------------------------------------
21 // wxPopupWindow: a special kind of top level window used for popup menus,
22 // combobox popups and such.
23 // ----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxPopupWindowBase
: public wxNonOwnedWindow
28 wxPopupWindowBase() { }
29 virtual ~wxPopupWindowBase();
31 // create the popup window
33 // style may only contain border flags
34 bool Create(wxWindow
*parent
, int style
= wxBORDER_NONE
);
36 // move the popup window to the right position, i.e. such that it is
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
43 // the point must be given in screen coordinates!
44 virtual void Position(const wxPoint
& ptOrigin
,
47 virtual bool IsTopLevel() const { return true; }
49 wxDECLARE_NO_COPY_CLASS(wxPopupWindowBase
);
53 // include the real class declaration
54 #if defined(__WXMSW__)
55 #include "wx/msw/popupwin.h"
56 #elif defined(__WXPM__)
57 #include "wx/os2/popupwin.h"
58 #elif defined(__WXGTK20__)
59 #include "wx/gtk/popupwin.h"
60 #elif defined(__WXGTK__)
61 #include "wx/gtk1/popupwin.h"
62 #elif defined(__WXX11__)
63 #include "wx/x11/popupwin.h"
64 #elif defined(__WXMOTIF__)
65 #include "wx/motif/popupwin.h"
66 #elif defined(__WXDFB__)
67 #include "wx/dfb/popupwin.h"
68 #elif defined(__WXMAC__)
69 #include "wx/osx/popupwin.h"
71 #error "wxPopupWindow is not supported under this platform."
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 // ----------------------------------------------------------------------------
79 class WXDLLIMPEXP_FWD_CORE wxPopupWindowHandler
;
80 class WXDLLIMPEXP_FWD_CORE wxPopupFocusHandler
;
82 class WXDLLIMPEXP_CORE wxPopupTransientWindow
: public wxPopupWindow
86 wxPopupTransientWindow() { Init(); }
87 wxPopupTransientWindow(wxWindow
*parent
, int style
= wxBORDER_NONE
);
89 virtual ~wxPopupTransientWindow();
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
);
96 virtual void Dismiss();
98 // can the window be dismissed now?
100 // VZ: where is this used??
101 virtual bool CanDismiss()
104 // called when a mouse is pressed while the popup is shown: return true
105 // from here to prevent its normal processing by the popup (which consists
106 // in dismissing it if the mouse is clicked outside it)
107 virtual bool ProcessLeftDown(wxMouseEvent
& event
);
109 // Overridden to grab the input on some plaforms
110 virtual bool Show( bool show
= true );
112 // Override to implement delayed destruction of this window.
113 virtual bool Destroy();
116 // common part of all ctors
119 // this is called when the popup is disappeared because of anything
120 // else but direct call to Dismiss()
121 virtual void OnDismiss();
123 // dismiss and notify the derived class
124 void DismissAndNotify();
126 // remove our event handlers
129 // get alerted when child gets deleted from under us
130 void OnDestroy(wxWindowDestroyEvent
& event
);
132 #if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON)
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.
135 void OnIdle(wxIdleEvent
& event
);
138 // the child of this popup if any
141 // the window which has the focus while we're shown
144 // these classes may call our DismissAndNotify()
145 friend class wxPopupWindowHandler
;
146 friend class wxPopupFocusHandler
;
148 // the handlers we created, may be NULL (if not, must be deleted)
149 wxPopupWindowHandler
*m_handlerPopup
;
150 wxPopupFocusHandler
*m_handlerFocus
;
152 DECLARE_EVENT_TABLE()
153 DECLARE_DYNAMIC_CLASS(wxPopupTransientWindow
)
154 wxDECLARE_NO_COPY_CLASS(wxPopupTransientWindow
);
157 #if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
159 // ----------------------------------------------------------------------------
160 // wxPopupComboWindow: wxPopupTransientWindow used by wxComboBox
161 // ----------------------------------------------------------------------------
163 class WXDLLIMPEXP_FWD_CORE wxComboBox
;
164 class WXDLLIMPEXP_FWD_CORE wxComboCtrl
;
166 class WXDLLIMPEXP_CORE wxPopupComboWindow
: public wxPopupTransientWindow
169 wxPopupComboWindow() { m_combo
= NULL
; }
170 wxPopupComboWindow(wxComboCtrl
*parent
);
172 bool Create(wxComboCtrl
*parent
);
174 // position the window correctly relatively to the combo
175 void PositionNearCombo();
178 // notify the combo here
179 virtual void OnDismiss();
181 // forward the key presses to the combobox
182 void OnKeyDown(wxKeyEvent
& event
);
184 // the parent combobox
185 wxComboCtrl
*m_combo
;
187 DECLARE_EVENT_TABLE()
188 DECLARE_DYNAMIC_CLASS(wxPopupComboWindow
)
191 #endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
193 #endif // wxUSE_POPUPWIN
195 #endif // _WX_POPUPWIN_H_BASE_