]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: choicdlg.h | |
ba2874ff | 3 | // Purpose: interface of wx[Multi|Single]ChoiceDialog |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxMultiChoiceDialog | |
7c913512 | 11 | |
bfac6166 BP |
12 | This class represents a dialog that shows a list of strings, and allows the |
13 | user to select one or more. | |
7c913512 | 14 | |
23324ae1 FM |
15 | @library{wxbase} |
16 | @category{cmndlg} | |
7c913512 | 17 | |
ba2874ff | 18 | @see @ref overview_cmndlg_multichoice, wxSingleChoiceDialog |
23324ae1 FM |
19 | */ |
20 | class wxMultiChoiceDialog : public wxDialog | |
21 | { | |
22 | public: | |
23 | //@{ | |
24 | /** | |
25 | Constructor taking an array of wxString choices. | |
ba2874ff | 26 | |
7c913512 | 27 | @param parent |
4cc4bfaf | 28 | Parent window. |
7c913512 | 29 | @param message |
4cc4bfaf | 30 | Message to show on the dialog. |
7c913512 | 31 | @param caption |
4cc4bfaf | 32 | The dialog caption. |
7c913512 | 33 | @param n |
4cc4bfaf | 34 | The number of choices. |
7c913512 | 35 | @param choices |
4cc4bfaf | 36 | An array of strings, or a string list, containing the choices. |
7c913512 | 37 | @param style |
4cc4bfaf | 38 | A dialog style (bitlist) containing flags chosen from standard |
ba2874ff BP |
39 | dialog style and the ones listed below. The default value is |
40 | equivalent to wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | | |
41 | wxCANCEL | wxCENTRE. | |
42 | @param pos | |
43 | Dialog position. Not Windows. | |
44 | ||
45 | @beginStyleTable | |
8c6791e4 | 46 | @style{wxOK} |
4cc4bfaf | 47 | Show an OK button. |
8c6791e4 | 48 | @style{wxCANCEL} |
4cc4bfaf | 49 | Show a Cancel button. |
8c6791e4 | 50 | @style{wxCENTRE} |
4cc4bfaf | 51 | Centre the message. Not Windows. |
ba2874ff BP |
52 | @endStyleTable |
53 | ||
23324ae1 | 54 | @remarks Use ShowModal() to show the dialog. |
bfac6166 BP |
55 | |
56 | @beginWxPythonOnly | |
57 | ||
58 | For Python the two parameters @a n and @a choices are collapsed into a | |
59 | multi parameter @a choices which is expected to be a Python list of | |
60 | strings. | |
61 | ||
62 | @endWxPythonOnly | |
23324ae1 FM |
63 | */ |
64 | wxMultiChoiceDialog(wxWindow* parent, const wxString& message, | |
65 | const wxString& caption, | |
bfac6166 | 66 | int n, const wxString* choices, |
23324ae1 FM |
67 | long style = wxCHOICEDLG_STYLE, |
68 | const wxPoint& pos = wxDefaultPosition); | |
7c913512 FM |
69 | wxMultiChoiceDialog(wxWindow* parent, |
70 | const wxString& message, | |
71 | const wxString& caption, | |
72 | const wxArrayString& choices, | |
73 | long style = wxCHOICEDLG_STYLE, | |
74 | const wxPoint& pos = wxDefaultPosition); | |
23324ae1 FM |
75 | //@} |
76 | ||
77 | /** | |
78 | Returns array with indexes of selected items. | |
79 | */ | |
328f5751 | 80 | wxArrayInt GetSelection() const; |
23324ae1 FM |
81 | |
82 | /** | |
83 | Sets selected items from the array of selected items' indexes. | |
84 | */ | |
328f5751 | 85 | void SetSelections(const wxArrayInt& selections) const; |
23324ae1 FM |
86 | |
87 | /** | |
88 | Shows the dialog, returning either wxID_OK or wxID_CANCEL. | |
89 | */ | |
90 | int ShowModal(); | |
91 | }; | |
92 | ||
93 | ||
e54c96f1 | 94 | |
23324ae1 FM |
95 | /** |
96 | @class wxSingleChoiceDialog | |
7c913512 | 97 | |
bfac6166 BP |
98 | This class represents a dialog that shows a list of strings, and allows the |
99 | user to select one. Double-clicking on a list item is equivalent to | |
23324ae1 | 100 | single-clicking and then pressing OK. |
7c913512 | 101 | |
23324ae1 FM |
102 | @library{wxbase} |
103 | @category{cmndlg} | |
7c913512 | 104 | |
ba2874ff | 105 | @see @ref overview_cmndlg_singlechoice, wxMultiChoiceDialog |
23324ae1 FM |
106 | */ |
107 | class wxSingleChoiceDialog : public wxDialog | |
108 | { | |
109 | public: | |
110 | //@{ | |
111 | /** | |
ba2874ff BP |
112 | Constructor, taking an array of wxString choices and optional client |
113 | data. | |
114 | ||
7c913512 | 115 | @param parent |
4cc4bfaf | 116 | Parent window. |
7c913512 | 117 | @param message |
4cc4bfaf | 118 | Message to show on the dialog. |
7c913512 | 119 | @param caption |
4cc4bfaf | 120 | The dialog caption. |
7c913512 | 121 | @param n |
4cc4bfaf | 122 | The number of choices. |
7c913512 | 123 | @param choices |
4cc4bfaf | 124 | An array of strings, or a string list, containing the choices. |
7c913512 | 125 | @param clientData |
bfac6166 BP |
126 | An array of client data to be associated with the items. See |
127 | GetSelectionClientData(). | |
7c913512 | 128 | @param style |
4cc4bfaf | 129 | A dialog style (bitlist) containing flags chosen from standard |
ba2874ff BP |
130 | dialog styles and the ones listed below. The default value is |
131 | equivalent to wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | | |
132 | wxCANCEL | wxCENTRE. | |
133 | @param pos | |
134 | Dialog position. Not Windows. | |
135 | ||
136 | @beginStyleTable | |
8c6791e4 | 137 | @style{wxOK} |
4cc4bfaf | 138 | Show an OK button. |
8c6791e4 | 139 | @style{wxCANCEL} |
4cc4bfaf | 140 | Show a Cancel button. |
8c6791e4 | 141 | @style{wxCENTRE} |
4cc4bfaf | 142 | Centre the message. Not Windows. |
ba2874ff BP |
143 | @endStyleTable |
144 | ||
23324ae1 | 145 | @remarks Use ShowModal() to show the dialog. |
bfac6166 BP |
146 | |
147 | @beginWxPythonOnly | |
148 | ||
149 | For Python the two parameters @a n and @a choices are collapsed into a | |
150 | multi parameter @a choices which is expected to be a Python list of | |
151 | strings. | |
152 | ||
153 | @endWxPythonOnly | |
23324ae1 FM |
154 | */ |
155 | wxSingleChoiceDialog(wxWindow* parent, const wxString& message, | |
156 | const wxString& caption, | |
bfac6166 | 157 | int n, const wxString* choices, |
4cc4bfaf | 158 | void** clientData = NULL, |
23324ae1 FM |
159 | long style = wxCHOICEDLG_STYLE, |
160 | const wxPoint& pos = wxDefaultPosition); | |
7c913512 FM |
161 | wxSingleChoiceDialog(wxWindow* parent, |
162 | const wxString& message, | |
163 | const wxString& caption, | |
164 | const wxArrayString& choices, | |
4cc4bfaf | 165 | void** clientData = NULL, |
7c913512 FM |
166 | long style = wxCHOICEDLG_STYLE, |
167 | const wxPoint& pos = wxDefaultPosition); | |
23324ae1 FM |
168 | //@} |
169 | ||
170 | /** | |
171 | Returns the index of selected item. | |
172 | */ | |
328f5751 | 173 | int GetSelection() const; |
23324ae1 FM |
174 | |
175 | /** | |
176 | Returns the client data associated with the selection. | |
177 | */ | |
328f5751 | 178 | char* GetSelectionClientData() const; |
23324ae1 FM |
179 | |
180 | /** | |
181 | Returns the selected string. | |
182 | */ | |
328f5751 | 183 | wxString GetStringSelection() const; |
23324ae1 FM |
184 | |
185 | /** | |
186 | Sets the index of the initially selected item. | |
187 | */ | |
328f5751 | 188 | void SetSelection(int selection) const; |
23324ae1 FM |
189 | |
190 | /** | |
191 | Shows the dialog, returning either wxID_OK or wxID_CANCEL. | |
192 | */ | |
193 | int ShowModal(); | |
194 | }; | |
195 | ||
196 | ||
e54c96f1 | 197 | |
23324ae1 FM |
198 | // ============================================================================ |
199 | // Global functions/macros | |
200 | // ============================================================================ | |
201 | ||
ba2874ff | 202 | /** @ingroup group_funcmacro_dialog */ |
23324ae1 | 203 | //@{ |
ba2874ff | 204 | |
23324ae1 | 205 | /** |
ba2874ff BP |
206 | Same as wxGetSingleChoice() but returns the index representing the |
207 | selected string. If the user pressed cancel, -1 is returned. | |
208 | ||
209 | @header{wx/choicdlg.h} | |
23324ae1 FM |
210 | */ |
211 | int wxGetSingleChoiceIndex(const wxString& message, | |
212 | const wxString& caption, | |
213 | const wxArrayString& aChoices, | |
4cc4bfaf | 214 | wxWindow* parent = NULL, |
23324ae1 FM |
215 | int x = -1, |
216 | int y = -1, | |
4cc4bfaf FM |
217 | bool centre = true, |
218 | int width = 150, | |
219 | int height = 200); | |
7c913512 FM |
220 | int wxGetSingleChoiceIndex(const wxString& message, |
221 | const wxString& caption, | |
222 | int n, | |
223 | const wxString& choices[], | |
4cc4bfaf | 224 | wxWindow* parent = NULL, |
7c913512 FM |
225 | int x = -1, |
226 | int y = -1, | |
4cc4bfaf FM |
227 | bool centre = true, |
228 | int width = 150, | |
229 | int height = 200); | |
ba2874ff | 230 | |
23324ae1 FM |
231 | //@} |
232 | ||
ba2874ff | 233 | /** @ingroup group_funcmacro_dialog */ |
23324ae1 | 234 | //@{ |
ba2874ff | 235 | |
23324ae1 FM |
236 | /** |
237 | Pops up a dialog box containing a message, OK/Cancel buttons and a | |
ba2874ff BP |
238 | single-selection listbox. The user may choose an item and press OK to |
239 | return a string or Cancel to return the empty string. Use | |
240 | wxGetSingleChoiceIndex() if empty string is a valid choice and if you want | |
241 | to be able to detect pressing Cancel reliably. | |
242 | ||
243 | You may pass the list of strings to choose from either using @c choices | |
4cc4bfaf | 244 | which is an array of @a n strings for the listbox or by using a single |
ba2874ff BP |
245 | @c aChoices parameter of type wxArrayString. |
246 | ||
247 | If @c centre is @true, the message text (which may include new line | |
23324ae1 | 248 | characters) is centred; if @false, the message is left-justified. |
ba2874ff BP |
249 | |
250 | @header{wx/choicdlg.h} | |
23324ae1 FM |
251 | */ |
252 | wxString wxGetSingleChoice(const wxString& message, | |
253 | const wxString& caption, | |
254 | const wxArrayString& aChoices, | |
4cc4bfaf | 255 | wxWindow* parent = NULL, |
23324ae1 FM |
256 | int x = -1, |
257 | int y = -1, | |
4cc4bfaf FM |
258 | bool centre = true, |
259 | int width = 150, | |
260 | int height = 200); | |
7c913512 FM |
261 | wxString wxGetSingleChoice(const wxString& message, |
262 | const wxString& caption, | |
263 | int n, | |
264 | const wxString& choices[], | |
4cc4bfaf | 265 | wxWindow* parent = NULL, |
7c913512 FM |
266 | int x = -1, |
267 | int y = -1, | |
4cc4bfaf FM |
268 | bool centre = true, |
269 | int width = 150, | |
270 | int height = 200); | |
ba2874ff | 271 | |
23324ae1 FM |
272 | //@} |
273 | ||
ba2874ff | 274 | /** @ingroup group_funcmacro_dialog */ |
23324ae1 | 275 | //@{ |
ba2874ff | 276 | |
23324ae1 | 277 | /** |
ba2874ff BP |
278 | Same as wxGetSingleChoice but takes an array of client data pointers |
279 | corresponding to the strings, and returns one of these pointers or @NULL | |
280 | if Cancel was pressed. The @c client_data array must have the same number | |
281 | of elements as @c choices or @c aChoices! | |
282 | ||
283 | @header{wx/choicdlg.h} | |
23324ae1 FM |
284 | */ |
285 | wxString wxGetSingleChoiceData(const wxString& message, | |
286 | const wxString& caption, | |
287 | const wxArrayString& aChoices, | |
288 | const wxString& client_data[], | |
4cc4bfaf | 289 | wxWindow* parent = NULL, |
23324ae1 FM |
290 | int x = -1, |
291 | int y = -1, | |
4cc4bfaf FM |
292 | bool centre = true, |
293 | int width = 150, | |
294 | int height = 200); | |
7c913512 FM |
295 | wxString wxGetSingleChoiceData(const wxString& message, |
296 | const wxString& caption, | |
297 | int n, | |
298 | const wxString& choices[], | |
299 | const wxString& client_data[], | |
4cc4bfaf | 300 | wxWindow* parent = NULL, |
7c913512 FM |
301 | int x = -1, |
302 | int y = -1, | |
4cc4bfaf FM |
303 | bool centre = true, |
304 | int width = 150, | |
305 | int height = 200); | |
ba2874ff | 306 | |
23324ae1 FM |
307 | //@} |
308 | ||
ba2874ff | 309 | /** @ingroup group_funcmacro_dialog */ |
23324ae1 | 310 | //@{ |
ba2874ff | 311 | |
23324ae1 FM |
312 | /** |
313 | Pops up a dialog box containing a message, OK/Cancel buttons and a | |
314 | multiple-selection listbox. The user may choose an arbitrary (including 0) | |
315 | number of items in the listbox whose indices will be returned in | |
ba2874ff | 316 | @c selections array. The initial contents of this array will be used to |
23324ae1 | 317 | select the items when the dialog is shown. |
ba2874ff BP |
318 | |
319 | You may pass the list of strings to choose from either using @c choices | |
4cc4bfaf | 320 | which is an array of @a n strings for the listbox or by using a single |
ba2874ff BP |
321 | @c aChoices parameter of type wxArrayString. |
322 | ||
323 | If @c centre is @true, the message text (which may include new line | |
23324ae1 | 324 | characters) is centred; if @false, the message is left-justified. |
ba2874ff BP |
325 | |
326 | @header{wx/choicdlg.h} | |
23324ae1 FM |
327 | */ |
328 | size_t wxGetMultipleChoices(wxArrayInt& selections, | |
329 | const wxString& message, | |
330 | const wxString& caption, | |
331 | const wxArrayString& aChoices, | |
4cc4bfaf | 332 | wxWindow* parent = NULL, |
23324ae1 FM |
333 | int x = -1, |
334 | int y = -1, | |
4cc4bfaf FM |
335 | bool centre = true, |
336 | int width = 150, | |
337 | int height = 200); | |
7c913512 FM |
338 | size_t wxGetMultipleChoices(wxArrayInt& selections, |
339 | const wxString& message, | |
340 | const wxString& caption, | |
341 | int n, | |
342 | const wxString& choices[], | |
4cc4bfaf | 343 | wxWindow* parent = NULL, |
7c913512 FM |
344 | int x = -1, |
345 | int y = -1, | |
4cc4bfaf FM |
346 | bool centre = true, |
347 | int width = 150, | |
348 | int height = 200); | |
ba2874ff | 349 | |
23324ae1 FM |
350 | //@} |
351 |