]>
git.saurik.com Git - wxWidgets.git/blob - interface/combobox.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxComboBox
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}
61 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
63 class wxComboBox
: public wxControlWithItems
68 Constructor, creating and showing a combobox.
71 Parent window. Must not be @NULL.
73 Window identifier. The value wxID_ANY indicates a default value.
75 Initial selection string. An empty string indicates no selection.
79 Window size. If wxDefaultSize is specified then the window is
83 Number of strings with which to initialise the control.
85 An array of strings with which to initialise the control.
87 Window style. See wxComboBox.
93 @see Create(), wxValidator
96 wxComboBox(wxWindow
* parent
, wxWindowID id
,
97 const wxString
& value
= "",
98 const wxPoint
& pos
= wxDefaultPosition
,
99 const wxSize
& size
= wxDefaultSize
,
101 const wxString choices
[] = NULL
,
103 const wxValidator
& validator
= wxDefaultValidator
,
104 const wxString
& name
= "comboBox");
105 wxComboBox(wxWindow
* parent
, wxWindowID id
,
106 const wxString
& value
,
109 const wxArrayString
& choices
,
111 const wxValidator
& validator
= wxDefaultValidator
,
112 const wxString
& name
= "comboBox");
116 Destructor, destroying the combobox.
121 Returns @true if the combobox is editable and there is a text selection to copy
123 Only available on Windows.
125 bool CanCopy() const;
128 Returns @true if the combobox is editable and there is a text selection to copy
130 Only available on Windows.
135 Returns @true if the combobox is editable and there is text on the clipboard
136 that can be pasted into the
137 text field. Only available on Windows.
139 bool CanPaste() const;
142 Returns @true if the combobox is editable and the last undo can be redone.
143 Only available on Windows.
145 bool CanRedo() const;
148 Returns @true if the combobox is editable and the last edit can be undone.
149 Only available on Windows.
151 bool CanUndo() const;
154 Copies the selected text to the clipboard.
160 Creates the combobox for two-step construction. Derived classes
161 should call or replace this function. See wxComboBox()
164 bool Create(wxWindow
* parent
, wxWindowID id
,
165 const wxString
& value
= "",
166 const wxPoint
& pos
= wxDefaultPosition
,
167 const wxSize
& size
= wxDefaultSize
,
168 int n
, const wxString choices
[],
170 const wxValidator
& validator
= wxDefaultValidator
,
171 const wxString
& name
= "comboBox");
172 bool Create(wxWindow
* parent
, wxWindowID id
,
173 const wxString
& value
,
176 const wxArrayString
& choices
,
178 const wxValidator
& validator
= wxDefaultValidator
,
179 const wxString
& name
= "comboBox");
183 Copies the selected text to the clipboard and removes the selection.
188 This function does the same things as
189 wxChoice::GetCurrentSelection and
190 returns the item currently selected in the dropdown list if it's open or the
191 same thing as wxControlWithItems::GetSelection otherwise.
193 int GetCurrentSelection() const;
196 Returns the insertion point for the combobox's text field.
197 @b Note: Under wxMSW, this function always returns 0 if the combobox
198 doesn't have the focus.
200 long GetInsertionPoint() const;
203 Returns the last position in the combobox text field.
205 virtual wxTextPos
GetLastPosition() const;
208 This is the same as wxTextCtrl::GetSelection
209 for the text control which is part of the combobox. Notice that this is a
210 different method from wxControlWithItems::GetSelection.
211 Currently this method is only implemented in wxMSW and wxGTK.
213 void GetSelection(long* from
, long* to
) const;
216 Returns the current value in the combobox text field.
218 wxString
GetValue() const;
221 Pastes text from the clipboard to the text field.
226 Redoes the last undo in the text field. Windows only.
231 Removes the text between the two positions in the combobox text field.
238 void Remove(long from
, long to
);
241 Replaces the text between two positions with the given text, in the combobox
251 void Replace(long from
, long to
, const wxString
& text
);
254 Sets the insertion point in the combobox text field.
257 The new insertion point.
259 void SetInsertionPoint(long pos
);
262 Sets the insertion point at the end of the combobox text field.
264 void SetInsertionPointEnd();
267 Selects the text between the two positions, in the combobox text field.
274 void SetSelection(long from
, long to
);
277 Sets the text for the combobox text field.
278 @b NB: For a combobox with @c wxCB_READONLY style the string must be in
279 the combobox choices list, otherwise the call to SetValue() is ignored.
284 void SetValue(const wxString
& text
);
287 Undoes the last edit in the text field. Windows only.