]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/combobox.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxComboBox
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A combobox is like a combination of an edit control and a listbox. It can
13 be displayed as static list with editable or read-only text field; or a
14 drop-down list with text field; or a drop-down list without a text field.
16 A combobox permits a single selection only. Combobox items are numbered
19 If you need a customized combobox, have a look at wxComboCtrl,
20 wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
24 Creates a combobox with a permanently displayed list. Windows only.
26 Creates a combobox with a drop-down list.
28 Same as wxCB_DROPDOWN but only the strings specified as the combobox
29 choices can be selected, it is impossible to select (even from a
30 program) a string which is not in the choices list.
32 Sorts the entries in the list alphabetically.
33 @style{wxTE_PROCESS_ENTER}
34 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
35 (otherwise pressing Enter key is either processed internally by the
36 control or used for navigation between dialog controls). Windows
40 @beginEventTable{wxCommandEvent}
41 @event{EVT_COMBOBOX(id, func)}
42 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
43 the list is selected. Note that calling GetValue() returns the new
45 @event{EVT_TEXT(id, func)}
46 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
48 @event{EVT_TEXT_ENTER(id, func)}
49 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
50 the combobox (notice that the combobox must have been created with
51 wxTE_PROCESS_ENTER style to receive this event).
56 <!-- @appearance{combobox.png} -->
58 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
60 class wxComboBox
: public wxControl
, public wxItemContainer
70 Constructor, creating and showing a combobox.
73 Parent window. Must not be @NULL.
75 Window identifier. The value wxID_ANY indicates a default value.
77 Initial selection string. An empty string indicates no selection.
81 Window size. If wxDefaultSize is specified then the window is sized
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.
95 The wxComboBox constructor in wxPython reduces the @a n and @a choices
96 arguments are to a single argument, which is a list of strings.
99 @see Create(), wxValidator
101 wxComboBox(wxWindow
* parent
, wxWindowID id
,
102 const wxString
& value
= "",
103 const wxPoint
& pos
= wxDefaultPosition
,
104 const wxSize
& size
= wxDefaultSize
,
106 const wxString choices
[] = NULL
,
108 const wxValidator
& validator
= wxDefaultValidator
,
109 const wxString
& name
= "comboBox");
110 wxComboBox(wxWindow
* parent
, wxWindowID id
,
111 const wxString
& value
,
114 const wxArrayString
& choices
,
116 const wxValidator
& validator
= wxDefaultValidator
,
117 const wxString
& name
= "comboBox");
121 Destructor, destroying the combobox.
127 Creates the combobox for two-step construction. Derived classes should
128 call or replace this function. See wxComboBox() for further details.
130 bool Create(wxWindow
* parent
, wxWindowID id
,
131 const wxString
& value
= "",
132 const wxPoint
& pos
= wxDefaultPosition
,
133 const wxSize
& size
= wxDefaultSize
,
134 int n
, const wxString choices
[],
136 const wxValidator
& validator
= wxDefaultValidator
,
137 const wxString
& name
= "comboBox");
138 bool Create(wxWindow
* parent
, wxWindowID id
,
139 const wxString
& value
,
142 const wxArrayString
& choices
,
144 const wxValidator
& validator
= wxDefaultValidator
,
145 const wxString
& name
= "comboBox");
149 Returns @true if the combobox is editable and there is a text selection
150 to copy to the clipboard. Only available on Windows.
152 bool CanCopy() const;
155 Returns @true if the combobox is editable and there is a text selection
156 to copy to the clipboard. Only available on Windows.
161 Returns @true if the combobox is editable and there is text on the
162 clipboard that can be pasted into the text field. Only available on
165 bool CanPaste() const;
168 Returns @true if the combobox is editable and the last undo can be
169 redone. Only available on Windows.
171 bool CanRedo() const;
174 Returns @true if the combobox is editable and the last edit can be
175 undone. Only available on Windows.
177 bool CanUndo() const;
180 Copies the selected text to the clipboard.
185 Copies the selected text to the clipboard and removes the selection.
190 This function does the same things as wxChoice::GetCurrentSelection()
191 and returns the item currently selected in the dropdown list if it's
192 open or the same thing as wxControlWithItems::GetSelection() otherwise.
194 int GetCurrentSelection() const;
197 Returns the insertion point for the combobox's text field.
199 @note Under wxMSW, this function always returns 0 if the combobox
200 doesn't have the focus.
202 long GetInsertionPoint() const;
205 Returns the last position in the combobox text field.
207 virtual wxTextPos
GetLastPosition() const;
210 This is the same as wxTextCtrl::GetSelection() for the text control
211 which is part of the combobox. Notice that this is a different method
212 from wxControlWithItems::GetSelection().
214 Currently this method is only implemented in wxMSW and wxGTK.
216 void GetSelection(long* from
, long* to
) const;
219 Returns the current value in the combobox text field.
221 wxString
GetValue() const;
224 Pastes text from the clipboard to the text field.
229 Redoes the last undo in the text field. Windows only.
234 Removes the text between the two positions in the combobox text field.
241 void Remove(long from
, long to
);
244 Replaces the text between two positions with the given text, in the
254 void Replace(long from
, long to
, const wxString
& text
);
257 Sets the insertion point in the combobox text field.
260 The new insertion point.
262 void SetInsertionPoint(long pos
);
265 Sets the insertion point at the end of the combobox text field.
267 void SetInsertionPointEnd();
270 Selects the text between the two positions, in the combobox text field.
278 This method is called SetMark() in wxPython, "SetSelection" is kept for
279 wxControlWithItems::SetSelection().
282 void SetSelection(long from
, long to
);
285 Sets the text for the combobox text field.
287 @note For a combobox with @c wxCB_READONLY style the string must be in
288 the combobox choices list, otherwise the call to SetValue() is
294 void SetValue(const wxString
& text
);
297 Undoes the last edit in the text field. Windows only.