]>
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$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
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)} |
ce7fe42e | 23 | Process a @c wxEVT_CHOICE event, when an item on the |
23324ae1 FM |
24 | list is selected. |
25 | @endEventTable | |
7c913512 | 26 | |
23324ae1 FM |
27 | @library{wxcore} |
28 | @category{ctrl} | |
ce154616 | 29 | @appearance{choice} |
7c913512 | 30 | |
e54c96f1 | 31 | @see wxListBox, wxComboBox, wxCommandEvent |
23324ae1 | 32 | */ |
3bb9348f VZ |
33 | class wxChoice : public wxControl, |
34 | public wxItemContainer | |
23324ae1 FM |
35 | { |
36 | public: | |
bfac6166 BP |
37 | /** |
38 | Default constructor. | |
39 | ||
40 | @see Create(), wxValidator | |
41 | */ | |
42 | wxChoice(); | |
43 | ||
23324ae1 FM |
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 | 69 | |
1058f652 MB |
70 | @beginWxPerlOnly |
71 | Not supported by wxPerl. | |
72 | @endWxPerlOnly | |
23324ae1 | 73 | */ |
882678eb FM |
74 | wxChoice( wxWindow *parent, wxWindowID id, |
75 | const wxPoint& pos = wxDefaultPosition, | |
76 | const wxSize& size = wxDefaultSize, | |
77 | int n = 0, const wxString choices[] = NULL, | |
78 | long style = 0, | |
79 | const wxValidator& validator = wxDefaultValidator, | |
80 | const wxString& name = wxChoiceNameStr ); | |
792255cc VZ |
81 | |
82 | /** | |
83 | Constructor, creating and showing a choice. | |
84 | ||
85 | @param parent | |
86 | Parent window. Must not be @NULL. | |
87 | @param id | |
88 | Window identifier. The value wxID_ANY indicates a default value. | |
89 | @param pos | |
90 | Window position. | |
91 | @param size | |
92 | Window size. If wxDefaultSize is specified then the choice is sized | |
93 | appropriately. | |
94 | @param choices | |
95 | An array of strings with which to initialise the choice control. | |
96 | @param style | |
97 | Window style. See wxChoice. | |
98 | @param validator | |
99 | Window validator. | |
100 | @param name | |
101 | Window name. | |
102 | ||
103 | @see Create(), wxValidator | |
104 | ||
1058f652 MB |
105 | @beginWxPerlOnly |
106 | Use an array reference for the @a choices parameter. | |
107 | @endWxPerlOnly | |
792255cc | 108 | */ |
882678eb FM |
109 | wxChoice( wxWindow *parent, wxWindowID id, |
110 | const wxPoint& pos, | |
111 | const wxSize& size, | |
112 | const wxArrayString& choices, | |
113 | long style = 0, | |
114 | const wxValidator& validator = wxDefaultValidator, | |
115 | const wxString& name = wxChoiceNameStr ); | |
23324ae1 FM |
116 | |
117 | /** | |
118 | Destructor, destroying the choice item. | |
119 | */ | |
b7e94bd7 | 120 | virtual ~wxChoice(); |
23324ae1 FM |
121 | |
122 | //@{ | |
123 | /** | |
124 | Creates the choice for two-step construction. See wxChoice(). | |
125 | */ | |
882678eb FM |
126 | bool Create( wxWindow *parent, wxWindowID id, |
127 | const wxPoint& pos = wxDefaultPosition, | |
128 | const wxSize& size = wxDefaultSize, | |
129 | int n = 0, const wxString choices[] = NULL, | |
130 | long style = 0, | |
131 | const wxValidator& validator = wxDefaultValidator, | |
132 | const wxString& name = wxChoiceNameStr ); | |
133 | bool Create( wxWindow *parent, wxWindowID id, | |
134 | const wxPoint& pos, | |
135 | const wxSize& size, | |
136 | const wxArrayString& choices, | |
137 | long style = 0, | |
138 | const wxValidator& validator = wxDefaultValidator, | |
139 | const wxString& name = wxChoiceNameStr ); | |
23324ae1 FM |
140 | //@} |
141 | ||
142 | /** | |
143 | Gets the number of columns in this choice item. | |
3c4f71cc | 144 | |
882678eb | 145 | @remarks This is implemented for GTK and Motif only and always |
3f16e52c | 146 | returns 1 for the other platforms. |
23324ae1 | 147 | */ |
b7e94bd7 | 148 | virtual int GetColumns() const; |
23324ae1 FM |
149 | |
150 | /** | |
bfac6166 BP |
151 | Unlike wxControlWithItems::GetSelection() which only returns the |
152 | accepted selection value, i.e. the selection in the control once the | |
153 | user closes the dropdown list, this function returns the current | |
154 | selection. That is, while the dropdown list is shown, it returns the | |
155 | currently selected item in it. When it is not shown, its result is the | |
156 | same as for the other function. | |
157 | ||
1e24c2af VS |
158 | @since 2.6.2. |
159 | In older versions, wxControlWithItems::GetSelection() itself | |
160 | behaved like this. | |
23324ae1 | 161 | */ |
b7e94bd7 | 162 | virtual int GetCurrentSelection() const; |
23324ae1 FM |
163 | |
164 | /** | |
165 | Sets the number of columns in this choice item. | |
3c4f71cc | 166 | |
7c913512 | 167 | @param n |
4cc4bfaf | 168 | Number of columns. |
bfac6166 | 169 | |
882678eb | 170 | @remarks This is implemented for GTK and Motif only and doesn’t do |
3f16e52c | 171 | anything under other platforms. |
23324ae1 | 172 | */ |
b7e94bd7 | 173 | virtual void SetColumns(int n = 1); |
8ff9b17d RD |
174 | |
175 | virtual bool IsSorted() const; | |
176 | ||
177 | virtual unsigned int GetCount() const ; | |
178 | virtual int GetSelection() const ; | |
179 | virtual void SetSelection(int n); | |
180 | ||
181 | virtual int FindString(const wxString& s, bool bCase = false) const; | |
182 | virtual wxString GetString(unsigned int n) const ; | |
183 | virtual void SetString(unsigned int pos, const wxString& s); | |
23324ae1 | 184 | }; |
e54c96f1 | 185 |