]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: choice.h | |
e54c96f1 | 3 | // Purpose: interface of wxChoice |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxChoice | |
7c913512 | 11 | |
23324ae1 | 12 | A choice item is used to select one of a list of strings. Unlike a |
bfac6166 | 13 | wxListBox, only the selection is visible until the user pulls down the |
23324ae1 | 14 | menu of choices. |
7c913512 | 15 | |
23324ae1 | 16 | @beginStyleTable |
8c6791e4 | 17 | @style{wxCB_SORT} |
23324ae1 FM |
18 | Sorts the entries alphabetically. |
19 | @endStyleTable | |
7c913512 | 20 | |
3051a44a | 21 | @beginEventEmissionTable{wxCommandEvent} |
8c6791e4 | 22 | @event{EVT_CHOICE(id, func)} |
23324ae1 FM |
23 | Process a wxEVT_COMMAND_CHOICE_SELECTED event, when an item on the |
24 | list is selected. | |
25 | @endEventTable | |
7c913512 | 26 | |
23324ae1 FM |
27 | @library{wxcore} |
28 | @category{ctrl} | |
7e59b885 | 29 | @appearance{choice.png} |
7c913512 | 30 | |
e54c96f1 | 31 | @see wxListBox, wxComboBox, wxCommandEvent |
23324ae1 FM |
32 | */ |
33 | class wxChoice : public wxControlWithItems | |
34 | { | |
35 | public: | |
bfac6166 BP |
36 | /** |
37 | Default constructor. | |
38 | ||
39 | @see Create(), wxValidator | |
40 | */ | |
41 | wxChoice(); | |
42 | ||
23324ae1 FM |
43 | //@{ |
44 | /** | |
45 | Constructor, creating and showing a choice. | |
3c4f71cc | 46 | |
7c913512 | 47 | @param parent |
4cc4bfaf | 48 | Parent window. Must not be @NULL. |
7c913512 | 49 | @param id |
4cc4bfaf | 50 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 51 | @param pos |
4cc4bfaf | 52 | Window position. |
dc1b07fd | 53 | If ::wxDefaultPosition is specified then a default position is chosen. |
7c913512 | 54 | @param size |
dc1b07fd FM |
55 | Window size. |
56 | If ::wxDefaultSize is specified then the choice is sized appropriately. | |
7c913512 | 57 | @param n |
4cc4bfaf | 58 | Number of strings with which to initialise the choice control. |
7c913512 | 59 | @param choices |
4cc4bfaf | 60 | An array of strings with which to initialise the choice control. |
7c913512 | 61 | @param style |
4cc4bfaf | 62 | Window style. See wxChoice. |
7c913512 | 63 | @param validator |
4cc4bfaf | 64 | Window validator. |
7c913512 | 65 | @param name |
4cc4bfaf | 66 | Window name. |
3c4f71cc | 67 | |
4cc4bfaf | 68 | @see Create(), wxValidator |
bfac6166 BP |
69 | |
70 | @beginWxPythonOnly | |
71 | ||
72 | The wxChoice constructor in wxPython reduces the @a n and @a choices | |
73 | arguments to a single argument, which is a list of strings. | |
74 | ||
75 | @endWxPythonOnly | |
1058f652 MB |
76 | |
77 | @beginWxPerlOnly | |
78 | Not supported by wxPerl. | |
79 | @endWxPerlOnly | |
23324ae1 | 80 | */ |
882678eb FM |
81 | wxChoice( wxWindow *parent, wxWindowID id, |
82 | const wxPoint& pos = wxDefaultPosition, | |
83 | const wxSize& size = wxDefaultSize, | |
84 | int n = 0, const wxString choices[] = NULL, | |
85 | long style = 0, | |
86 | const wxValidator& validator = wxDefaultValidator, | |
87 | const wxString& name = wxChoiceNameStr ); | |
792255cc VZ |
88 | |
89 | /** | |
90 | Constructor, creating and showing a choice. | |
91 | ||
92 | @param parent | |
93 | Parent window. Must not be @NULL. | |
94 | @param id | |
95 | Window identifier. The value wxID_ANY indicates a default value. | |
96 | @param pos | |
97 | Window position. | |
98 | @param size | |
99 | Window size. If wxDefaultSize is specified then the choice is sized | |
100 | appropriately. | |
101 | @param choices | |
102 | An array of strings with which to initialise the choice control. | |
103 | @param style | |
104 | Window style. See wxChoice. | |
105 | @param validator | |
106 | Window validator. | |
107 | @param name | |
108 | Window name. | |
109 | ||
110 | @see Create(), wxValidator | |
111 | ||
112 | @beginWxPythonOnly | |
113 | ||
114 | The wxChoice constructor in wxPython reduces the @a n and @a choices | |
115 | arguments to a single argument, which is a list of strings. | |
116 | ||
117 | @endWxPythonOnly | |
1058f652 MB |
118 | |
119 | @beginWxPerlOnly | |
120 | Use an array reference for the @a choices parameter. | |
121 | @endWxPerlOnly | |
792255cc | 122 | */ |
882678eb FM |
123 | wxChoice( wxWindow *parent, wxWindowID id, |
124 | const wxPoint& pos, | |
125 | const wxSize& size, | |
126 | const wxArrayString& choices, | |
127 | long style = 0, | |
128 | const wxValidator& validator = wxDefaultValidator, | |
129 | const wxString& name = wxChoiceNameStr ); | |
23324ae1 FM |
130 | //@} |
131 | ||
132 | /** | |
133 | Destructor, destroying the choice item. | |
134 | */ | |
b7e94bd7 | 135 | virtual ~wxChoice(); |
23324ae1 FM |
136 | |
137 | //@{ | |
138 | /** | |
139 | Creates the choice for two-step construction. See wxChoice(). | |
140 | */ | |
882678eb FM |
141 | bool Create( wxWindow *parent, wxWindowID id, |
142 | const wxPoint& pos = wxDefaultPosition, | |
143 | const wxSize& size = wxDefaultSize, | |
144 | int n = 0, const wxString choices[] = NULL, | |
145 | long style = 0, | |
146 | const wxValidator& validator = wxDefaultValidator, | |
147 | const wxString& name = wxChoiceNameStr ); | |
148 | bool Create( wxWindow *parent, wxWindowID id, | |
149 | const wxPoint& pos, | |
150 | const wxSize& size, | |
151 | const wxArrayString& choices, | |
152 | long style = 0, | |
153 | const wxValidator& validator = wxDefaultValidator, | |
154 | const wxString& name = wxChoiceNameStr ); | |
23324ae1 FM |
155 | //@} |
156 | ||
157 | /** | |
158 | Gets the number of columns in this choice item. | |
3c4f71cc | 159 | |
882678eb | 160 | @remarks This is implemented for GTK and Motif only and always |
3f16e52c | 161 | returns 1 for the other platforms. |
23324ae1 | 162 | */ |
b7e94bd7 | 163 | virtual int GetColumns() const; |
23324ae1 FM |
164 | |
165 | /** | |
bfac6166 BP |
166 | Unlike wxControlWithItems::GetSelection() which only returns the |
167 | accepted selection value, i.e. the selection in the control once the | |
168 | user closes the dropdown list, this function returns the current | |
169 | selection. That is, while the dropdown list is shown, it returns the | |
170 | currently selected item in it. When it is not shown, its result is the | |
171 | same as for the other function. | |
172 | ||
1e24c2af VS |
173 | @since 2.6.2. |
174 | In older versions, wxControlWithItems::GetSelection() itself | |
175 | behaved like this. | |
23324ae1 | 176 | */ |
b7e94bd7 | 177 | virtual int GetCurrentSelection() const; |
23324ae1 FM |
178 | |
179 | /** | |
180 | Sets the number of columns in this choice item. | |
3c4f71cc | 181 | |
7c913512 | 182 | @param n |
4cc4bfaf | 183 | Number of columns. |
bfac6166 | 184 | |
882678eb | 185 | @remarks This is implemented for GTK and Motif only and doesn’t do |
3f16e52c | 186 | anything under other platforms. |
23324ae1 | 187 | */ |
b7e94bd7 | 188 | virtual void SetColumns(int n = 1); |
23324ae1 | 189 | }; |
e54c96f1 | 190 |