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