]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/combobox.h
Removing more CodeWarrior project files.
[wxWidgets.git] / interface / wx / combobox.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: combobox.h
e54c96f1 3// Purpose: interface of wxComboBox
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxComboBox
7c913512 11
2e7789a9
VZ
12 A combobox is like a combination of an edit control and a listbox.
13
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
16 field.
7c913512 17
bd0812fe
BP
18 A combobox permits a single selection only. Combobox items are numbered
19 from zero.
7c913512 20
bd0812fe
BP
21 If you need a customized combobox, have a look at wxComboCtrl,
22 wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
7c913512 23
2e7789a9
VZ
24 Please refer to wxTextEntry documentation for the description of methods
25 operating with the text entry part of the combobox.
26
23324ae1 27 @beginStyleTable
8c6791e4 28 @style{wxCB_SIMPLE}
23324ae1 29 Creates a combobox with a permanently displayed list. Windows only.
8c6791e4 30 @style{wxCB_DROPDOWN}
23324ae1 31 Creates a combobox with a drop-down list.
8c6791e4 32 @style{wxCB_READONLY}
bd0812fe
BP
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.
8c6791e4 36 @style{wxCB_SORT}
23324ae1 37 Sorts the entries in the list alphabetically.
8c6791e4 38 @style{wxTE_PROCESS_ENTER}
23324ae1
FM
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
42 only.
43 @endStyleTable
7c913512 44
3051a44a 45 @beginEventEmissionTable{wxCommandEvent}
8c6791e4 46 @event{EVT_COMBOBOX(id, func)}
23324ae1 47 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
bd0812fe 48 the list is selected. Note that calling GetValue() returns the new
23324ae1 49 value of selection.
8c6791e4 50 @event{EVT_TEXT(id, func)}
23324ae1
FM
51 Process a wxEVT_COMMAND_TEXT_UPDATED event, when the combobox text
52 changes.
8c6791e4 53 @event{EVT_TEXT_ENTER(id, func)}
23324ae1
FM
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).
57 @endEventTable
7c913512 58
23324ae1
FM
59 @library{wxcore}
60 @category{ctrl}
7e59b885 61 @appearance{combobox.png}
7c913512 62
e54c96f1 63 @see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
23324ae1 64*/
2e7789a9
VZ
65class wxComboBox : public wxControl,
66 public wxItemContainer,
67 public wxTextEntry
23324ae1
FM
68{
69public:
bd0812fe
BP
70 /**
71 Default constructor.
72 */
73 wxComboBox();
74
23324ae1
FM
75 //@{
76 /**
77 Constructor, creating and showing a combobox.
3c4f71cc 78
7c913512 79 @param parent
4cc4bfaf 80 Parent window. Must not be @NULL.
7c913512 81 @param id
4cc4bfaf 82 Window identifier. The value wxID_ANY indicates a default value.
7c913512 83 @param value
4cc4bfaf 84 Initial selection string. An empty string indicates no selection.
a3281dbc
VZ
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.
7c913512 87 @param pos
4cc4bfaf 88 Window position.
7c913512 89 @param size
bd0812fe 90 Window size. If wxDefaultSize is specified then the window is sized
4cc4bfaf 91 appropriately.
7c913512 92 @param n
4cc4bfaf 93 Number of strings with which to initialise the control.
7c913512 94 @param choices
4cc4bfaf 95 An array of strings with which to initialise the control.
7c913512 96 @param style
4cc4bfaf 97 Window style. See wxComboBox.
7c913512 98 @param validator
4cc4bfaf 99 Window validator.
7c913512 100 @param name
4cc4bfaf 101 Window name.
3c4f71cc 102
bd0812fe
BP
103 @beginWxPythonOnly
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.
106 @endWxPythonOnly
107
4cc4bfaf 108 @see Create(), wxValidator
23324ae1 109 */
7c913512 110 wxComboBox(wxWindow* parent, wxWindowID id,
e9c3992c 111 const wxString& value = wxEmptyString,
7c913512
FM
112 const wxPoint& pos = wxDefaultPosition,
113 const wxSize& size = wxDefaultSize,
114 int n = 0,
4cc4bfaf 115 const wxString choices[] = NULL,
7c913512
FM
116 long style = 0,
117 const wxValidator& validator = wxDefaultValidator,
882678eb 118 const wxString& name = wxComboBoxNameStr);
792255cc
VZ
119 /**
120 Constructor, creating and showing a combobox.
121
122 @param parent
123 Parent window. Must not be @NULL.
124 @param id
125 Window identifier. The value wxID_ANY indicates a default value.
126 @param value
127 Initial selection string. An empty string indicates no selection.
128 @param pos
129 Window position.
130 @param size
131 Window size. If wxDefaultSize is specified then the window is sized
132 appropriately.
133 @param choices
134 An array of strings with which to initialise the control.
135 @param style
136 Window style. See wxComboBox.
137 @param validator
138 Window validator.
139 @param name
140 Window name.
141
142 @beginWxPythonOnly
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.
145 @endWxPythonOnly
146
147 @see Create(), wxValidator
148 */
7c913512
FM
149 wxComboBox(wxWindow* parent, wxWindowID id,
150 const wxString& value,
151 const wxPoint& pos,
152 const wxSize& size,
153 const wxArrayString& choices,
154 long style = 0,
155 const wxValidator& validator = wxDefaultValidator,
882678eb 156 const wxString& name = wxComboBoxNameStr);
23324ae1
FM
157 //@}
158
159 /**
160 Destructor, destroying the combobox.
161 */
b7e94bd7 162 virtual ~wxComboBox();
23324ae1 163
bd0812fe 164 //@{
23324ae1 165 /**
bd0812fe
BP
166 Creates the combobox for two-step construction. Derived classes should
167 call or replace this function. See wxComboBox() for further details.
168 */
57bf907d
FM
169 bool Create(wxWindow *parent, wxWindowID id,
170 const wxString& value = wxEmptyString,
bd0812fe
BP
171 const wxPoint& pos = wxDefaultPosition,
172 const wxSize& size = wxDefaultSize,
57bf907d 173 int n = 0, const wxString choices[] = (const wxString *) NULL,
bd0812fe
BP
174 long style = 0,
175 const wxValidator& validator = wxDefaultValidator,
57bf907d
FM
176 const wxString& name = wxComboBoxNameStr);
177 bool Create(wxWindow *parent, wxWindowID id,
bd0812fe
BP
178 const wxString& value,
179 const wxPoint& pos,
180 const wxSize& size,
181 const wxArrayString& choices,
182 long style = 0,
183 const wxValidator& validator = wxDefaultValidator,
57bf907d 184 const wxString& name = wxComboBoxNameStr);
bd0812fe
BP
185 //@}
186
187 /**
2e7789a9 188 Returns the item being selected right now.
23324ae1 189
bd0812fe
BP
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.
23324ae1 193 */
b7e94bd7 194 virtual int GetCurrentSelection() const;
23324ae1
FM
195
196 /**
2e7789a9 197 Same as wxTextEntry::GetInsertionPoint().
bd0812fe 198
cdbcf4c2 199 @note Under wxMSW, this function always returns 0 if the combobox
bd0812fe 200 doesn't have the focus.
23324ae1 201 */
0004982c 202 virtual long GetInsertionPoint() const;
23324ae1
FM
203
204 /**
2e7789a9 205 Same as wxTextEntry::SetSelection().
bd0812fe
BP
206
207 @beginWxPythonOnly
208 This method is called SetMark() in wxPython, "SetSelection" is kept for
209 wxControlWithItems::SetSelection().
210 @endWxPythonOnly
23324ae1 211 */
b7e94bd7 212 virtual void SetSelection(long from, long to);
23324ae1
FM
213
214 /**
215 Sets the text for the combobox text field.
1f1d2182
FM
216
217 @note For a combobox with @c wxCB_READONLY style the string must be in
bd0812fe
BP
218 the combobox choices list, otherwise the call to SetValue() is
219 ignored.
3c4f71cc 220
7c913512 221 @param text
4cc4bfaf 222 The text to set.
23324ae1 223 */
0004982c 224 virtual void SetValue(const wxString& text);
23324ae1 225};
e54c96f1 226