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