]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/combobox.tex
fixed bug in mouse handling
[wxWidgets.git] / docs / latex / wx / combobox.tex
1 \section{\class{wxComboBox}}\label{wxcombobox}
2
3 A combobox is like a combination of an edit control and a listbox. It can be
4 displayed as static list with editable or read-only text field; or a drop-down list with
5 text field; or a drop-down list without a text field.
6
7 A combobox permits a single selection only. Combobox items are numbered from zero.
8
9 \wxheading{Derived from}
10
11 \helpref{wxChoice}{wxchoice}\\
12 \helpref{wxControl}{wxcontrol}\\
13 \helpref{wxWindow}{wxwindow}\\
14 \helpref{wxEvtHandler}{wxevthandler}\\
15 \helpref{wxObject}{wxobject}
16
17 \wxheading{Include files}
18
19 <wx/combobox.h>
20
21 \wxheading{Window styles}
22
23 \begin{twocollist}\itemsep=0pt
24 \twocolitem{\windowstyle{wxCB\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only. }
25 \twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.}
26 \twocolitem{\windowstyle{wxCB\_READONLY}}{Same as wxCB\_DROPDOWN but only the
27 strings specified as the combobox choices can be selected, it is impossible to
28 select (even from a program) a string which is not in the choices list.}
29 \twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
30 \end{twocollist}
31
32 See also \helpref{window styles overview}{windowstyles}.
33
34 \wxheading{Event handling}
35
36 \twocolwidtha{7cm}
37 \begin{twocollist}\itemsep=0pt
38 \twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
39 when an item on the list is selected.}
40 \twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
41 when the combobox text changes.}
42 \end{twocollist}
43
44 \wxheading{See also}
45
46 \helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
47 \rtfsp\helpref{wxCommandEvent}{wxcommandevent}
48
49 \latexignore{\rtfignore{\wxheading{Members}}}
50
51 \membersection{wxComboBox::wxComboBox}\label{wxcomboboxconstr}
52
53 \func{}{wxComboBox}{\void}
54
55 Default constructor.
56
57 \func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
58 \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
59 \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
60 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
61
62 Constructor, creating and showing a combobox.
63
64 \wxheading{Parameters}
65
66 \docparam{parent}{Parent window. Must not be NULL.}
67
68 \docparam{id}{Window identifier. A value of -1 indicates a default value.}
69
70 \docparam{pos}{Window position.}
71
72 \docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
73 appropriately.}
74
75 \docparam{n}{Number of strings with which to initialise the control.}
76
77 \docparam{choices}{An array of strings with which to initialise the control.}
78
79 \docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
80
81 \docparam{validator}{Window validator.}
82
83 \docparam{name}{Window name.}
84
85 \wxheading{See also}
86
87 \helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
88
89 \pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n}
90 and {\tt choices} arguments are to a single argument, which is
91 a list of strings.}
92
93
94 \membersection{wxComboBox::\destruct{wxComboBox}}
95
96 \func{}{\destruct{wxComboBox}}{\void}
97
98 Destructor, destroying the combobox.
99
100 \membersection{wxComboBox::Append}\label{wxcomboboxappend}
101
102 \func{void}{Append}{\param{const wxString\& }{item}}
103
104 Adds the item to the end of the combobox.
105
106 \func{void}{Append}{\param{const wxString\& }{ item}, \param{void* }{clientData}}
107
108 Adds the item to the end of the combobox, associating the given data
109 with the item.
110
111 \wxheading{Parameters}
112
113 \docparam{item}{The string to add.}
114
115 \docparam{clientData}{Client data to associate with the item.}
116
117 \membersection{wxComboBox::Clear}\label{wxcomboboxclear}
118
119 \func{void}{Clear}{\void}
120
121 Clears all strings from the combobox.
122
123 \membersection{wxComboBox::Create}\label{wxcomboboxcreate}
124
125 \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
126 \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
127 \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
128 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
129
130 Creates the combobox for two-step construction. Derived classes
131 should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxconstr}\rtfsp
132 for further details.
133
134 \membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
135
136 \func{void}{Copy}{\void}
137
138 Copies the selected text to the clipboard.
139
140 \membersection{wxComboBox::Cut}\label{wxcomboboxcut}
141
142 \func{void}{Cut}{\void}
143
144 Copies the selected text to the clipboard and removes the selection.
145
146 \membersection{wxComboBox::Delete}\label{wxcomboboxdelete}
147
148 \func{void}{Delete}{\param{int}{ n}}
149
150 Deletes an item from the combobox.
151
152 \wxheading{Parameters}
153
154 \docparam{n}{The item to delete, starting from zero.}
155
156 \membersection{wxComboBox::FindString}\label{wxcomboboxfindstring}
157
158 \func{int}{FindString}{\param{const wxString\& }{string}}
159
160 Finds a choice matching the given string.
161
162 \wxheading{Parameters}
163
164 \docparam{string}{The item to find.}
165
166 \wxheading{Return value}
167
168 The position if found, or -1 if not found.
169
170 \membersection{wxComboBox::GetClientData}\label{wxcomboboxgetclientdata}
171
172 \constfunc{void*}{GetClientData}{\param{int}{ n}}
173
174 Returns a pointer to the client data associated with the given item (if any).
175
176 \wxheading{Parameters}
177
178 \docparam{n}{An item, starting from zero.}
179
180 \wxheading{Return value}
181
182 A pointer to the client data, or NULL if the item was not found.
183
184 \membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
185
186 \constfunc{long}{GetInsertionPoint}{\void}
187
188 Returns the insertion point for the combobox's text field.
189
190 \membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
191
192 \constfunc{long}{GetLastPosition}{\void}
193
194 Returns the last position in the combobox text field.
195
196 \membersection{wxComboBox::GetSelection}\label{wxcomboboxgetselection}
197
198 \constfunc{int}{GetSelection}{\void}
199
200 Gets the position of the selected string, or -1 if there is no selection.
201
202 \membersection{wxComboBox::GetString}\label{wxcomboboxgetstring}
203
204 \constfunc{wxString}{GetString}{\param{int}{ n}}
205
206 Returns the string at position {\it n}.
207
208 \wxheading{Parameters}
209
210 \docparam{n}{The item position, starting from zero.}
211
212 \wxheading{Return value}
213
214 The string if the item is found, otherwise the empty string.
215
216 \membersection{wxComboBox::GetStringSelection}\label{wxcomboboxgetstringselection}
217
218 \constfunc{wxString}{GetStringSelection}{\void}
219
220 Gets the selected string.
221
222 \membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
223
224 \constfunc{wxString}{GetValue}{\void}
225
226 Returns the current value in the combobox text field.
227
228 \membersection{wxComboBox::Number}\label{wxcomboboxnumber}
229
230 \constfunc{int}{Number}{\void}
231
232 Returns the number of items in the combobox list.
233 %TODO: make this GetNumber or GetCount?
234
235 \membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
236
237 \func{void}{Paste}{\void}
238
239 Pastes text from the clipboard to the text field.
240
241 \membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
242
243 \func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
244
245 Replaces the text between two positions with the given text, in the combobox text field.
246
247 \wxheading{Parameters}
248
249 \docparam{from}{The first position.}
250
251 \docparam{to}{The second position.}
252
253 \docparam{text}{The text to insert.}
254
255 \membersection{wxComboBox::Remove}\label{wxcomboboxremove}
256
257 \func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
258
259 Removes the text between the two positions in the combobox text field.
260
261 \wxheading{Parameters}
262
263 \docparam{from}{The first position.}
264
265 \docparam{to}{The last position.}
266
267 \membersection{wxComboBox::SetClientData}\label{wxcomboboxsetclientdata}
268
269 \func{void}{SetClientData}{\param{int}{ n}, \param{void* }{data}}
270
271 Associates the given client data pointer with the given item.
272
273 \wxheading{Parameters}
274
275 \docparam{n}{The zero-based item.}
276
277 \docparam{data}{The client data.}
278
279 \membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
280
281 \func{void}{SetInsertionPoint}{\param{long}{ pos}}
282
283 Sets the insertion point in the combobox text field.
284
285 \wxheading{Parameters}
286
287 \docparam{pos}{The new insertion point.}
288
289 \membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
290
291 \func{void}{SetInsertionPointEnd}{\void}
292
293 Sets the insertion point at the end of the combobox text field.
294
295 \membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
296
297 \func{void}{SetSelection}{\param{int}{ n}}
298
299 Selects the given item in the combobox list. This does not cause a
300 wxEVT\_COMMAND\_COMBOBOX\_SELECTED event to get emitted.
301
302 \func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
303
304 Selects the text between the two positions, in the combobox text field.
305
306 \wxheading{Parameters}
307
308 \docparam{n}{The zero-based item to select.}
309
310 \docparam{from}{The first position.}
311
312 \docparam{to}{The second position.}
313
314 \pythonnote{The second form of this method is called {\tt SetMark} in
315 wxPython.}
316
317 \membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
318
319 \func{void}{SetValue}{\param{const wxString\& }{text}}
320
321 Sets the text for the combobox text field.
322
323 {\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in
324 the combobox choices list, otherwise the call to SetValue() is ignored.
325
326 \wxheading{Parameters}
327
328 \docparam{text}{The text to set.}
329
330