]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/generic/combo.h | |
3 | // Purpose: Generic wxComboCtrl | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: Apr-30-2006 | |
7 | // Copyright: (c) Jaakko Salli | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_GENERIC_COMBOCTRL_H_ | |
12 | #define _WX_GENERIC_COMBOCTRL_H_ | |
13 | ||
14 | #if wxUSE_COMBOCTRL | |
15 | ||
16 | // Only define generic if native doesn't have all the features | |
17 | #if !defined(wxCOMBOCONTROL_FULLY_FEATURED) | |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // Generic wxComboCtrl | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #if defined(__WXUNIVERSAL__) | |
24 | ||
25 | // all actions of single line text controls are supported | |
26 | ||
27 | // popup/dismiss the choice window | |
28 | #define wxACTION_COMBOBOX_POPUP wxT("popup") | |
29 | #define wxACTION_COMBOBOX_DISMISS wxT("dismiss") | |
30 | ||
31 | #endif | |
32 | ||
33 | #include "wx/dcbuffer.h" | |
34 | ||
35 | extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[]; | |
36 | ||
37 | class WXDLLIMPEXP_CORE wxGenericComboCtrl : public wxComboCtrlBase | |
38 | { | |
39 | public: | |
40 | // ctors and such | |
41 | wxGenericComboCtrl() : wxComboCtrlBase() { Init(); } | |
42 | ||
43 | wxGenericComboCtrl(wxWindow *parent, | |
44 | wxWindowID id = wxID_ANY, | |
45 | const wxString& value = wxEmptyString, | |
46 | const wxPoint& pos = wxDefaultPosition, | |
47 | const wxSize& size = wxDefaultSize, | |
48 | long style = 0, | |
49 | const wxValidator& validator = wxDefaultValidator, | |
50 | const wxString& name = wxComboBoxNameStr) | |
51 | : wxComboCtrlBase() | |
52 | { | |
53 | Init(); | |
54 | ||
55 | (void)Create(parent, id, value, pos, size, style, validator, name); | |
56 | } | |
57 | ||
58 | bool Create(wxWindow *parent, | |
59 | wxWindowID id = wxID_ANY, | |
60 | const wxString& value = wxEmptyString, | |
61 | const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, | |
63 | long style = 0, | |
64 | const wxValidator& validator = wxDefaultValidator, | |
65 | const wxString& name = wxComboBoxNameStr); | |
66 | ||
67 | virtual ~wxGenericComboCtrl(); | |
68 | ||
69 | void SetCustomPaintWidth( int width ); | |
70 | ||
71 | virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const; | |
72 | ||
73 | static int GetFeatures() { return wxComboCtrlFeatures::All; } | |
74 | ||
75 | #if defined(__WXUNIVERSAL__) | |
76 | // we have our own input handler and our own actions | |
77 | virtual bool PerformAction(const wxControlAction& action, | |
78 | long numArg = 0l, | |
79 | const wxString& strArg = wxEmptyString); | |
80 | #endif | |
81 | ||
82 | protected: | |
83 | ||
84 | // Dummies for platform-specific wxTextEntry implementations | |
85 | #if defined(__WXUNIVERSAL__) | |
86 | // Looks like there's nothing we need to override here | |
87 | #elif defined(__WXMOTIF__) | |
88 | virtual WXWidget GetTextWidget() const { return NULL; } | |
89 | #elif defined(__WXGTK__) | |
90 | #if defined(__WXGTK20__) | |
91 | virtual GtkEditable *GetEditable() const { return NULL; } | |
92 | virtual GtkEntry *GetEntry() const { return NULL; } | |
93 | #endif | |
94 | #elif defined(__WXMAC__) | |
95 | // Looks like there's nothing we need to override here | |
96 | #elif defined(__WXPM__) | |
97 | virtual WXHWND GetEditHWND() const { return NULL; } | |
98 | #endif | |
99 | ||
100 | // For better transparent background rendering | |
101 | virtual bool HasTransparentBackground() | |
102 | { | |
103 | #if wxALWAYS_NATIVE_DOUBLE_BUFFER | |
104 | #ifdef __WXGTK__ | |
105 | // Sanity check for GTK+ | |
106 | return IsDoubleBuffered(); | |
107 | #else | |
108 | return true; | |
109 | #endif | |
110 | #else | |
111 | return false; | |
112 | #endif | |
113 | } | |
114 | ||
115 | // Mandatory virtuals | |
116 | virtual void OnResize(); | |
117 | ||
118 | // Event handlers | |
119 | void OnPaintEvent( wxPaintEvent& event ); | |
120 | void OnMouseEvent( wxMouseEvent& event ); | |
121 | ||
122 | private: | |
123 | void Init(); | |
124 | ||
125 | DECLARE_EVENT_TABLE() | |
126 | ||
127 | DECLARE_DYNAMIC_CLASS(wxGenericComboCtrl) | |
128 | }; | |
129 | ||
130 | ||
131 | #ifndef _WX_COMBOCONTROL_H_ | |
132 | ||
133 | // If native wxComboCtrl was not defined, then prepare a simple | |
134 | // front-end so that wxRTTI works as expected. | |
135 | ||
136 | class WXDLLIMPEXP_CORE wxComboCtrl : public wxGenericComboCtrl | |
137 | { | |
138 | public: | |
139 | wxComboCtrl() : wxGenericComboCtrl() {} | |
140 | ||
141 | wxComboCtrl(wxWindow *parent, | |
142 | wxWindowID id = wxID_ANY, | |
143 | const wxString& value = wxEmptyString, | |
144 | const wxPoint& pos = wxDefaultPosition, | |
145 | const wxSize& size = wxDefaultSize, | |
146 | long style = 0, | |
147 | const wxValidator& validator = wxDefaultValidator, | |
148 | const wxString& name = wxComboBoxNameStr) | |
149 | : wxGenericComboCtrl() | |
150 | { | |
151 | (void)Create(parent, id, value, pos, size, style, validator, name); | |
152 | } | |
153 | ||
154 | virtual ~wxComboCtrl() {} | |
155 | ||
156 | protected: | |
157 | ||
158 | private: | |
159 | DECLARE_DYNAMIC_CLASS(wxComboCtrl) | |
160 | }; | |
161 | ||
162 | #endif // _WX_COMBOCONTROL_H_ | |
163 | ||
164 | #else | |
165 | ||
166 | #define wxGenericComboCtrl wxComboCtrl | |
167 | ||
168 | #endif // !defined(wxCOMBOCONTROL_FULLY_FEATURED) | |
169 | ||
170 | #endif // wxUSE_COMBOCTRL | |
171 | #endif | |
172 | // _WX_GENERIC_COMBOCTRL_H_ |