]> git.saurik.com Git - wxWidgets.git/blame - include/wx/popupwin.h
Trying to hide evidence of my negative programming skills...
[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
7// RCS-ID: $Id$
8// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// License: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_POPUPWIN_H_BASE_
13#define _WX_POPUPWIN_H_BASE_
14
15#ifdef __GNUG__
16 #pragma interface "popupwin.h"
17#endif
18
19#include "wx/window.h"
20
21#if wxUSE_POPUPWIN
22
23// ----------------------------------------------------------------------------
24// wxPopupWindow: a special kind of top level window used for popup menus,
25// combobox popups and such.
26// ----------------------------------------------------------------------------
27
28class WXDLLEXPORT wxPopupWindowBase : public wxWindow
29{
30public:
31 wxPopupWindowBase() { }
32
33 // create the popup window
34 //
35 // style may only contain border flags
36 bool Create(wxWindow *parent, int style = wxBORDER_NONE);
37
38 // move the popup window to the right position, i.e. such that it is
39 // entirely visible
40 //
41 // the popup is positioned at ptOrigin + size if it opens below and to the
42 // right (default), at ptOrigin - sizePopup if it opens above and to the
43 // left &c
44 //
45 // the point must be given in screen coordinates!
46 virtual void Position(const wxPoint& ptOrigin,
47 const wxSize& size);
48};
49
50// include the real class declaration
51#ifdef __WXMSW__
52 #include "wx/msw/popupwin.h"
9f41d601
RR
53#elif __WXGTK__
54 #include "wx/gtk/popupwin.h"
1e6feb95
VZ
55#else
56 #error "wxPopupWindow is not supported under this platform."
57#endif
58
59// ----------------------------------------------------------------------------
60// wxPopupTransientWindow: a wxPopupWindow which disappears automatically
61// when the user clicks mouse outside it or if it loses focus in any other way
62// ----------------------------------------------------------------------------
63
64class WXDLLEXPORT wxPopupTransientWindow : public wxPopupWindow
65{
66public:
67 // ctors
68 wxPopupTransientWindow() { Init(); }
69 wxPopupTransientWindow(wxWindow *parent);
70
71 virtual ~wxPopupTransientWindow();
72
73 // popup the window (this will show it too) and keep focus at winFocus
74 // (or itself if it's NULL), dismiss the popup if we lose focus
75 virtual void Popup(wxWindow *focus = NULL);
76
77 // hide the window
78 virtual void Dismiss();
79
80 // called when a mouse is pressed while the popup is shown: return TRUE
81 // from here to prevent its normal processing by the popup (which consists
82 // in dismissing it if the mouse is cilcked outside it)
83 virtual bool ProcessLeftDown(wxMouseEvent& event);
84
85protected:
86 // common part of all ctors
87 void Init();
88
89 // this is called when the popup is disappeared because of anything
90 // else but direct call to Dismiss()
91 virtual void OnDismiss();
92
93 // dismiss and notify the derived class
94 void DismissAndNotify();
95
96 // remove our event handlers
97 void PopHandlers();
98
99 // the child of this popup if any
100 wxWindow *m_child;
101
102 // the window which has the focus while we're shown
103 wxWindow *m_focus;
104
105 friend class wxPopupWindowHandler;
106 friend class wxPopupFocusHandler;
107};
108
109#if wxUSE_COMBOBOX
110
111// ----------------------------------------------------------------------------
112// wxPopupComboWindow: wxPopupTransientWindow used by wxComboBox
113// ----------------------------------------------------------------------------
114
115class WXDLLEXPORT wxComboBox;
116class WXDLLEXPORT wxComboControl;
117
118class WXDLLEXPORT wxPopupComboWindow : public wxPopupTransientWindow
119{
120public:
121 wxPopupComboWindow(wxComboControl *parent);
122
123 bool Create(wxComboControl *parent);
124
125 // position the window correctly relatively to the combo
126 void PositionNearCombo();
127
128protected:
129 // notify the combo here
130 virtual void OnDismiss();
131
132 // the parent combobox
133 wxComboControl *m_combo;
134};
135
136#endif // wxUSE_COMBOBOX
137
138#endif // wxUSE_POPUPWIN
139
140#endif // _WX_POPUPWIN_H_BASE_
141