]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
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 | ||
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 |
27 | strings specified as the combobox choices can be selected, it is impossible to | |
28 | select (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 | ||
32 | See 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, | |
13bcc348 VZ |
39 | when an item on the list is selected. Note that calling |
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, |
42 | when the combobox text changes.} | |
43 | \end{twocollist} | |
44 | ||
a660d684 KB |
45 | \wxheading{See also} |
46 | ||
5de76427 JS |
47 | \helpref{wxListBox}{wxlistbox}, \helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxChoice}{wxchoice}, |
48 | \rtfsp\helpref{wxCommandEvent}{wxcommandevent} | |
a660d684 KB |
49 | |
50 | \latexignore{\rtfignore{\wxheading{Members}}} | |
51 | ||
52 | \membersection{wxComboBox::wxComboBox}\label{wxcomboboxconstr} | |
53 | ||
54 | \func{}{wxComboBox}{\void} | |
55 | ||
56 | Default constructor. | |
57 | ||
eaaa6a06 | 58 | \func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 59 | \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 JS |
60 | \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp |
61 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}} | |
a660d684 | 62 | |
56b88f12 MB |
63 | \func{}{wxComboBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
64 | \param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp | |
65 | \param{const wxArrayString\& }{choices},\rtfsp | |
66 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}} | |
67 | ||
a660d684 KB |
68 | Constructor, creating and showing a combobox. |
69 | ||
70 | \wxheading{Parameters} | |
71 | ||
72 | \docparam{parent}{Parent window. Must not be NULL.} | |
73 | ||
74 | \docparam{id}{Window identifier. A value of -1 indicates a default value.} | |
75 | ||
2b5f62a0 VZ |
76 | \docparam{value}{Initial selection string. An empty string indicates no selection.} |
77 | ||
a660d684 KB |
78 | \docparam{pos}{Window position.} |
79 | ||
80 | \docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized | |
81 | appropriately.} | |
82 | ||
83 | \docparam{n}{Number of strings with which to initialise the control.} | |
84 | ||
85 | \docparam{choices}{An array of strings with which to initialise the control.} | |
86 | ||
87 | \docparam{style}{Window style. See \helpref{wxComboBox}{wxcombobox}.} | |
88 | ||
89 | \docparam{validator}{Window validator.} | |
90 | ||
91 | \docparam{name}{Window name.} | |
92 | ||
93 | \wxheading{See also} | |
94 | ||
95 | \helpref{wxComboBox::Create}{wxcomboboxcreate}, \helpref{wxValidator}{wxvalidator} | |
96 | ||
c9110876 VS |
97 | \pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n} |
98 | and {\tt choices} arguments are to a single argument, which is | |
06d20283 RD |
99 | a list of strings.} |
100 | ||
5873607e VZ |
101 | \perlnote{In wxPerl there is just an array reference in place of {\tt n} |
102 | and {\tt choices}.} | |
06d20283 | 103 | |
a660d684 KB |
104 | \membersection{wxComboBox::\destruct{wxComboBox}} |
105 | ||
106 | \func{}{\destruct{wxComboBox}}{\void} | |
107 | ||
108 | Destructor, destroying the combobox. | |
109 | ||
a660d684 KB |
110 | \membersection{wxComboBox::Create}\label{wxcomboboxcreate} |
111 | ||
eaaa6a06 | 112 | \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 113 | \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 JS |
114 | \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp |
115 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}} | |
a660d684 | 116 | |
56b88f12 MB |
117 | \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
118 | \param{const wxString\& }{value}, \param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp | |
119 | \param{const wxArrayString\& }{choices},\rtfsp | |
120 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}} | |
121 | ||
a660d684 KB |
122 | Creates the combobox for two-step construction. Derived classes |
123 | should call or replace this function. See \helpref{wxComboBox::wxComboBox}{wxcomboboxconstr}\rtfsp | |
124 | for further details. | |
125 | ||
126 | \membersection{wxComboBox::Copy}\label{wxcomboboxcopy} | |
127 | ||
128 | \func{void}{Copy}{\void} | |
129 | ||
130 | Copies the selected text to the clipboard. | |
131 | ||
132 | \membersection{wxComboBox::Cut}\label{wxcomboboxcut} | |
133 | ||
134 | \func{void}{Cut}{\void} | |
135 | ||
136 | Copies the selected text to the clipboard and removes the selection. | |
137 | ||
a660d684 KB |
138 | \membersection{wxComboBox::GetInsertionPoint}\label{wxcomboboxgetinsertionpoint} |
139 | ||
140 | \constfunc{long}{GetInsertionPoint}{\void} | |
141 | ||
142 | Returns the insertion point for the combobox's text field. | |
143 | ||
144 | \membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition} | |
145 | ||
146 | \constfunc{long}{GetLastPosition}{\void} | |
147 | ||
148 | Returns the last position in the combobox text field. | |
149 | ||
a660d684 KB |
150 | \membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue} |
151 | ||
152 | \constfunc{wxString}{GetValue}{\void} | |
153 | ||
154 | Returns the current value in the combobox text field. | |
155 | ||
a660d684 KB |
156 | \membersection{wxComboBox::Paste}\label{wxcomboboxpaste} |
157 | ||
158 | \func{void}{Paste}{\void} | |
159 | ||
160 | Pastes text from the clipboard to the text field. | |
161 | ||
162 | \membersection{wxComboBox::Replace}\label{wxcomboboxreplace} | |
163 | ||
eaaa6a06 | 164 | \func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}} |
a660d684 KB |
165 | |
166 | Replaces the text between two positions with the given text, in the combobox text field. | |
167 | ||
168 | \wxheading{Parameters} | |
169 | ||
170 | \docparam{from}{The first position.} | |
171 | ||
172 | \docparam{to}{The second position.} | |
173 | ||
174 | \docparam{text}{The text to insert.} | |
175 | ||
176 | \membersection{wxComboBox::Remove}\label{wxcomboboxremove} | |
177 | ||
eaaa6a06 | 178 | \func{void}{Remove}{\param{long}{ from}, \param{long}{ to}} |
a660d684 KB |
179 | |
180 | Removes the text between the two positions in the combobox text field. | |
181 | ||
182 | \wxheading{Parameters} | |
183 | ||
184 | \docparam{from}{The first position.} | |
185 | ||
186 | \docparam{to}{The last position.} | |
187 | ||
a660d684 KB |
188 | \membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint} |
189 | ||
eaaa6a06 | 190 | \func{void}{SetInsertionPoint}{\param{long}{ pos}} |
a660d684 KB |
191 | |
192 | Sets the insertion point in the combobox text field. | |
193 | ||
194 | \wxheading{Parameters} | |
195 | ||
196 | \docparam{pos}{The new insertion point.} | |
197 | ||
198 | \membersection{wxComboBox::SetInsertionPointEnd}\label{wxcomboboxsetinsertionpointend} | |
199 | ||
200 | \func{void}{SetInsertionPointEnd}{\void} | |
201 | ||
202 | Sets the insertion point at the end of the combobox text field. | |
203 | ||
204 | \membersection{wxComboBox::SetSelection}\label{wxcomboboxsetselection} | |
205 | ||
eaaa6a06 | 206 | \func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}} |
a660d684 KB |
207 | |
208 | Selects the text between the two positions, in the combobox text field. | |
209 | ||
210 | \wxheading{Parameters} | |
211 | ||
a660d684 KB |
212 | \docparam{from}{The first position.} |
213 | ||
214 | \docparam{to}{The second position.} | |
215 | ||
bed5584e VZ |
216 | \pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection} |
217 | name is kept for | |
218 | \helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.} | |
532da0d1 | 219 | |
a660d684 KB |
220 | \membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue} |
221 | ||
222 | \func{void}{SetValue}{\param{const wxString\& }{text}} | |
223 | ||
224 | Sets the text for the combobox text field. | |
225 | ||
3ca6a5f0 BP |
226 | {\bf NB:} For a combobox with {\tt wxCB\_READONLY} style the string must be in |
227 | the combobox choices list, otherwise the call to SetValue() is ignored. | |
228 | ||
a660d684 KB |
229 | \wxheading{Parameters} |
230 | ||
231 | \docparam{text}{The text to set.} | |
232 | ||
233 |