]>
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, wxOwnerDrawnComboBox,
22 wxComboPopup and the ready-to-use wxBitmapComboBox.
26 Creates a combobox with a permanently displayed list. Windows only.
28 Creates a combobox with a drop-down list.
30 Same as wxCB_DROPDOWN but only the strings specified as the
31 combobox choices can be selected, it is impossible to select (even
32 from a program) a string which is not in the choices list.
34 Sorts the entries in the list alphabetically.
35 @style{wxTE_PROCESS_ENTER}
36 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
37 (otherwise pressing Enter key is either processed internally by the
38 control or used for navigation between dialog controls). Windows
42 @beginEventTable{wxCommandEvent}
43 @event{EVT_COMBOBOX(id, func)}
44 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
45 the list is selected. Note that calling GetValue returns the new
47 @event{EVT_TEXT(id, func)}
48 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
50 @event{EVT_TEXT_ENTER(id, func)}
51 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
52 the combobox (notice that the combobox must have been created with
53 wxTE_PROCESS_ENTER style to receive this event).
58 @appearance{combobox.png}
60 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
62 class wxComboBox
: public wxControlWithItems
67 Constructor, creating and showing a combobox.
70 Parent window. Must not be @NULL.
72 Window identifier. The value wxID_ANY indicates a default value.
74 Initial selection string. An empty string indicates no selection.
78 Window size. If wxDefaultSize is specified then the window is
82 Number of strings with which to initialise the control.
84 An array of strings with which to initialise the control.
86 Window style. See wxComboBox.
92 @see Create(), wxValidator
95 wxComboBox(wxWindow
* parent
, wxWindowID id
,
96 const wxString
& value
= "",
97 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxSize
& size
= wxDefaultSize
,
100 const wxString choices
[] = NULL
,
102 const wxValidator
& validator
= wxDefaultValidator
,
103 const wxString
& name
= "comboBox");
104 wxComboBox(wxWindow
* parent
, wxWindowID id
,
105 const wxString
& value
,
108 const wxArrayString
& choices
,
110 const wxValidator
& validator
= wxDefaultValidator
,
111 const wxString
& name
= "comboBox");
115 Destructor, destroying the combobox.
120 Returns @true if the combobox is editable and there is a text selection to copy
122 Only available on Windows.
124 bool CanCopy() const;
127 Returns @true if the combobox is editable and there is a text selection to copy
129 Only available on Windows.
134 Returns @true if the combobox is editable and there is text on the clipboard
135 that can be pasted into the
136 text field. Only available on Windows.
138 bool CanPaste() const;
141 Returns @true if the combobox is editable and the last undo can be redone.
142 Only available on Windows.
144 bool CanRedo() const;
147 Returns @true if the combobox is editable and the last edit can be undone.
148 Only available on Windows.
150 bool CanUndo() const;
153 Copies the selected text to the clipboard.
159 Creates the combobox for two-step construction. Derived classes
160 should call or replace this function. See wxComboBox()
163 bool Create(wxWindow
* parent
, wxWindowID id
,
164 const wxString
& value
= "",
165 const wxPoint
& pos
= wxDefaultPosition
,
166 const wxSize
& size
= wxDefaultSize
,
167 int n
, const wxString choices
[],
169 const wxValidator
& validator
= wxDefaultValidator
,
170 const wxString
& name
= "comboBox");
171 bool Create(wxWindow
* parent
, wxWindowID id
,
172 const wxString
& value
,
175 const wxArrayString
& choices
,
177 const wxValidator
& validator
= wxDefaultValidator
,
178 const wxString
& name
= "comboBox");
182 Copies the selected text to the clipboard and removes the selection.
187 This function does the same things as
188 wxChoice::GetCurrentSelection and
189 returns the item currently selected in the dropdown list if it's open or the
190 same thing as wxControlWithItems::GetSelection otherwise.
192 int GetCurrentSelection() const;
195 Returns the insertion point for the combobox's text field.
196 @note Under wxMSW, this function always returns 0 if the combobox
197 doesn't have the focus.
199 long GetInsertionPoint() const;
202 Returns the last position in the combobox text field.
204 virtual wxTextPos
GetLastPosition() const;
207 This is the same as wxTextCtrl::GetSelection
208 for the text control which is part of the combobox. Notice that this is a
209 different method from wxControlWithItems::GetSelection.
210 Currently this method is only implemented in wxMSW and wxGTK.
212 void GetSelection(long* from
, long* to
) const;
215 Returns the current value in the combobox text field.
217 wxString
GetValue() const;
220 Pastes text from the clipboard to the text field.
225 Redoes the last undo in the text field. Windows only.
230 Removes the text between the two positions in the combobox text field.
237 void Remove(long from
, long to
);
240 Replaces the text between two positions with the given text, in the combobox
250 void Replace(long from
, long to
, const wxString
& text
);
253 Sets the insertion point in the combobox text field.
256 The new insertion point.
258 void SetInsertionPoint(long pos
);
261 Sets the insertion point at the end of the combobox text field.
263 void SetInsertionPointEnd();
266 Selects the text between the two positions, in the combobox text field.
273 void SetSelection(long from
, long to
);
276 Sets the text for the combobox text field.
278 @note 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.