]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/choice.tex
added wxListCtrl::AssignImageList
[wxWidgets.git] / docs / latex / wx / choice.tex
CommitLineData
a660d684
KB
1\section{\class{wxChoice}}\label{wxchoice}
2
3A choice item is used to select one of a list of strings. Unlike a
4listbox, only the selection is visible until the user pulls down the
5menu 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
20There are no special styles for wxChoice.
21
22See 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,
29when 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
43Default 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
50Constructor, 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
61appropriately.}
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}
78and {\tt choices} arguments are to a single argument, which is
06d20283
RD
79a list of strings.}
80
a660d684
KB
81\membersection{wxChoice::\destruct{wxChoice}}
82
83\func{}{\destruct{wxChoice}}{\void}
84
85Destructor, destroying the choice item.
86
87\membersection{wxChoice::Append}\label{wxchoiceappend}
88
89\func{void}{Append}{\param{const wxString\& }{ item}}
90
91Adds the item to the end of the choice control.
92
9c884972
RR
93\func{void}{Append}{\param{const wxString\& }{ item}, \param{void* }{clientData}}
94
95Adds the item to the end of the combobox, associating the given data
96with the item.
97
a660d684
KB
98\wxheading{Parameters}
99
100\docparam{item}{String to add.}
101
9c884972
RR
102\docparam{clientData}{Client data to associate with the item.}
103
a660d684
KB
104\membersection{wxChoice::Clear}\label{wxchoiceclear}
105
106\func{void}{Clear}{\void}
107
108Clears the strings from the choice item.
109
110\membersection{wxChoice::Create}\label{wxchoicecreate}
111
eaaa6a06 112\func{bool}{Create}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 113\param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp
eaaa6a06
JS
114\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
115\param{long}{ style = 0}, \param{const wxString\& }{name = ``choice"}}
a660d684
KB
116
117Creates the choice for two-step construction. See \helpref{wxChoice::wxChoice}{wxchoiceconstr}.
118
119\membersection{wxChoice::FindString}\label{wxchoicefindstring}
120
121\constfunc{int}{FindString}{\param{const wxString\& }{string}}
122
123Finds a choice matching the given string.
124
125\wxheading{Parameters}
126
127\docparam{string}{String to find.}
128
129\wxheading{Return value}
130
131Returns the position if found, or -1 if not found.
132
133\membersection{wxChoice::GetColumns}\label{wxchoicegetcolumns}
134
135\constfunc{int}{GetColumns}{\void}
136
137Gets the number of columns in this choice item.
138
139\wxheading{Remarks}
140
141This is implemented for Motif only.
142
9c884972
RR
143\membersection{wxChoice::GetClientData}\label{wxchoicegetclientdata}
144
145\constfunc{void*}{GetClientData}{\param{int}{ n}}
146
147Returns a pointer to the client data associated with the given item (if any).
148
149\wxheading{Parameters}
150
151\docparam{n}{An item, starting from zero.}
152
153\wxheading{Return value}
154
155A pointer to the client data, or NULL if the item was not found.
156
a660d684
KB
157\membersection{wxChoice::GetSelection}\label{wxchoicegetselection}
158
159\constfunc{int}{GetSelection}{\void}
160
161Gets the id (position) of the selected string, or -1 if there is no selection.
162
163\membersection{wxChoice::GetString}\label{wxchoicegetstring}
164
eaaa6a06 165\constfunc{wxString}{GetString}{\param{int}{ n}}
a660d684
KB
166
167Returns the string at the given position.
168
169\wxheading{Parameters}
170
171\docparam{n}{The zero-based position.}
172
173\wxheading{Return value}
174
175The string at the given position, or the empty string if {\it n} is invalid.
176
177\membersection{wxChoice::GetStringSelection}\label{wxchoicegetstringselection}
178
179\constfunc{wxString}{GetStringSelection}{\void}
180
181Gets the selected string, or the empty string if no string is selected.
182
183\membersection{wxChoice::Number}\label{wxchoicenumber}
184
185\constfunc{int}{Number}{\void}
186
187Returns the number of strings in the choice control.
188
9c884972
RR
189\membersection{wxChoice::SetClientData}\label{wxchoicesetclientdata}
190
191\func{void}{SetClientData}{\param{int}{ n}, \param{void* }{data}}
192
193Associates the given client data pointer with the given item.
194
195\wxheading{Parameters}
196
197\docparam{n}{The zero-based item.}
198
199\docparam{data}{The client data.}
200
a660d684
KB
201\membersection{wxChoice::SetColumns}\label{wxchoicesetcolumns}
202
eaaa6a06 203\func{void}{SetColumns}{\param{int}{ n = 1}}
a660d684
KB
204
205Sets the number of columns in this choice item.
206
207\wxheading{Parameters}
208
209\docparam{n}{Number of columns.}
210
211\wxheading{Remarks}
212
213This is implemented for Motif only.
214
215\membersection{wxChoice::SetSelection}\label{wxchoicesetselection}
216
eaaa6a06 217\func{void}{SetSelection}{\param{int}{ n}}
a660d684 218
953704c1
RR
219Sets the choice by passing the desired string position. This does not cause
220a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
a660d684
KB
221
222\wxheading{Parameters}
223
224\docparam{n}{The string position to select, starting from zero.}
225
226\wxheading{See also}
227
228\helpref{wxChoice::SetStringSelection}{wxchoicesetstringselection}
229
230\membersection{wxChoice::SetStringSelection}\label{wxchoicesetstringselection}
231
232\func{void}{SetStringSelection}{\param{const wxString\& }{ string}}
233
953704c1
RR
234Sets the choice by passing the desired string. This does not cause
235a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
a660d684
KB
236
237\wxheading{Parameters}
238
239\docparam{string}{The string to select.}
240
241\wxheading{See also}
242
243\helpref{wxChoice::SetSelection}{wxchoicesetselection}
244
245