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