]>
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
= wxEmptyString
,
103 const wxPoint
& pos
= wxDefaultPosition
,
104 const wxSize
& size
= wxDefaultSize
,
106 const wxString choices
[] = NULL
,
108 const wxValidator
& validator
= wxDefaultValidator
,
109 const wxString
& name
= wxComboBoxNameStr
);
111 Constructor, creating and showing a combobox.
114 Parent window. Must not be @NULL.
116 Window identifier. The value wxID_ANY indicates a default value.
118 Initial selection string. An empty string indicates no selection.
122 Window size. If wxDefaultSize is specified then the window is sized
125 An array of strings with which to initialise the control.
127 Window style. See wxComboBox.
134 The wxComboBox constructor in wxPython reduces the @a n and @a choices
135 arguments are to a single argument, which is a list of strings.
138 @see Create(), wxValidator
140 wxComboBox(wxWindow
* parent
, wxWindowID id
,
141 const wxString
& value
,
144 const wxArrayString
& choices
,
146 const wxValidator
& validator
= wxDefaultValidator
,
147 const wxString
& name
= wxComboBoxNameStr
);
151 Destructor, destroying the combobox.
153 virtual ~wxComboBox();
157 Creates the combobox for two-step construction. Derived classes should
158 call or replace this function. See wxComboBox() for further details.
160 bool Create(wxWindow
*parent
, wxWindowID id
,
161 const wxString
& value
= wxEmptyString
,
162 const wxPoint
& pos
= wxDefaultPosition
,
163 const wxSize
& size
= wxDefaultSize
,
164 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
166 const wxValidator
& validator
= wxDefaultValidator
,
167 const wxString
& name
= wxComboBoxNameStr
);
168 bool Create(wxWindow
*parent
, wxWindowID id
,
169 const wxString
& value
,
172 const wxArrayString
& choices
,
174 const wxValidator
& validator
= wxDefaultValidator
,
175 const wxString
& name
= wxComboBoxNameStr
);
179 Returns @true if the combobox is editable and there is a text selection
180 to copy to the clipboard. Only available on Windows.
182 virtual bool CanCopy() const;
185 Returns @true if the combobox is editable and there is a text selection
186 to copy to the clipboard. Only available on Windows.
188 virtual bool CanCut() const;
191 Returns @true if the combobox is editable and there is text on the
192 clipboard that can be pasted into the text field. Only available on
195 virtual bool CanPaste() const;
198 Returns @true if the combobox is editable and the last undo can be
199 redone. Only available on Windows.
201 virtual bool CanRedo() const;
204 Returns @true if the combobox is editable and the last edit can be
205 undone. Only available on Windows.
207 virtual bool CanUndo() const;
210 Copies the selected text to the clipboard.
215 Copies the selected text to the clipboard and removes the selection.
220 This function does the same things as wxChoice::GetCurrentSelection()
221 and returns the item currently selected in the dropdown list if it's
222 open or the same thing as wxControlWithItems::GetSelection() otherwise.
224 virtual int GetCurrentSelection() const;
227 Returns the insertion point for the combobox's text field.
229 @note Under wxMSW, this function always returns 0 if the combobox
230 doesn't have the focus.
232 virtual long GetInsertionPoint() const;
235 Returns the last position in the combobox text field.
237 virtual long GetLastPosition() const;
240 This is the same as wxTextCtrl::GetSelection() for the text control
241 which is part of the combobox. Notice that this is a different method
242 from wxControlWithItems::GetSelection().
244 Currently this method is only implemented in wxMSW and wxGTK.
246 virtual void GetSelection(long* from
, long* to
) const;
249 Returns the current value in the combobox text field.
251 virtual wxString
GetValue() const;
254 Pastes text from the clipboard to the text field.
256 virtual void Paste();
259 Redoes the last undo in the text field. Windows only.
264 Removes the text between the two positions in the combobox text field.
271 virtual void Remove(long from
, long to
);
274 Replaces the text between two positions with the given text, in the
284 virtual void Replace(long from
, long to
, const wxString
& text
);
287 Sets the insertion point in the combobox text field.
290 The new insertion point.
292 virtual void SetInsertionPoint(long pos
);
295 Sets the insertion point at the end of the combobox text field.
297 virtual void SetInsertionPointEnd();
300 Selects the text between the two positions, in the combobox text field.
308 This method is called SetMark() in wxPython, "SetSelection" is kept for
309 wxControlWithItems::SetSelection().
312 virtual void SetSelection(long from
, long to
);
315 Sets the text for the combobox text field.
317 @note For a combobox with @c wxCB_READONLY style the string must be in
318 the combobox choices list, otherwise the call to SetValue() is
324 virtual void SetValue(const wxString
& text
);
327 Undoes the last edit in the text field. Windows only.