]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/combobox.tex
define _HPUX_SOURCE under HP-UX, otherwise many things are not defined in standard...
[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
bed5584e 11\helpref{wxControlWithItems}{wxcontrolwithitems}\\
a660d684
KB
12\helpref{wxControl}{wxcontrol}\\
13\helpref{wxWindow}{wxwindow}\\
14\helpref{wxEvtHandler}{wxevthandler}\\
15\helpref{wxObject}{wxobject}
16
954b8ae6
JS
17\wxheading{Include files}
18
f6bcfd97 19<wx/combobox.h>
954b8ae6 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 25\twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.}
3ca6a5f0
BP
26\twocolitem{\windowstyle{wxCB\_READONLY}}{Same as wxCB\_DROPDOWN but only the
27strings specified as the combobox choices can be selected, it is impossible to
28select (even from a program) a string which is not in the choices list.}
a660d684
KB
29\twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
30\end{twocollist}
31
32See also \helpref{window styles overview}{windowstyles}.
33
5de76427
JS
34\wxheading{Event handling}
35
36\twocolwidtha{7cm}
37\begin{twocollist}\itemsep=0pt
38\twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
7d8268a1 39when an item on the list is selected. Note that calling
13bcc348 40\helpref{GetValue}{wxcomboboxgetvalue} returns the new value of selection.}
5de76427
JS
41\twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
42when the combobox text changes.}
3980000c
RR
43\twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_ENTER event,
44when <RETURN> is pressed in the combobox.}
5de76427
JS
45\end{twocollist}
46
a660d684
KB
47\wxheading{See also}
48
5de76427
JS
49\helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
50\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
a660d684
KB
51
52\latexignore{\rtfignore{\wxheading{Members}}}
53
f510b7b2 54\membersection{wxComboBox::wxComboBox}\label{wxcomboboxctor}
a660d684
KB
55
56\func{}{wxComboBox}{\void}
57
58Default constructor.
59
eaaa6a06 60\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 61\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
62\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
63\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684 64
56b88f12
MB
65\func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
66\param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
67\param{const wxArrayString\& }{choices},\rtfsp
68\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
69
a660d684
KB
70Constructor, creating and showing a combobox.
71
72\wxheading{Parameters}
73
74\docparam{parent}{Parent window. Must not be NULL.}
75
76\docparam{id}{Window identifier. A value of -1 indicates a default value.}
77
2b5f62a0
VZ
78\docparam{value}{Initial selection string. An empty string indicates no selection.}
79
a660d684
KB
80\docparam{pos}{Window position.}
81
82\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
83appropriately.}
84
85\docparam{n}{Number of strings with which to initialise the control.}
86
87\docparam{choices}{An array of strings with which to initialise the control.}
88
89\docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
90
91\docparam{validator}{Window validator.}
92
93\docparam{name}{Window name.}
94
95\wxheading{See also}
96
97\helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
98
c9110876
VS
99\pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n}
100and {\tt choices} arguments are to a single argument, which is
06d20283
RD
101a list of strings.}
102
5873607e
VZ
103\perlnote{In wxPerl there is just an array reference in place of {\tt n}
104and {\tt choices}.}
06d20283 105
f510b7b2 106\membersection{wxComboBox::\destruct{wxComboBox}}\label{wxcomboboxdtor}
a660d684
KB
107
108\func{}{\destruct{wxComboBox}}{\void}
109
110Destructor, destroying the combobox.
111
a660d684
KB
112\membersection{wxComboBox::Create}\label{wxcomboboxcreate}
113
eaaa6a06 114\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 115\param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06
JS
116\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
117\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
a660d684 118
56b88f12
MB
119\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
120\param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
121\param{const wxArrayString\& }{choices},\rtfsp
122\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
123
a660d684 124Creates the combobox for two-step construction. Derived classes
f510b7b2 125should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxctor}\rtfsp
a660d684
KB
126for further details.
127
150e31d2
JS
128\membersection{wxComboBox::CanCopy}\label{wxcomboboxcancopy}
129
130\constfunc{bool}{CanCopy}{\void}
131
132Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
133Only available on Windows.
134
135\membersection{wxComboBox::CanCut}\label{wxcomboboxcancut}
136
137\constfunc{bool}{CanCut}{\void}
138
139Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
140Only available on Windows.
141
142\membersection{wxComboBox::CanPaste}\label{wxcomboboxcanpaste}
143
144\constfunc{bool}{CanPaste}{\void}
145
146Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
147text field. Only available on Windows.
148
149\membersection{wxComboBox::CanRedo}\label{wxcomboboxcanredo}
150
151\constfunc{bool}{CanRedo}{\void}
152
153Returns true if the combobox is editable and the last undo can be redone.
154Only available on Windows.
7d8268a1 155
150e31d2
JS
156\membersection{wxComboBox::CanUndo}\label{wxcomboboxcanundo}
157
158\constfunc{bool}{CanUndo}{\void}
159
160Returns true if the combobox is editable and the last edit can be undone.
161Only available on Windows.
7d8268a1 162
a660d684
KB
163\membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
164
165\func{void}{Copy}{\void}
166
167Copies the selected text to the clipboard.
168
169\membersection{wxComboBox::Cut}\label{wxcomboboxcut}
170
171\func{void}{Cut}{\void}
172
173Copies the selected text to the clipboard and removes the selection.
174
a660d684
KB
175\membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
176
177\constfunc{long}{GetInsertionPoint}{\void}
178
179Returns the insertion point for the combobox's text field.
180
181\membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
182
7d8268a1 183\constfunc{virtual wxTextPos}{GetLastPosition}{\void}
a660d684
KB
184
185Returns the last position in the combobox text field.
186
a660d684
KB
187\membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
188
189\constfunc{wxString}{GetValue}{\void}
190
191Returns the current value in the combobox text field.
192
a660d684
KB
193\membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
194
195\func{void}{Paste}{\void}
196
197Pastes text from the clipboard to the text field.
198
150e31d2
JS
199\membersection{wxComboBox::Redo}\label{wxcomboboxredo}
200
201\func{void}{Redo}{\void}
202
203Redoes the last undo in the text field. Windows only.
204
a660d684
KB
205\membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
206
eaaa6a06 207\func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
a660d684
KB
208
209Replaces the text between two positions with the given text, in the combobox text field.
210
211\wxheading{Parameters}
212
213\docparam{from}{The first position.}
214
215\docparam{to}{The second position.}
216
217\docparam{text}{The text to insert.}
218
219\membersection{wxComboBox::Remove}\label{wxcomboboxremove}
220
eaaa6a06 221\func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
222
223Removes the text between the two positions in the combobox text field.
224
225\wxheading{Parameters}
226
227\docparam{from}{The first position.}
228
229\docparam{to}{The last position.}
230
a660d684
KB
231\membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
232
eaaa6a06 233\func{void}{SetInsertionPoint}{\param{long}{ pos}}
a660d684
KB
234
235Sets the insertion point in the combobox text field.
236
237\wxheading{Parameters}
238
239\docparam{pos}{The new insertion point.}
240
241\membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
242
243\func{void}{SetInsertionPointEnd}{\void}
244
245Sets the insertion point at the end of the combobox text field.
246
247\membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
248
eaaa6a06 249\func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
a660d684
KB
250
251Selects the text between the two positions, in the combobox text field.
252
253\wxheading{Parameters}
254
a660d684
KB
255\docparam{from}{The first position.}
256
257\docparam{to}{The second position.}
258
bed5584e 259\pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection}
7d8268a1 260name is kept for
bed5584e 261\helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.}
532da0d1 262
a660d684
KB
263\membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
264
265\func{void}{SetValue}{\param{const wxString\& }{text}}
266
267Sets the text for the combobox text field.
268
3ca6a5f0
BP
269{\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in
270the combobox choices list, otherwise the call to SetValue() is ignored.
271
a660d684
KB
272\wxheading{Parameters}
273
274\docparam{text}{The text to set.}
275
150e31d2
JS
276\membersection{wxComboBox::Undo}\label{wxcomboboxundo}
277
278\func{void}{Undo}{\void}
279
280Undoes the last edit in the text field. Windows only.
a660d684 281