]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
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 | ||
954b8ae6 JS |
14 | \wxheading{Include files} |
15 | ||
16 | <wx/choice.h> | |
17 | ||
a660d684 KB |
18 | \wxheading{Window styles} |
19 | ||
20 | There are no special styles for wxChoice. | |
21 | ||
22 | See also \helpref{window styles overview}{windowstyles}. | |
23 | ||
5de76427 JS |
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 | ||
a660d684 KB |
32 | \wxheading{See also} |
33 | ||
5de76427 JS |
34 | \helpref{wxListBox}{wxlistbox}, \helpref{wxComboBox}{wxcombobox}, |
35 | \rtfsp\helpref{wxCommandEvent}{wxcommandevent} | |
a660d684 KB |
36 | |
37 | \latexignore{\rtfignore{\wxheading{Members}}} | |
38 | ||
39 | \membersection{wxChoice::wxChoice}\label{wxchoiceconstr} | |
40 | ||
41 | \func{}{wxChoice}{\void} | |
42 | ||
43 | Default constructor. | |
44 | ||
eaaa6a06 | 45 | \func{}{wxChoice}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 46 | \param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp |
eaaa6a06 JS |
47 | \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp |
48 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``choice"}} | |
a660d684 KB |
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 | ||
c9110876 VS |
77 | \pythonnote{The wxChoice constructor in wxPython reduces the {\tt n} |
78 | and {\tt choices} arguments are to a single argument, which is | |
06d20283 RD |
79 | a list of strings.} |
80 | ||
5873607e VZ |
81 | \perlnote{In wxPerl there is just an array reference in place of {\tt n} |
82 | and {\tt choices}.} | |
83 | ||
a660d684 KB |
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{void}{Append}{\param{const wxString\& }{ item}} | |
93 | ||
94 | Adds the item to the end of the choice control. | |
95 | ||
9c884972 RR |
96 | \func{void}{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 | ||
a660d684 KB |
101 | \wxheading{Parameters} |
102 | ||
103 | \docparam{item}{String to add.} | |
104 | ||
9c884972 RR |
105 | \docparam{clientData}{Client data to associate with the item.} |
106 | ||
a660d684 KB |
107 | \membersection{wxChoice::Clear}\label{wxchoiceclear} |
108 | ||
109 | \func{void}{Clear}{\void} | |
110 | ||
111 | Clears the strings from the choice item. | |
112 | ||
113 | \membersection{wxChoice::Create}\label{wxchoicecreate} | |
114 | ||
eaaa6a06 | 115 | \func{bool}{Create}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 116 | \param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp |
eaaa6a06 JS |
117 | \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp |
118 | \param{long}{ style = 0}, \param{const wxString\& }{name = ``choice"}} | |
a660d684 KB |
119 | |
120 | Creates the choice for two-step construction. See \helpref{wxChoice::wxChoice}{wxchoiceconstr}. | |
121 | ||
645420d8 VZ |
122 | \membersection{wxChoice::Delete}\label{wxchoicedelete} |
123 | ||
124 | \func{void}{Delete}{\param{int }{n}} | |
125 | ||
126 | Deletes the item with the given index from the control. | |
127 | ||
128 | \wxheading{Parameters} | |
129 | ||
130 | \docparam{n}{The item to delete.} | |
131 | ||
a660d684 KB |
132 | \membersection{wxChoice::FindString}\label{wxchoicefindstring} |
133 | ||
134 | \constfunc{int}{FindString}{\param{const wxString\& }{string}} | |
135 | ||
136 | Finds a choice matching the given string. | |
137 | ||
138 | \wxheading{Parameters} | |
139 | ||
140 | \docparam{string}{String to find.} | |
141 | ||
142 | \wxheading{Return value} | |
143 | ||
144 | Returns the position if found, or -1 if not found. | |
145 | ||
146 | \membersection{wxChoice::GetColumns}\label{wxchoicegetcolumns} | |
147 | ||
148 | \constfunc{int}{GetColumns}{\void} | |
149 | ||
150 | Gets the number of columns in this choice item. | |
151 | ||
152 | \wxheading{Remarks} | |
153 | ||
154 | This is implemented for Motif only. | |
155 | ||
9c884972 RR |
156 | \membersection{wxChoice::GetClientData}\label{wxchoicegetclientdata} |
157 | ||
158 | \constfunc{void*}{GetClientData}{\param{int}{ n}} | |
159 | ||
160 | Returns a pointer to the client data associated with the given item (if any). | |
161 | ||
162 | \wxheading{Parameters} | |
163 | ||
164 | \docparam{n}{An item, starting from zero.} | |
165 | ||
166 | \wxheading{Return value} | |
167 | ||
168 | A pointer to the client data, or NULL if the item was not found. | |
169 | ||
28ca7610 VZ |
170 | \membersection{wxChoice::GetCount}\label{wxchoicegetcount} |
171 | ||
172 | \constfunc{int}{GetCount}{\void} | |
173 | ||
174 | Returns the number of items in the choice. | |
175 | ||
a660d684 KB |
176 | \membersection{wxChoice::GetSelection}\label{wxchoicegetselection} |
177 | ||
178 | \constfunc{int}{GetSelection}{\void} | |
179 | ||
180 | Gets the id (position) of the selected string, or -1 if there is no selection. | |
181 | ||
182 | \membersection{wxChoice::GetString}\label{wxchoicegetstring} | |
183 | ||
eaaa6a06 | 184 | \constfunc{wxString}{GetString}{\param{int}{ n}} |
a660d684 KB |
185 | |
186 | Returns the string at the given position. | |
187 | ||
188 | \wxheading{Parameters} | |
189 | ||
190 | \docparam{n}{The zero-based position.} | |
191 | ||
192 | \wxheading{Return value} | |
193 | ||
194 | The string at the given position, or the empty string if {\it n} is invalid. | |
195 | ||
196 | \membersection{wxChoice::GetStringSelection}\label{wxchoicegetstringselection} | |
197 | ||
198 | \constfunc{wxString}{GetStringSelection}{\void} | |
199 | ||
200 | Gets the selected string, or the empty string if no string is selected. | |
201 | ||
202 | \membersection{wxChoice::Number}\label{wxchoicenumber} | |
203 | ||
204 | \constfunc{int}{Number}{\void} | |
205 | ||
28ca7610 VZ |
206 | {\bf Obsolescence note:} This method is obsolete and was replaced with |
207 | \helpref{GetCount}{wxchoicegetcount}, please use the new method in the new | |
208 | code. This method is only available if wxWindows was compiled with | |
209 | {\tt WXWIN\_COMPATIBILITY\_2\_2} defined and will disappear completely in | |
210 | future versions. | |
211 | ||
a660d684 KB |
212 | Returns the number of strings in the choice control. |
213 | ||
9c884972 RR |
214 | \membersection{wxChoice::SetClientData}\label{wxchoicesetclientdata} |
215 | ||
216 | \func{void}{SetClientData}{\param{int}{ n}, \param{void* }{data}} | |
217 | ||
218 | Associates the given client data pointer with the given item. | |
219 | ||
220 | \wxheading{Parameters} | |
221 | ||
222 | \docparam{n}{The zero-based item.} | |
223 | ||
224 | \docparam{data}{The client data.} | |
225 | ||
a660d684 KB |
226 | \membersection{wxChoice::SetColumns}\label{wxchoicesetcolumns} |
227 | ||
eaaa6a06 | 228 | \func{void}{SetColumns}{\param{int}{ n = 1}} |
a660d684 KB |
229 | |
230 | Sets the number of columns in this choice item. | |
231 | ||
232 | \wxheading{Parameters} | |
233 | ||
234 | \docparam{n}{Number of columns.} | |
235 | ||
236 | \wxheading{Remarks} | |
237 | ||
238 | This is implemented for Motif only. | |
239 | ||
240 | \membersection{wxChoice::SetSelection}\label{wxchoicesetselection} | |
241 | ||
eaaa6a06 | 242 | \func{void}{SetSelection}{\param{int}{ n}} |
a660d684 | 243 | |
953704c1 RR |
244 | Sets the choice by passing the desired string position. This does not cause |
245 | a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted. | |
a660d684 KB |
246 | |
247 | \wxheading{Parameters} | |
248 | ||
249 | \docparam{n}{The string position to select, starting from zero.} | |
250 | ||
251 | \wxheading{See also} | |
252 | ||
532da0d1 VZ |
253 | \membersection{wxChoice::SetString}\label{wxchoicesetstring} |
254 | ||
255 | \func{void}{SetString}{\param{int }{n}, \param{const wxString\& }{text}} | |
256 | ||
257 | Replaces the specified string in the control with another one. | |
258 | ||
259 | \wxheading{Parameters} | |
260 | ||
261 | \docparam{n}{The zero-based index of the string to replace} | |
262 | ||
263 | \docparam{text}{The new value for this item} | |
264 | ||
265 | {\bf NB:} This method is currently not implemented in wxGTK. | |
266 | ||
a660d684 KB |
267 | \helpref{wxChoice::SetStringSelection}{wxchoicesetstringselection} |
268 | ||
269 | \membersection{wxChoice::SetStringSelection}\label{wxchoicesetstringselection} | |
270 | ||
271 | \func{void}{SetStringSelection}{\param{const wxString\& }{ string}} | |
272 | ||
953704c1 RR |
273 | Sets the choice by passing the desired string. This does not cause |
274 | a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted. | |
a660d684 KB |
275 | |
276 | \wxheading{Parameters} | |
277 | ||
278 | \docparam{string}{The string to select.} | |
279 | ||
280 | \wxheading{See also} | |
281 | ||
282 | \helpref{wxChoice::SetSelection}{wxchoicesetselection} | |
283 | ||
284 |