]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/choice.tex
fixed tex2rtf error
[wxWidgets.git] / docs / latex / wx / choice.tex
1 \section{\class{wxChoice}}\label{wxchoice}
2
3 A choice item is used to select one of a list of strings. Unlike a
4 listbox, only the selection is visible until the user pulls down the
5 menu of choices.
6
7 \wxheading{Derived from}
8
9 \helpref{wxControl}{wxcontrol}\\
10 \helpref{wxWindow}{wxwindow}\\
11 \helpref{wxEvtHandler}{wxevthandler}\\
12 \helpref{wxObject}{wxobject}
13
14 \wxheading{Include files}
15
16 <wx/choice.h>
17
18 \wxheading{Window styles}
19
20 There are no special styles for wxChoice.
21
22 See also \helpref{window styles overview}{windowstyles}.
23
24 \wxheading{Event handling}
25
26 \twocolwidtha{7cm}
27 \begin{twocollist}\itemsep=0pt
28 \twocolitem{{\bf EVT\_CHOICE(id, func)}}{Process a wxEVT\_COMMAND\_CHOICE\_SELECTED event,
29 when an item on the list is selected.}
30 \end{twocollist}
31
32 \wxheading{See also}
33
34 \helpref{wxListBox}{wxlistbox}, \helpref{wxComboBox}{wxcombobox},
35 \rtfsp\helpref{wxCommandEvent}{wxcommandevent}
36
37 \latexignore{\rtfignore{\wxheading{Members}}}
38
39 \membersection{wxChoice::wxChoice}\label{wxchoiceconstr}
40
41 \func{}{wxChoice}{\void}
42
43 Default constructor.
44
45 \func{}{wxChoice}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp
46 \param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp
47 \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
48 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``choice"}}
49
50 Constructor, creating and showing a choice.
51
52 \wxheading{Parameters}
53
54 \docparam{parent}{Parent window. Must not be NULL.}
55
56 \docparam{id}{Window identifier. A value of -1 indicates a default value.}
57
58 \docparam{pos}{Window position.}
59
60 \docparam{size}{Window size. If the default size (-1, -1) is specified then the choice is sized
61 appropriately.}
62
63 \docparam{n}{Number of strings with which to initialise the choice control.}
64
65 \docparam{choices}{An array of strings with which to initialise the choice control.}
66
67 \docparam{style}{Window style. See \helpref{wxChoice}{wxchoice}.}
68
69 \docparam{validator}{Window validator.}
70
71 \docparam{name}{Window name.}
72
73 \wxheading{See also}
74
75 \helpref{wxChoice::Create}{wxchoicecreate}, \helpref{wxValidator}{wxvalidator}
76
77 \pythonnote{The wxChoice constructor in wxPython reduces the {\tt n}
78 and {\tt choices} arguments are to a single argument, which is
79 a list of strings.}
80
81 \perlnote{In wxPerl there is just an array reference in place of {\tt n}
82 and {\tt choices}.}
83
84 \membersection{wxChoice::\destruct{wxChoice}}
85
86 \func{}{\destruct{wxChoice}}{\void}
87
88 Destructor, destroying the choice item.
89
90 \membersection{wxChoice::Append}\label{wxchoiceappend}
91
92 \func{int}{Append}{\param{const wxString\& }{ item}}
93
94 Adds the item to the end of the choice control.
95
96 \func{int}{Append}{\param{const wxString\& }{ item}, \param{void* }{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}{String to add.}
104
105 \docparam{clientData}{Client data to associate with the item.}
106
107 \wxheading{Return value}
108
109 The index of the newly added item, may be different from the last one if the
110 control has {\tt wxLB\_SORT} style.
111
112 \membersection{wxChoice::Clear}\label{wxchoiceclear}
113
114 \func{void}{Clear}{\void}
115
116 Clears the strings from the choice item.
117
118 \membersection{wxChoice::Create}\label{wxchoicecreate}
119
120 \func{bool}{Create}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp
121 \param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp
122 \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
123 \param{long}{ style = 0}, \param{const wxString\& }{name = ``choice"}}
124
125 Creates the choice for two-step construction. See \helpref{wxChoice::wxChoice}{wxchoiceconstr}.
126
127 \membersection{wxChoice::Delete}\label{wxchoicedelete}
128
129 \func{void}{Delete}{\param{int }{n}}
130
131 Deletes the item with the given index from the control.
132
133 \wxheading{Parameters}
134
135 \docparam{n}{The item to delete.}
136
137 \membersection{wxChoice::FindString}\label{wxchoicefindstring}
138
139 \constfunc{int}{FindString}{\param{const wxString\& }{string}}
140
141 Finds a choice matching the given string.
142
143 \wxheading{Parameters}
144
145 \docparam{string}{String to find.}
146
147 \wxheading{Return value}
148
149 Returns the position if found, or -1 if not found.
150
151 \membersection{wxChoice::GetColumns}\label{wxchoicegetcolumns}
152
153 \constfunc{int}{GetColumns}{\void}
154
155 Gets the number of columns in this choice item.
156
157 \wxheading{Remarks}
158
159 This is implemented for Motif only.
160
161 \membersection{wxChoice::GetClientData}\label{wxchoicegetclientdata}
162
163 \constfunc{void*}{GetClientData}{\param{int}{ n}}
164
165 Returns a pointer to the client data associated with the given item (if any).
166
167 \wxheading{Parameters}
168
169 \docparam{n}{An item, starting from zero.}
170
171 \wxheading{Return value}
172
173 A pointer to the client data, or NULL if the item was not found.
174
175 \membersection{wxChoice::GetCount}\label{wxchoicegetcount}
176
177 \constfunc{int}{GetCount}{\void}
178
179 Returns the number of items in the choice.
180
181 \membersection{wxChoice::GetSelection}\label{wxchoicegetselection}
182
183 \constfunc{int}{GetSelection}{\void}
184
185 Gets the id (position) of the selected string, or -1 if there is no selection.
186
187 \membersection{wxChoice::GetString}\label{wxchoicegetstring}
188
189 \constfunc{wxString}{GetString}{\param{int}{ n}}
190
191 Returns the string at the given position.
192
193 \wxheading{Parameters}
194
195 \docparam{n}{The zero-based position.}
196
197 \wxheading{Return value}
198
199 The string at the given position, or the empty string if {\it n} is invalid.
200
201 \membersection{wxChoice::GetStringSelection}\label{wxchoicegetstringselection}
202
203 \constfunc{wxString}{GetStringSelection}{\void}
204
205 Gets the selected string, or the empty string if no string is selected.
206
207 \membersection{wxChoice::Number}\label{wxchoicenumber}
208
209 \constfunc{int}{Number}{\void}
210
211 {\bf Obsolescence note:} This method is obsolete and was replaced with
212 \helpref{GetCount}{wxchoicegetcount}, please use the new method in the new
213 code. This method is only available if wxWindows was compiled with
214 {\tt WXWIN\_COMPATIBILITY\_2\_2} defined and will disappear completely in
215 future versions.
216
217 Returns the number of strings in the choice control.
218
219 \membersection{wxChoice::SetClientData}\label{wxchoicesetclientdata}
220
221 \func{void}{SetClientData}{\param{int}{ n}, \param{void* }{data}}
222
223 Associates the given client data pointer with the given item.
224
225 \wxheading{Parameters}
226
227 \docparam{n}{The zero-based item.}
228
229 \docparam{data}{The client data.}
230
231 \membersection{wxChoice::SetColumns}\label{wxchoicesetcolumns}
232
233 \func{void}{SetColumns}{\param{int}{ n = 1}}
234
235 Sets the number of columns in this choice item.
236
237 \wxheading{Parameters}
238
239 \docparam{n}{Number of columns.}
240
241 \wxheading{Remarks}
242
243 This is implemented for Motif only.
244
245 \membersection{wxChoice::SetSelection}\label{wxchoicesetselection}
246
247 \func{void}{SetSelection}{\param{int}{ n}}
248
249 Sets the choice by passing the desired string position. This does not cause
250 a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
251
252 \wxheading{Parameters}
253
254 \docparam{n}{The string position to select, starting from zero.}
255
256 \wxheading{See also}
257
258 \membersection{wxChoice::SetString}\label{wxchoicesetstring}
259
260 \func{void}{SetString}{\param{int }{n}, \param{const wxString\& }{text}}
261
262 Replaces the specified string in the control with another one.
263
264 \wxheading{Parameters}
265
266 \docparam{n}{The zero-based index of the string to replace}
267
268 \docparam{text}{The new value for this item}
269
270 {\bf NB:} This method is currently not implemented in wxGTK.
271
272 \helpref{wxChoice::SetStringSelection}{wxchoicesetstringselection}
273
274 \membersection{wxChoice::SetStringSelection}\label{wxchoicesetstringselection}
275
276 \func{void}{SetStringSelection}{\param{const wxString\& }{ string}}
277
278 Sets the choice by passing the desired string. This does not cause
279 a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
280
281 \wxheading{Parameters}
282
283 \docparam{string}{The string to select.}
284
285 \wxheading{See also}
286
287 \helpref{wxChoice::SetSelection}{wxchoicesetselection}
288
289