]>
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{wxChoice}{wxchoice}\\ |
13 | \helpref{wxControl}{wxcontrol}\\ | |
14 | \helpref{wxWindow}{wxwindow}\\ | |
15 | \helpref{wxEvtHandler}{wxevthandler}\\ | |
16 | \helpref{wxObject}{wxobject} | |
17 | ||
954b8ae6 JS |
18 | \wxheading{Include files} |
19 | ||
f6bcfd97 | 20 | <wx/combobox.h> |
954b8ae6 | 21 | |
a660d684 KB |
22 | \wxheading{Window styles} |
23 | ||
24 | \begin{twocollist}\itemsep=0pt | |
9c884972 | 25 | \twocolitem{\windowstyle{wxCB\_SIMPLE}}{Creates a combobox with a permanently displayed list. Windows only. } |
a660d684 | 26 | \twocolitem{\windowstyle{wxCB\_DROPDOWN}}{Creates a combobox with a drop-down list.} |
3ca6a5f0 BP |
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.} | |
a660d684 KB |
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 | ||
5de76427 JS |
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 | ||
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 KB |
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 | ||
2b5f62a0 VZ |
71 | \docparam{value}{Initial selection string. An empty string indicates no selection.} |
72 | ||
a660d684 KB |
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 | ||
c9110876 VS |
92 | \pythonnote{The wxComboBox constructor in wxPython reduces the {\tt n} |
93 | and {\tt choices} arguments are to a single argument, which is | |
06d20283 RD |
94 | a list of strings.} |
95 | ||
5873607e VZ |
96 | \perlnote{In wxPerl there is just an array reference in place of {\tt n} |
97 | and {\tt choices}.} | |
06d20283 | 98 | |
a660d684 KB |
99 | \membersection{wxComboBox::\destruct{wxComboBox}} |
100 | ||
101 | \func{}{\destruct{wxComboBox}}{\void} | |
102 | ||
103 | Destructor, destroying the combobox. | |
104 | ||
a660d684 KB |
105 | \membersection{wxComboBox::Create}\label{wxcomboboxcreate} |
106 | ||
eaaa6a06 | 107 | \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 108 | \param{const wxString\& }{value = ``"}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 JS |
109 | \param{int}{ n}, \param{const wxString }{choices[]},\rtfsp |
110 | \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``comboBox"}} | |
a660d684 KB |
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 | ||
a660d684 KB |
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 | ||
a660d684 KB |
140 | \membersection{wxComboBox::GetValue}\label{wxcomboboxgetvalue} |
141 | ||
142 | \constfunc{wxString}{GetValue}{\void} | |
143 | ||
144 | Returns the current value in the combobox text field. | |
145 | ||
a660d684 KB |
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 | ||
eaaa6a06 | 154 | \func{void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{text}} |
a660d684 KB |
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 | ||
eaaa6a06 | 168 | \func{void}{Remove}{\param{long}{ from}, \param{long}{ to}} |
a660d684 KB |
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 | ||
a660d684 KB |
178 | \membersection{wxComboBox::SetInsertionPoint}\label{wxcomboboxsetinsertionpoint} |
179 | ||
eaaa6a06 | 180 | \func{void}{SetInsertionPoint}{\param{long}{ pos}} |
a660d684 KB |
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 | ||
eaaa6a06 | 196 | \func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}} |
a660d684 KB |
197 | |
198 | Selects the text between the two positions, in the combobox text field. | |
199 | ||
200 | \wxheading{Parameters} | |
201 | ||
a660d684 KB |
202 | \docparam{from}{The first position.} |
203 | ||
204 | \docparam{to}{The second position.} | |
205 | ||
bed5584e VZ |
206 | \pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection} |
207 | name is kept for | |
208 | \helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.} | |
532da0d1 | 209 | |
a660d684 KB |
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 | ||
3ca6a5f0 BP |
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 | ||
a660d684 KB |
219 | \wxheading{Parameters} |
220 | ||
221 | \docparam{text}{The text to set.} | |
222 | ||
223 |