]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/combobox.tex
clarified some Mac OS related preprocessor defines
[wxWidgets.git] / docs / latex / wx / combobox.tex
1 \section{\class{wxComboBox}}\label{wxcombobox}
2
3 A combobox is like a combination of an edit control and a listbox. It can be
4 displayed as static list with editable or read-only text field; or a drop-down list with
5 text field; or a drop-down list without a text field.
6
7 A combobox permits a single selection only. Combobox items are numbered from zero.
8
9 \wxheading{Derived from}
10
11 \helpref{wxControlWithItems}{wxcontrolwithitems}\\
12 \helpref{wxChoice}{wxchoice}\\
13 \helpref{wxControl}{wxcontrol}\\
14 \helpref{wxWindow}{wxwindow}\\
15 \helpref{wxEvtHandler}{wxevthandler}\\
16 \helpref{wxObject}{wxobject}
17
18 \wxheading{Include files}
19
20 <wx/combobox.h>
21
22 \wxheading{Window styles}
23
24 \begin{twocollist}\itemsep=0pt
25 \twocolitem{\windowstyle{wxCB\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only. }
26 \twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.}
27 \twocolitem{\windowstyle{wxCB\_READONLY}}{Same as wxCB\_DROPDOWN but only the
28 strings specified as the combobox choices can be selected, it is impossible to
29 select (even from a program) a string which is not in the choices list.}
30 \twocolitem{\windowstyle{wxCB\_SORT}}{Sorts the entries in the list alphabetically.}
31 \end{twocollist}
32
33 See also \helpref{window styles overview}{windowstyles}.
34
35 \wxheading{Event handling}
36
37 \twocolwidtha{7cm}
38 \begin{twocollist}\itemsep=0pt
39 \twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event,
40 when an item on the list is selected.}
41 \twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event,
42 when the combobox text changes.}
43 \end{twocollist}
44
45 \wxheading{See also}
46
47 \helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice},
48 \rtfsp\helpref{wxCommandEvent}{wxcommandevent}
49
50 \latexignore{\rtfignore{\wxheading{Members}}}
51
52 \membersection{wxComboBox::wxComboBox}\label{wxcomboboxconstr}
53
54 \func{}{wxComboBox}{\void}
55
56 Default constructor.
57
58 \func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
59 \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
60 \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
61 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
62
63 Constructor, creating and showing a combobox.
64
65 \wxheading{Parameters}
66
67 \docparam{parent}{Parent window. Must not be NULL.}
68
69 \docparam{id}{Window identifier. A value of -1 indicates a default value.}
70
71 \docparam{value}{Initial selection string. An empty string indicates no selection.}
72
73 \docparam{pos}{Window position.}
74
75 \docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
76 appropriately.}
77
78 \docparam{n}{Number of strings with which to initialise the control.}
79
80 \docparam{choices}{An array of strings with which to initialise the control.}
81
82 \docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.}
83
84 \docparam{validator}{Window validator.}
85
86 \docparam{name}{Window name.}
87
88 \wxheading{See also}
89
90 \helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator}
91
92 \pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n}
93 and {\tt choices} arguments are to a single argument, which is
94 a list of strings.}
95
96 \perlnote{In wxPerl there is just an array reference in place of {\tt n}
97 and {\tt choices}.}
98
99 \membersection{wxComboBox::\destruct{wxComboBox}}
100
101 \func{}{\destruct{wxComboBox}}{\void}
102
103 Destructor, destroying the combobox.
104
105 \membersection{wxComboBox::Create}\label{wxcomboboxcreate}
106
107 \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
108 \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
109 \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
110 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}}
111
112 Creates the combobox for two-step construction. Derived classes
113 should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxconstr}\rtfsp
114 for further details.
115
116 \membersection{wxComboBox::Copy}\label{wxcomboboxcopy}
117
118 \func{void}{Copy}{\void}
119
120 Copies the selected text to the clipboard.
121
122 \membersection{wxComboBox::Cut}\label{wxcomboboxcut}
123
124 \func{void}{Cut}{\void}
125
126 Copies the selected text to the clipboard and removes the selection.
127
128 \membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint}
129
130 \constfunc{long}{GetInsertionPoint}{\void}
131
132 Returns the insertion point for the combobox's text field.
133
134 \membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition}
135
136 \constfunc{long}{GetLastPosition}{\void}
137
138 Returns the last position in the combobox text field.
139
140 \membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue}
141
142 \constfunc{wxString}{GetValue}{\void}
143
144 Returns the current value in the combobox text field.
145
146 \membersection{wxComboBox::Paste}\label{wxcomboboxpaste}
147
148 \func{void}{Paste}{\void}
149
150 Pastes text from the clipboard to the text field.
151
152 \membersection{wxComboBox::Replace}\label{wxcomboboxreplace}
153
154 \func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}}
155
156 Replaces the text between two positions with the given text, in the combobox text field.
157
158 \wxheading{Parameters}
159
160 \docparam{from}{The first position.}
161
162 \docparam{to}{The second position.}
163
164 \docparam{text}{The text to insert.}
165
166 \membersection{wxComboBox::Remove}\label{wxcomboboxremove}
167
168 \func{void}{Remove}{\param{long}{ from}, \param{long}{ to}}
169
170 Removes the text between the two positions in the combobox text field.
171
172 \wxheading{Parameters}
173
174 \docparam{from}{The first position.}
175
176 \docparam{to}{The last position.}
177
178 \membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint}
179
180 \func{void}{SetInsertionPoint}{\param{long}{ pos}}
181
182 Sets the insertion point in the combobox text field.
183
184 \wxheading{Parameters}
185
186 \docparam{pos}{The new insertion point.}
187
188 \membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend}
189
190 \func{void}{SetInsertionPointEnd}{\void}
191
192 Sets the insertion point at the end of the combobox text field.
193
194 \membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection}
195
196 \func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
197
198 Selects the text between the two positions, in the combobox text field.
199
200 \wxheading{Parameters}
201
202 \docparam{from}{The first position.}
203
204 \docparam{to}{The second position.}
205
206 \pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection}
207 name is kept for
208 \helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.}
209
210 \membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue}
211
212 \func{void}{SetValue}{\param{const wxString\& }{text}}
213
214 Sets the text for the combobox text field.
215
216 {\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in
217 the combobox choices list, otherwise the call to SetValue() is ignored.
218
219 \wxheading{Parameters}
220
221 \docparam{text}{The text to set.}
222
223