]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/combobox.h
Document wxDV_NO_HEADER style.
[wxWidgets.git] / interface / wx / combobox.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: combobox.h
e54c96f1 3// Purpose: interface of wxComboBox
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxComboBox
7c913512 11
2e7789a9
VZ
12 A combobox is like a combination of an edit control and a listbox.
13
14 It can be displayed as static list with editable or read-only text field;
15 or a drop-down list with text field; or a drop-down list without a text
16 field.
7c913512 17
bd0812fe
BP
18 A combobox permits a single selection only. Combobox items are numbered
19 from zero.
7c913512 20
bd0812fe
BP
21 If you need a customized combobox, have a look at wxComboCtrl,
22 wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
7c913512 23
2e7789a9
VZ
24 Please refer to wxTextEntry documentation for the description of methods
25 operating with the text entry part of the combobox.
26
23324ae1 27 @beginStyleTable
8c6791e4 28 @style{wxCB_SIMPLE}
23324ae1 29 Creates a combobox with a permanently displayed list. Windows only.
8c6791e4 30 @style{wxCB_DROPDOWN}
23324ae1 31 Creates a combobox with a drop-down list.
8c6791e4 32 @style{wxCB_READONLY}
bd0812fe
BP
33 Same as wxCB_DROPDOWN but only the strings specified as the combobox
34 choices can be selected, it is impossible to select (even from a
35 program) a string which is not in the choices list.
8c6791e4 36 @style{wxCB_SORT}
23324ae1 37 Sorts the entries in the list alphabetically.
8c6791e4 38 @style{wxTE_PROCESS_ENTER}
23324ae1
FM
39 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
40 (otherwise pressing Enter key is either processed internally by the
41 control or used for navigation between dialog controls). Windows
42 only.
43 @endStyleTable
7c913512 44
3051a44a 45 @beginEventEmissionTable{wxCommandEvent}
8c6791e4 46 @event{EVT_COMBOBOX(id, func)}
23324ae1 47 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
bd0812fe 48 the list is selected. Note that calling GetValue() returns the new
23324ae1 49 value of selection.
8c6791e4 50 @event{EVT_TEXT(id, func)}
23324ae1
FM
51 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
52 changes.
8c6791e4 53 @event{EVT_TEXT_ENTER(id, func)}
23324ae1
FM
54 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
55 the combobox (notice that the combobox must have been created with
56 wxTE_PROCESS_ENTER style to receive this event).
23d74d89 57 @event{EVT_COMBOBOX_DROPDOWN(id, func)}
8933fbc6
VZ
58 Process a wxEVT_COMMAND_COMBOBOX_DROPDOWN event, which is generated
59 when the list box part of the combo box is shown (drops down).
60 Notice that this event is currently only supported by wxMSW and
61 wxGTK with GTK+ 2.10 or later.
23d74d89 62 @event{EVT_COMBOBOX_CLOSEUP(id, func)}
8933fbc6
VZ
63 Process a wxEVT_COMMAND_COMBOBOX_CLOSEUP event, which is generated
64 when the list box of the combo box disappears (closes up). This
65 event is only generated for the same platforms as
bb3400a8
JS
66 wxEVT_COMMAND_COMBOBOX_DROPDOWN above. Also note that only wxMSW
67 supports adding or deleting items in this event.
23324ae1 68 @endEventTable
7c913512 69
23324ae1
FM
70 @library{wxcore}
71 @category{ctrl}
7e59b885 72 @appearance{combobox.png}
7c913512 73
e54c96f1 74 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
23324ae1 75*/
2e7789a9
VZ
76class wxComboBox : public wxControl,
77 public wxItemContainer,
78 public wxTextEntry
23324ae1
FM
79{
80public:
bd0812fe
BP
81 /**
82 Default constructor.
83 */
84 wxComboBox();
85
23324ae1
FM
86 //@{
87 /**
88 Constructor, creating and showing a combobox.
3c4f71cc 89
7c913512 90 @param parent
4cc4bfaf 91 Parent window. Must not be @NULL.
7c913512 92 @param id
4cc4bfaf 93 Window identifier. The value wxID_ANY indicates a default value.
7c913512 94 @param value
4cc4bfaf 95 Initial selection string. An empty string indicates no selection.
a3281dbc
VZ
96 Notice that for the controls with @c wxCB_READONLY style this
97 string must be one of the valid choices if it is not empty.
7c913512 98 @param pos
4cc4bfaf 99 Window position.
dc1b07fd 100 If ::wxDefaultPosition is specified then a default position is chosen.
7c913512 101 @param size
dc1b07fd
FM
102 Window size.
103 If ::wxDefaultSize is specified then the window is sized appropriately.
7c913512 104 @param n
4cc4bfaf 105 Number of strings with which to initialise the control.
7c913512 106 @param choices
4cc4bfaf 107 An array of strings with which to initialise the control.
7c913512 108 @param style
4cc4bfaf 109 Window style. See wxComboBox.
7c913512 110 @param validator
4cc4bfaf 111 Window validator.
7c913512 112 @param name
4cc4bfaf 113 Window name.
3c4f71cc 114
bd0812fe
BP
115 @beginWxPythonOnly
116 The wxComboBox constructor in wxPython reduces the @a n and @a choices
117 arguments are to a single argument, which is a list of strings.
118 @endWxPythonOnly
119
1058f652
MB
120 @beginWxPerlOnly
121 Not supported by wxPerl.
122 @endWxPerlOnly
123
4cc4bfaf 124 @see Create(), wxValidator
23324ae1 125 */
7c913512 126 wxComboBox(wxWindow* parent, wxWindowID id,
e9c3992c 127 const wxString& value = wxEmptyString,
7c913512
FM
128 const wxPoint& pos = wxDefaultPosition,
129 const wxSize& size = wxDefaultSize,
130 int n = 0,
4cc4bfaf 131 const wxString choices[] = NULL,
7c913512
FM
132 long style = 0,
133 const wxValidator& validator = wxDefaultValidator,
882678eb 134 const wxString& name = wxComboBoxNameStr);
792255cc
VZ
135 /**
136 Constructor, creating and showing a combobox.
137
138 @param parent
139 Parent window. Must not be @NULL.
140 @param id
141 Window identifier. The value wxID_ANY indicates a default value.
142 @param value
143 Initial selection string. An empty string indicates no selection.
144 @param pos
145 Window position.
146 @param size
147 Window size. If wxDefaultSize is specified then the window is sized
148 appropriately.
149 @param choices
150 An array of strings with which to initialise the control.
151 @param style
152 Window style. See wxComboBox.
153 @param validator
154 Window validator.
155 @param name
156 Window name.
157
158 @beginWxPythonOnly
159 The wxComboBox constructor in wxPython reduces the @a n and @a choices
160 arguments are to a single argument, which is a list of strings.
161 @endWxPythonOnly
162
1058f652
MB
163 @beginWxPerlOnly
164 Use an array reference for the @a choices parameter.
165 @endWxPerlOnly
166
792255cc
VZ
167 @see Create(), wxValidator
168 */
7c913512
FM
169 wxComboBox(wxWindow* parent, wxWindowID id,
170 const wxString& value,
171 const wxPoint& pos,
172 const wxSize& size,
173 const wxArrayString& choices,
174 long style = 0,
175 const wxValidator& validator = wxDefaultValidator,
882678eb 176 const wxString& name = wxComboBoxNameStr);
23324ae1
FM
177 //@}
178
179 /**
180 Destructor, destroying the combobox.
181 */
b7e94bd7 182 virtual ~wxComboBox();
23324ae1 183
bd0812fe 184 //@{
23324ae1 185 /**
bd0812fe
BP
186 Creates the combobox for two-step construction. Derived classes should
187 call or replace this function. See wxComboBox() for further details.
188 */
57bf907d
FM
189 bool Create(wxWindow *parent, wxWindowID id,
190 const wxString& value = wxEmptyString,
bd0812fe
BP
191 const wxPoint& pos = wxDefaultPosition,
192 const wxSize& size = wxDefaultSize,
57bf907d 193 int n = 0, const wxString choices[] = (const wxString *) NULL,
bd0812fe
BP
194 long style = 0,
195 const wxValidator& validator = wxDefaultValidator,
57bf907d
FM
196 const wxString& name = wxComboBoxNameStr);
197 bool Create(wxWindow *parent, wxWindowID id,
bd0812fe
BP
198 const wxString& value,
199 const wxPoint& pos,
200 const wxSize& size,
201 const wxArrayString& choices,
202 long style = 0,
203 const wxValidator& validator = wxDefaultValidator,
57bf907d 204 const wxString& name = wxComboBoxNameStr);
bd0812fe
BP
205 //@}
206
207 /**
2e7789a9 208 Returns the item being selected right now.
23324ae1 209
bd0812fe
BP
210 This function does the same things as wxChoice::GetCurrentSelection()
211 and returns the item currently selected in the dropdown list if it's
212 open or the same thing as wxControlWithItems::GetSelection() otherwise.
23324ae1 213 */
b7e94bd7 214 virtual int GetCurrentSelection() const;
23324ae1
FM
215
216 /**
2e7789a9 217 Same as wxTextEntry::GetInsertionPoint().
bd0812fe 218
cdbcf4c2 219 @note Under wxMSW, this function always returns 0 if the combobox
bd0812fe 220 doesn't have the focus.
23324ae1 221 */
0004982c 222 virtual long GetInsertionPoint() const;
23324ae1
FM
223
224 /**
2e7789a9 225 Same as wxTextEntry::SetSelection().
bd0812fe
BP
226
227 @beginWxPythonOnly
228 This method is called SetMark() in wxPython, "SetSelection" is kept for
229 wxControlWithItems::SetSelection().
230 @endWxPythonOnly
23324ae1 231 */
b7e94bd7 232 virtual void SetSelection(long from, long to);
23324ae1
FM
233
234 /**
235 Sets the text for the combobox text field.
1f1d2182 236
35b9a078
VZ
237 Notice that this method will generate a wxEVT_COMMAND_TEXT_UPDATED
238 event, use wxTextEntry::ChangeValue() if this is undesirable.
239
1f1d2182 240 @note For a combobox with @c wxCB_READONLY style the string must be in
bd0812fe
BP
241 the combobox choices list, otherwise the call to SetValue() is
242 ignored.
3c4f71cc 243
7c913512 244 @param text
4cc4bfaf 245 The text to set.
23324ae1 246 */
0004982c 247 virtual void SetValue(const wxString& text);
23324ae1 248};
e54c96f1 249