]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/combobox.h
c3ac2859d0216e9f543ebfc2317d078a7c70fbbf
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.
14 It can be displayed as static list with editable or read-only text field;
15 or a drop-down list with text field; or a drop-down list without a text
18 A combobox permits a single selection only. Combobox items are numbered
21 If you need a customized combobox, have a look at wxComboCtrl,
22 wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
24 Please refer to wxTextEntry documentation for the description of methods
25 operating with the text entry part of the combobox.
29 Creates a combobox with a permanently displayed list. Windows only.
31 Creates a combobox with a drop-down list.
33 Same as wxCB_DROPDOWN but only the strings specified as the combobox
34 choices can be selected, it is impossible to select (even from a
35 program) a string which is not in the choices list.
37 Sorts the entries in the list alphabetically.
38 @style{wxTE_PROCESS_ENTER}
39 The control will generate the event wxEVT_COMMAND_TEXT_ENTER
40 (otherwise pressing Enter key is either processed internally by the
41 control or used for navigation between dialog controls). Windows
45 @beginEventEmissionTable{wxCommandEvent}
46 @event{EVT_COMBOBOX(id, func)}
47 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
48 the list is selected. Note that calling GetValue() returns the new
50 @event{EVT_TEXT(id, func)}
51 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
53 @event{EVT_TEXT_ENTER(id, func)}
54 Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
55 the combobox (notice that the combobox must have been created with
56 wxTE_PROCESS_ENTER style to receive this event).
61 @appearance{combobox.png}
63 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
65 class wxComboBox
: public wxControl
,
66 public wxItemContainer
,
77 Constructor, creating and showing a combobox.
80 Parent window. Must not be @NULL.
82 Window identifier. The value wxID_ANY indicates a default value.
84 Initial selection string. An empty string indicates no selection.
85 Notice that for the controls with @c wxCB_READONLY style this
86 string must be one of the valid choices if it is not empty.
90 Window size. If wxDefaultSize is specified then the window is sized
93 Number of strings with which to initialise the control.
95 An array of strings with which to initialise the control.
97 Window style. See wxComboBox.
104 The wxComboBox constructor in wxPython reduces the @a n and @a choices
105 arguments are to a single argument, which is a list of strings.
108 @see Create(), wxValidator
110 wxComboBox(wxWindow
* parent
, wxWindowID id
,
111 const wxString
& value
= wxEmptyString
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
115 const wxString choices
[] = NULL
,
117 const wxValidator
& validator
= wxDefaultValidator
,
118 const wxString
& name
= wxComboBoxNameStr
);
120 Constructor, creating and showing a combobox.
123 Parent window. Must not be @NULL.
125 Window identifier. The value wxID_ANY indicates a default value.
127 Initial selection string. An empty string indicates no selection.
131 Window size. If wxDefaultSize is specified then the window is sized
134 An array of strings with which to initialise the control.
136 Window style. See wxComboBox.
143 The wxComboBox constructor in wxPython reduces the @a n and @a choices
144 arguments are to a single argument, which is a list of strings.
147 @see Create(), wxValidator
149 wxComboBox(wxWindow
* parent
, wxWindowID id
,
150 const wxString
& value
,
153 const wxArrayString
& choices
,
155 const wxValidator
& validator
= wxDefaultValidator
,
156 const wxString
& name
= wxComboBoxNameStr
);
160 Destructor, destroying the combobox.
162 virtual ~wxComboBox();
166 Creates the combobox for two-step construction. Derived classes should
167 call or replace this function. See wxComboBox() for further details.
169 bool Create(wxWindow
*parent
, wxWindowID id
,
170 const wxString
& value
= wxEmptyString
,
171 const wxPoint
& pos
= wxDefaultPosition
,
172 const wxSize
& size
= wxDefaultSize
,
173 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
175 const wxValidator
& validator
= wxDefaultValidator
,
176 const wxString
& name
= wxComboBoxNameStr
);
177 bool Create(wxWindow
*parent
, wxWindowID id
,
178 const wxString
& value
,
181 const wxArrayString
& choices
,
183 const wxValidator
& validator
= wxDefaultValidator
,
184 const wxString
& name
= wxComboBoxNameStr
);
188 Returns the item being selected right now.
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 virtual int GetCurrentSelection() const;
197 Same as wxTextEntry::GetInsertionPoint().
199 @note Under wxMSW, this function always returns 0 if the combobox
200 doesn't have the focus.
202 virtual long GetInsertionPoint() const;
205 Same as wxTextEntry::SetSelection().
208 This method is called SetMark() in wxPython, "SetSelection" is kept for
209 wxControlWithItems::SetSelection().
212 virtual void SetSelection(long from
, long to
);
215 Sets the text for the combobox text field.
217 @note For a combobox with @c wxCB_READONLY style the string must be in
218 the combobox choices list, otherwise the call to SetValue() is
224 virtual void SetValue(const wxString
& text
);