]>
git.saurik.com Git - wxWidgets.git/blob - interface/combobox.h
b47bb712dc768b6c049c45dc88d3aeae4afe4c5a
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.
74 Window identifier. The value wxID_ANY indicates a default value.
76 Initial selection string. An empty string indicates no selection.
80 Window size. If wxDefaultSize is specified then the window is
84 Number of strings with which to initialise the control.
86 An array of strings with which to initialise the control.
88 Window style. See wxComboBox.
94 @see Create(), wxValidator
97 wxComboBox(wxWindow
* parent
, wxWindowID id
,
98 const wxString
& value
= "",
99 const wxPoint
& pos
= wxDefaultPosition
,
100 const wxSize
& size
= wxDefaultSize
,
102 const wxString choices
[] = NULL
,
104 const wxValidator
& validator
= wxDefaultValidator
,
105 const wxString
& name
= "comboBox");
106 wxComboBox(wxWindow
* parent
, wxWindowID id
,
107 const wxString
& value
,
110 const wxArrayString
& choices
,
112 const wxValidator
& validator
= wxDefaultValidator
,
113 const wxString
& name
= "comboBox");
117 Destructor, destroying the combobox.
122 Returns @true if the combobox is editable and there is a text selection to copy
124 Only available on Windows.
129 Returns @true if the combobox is editable and there is a text selection to copy
131 Only available on Windows.
136 Returns @true if the combobox is editable and there is text on the clipboard
137 that can be pasted into the
138 text field. Only available on Windows.
143 Returns @true if the combobox is editable and the last undo can be redone.
144 Only available on Windows.
149 Returns @true if the combobox is editable and the last edit can be undone.
150 Only available on Windows.
155 Copies the selected text to the clipboard.
161 Creates the combobox for two-step construction. Derived classes
162 should call or replace this function. See wxComboBox()
165 bool Create(wxWindow
* parent
, wxWindowID id
,
166 const wxString
& value
= "",
167 const wxPoint
& pos
= wxDefaultPosition
,
168 const wxSize
& size
= wxDefaultSize
,
169 int n
, const wxString choices
[],
171 const wxValidator
& validator
= wxDefaultValidator
,
172 const wxString
& name
= "comboBox");
173 bool Create(wxWindow
* parent
, wxWindowID id
,
174 const wxString
& value
,
177 const wxArrayString
& choices
,
179 const wxValidator
& validator
= wxDefaultValidator
,
180 const wxString
& name
= "comboBox");
184 Copies the selected text to the clipboard and removes the selection.
189 This function does the same things as
190 wxChoice::GetCurrentSelection and
191 returns the item currently selected in the dropdown list if it's open or the
192 same thing as wxControlWithItems::GetSelection otherwise.
194 int GetCurrentSelection();
197 Returns the insertion point for the combobox's text field.
198 @b Note: Under wxMSW, this function always returns 0 if the combobox
199 doesn't have the focus.
201 long GetInsertionPoint();
204 Returns the last position in the combobox text field.
206 virtual wxTextPos
GetLastPosition();
209 This is the same as wxTextCtrl::GetSelection
210 for the text control which is part of the combobox. Notice that this is a
211 different method from wxControlWithItems::GetSelection.
212 Currently this method is only implemented in wxMSW and wxGTK.
214 void GetSelection(long* from
, long* to
);
217 Returns the current value in the combobox text field.
222 Pastes text from the clipboard to the text field.
227 Redoes the last undo in the text field. Windows only.
232 Removes the text between the two positions in the combobox text field.
239 void Remove(long from
, long to
);
242 Replaces the text between two positions with the given text, in the combobox
252 void Replace(long from
, long to
, const wxString
& text
);
255 Sets the insertion point in the combobox text field.
258 The new insertion point.
260 void SetInsertionPoint(long pos
);
263 Sets the insertion point at the end of the combobox text field.
265 void SetInsertionPointEnd();
268 Selects the text between the two positions, in the combobox text field.
275 void SetSelection(long from
, long to
);
278 Sets the text for the combobox text field.
279 @b NB: For a combobox with @c wxCB_READONLY style the string must be in
280 the combobox choices list, otherwise the call to SetValue() is ignored.
285 void SetValue(const wxString
& text
);
288 Undoes the last edit in the text field. Windows only.