]>
git.saurik.com Git - wxWidgets.git/blob - interface/combobox.h
1302069b8e37cbe5507612069553c3d0e997829e
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxComboBox class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A combobox is like a combination of an edit control and a listbox. It can be
14 displayed as static list with editable or read-only text field; or a drop-down
16 text field; or a drop-down list without a text field.
18 A combobox permits a single selection only. Combobox items are numbered from
21 If you need a customized combobox, have a look at wxComboCtrl,
22 wxOwnerDrawnComboBox, wxComboPopup
23 and the ready-to-use wxBitmapComboBox.
27 Creates a combobox with a permanently displayed list. Windows only.
28 @style{wxCB_DROPDOWN}:
29 Creates a combobox with a drop-down list.
30 @style{wxCB_READONLY}:
31 Same as wxCB_DROPDOWN but only the strings specified as the
32 combobox choices can be selected, it is impossible to select (even
33 from a program) a string which is not in the choices list.
35 Sorts the entries in the list alphabetically.
36 @style{wxTE_PROCESS_ENTER}:
37 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
38 (otherwise pressing Enter key is either processed internally by the
39 control or used for navigation between dialog controls). Windows
44 @event{EVT_COMBOBOX(id\, func)}:
45 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
46 the list is selected. Note that calling GetValue returns the new
48 @event{EVT_TEXT(id\, func)}:
49 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
51 @event{EVT_TEXT_ENTER(id\, func)}:
52 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
53 the combobox (notice that the combobox must have been created with
54 wxTE_PROCESS_ENTER style to receive this event).
59 @appearance{combobox.png}
62 wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
64 class wxComboBox
: public wxControlWithItems
69 Constructor, creating and showing a combobox.
72 Parent window. Must not be @NULL.
75 Window identifier. The value wxID_ANY indicates a default value.
78 Initial selection string. An empty string indicates no selection.
84 Window size. If wxDefaultSize is specified then the window is sized
88 Number of strings with which to initialise the control.
91 An array of strings with which to initialise the control.
94 Window style. See wxComboBox.
102 @sa Create(), wxValidator
105 wxComboBox(wxWindow
* parent
, wxWindowID id
,
106 const wxString
& value
= "",
107 const wxPoint
& pos
= wxDefaultPosition
,
108 const wxSize
& size
= wxDefaultSize
,
110 const wxString choices
[] = @NULL
,
112 const wxValidator
& validator
= wxDefaultValidator
,
113 const wxString
& name
= "comboBox");
114 wxComboBox(wxWindow
* parent
, wxWindowID id
,
115 const wxString
& value
,
118 const wxArrayString
& choices
,
120 const wxValidator
& validator
= wxDefaultValidator
,
121 const wxString
& name
= "comboBox");
125 Destructor, destroying the combobox.
130 Returns @true if the combobox is editable and there is a text selection to copy
132 Only available on Windows.
137 Returns @true if the combobox is editable and there is a text selection to copy
139 Only available on Windows.
144 Returns @true if the combobox is editable and there is text on the clipboard
145 that can be pasted into the
146 text field. Only available on Windows.
151 Returns @true if the combobox is editable and the last undo can be redone.
152 Only available on Windows.
157 Returns @true if the combobox is editable and the last edit can be undone.
158 Only available on Windows.
163 Copies the selected text to the clipboard.
169 Creates the combobox for two-step construction. Derived classes
170 should call or replace this function. See wxComboBox()
173 bool Create(wxWindow
* parent
, wxWindowID id
,
174 const wxString
& value
= "",
175 const wxPoint
& pos
= wxDefaultPosition
,
176 const wxSize
& size
= wxDefaultSize
,
177 int n
, const wxString choices
[],
179 const wxValidator
& validator
= wxDefaultValidator
,
180 const wxString
& name
= "comboBox");
181 bool Create(wxWindow
* parent
, wxWindowID id
,
182 const wxString
& value
,
185 const wxArrayString
& choices
,
187 const wxValidator
& validator
= wxDefaultValidator
,
188 const wxString
& name
= "comboBox");
192 Copies the selected text to the clipboard and removes the selection.
194 #define void Cut() /* implementation is private */
197 This function does the same things as
198 wxChoice::GetCurrentSelection and
199 returns the item currently selected in the dropdown list if it's open or the
200 same thing as wxControlWithItems::GetSelection otherwise.
202 int GetCurrentSelection();
205 Returns the insertion point for the combobox's text field.
207 @b Note: Under wxMSW, this function always returns 0 if the combobox
208 doesn't have the focus.
210 long GetInsertionPoint();
213 Returns the last position in the combobox text field.
215 virtual wxTextPos
GetLastPosition();
218 This is the same as wxTextCtrl::GetSelection
219 for the text control which is part of the combobox. Notice that this is a
220 different method from wxControlWithItems::GetSelection.
222 Currently this method is only implemented in wxMSW and wxGTK.
224 void GetSelection(long * from
, long * to
);
227 Returns the current value in the combobox text field.
232 Pastes text from the clipboard to the text field.
237 Redoes the last undo in the text field. Windows only.
242 Removes the text between the two positions in the combobox text field.
250 void Remove(long from
, long to
);
253 Replaces the text between two positions with the given text, in the combobox
265 void Replace(long from
, long to
, const wxString
& text
);
268 Sets the insertion point in the combobox text field.
271 The new insertion point.
273 void SetInsertionPoint(long pos
);
276 Sets the insertion point at the end of the combobox text field.
278 void SetInsertionPointEnd();
281 Selects the text between the two positions, in the combobox text field.
289 void SetSelection(long from
, long to
);
292 Sets the text for the combobox text field.
294 @b NB: For a combobox with @c wxCB_READONLY style the string must be in
295 the combobox choices list, otherwise the call to SetValue() is ignored.
300 void SetValue(const wxString
& text
);
303 Undoes the last edit in the text field. Windows only.