]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/combobox.tex
typo
[wxWidgets.git] / docs / latex / wx / combobox.tex
... / ...
CommitLineData
1\section{\class{wxComboBox}}\label{wxcombobox}
2
3A combobox is like a combination of an edit control and a listbox. It can be
4displayed as static list with editable or read-only text field; or a drop-down list with
5text field; or a drop-down list without a text field.
6
7A combobox permits a single selection only. Combobox items are numbered from zero.
8
9If you need a customized combobox, have a look at \helpref{wxComboCtrl}{wxcomboctrl},
10\helpref{wxOwnerDrawnComboBox}{wxownerdrawncombobox}, \helpref{wxComboPopup}{wxcombopopup}
11and the ready-to-use \helpref{wxBitmapComboBox}{wxbitmapcombobox}.
12
13\wxheading{Derived from}
14
15\helpref{wxControlWithItems}{wxcontrolwithitems}\\
16\helpref{wxControl}{wxcontrol}\\
17\helpref{wxWindow}{wxwindow}\\
18\helpref{wxEvtHandler}{wxevthandler}\\
19\helpref{wxObject}{wxobject}
20
21\wxheading{Include files}
22
23<wx/combobox.h>
24
25\wxheading{Library}
26
27\helpref{wxCore}{librarieslist}
28
29\wxheading{Window styles}
30
31\begin{twocollist}\itemsep=0pt
32\twocolitem{\windowstyle{wxCB\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only. }
33\twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.}
34\twocolitem{\windowstyle{wxCB\_READONLY}}{Same as wxCB\_DROPDOWN but only the
35strings specified as the combobox choices can be selected, it is impossible to
36select (even from a program) a string which is not in the choices list.}
37\twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
38\twocolitem{\windowstyle{wxTE\_PROCESS\_ENTER}}{The control will generate
39the event wxEVT\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
40is either processed internally by the control or used for navigation between
41dialog controls). Windows only.}
42\end{twocollist}
43
44See also \helpref{window styles overview}{windowstyles}.
45
46\wxheading{Event handling}
47
48\twocolwidtha{7cm}
49\begin{twocollist}\itemsep=0pt
50\twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
51when an item on the list is selected. Note that calling
52\helpref{GetValue}{wxcomboboxgetvalue} returns the new value of selection.}
53\twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
54when the combobox text changes.}
55\twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_ENTER event,
56when <RETURN> is pressed in the combobox.}
57\end{twocollist}
58
59\wxheading{See also}
60
61\helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
62\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
63
64\latexignore{\rtfignore{\wxheading{Members}}}
65
66
67\membersection{wxComboBox::wxComboBox}\label{wxcomboboxctor}
68
69\func{}{wxComboBox}{\void}
70
71Default constructor.
72
73\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
74\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
75\param{int}{ n = 0}, \param{const wxString }{choices[] = NULL},\rtfsp
76\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
77
78\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
79\param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
80\param{const wxArrayString\& }{choices},\rtfsp
81\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
82
83Constructor, creating and showing a combobox.
84
85\wxheading{Parameters}
86
87\docparam{parent}{Parent window. Must not be NULL.}
88
89\docparam{id}{Window identifier. A value of -1 indicates a default value.}
90
91\docparam{value}{Initial selection string. An empty string indicates no selection.}
92
93\docparam{pos}{Window position.}
94
95\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
96appropriately.}
97
98\docparam{n}{Number of strings with which to initialise the control.}
99
100\docparam{choices}{An array of strings with which to initialise the control.}
101
102\docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
103
104\docparam{validator}{Window validator.}
105
106\docparam{name}{Window name.}
107
108\wxheading{See also}
109
110\helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
111
112\pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n}
113and {\tt choices} arguments are to a single argument, which is
114a list of strings.}
115
116\perlnote{In wxPerl there is just an array reference in place of {\tt n}
117and {\tt choices}.}
118
119
120\membersection{wxComboBox::\destruct{wxComboBox}}\label{wxcomboboxdtor}
121
122\func{}{\destruct{wxComboBox}}{\void}
123
124Destructor, destroying the combobox.
125
126
127\membersection{wxComboBox::Create}\label{wxcomboboxcreate}
128
129\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
130\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
131\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
132\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
133
134\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
135\param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
136\param{const wxArrayString\& }{choices},\rtfsp
137\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
138
139Creates the combobox for two-step construction. Derived classes
140should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxctor}\rtfsp
141for further details.
142
143
144\membersection{wxComboBox::CanCopy}\label{wxcomboboxcancopy}
145
146\constfunc{bool}{CanCopy}{\void}
147
148Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
149Only available on Windows.
150
151
152\membersection{wxComboBox::CanCut}\label{wxcomboboxcancut}
153
154\constfunc{bool}{CanCut}{\void}
155
156Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
157Only available on Windows.
158
159
160\membersection{wxComboBox::CanPaste}\label{wxcomboboxcanpaste}
161
162\constfunc{bool}{CanPaste}{\void}
163
164Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
165text field. Only available on Windows.
166
167
168\membersection{wxComboBox::CanRedo}\label{wxcomboboxcanredo}
169
170\constfunc{bool}{CanRedo}{\void}
171
172Returns true if the combobox is editable and the last undo can be redone.
173Only available on Windows.
174
175
176\membersection{wxComboBox::CanUndo}\label{wxcomboboxcanundo}
177
178\constfunc{bool}{CanUndo}{\void}
179
180Returns true if the combobox is editable and the last edit can be undone.
181Only available on Windows.
182
183
184\membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
185
186\func{void}{Copy}{\void}
187
188Copies the selected text to the clipboard.
189
190
191\membersection{wxComboBox::Cut}\label{wxcomboboxcut}
192
193\func{void}{Cut}{\void}
194
195Copies the selected text to the clipboard and removes the selection.
196
197
198\membersection{wxComboBox::GetCurrentSelection}\label{wxcomboboxgetcurrentselection}
199
200\constfunc{int}{GetCurrentSelection}{\void}
201
202This function does the same things as
203\helpref{wxChoice::GetCurrentSelection}{wxchoicegetcurrentselection} and
204returns the item currently selected in the dropdown list if it's open or the
205same thing as \helpref{GetSelection}{wxcontrolwithitemsgetselection} otherwise.
206
207
208\membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
209
210\constfunc{long}{GetInsertionPoint}{\void}
211
212Returns the insertion point for the combobox's text field.
213
214\textbf{Note:} Under wxMSW, this function always returns $0$ if the combobox
215doesn't have the focus.
216
217
218\membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
219
220\constfunc{virtual wxTextPos}{GetLastPosition}{\void}
221
222Returns the last position in the combobox text field.
223
224
225\membersection{wxComboBox::GetSelection}\label{wxcomboboxgetselection}
226
227\constfunc{void}{GetSelection}{\param{long *}{from}, \param{long *}{to}}
228
229This is the same as \helpref{wxTextCtrl::GetSelection}{wxtextctrlgetselection}
230for the text control which is part of the combobox. Notice that this is a
231different method from \helpref{wxControlWithItems::GetSelection}{wxcontrolwithitemsgetselection}.
232
233Currently this method is only implemented in wxMSW and wxGTK.
234
235
236\membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
237
238\constfunc{wxString}{GetValue}{\void}
239
240Returns the current value in the combobox text field.
241
242
243\membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
244
245\func{void}{Paste}{\void}
246
247Pastes text from the clipboard to the text field.
248
249
250\membersection{wxComboBox::Redo}\label{wxcomboboxredo}
251
252\func{void}{Redo}{\void}
253
254Redoes the last undo in the text field. Windows only.
255
256
257\membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
258
259\func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
260
261Replaces the text between two positions with the given text, in the combobox text field.
262
263\wxheading{Parameters}
264
265\docparam{from}{The first position.}
266
267\docparam{to}{The second position.}
268
269\docparam{text}{The text to insert.}
270
271
272\membersection{wxComboBox::Remove}\label{wxcomboboxremove}
273
274\func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
275
276Removes the text between the two positions in the combobox text field.
277
278\wxheading{Parameters}
279
280\docparam{from}{The first position.}
281
282\docparam{to}{The last position.}
283
284
285\membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
286
287\func{void}{SetInsertionPoint}{\param{long}{ pos}}
288
289Sets the insertion point in the combobox text field.
290
291\wxheading{Parameters}
292
293\docparam{pos}{The new insertion point.}
294
295
296\membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
297
298\func{void}{SetInsertionPointEnd}{\void}
299
300Sets the insertion point at the end of the combobox text field.
301
302
303\membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
304
305\func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
306
307Selects the text between the two positions, in the combobox text field.
308
309\wxheading{Parameters}
310
311\docparam{from}{The first position.}
312
313\docparam{to}{The second position.}
314
315\pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection}
316name is kept for
317\helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.}
318
319
320\membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
321
322\func{void}{SetValue}{\param{const wxString\& }{text}}
323
324Sets the text for the combobox text field.
325
326{\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in
327the combobox choices list, otherwise the call to SetValue() is ignored.
328
329\wxheading{Parameters}
330
331\docparam{text}{The text to set.}
332
333
334\membersection{wxComboBox::Undo}\label{wxcomboboxundo}
335
336\func{void}{Undo}{\void}
337
338Undoes the last edit in the text field. Windows only.
339