]>
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
14 be displayed as static list with editable or read-only text field; or a
15 drop-down list with text field; or a drop-down list without a text field.
17 A combobox permits a single selection only. Combobox items are numbered
20 If you need a customized combobox, have a look at wxComboCtrl,
21 wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
25 Creates a combobox with a permanently displayed list. Windows only.
27 Creates a combobox with a drop-down list.
29 Same as wxCB_DROPDOWN but only the strings specified as the combobox
30 choices can be selected, it is impossible to select (even from a
31 program) a string which is not in the choices list.
33 Sorts the entries in the list alphabetically.
34 @style{wxTE_PROCESS_ENTER}
35 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
36 (otherwise pressing Enter key is either processed internally by the
37 control or used for navigation between dialog controls). Windows
41 @beginEventTable{wxCommandEvent}
42 @event{EVT_COMBOBOX(id, func)}
43 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
44 the list is selected. Note that calling GetValue() returns the new
46 @event{EVT_TEXT(id, func)}
47 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
49 @event{EVT_TEXT_ENTER(id, func)}
50 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
51 the combobox (notice that the combobox must have been created with
52 wxTE_PROCESS_ENTER style to receive this event).
57 <!-- @appearance{combobox.png} -->
59 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
61 class wxComboBox
: public wxControl
, public wxItemContainer
71 Constructor, creating and showing a combobox.
74 Parent window. Must not be @NULL.
76 Window identifier. The value wxID_ANY indicates a default value.
78 Initial selection string. An empty string indicates no selection.
82 Window size. If wxDefaultSize is specified then the window is sized
85 Number of strings with which to initialise the control.
87 An array of strings with which to initialise the control.
89 Window style. See wxComboBox.
96 The wxComboBox constructor in wxPython reduces the @a n and @a choices
97 arguments are to a single argument, which is a list of strings.
100 @see Create(), wxValidator
102 wxComboBox(wxWindow
* parent
, wxWindowID id
,
103 const wxString
& value
= "",
104 const wxPoint
& pos
= wxDefaultPosition
,
105 const wxSize
& size
= wxDefaultSize
,
107 const wxString choices
[] = NULL
,
109 const wxValidator
& validator
= wxDefaultValidator
,
110 const wxString
& name
= "comboBox");
111 wxComboBox(wxWindow
* parent
, wxWindowID id
,
112 const wxString
& value
,
115 const wxArrayString
& choices
,
117 const wxValidator
& validator
= wxDefaultValidator
,
118 const wxString
& name
= "comboBox");
122 Destructor, destroying the combobox.
128 Creates the combobox for two-step construction. Derived classes should
129 call or replace this function. See wxComboBox() for further details.
131 bool Create(wxWindow
* parent
, wxWindowID id
,
132 const wxString
& value
= "",
133 const wxPoint
& pos
= wxDefaultPosition
,
134 const wxSize
& size
= wxDefaultSize
,
135 int n
, const wxString choices
[],
137 const wxValidator
& validator
= wxDefaultValidator
,
138 const wxString
& name
= "comboBox");
139 bool Create(wxWindow
* parent
, wxWindowID id
,
140 const wxString
& value
,
143 const wxArrayString
& choices
,
145 const wxValidator
& validator
= wxDefaultValidator
,
146 const wxString
& name
= "comboBox");
150 Returns @true if the combobox is editable and there is a text selection
151 to copy to the clipboard. Only available on Windows.
153 bool CanCopy() const;
156 Returns @true if the combobox is editable and there is a text selection
157 to copy to the clipboard. Only available on Windows.
162 Returns @true if the combobox is editable and there is text on the
163 clipboard that can be pasted into the text field. Only available on
166 bool CanPaste() const;
169 Returns @true if the combobox is editable and the last undo can be
170 redone. Only available on Windows.
172 bool CanRedo() const;
175 Returns @true if the combobox is editable and the last edit can be
176 undone. Only available on Windows.
178 bool CanUndo() const;
181 Copies the selected text to the clipboard.
186 Copies the selected text to the clipboard and removes the selection.
191 This function does the same things as wxChoice::GetCurrentSelection()
192 and returns the item currently selected in the dropdown list if it's
193 open or the same thing as wxControlWithItems::GetSelection() otherwise.
195 int GetCurrentSelection() const;
198 Returns the insertion point for the combobox's text field.
200 @note Under wxMSW, this function always returns 0 if the combobox
201 doesn't have the focus.
203 long GetInsertionPoint() const;
206 Returns the last position in the combobox text field.
208 virtual wxTextPos
GetLastPosition() const;
211 This is the same as wxTextCtrl::GetSelection() for the text control
212 which is part of the combobox. Notice that this is a different method
213 from wxControlWithItems::GetSelection().
215 Currently this method is only implemented in wxMSW and wxGTK.
217 void GetSelection(long* from
, long* to
) const;
220 Returns the current value in the combobox text field.
222 wxString
GetValue() const;
225 Pastes text from the clipboard to the text field.
230 Redoes the last undo in the text field. Windows only.
235 Removes the text between the two positions in the combobox text field.
242 void Remove(long from
, long to
);
245 Replaces the text between two positions with the given text, in the
255 void Replace(long from
, long to
, const wxString
& text
);
258 Sets the insertion point in the combobox text field.
261 The new insertion point.
263 void SetInsertionPoint(long pos
);
266 Sets the insertion point at the end of the combobox text field.
268 void SetInsertionPointEnd();
271 Selects the text between the two positions, in the combobox text field.
279 This method is called SetMark() in wxPython, "SetSelection" is kept for
280 wxControlWithItems::SetSelection().
283 void SetSelection(long from
, long to
);
286 Sets the text for the combobox text field.
288 @note For a combobox with @c wxCB_READONLY style the string must be in
289 the combobox choices list, otherwise the call to SetValue() is
295 void SetValue(const wxString
& text
);
298 Undoes the last edit in the text field. Windows only.