]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/combobox.h
Corrected library association
[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
bd0812fe
BP
12 A combobox is like a combination of an edit control and a listbox. It can
13 be displayed as static list with editable or read-only text field; or a
14 drop-down list with text field; or a drop-down list without a text field.
7c913512 15
bd0812fe
BP
16 A combobox permits a single selection only. Combobox items are numbered
17 from zero.
7c913512 18
bd0812fe
BP
19 If you need a customized combobox, have a look at wxComboCtrl,
20 wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
7c913512 21
23324ae1 22 @beginStyleTable
8c6791e4 23 @style{wxCB_SIMPLE}
23324ae1 24 Creates a combobox with a permanently displayed list. Windows only.
8c6791e4 25 @style{wxCB_DROPDOWN}
23324ae1 26 Creates a combobox with a drop-down list.
8c6791e4 27 @style{wxCB_READONLY}
bd0812fe
BP
28 Same as wxCB_DROPDOWN but only the strings specified as the combobox
29 choices can be selected, it is impossible to select (even from a
30 program) a string which is not in the choices list.
8c6791e4 31 @style{wxCB_SORT}
23324ae1 32 Sorts the entries in the list alphabetically.
8c6791e4 33 @style{wxTE_PROCESS_ENTER}
23324ae1
FM
34 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
35 (otherwise pressing Enter key is either processed internally by the
36 control or used for navigation between dialog controls). Windows
37 only.
38 @endStyleTable
7c913512 39
1f1d2182 40 @beginEventTable{wxCommandEvent}
8c6791e4 41 @event{EVT_COMBOBOX(id, func)}
23324ae1 42 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
bd0812fe 43 the list is selected. Note that calling GetValue() returns the new
23324ae1 44 value of selection.
8c6791e4 45 @event{EVT_TEXT(id, func)}
23324ae1
FM
46 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
47 changes.
8c6791e4 48 @event{EVT_TEXT_ENTER(id, func)}
23324ae1
FM
49 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
50 the combobox (notice that the combobox must have been created with
51 wxTE_PROCESS_ENTER style to receive this event).
52 @endEventTable
7c913512 53
23324ae1
FM
54 @library{wxcore}
55 @category{ctrl}
7e59b885 56 @appearance{combobox.png}
7c913512 57
e54c96f1 58 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
23324ae1 59*/
bf84f3e2 60class wxComboBox : public wxControl, public wxItemContainer
23324ae1
FM
61{
62public:
bd0812fe
BP
63 /**
64 Default constructor.
65 */
66 wxComboBox();
67
23324ae1
FM
68 //@{
69 /**
70 Constructor, creating and showing a combobox.
3c4f71cc 71
7c913512 72 @param parent
4cc4bfaf 73 Parent window. Must not be @NULL.
7c913512 74 @param id
4cc4bfaf 75 Window identifier. The value wxID_ANY indicates a default value.
7c913512 76 @param value
4cc4bfaf 77 Initial selection string. An empty string indicates no selection.
7c913512 78 @param pos
4cc4bfaf 79 Window position.
7c913512 80 @param size
bd0812fe 81 Window size. If wxDefaultSize is specified then the window is sized
4cc4bfaf 82 appropriately.
7c913512 83 @param n
4cc4bfaf 84 Number of strings with which to initialise the control.
7c913512 85 @param choices
4cc4bfaf 86 An array of strings with which to initialise the control.
7c913512 87 @param style
4cc4bfaf 88 Window style. See wxComboBox.
7c913512 89 @param validator
4cc4bfaf 90 Window validator.
7c913512 91 @param name
4cc4bfaf 92 Window name.
3c4f71cc 93
bd0812fe
BP
94 @beginWxPythonOnly
95 The wxComboBox constructor in wxPython reduces the @a n and @a choices
96 arguments are to a single argument, which is a list of strings.
97 @endWxPythonOnly
98
4cc4bfaf 99 @see Create(), wxValidator
23324ae1 100 */
7c913512
FM
101 wxComboBox(wxWindow* parent, wxWindowID id,
102 const wxString& value = "",
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& size = wxDefaultSize,
105 int n = 0,
4cc4bfaf 106 const wxString choices[] = NULL,
7c913512
FM
107 long style = 0,
108 const wxValidator& validator = wxDefaultValidator,
109 const wxString& name = "comboBox");
792255cc
VZ
110 /**
111 Constructor, creating and showing a combobox.
112
113 @param parent
114 Parent window. Must not be @NULL.
115 @param id
116 Window identifier. The value wxID_ANY indicates a default value.
117 @param value
118 Initial selection string. An empty string indicates no selection.
119 @param pos
120 Window position.
121 @param size
122 Window size. If wxDefaultSize is specified then the window is sized
123 appropriately.
124 @param choices
125 An array of strings with which to initialise the control.
126 @param style
127 Window style. See wxComboBox.
128 @param validator
129 Window validator.
130 @param name
131 Window name.
132
133 @beginWxPythonOnly
134 The wxComboBox constructor in wxPython reduces the @a n and @a choices
135 arguments are to a single argument, which is a list of strings.
136 @endWxPythonOnly
137
138 @see Create(), wxValidator
139 */
7c913512
FM
140 wxComboBox(wxWindow* parent, wxWindowID id,
141 const wxString& value,
142 const wxPoint& pos,
143 const wxSize& size,
144 const wxArrayString& choices,
145 long style = 0,
146 const wxValidator& validator = wxDefaultValidator,
147 const wxString& name = "comboBox");
23324ae1
FM
148 //@}
149
150 /**
151 Destructor, destroying the combobox.
152 */
b7e94bd7 153 virtual ~wxComboBox();
23324ae1 154
bd0812fe 155 //@{
23324ae1 156 /**
bd0812fe
BP
157 Creates the combobox for two-step construction. Derived classes should
158 call or replace this function. See wxComboBox() for further details.
159 */
160 bool Create(wxWindow* parent, wxWindowID id,
161 const wxString& value = "",
162 const wxPoint& pos = wxDefaultPosition,
163 const wxSize& size = wxDefaultSize,
164 int n, const wxString choices[],
165 long style = 0,
166 const wxValidator& validator = wxDefaultValidator,
167 const wxString& name = "comboBox");
168 bool Create(wxWindow* parent, wxWindowID id,
169 const wxString& value,
170 const wxPoint& pos,
171 const wxSize& size,
172 const wxArrayString& choices,
173 long style = 0,
174 const wxValidator& validator = wxDefaultValidator,
175 const wxString& name = "comboBox");
176 //@}
177
178 /**
179 Returns @true if the combobox is editable and there is a text selection
180 to copy to the clipboard. Only available on Windows.
23324ae1 181 */
0004982c 182 virtual bool CanCopy() const;
23324ae1
FM
183
184 /**
bd0812fe
BP
185 Returns @true if the combobox is editable and there is a text selection
186 to copy to the clipboard. Only available on Windows.
23324ae1 187 */
0004982c 188 virtual bool CanCut() const;
23324ae1
FM
189
190 /**
bd0812fe
BP
191 Returns @true if the combobox is editable and there is text on the
192 clipboard that can be pasted into the text field. Only available on
193 Windows.
23324ae1 194 */
0004982c 195 virtual bool CanPaste() const;
23324ae1
FM
196
197 /**
bd0812fe
BP
198 Returns @true if the combobox is editable and the last undo can be
199 redone. Only available on Windows.
23324ae1 200 */
0004982c 201 virtual bool CanRedo() const;
23324ae1
FM
202
203 /**
bd0812fe
BP
204 Returns @true if the combobox is editable and the last edit can be
205 undone. Only available on Windows.
23324ae1 206 */
0004982c 207 virtual bool CanUndo() const;
23324ae1
FM
208
209 /**
210 Copies the selected text to the clipboard.
211 */
0004982c 212 virtual void Copy();
23324ae1 213
23324ae1
FM
214 /**
215 Copies the selected text to the clipboard and removes the selection.
216 */
0004982c 217 virtual void Cut();
23324ae1
FM
218
219 /**
bd0812fe
BP
220 This function does the same things as wxChoice::GetCurrentSelection()
221 and returns the item currently selected in the dropdown list if it's
222 open or the same thing as wxControlWithItems::GetSelection() otherwise.
23324ae1 223 */
b7e94bd7 224 virtual int GetCurrentSelection() const;
23324ae1
FM
225
226 /**
227 Returns the insertion point for the combobox's text field.
bd0812fe 228
cdbcf4c2 229 @note Under wxMSW, this function always returns 0 if the combobox
bd0812fe 230 doesn't have the focus.
23324ae1 231 */
0004982c 232 virtual long GetInsertionPoint() const;
23324ae1
FM
233
234 /**
235 Returns the last position in the combobox text field.
236 */
328f5751 237 virtual wxTextPos GetLastPosition() const;
23324ae1
FM
238
239 /**
bd0812fe
BP
240 This is the same as wxTextCtrl::GetSelection() for the text control
241 which is part of the combobox. Notice that this is a different method
242 from wxControlWithItems::GetSelection().
243
23324ae1
FM
244 Currently this method is only implemented in wxMSW and wxGTK.
245 */
b7e94bd7 246 virtual void GetSelection(long* from, long* to) const;
23324ae1
FM
247
248 /**
249 Returns the current value in the combobox text field.
250 */
0004982c 251 virtual wxString GetValue() const;
23324ae1
FM
252
253 /**
254 Pastes text from the clipboard to the text field.
255 */
0004982c 256 virtual void Paste();
23324ae1
FM
257
258 /**
259 Redoes the last undo in the text field. Windows only.
260 */
0004982c 261 virtual void Redo();
23324ae1
FM
262
263 /**
264 Removes the text between the two positions in the combobox text field.
3c4f71cc 265
7c913512 266 @param from
4cc4bfaf 267 The first position.
7c913512 268 @param to
4cc4bfaf 269 The last position.
23324ae1 270 */
0004982c 271 virtual void Remove(long from, long to);
23324ae1
FM
272
273 /**
bd0812fe
BP
274 Replaces the text between two positions with the given text, in the
275 combobox text field.
3c4f71cc 276
7c913512 277 @param from
4cc4bfaf 278 The first position.
7c913512 279 @param to
4cc4bfaf 280 The second position.
7c913512 281 @param text
4cc4bfaf 282 The text to insert.
23324ae1 283 */
0004982c 284 virtual void Replace(long from, long to, const wxString& text);
23324ae1
FM
285
286 /**
287 Sets the insertion point in the combobox text field.
3c4f71cc 288
7c913512 289 @param pos
4cc4bfaf 290 The new insertion point.
23324ae1 291 */
0004982c 292 virtual void SetInsertionPoint(long pos);
23324ae1
FM
293
294 /**
295 Sets the insertion point at the end of the combobox text field.
296 */
0004982c 297 virtual void SetInsertionPointEnd();
23324ae1
FM
298
299 /**
300 Selects the text between the two positions, in the combobox text field.
3c4f71cc 301
7c913512 302 @param from
4cc4bfaf 303 The first position.
7c913512 304 @param to
4cc4bfaf 305 The second position.
bd0812fe
BP
306
307 @beginWxPythonOnly
308 This method is called SetMark() in wxPython, "SetSelection" is kept for
309 wxControlWithItems::SetSelection().
310 @endWxPythonOnly
23324ae1 311 */
b7e94bd7 312 virtual void SetSelection(long from, long to);
23324ae1
FM
313
314 /**
315 Sets the text for the combobox text field.
1f1d2182
FM
316
317 @note For a combobox with @c wxCB_READONLY style the string must be in
bd0812fe
BP
318 the combobox choices list, otherwise the call to SetValue() is
319 ignored.
3c4f71cc 320
7c913512 321 @param text
4cc4bfaf 322 The text to set.
23324ae1 323 */
0004982c 324 virtual void SetValue(const wxString& text);
23324ae1
FM
325
326 /**
327 Undoes the last edit in the text field. Windows only.
328 */
0004982c 329 virtual void Undo();
23324ae1 330};
e54c96f1 331