]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/choicdlg.h
Use /bin/echo for creation of Mac OS X PkgInfo files.
[wxWidgets.git] / interface / wx / choicdlg.h
CommitLineData
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$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
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*/
20class wxMultiChoiceDialog : public wxDialog
21{
22public:
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
1058f652
MB
63
64 @beginWxPerlOnly
65 Not supported by wxPerl.
66 @endWxPerlOnly
23324ae1
FM
67 */
68 wxMultiChoiceDialog(wxWindow* parent, const wxString& message,
69 const wxString& caption,
bfac6166 70 int n, const wxString* choices,
23324ae1
FM
71 long style = wxCHOICEDLG_STYLE,
72 const wxPoint& pos = wxDefaultPosition);
792255cc
VZ
73 /**
74 Constructor taking an array of wxString choices.
75
76 @param parent
77 Parent window.
78 @param message
79 Message to show on the dialog.
80 @param caption
81 The dialog caption.
82 @param choices
83 An array of strings, or a string list, containing the choices.
84 @param style
85 A dialog style (bitlist) containing flags chosen from standard
86 dialog style and the ones listed below. The default value is
87 equivalent to wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK |
88 wxCANCEL | wxCENTRE.
89 @param pos
90 Dialog position. Not Windows.
91
92 @beginStyleTable
93 @style{wxOK}
94 Show an OK button.
95 @style{wxCANCEL}
96 Show a Cancel button.
97 @style{wxCENTRE}
98 Centre the message. Not Windows.
99 @endStyleTable
100
101 @remarks Use ShowModal() to show the dialog.
102
103 @beginWxPythonOnly
104
105 For Python the two parameters @a n and @a choices are collapsed into a
106 multi parameter @a choices which is expected to be a Python list of
107 strings.
108
109 @endWxPythonOnly
1058f652
MB
110
111 @beginWxPerlOnly
112 Use an array reference for the @a choices parameter.
113 @endWxPerlOnly
792255cc 114 */
7c913512
FM
115 wxMultiChoiceDialog(wxWindow* parent,
116 const wxString& message,
117 const wxString& caption,
118 const wxArrayString& choices,
119 long style = wxCHOICEDLG_STYLE,
120 const wxPoint& pos = wxDefaultPosition);
23324ae1
FM
121 //@}
122
123 /**
124 Returns array with indexes of selected items.
125 */
c68b8967 126 wxArrayInt GetSelections() const;
23324ae1
FM
127
128 /**
129 Sets selected items from the array of selected items' indexes.
130 */
b7e94bd7 131 void SetSelections(const wxArrayInt& selections);
23324ae1
FM
132
133 /**
134 Shows the dialog, returning either wxID_OK or wxID_CANCEL.
135 */
136 int ShowModal();
137};
138
139
e54c96f1 140
23324ae1
FM
141/**
142 @class wxSingleChoiceDialog
7c913512 143
bfac6166
BP
144 This class represents a dialog that shows a list of strings, and allows the
145 user to select one. Double-clicking on a list item is equivalent to
23324ae1 146 single-clicking and then pressing OK.
7c913512 147
23324ae1
FM
148 @library{wxbase}
149 @category{cmndlg}
7c913512 150
ba2874ff 151 @see @ref overview_cmndlg_singlechoice, wxMultiChoiceDialog
23324ae1
FM
152*/
153class wxSingleChoiceDialog : public wxDialog
154{
155public:
156 //@{
157 /**
ba2874ff
BP
158 Constructor, taking an array of wxString choices and optional client
159 data.
160
7c913512 161 @param parent
4cc4bfaf 162 Parent window.
7c913512 163 @param message
4cc4bfaf 164 Message to show on the dialog.
7c913512 165 @param caption
4cc4bfaf 166 The dialog caption.
7c913512 167 @param n
4cc4bfaf 168 The number of choices.
7c913512 169 @param choices
4cc4bfaf 170 An array of strings, or a string list, containing the choices.
7c913512 171 @param clientData
bfac6166 172 An array of client data to be associated with the items. See
fc12b1f1 173 GetSelectionData().
7c913512 174 @param style
4cc4bfaf 175 A dialog style (bitlist) containing flags chosen from standard
ba2874ff
BP
176 dialog styles and the ones listed below. The default value is
177 equivalent to wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK |
178 wxCANCEL | wxCENTRE.
179 @param pos
180 Dialog position. Not Windows.
181
182 @beginStyleTable
8c6791e4 183 @style{wxOK}
4cc4bfaf 184 Show an OK button.
8c6791e4 185 @style{wxCANCEL}
4cc4bfaf 186 Show a Cancel button.
8c6791e4 187 @style{wxCENTRE}
4cc4bfaf 188 Centre the message. Not Windows.
ba2874ff
BP
189 @endStyleTable
190
23324ae1 191 @remarks Use ShowModal() to show the dialog.
bfac6166
BP
192
193 @beginWxPythonOnly
194
195 For Python the two parameters @a n and @a choices are collapsed into a
196 multi parameter @a choices which is expected to be a Python list of
197 strings.
198
199 @endWxPythonOnly
1058f652
MB
200
201 @beginWxPerlOnly
202 Not supported by wxPerl.
203 @endWxPerlOnly
23324ae1
FM
204 */
205 wxSingleChoiceDialog(wxWindow* parent, const wxString& message,
206 const wxString& caption,
bfac6166 207 int n, const wxString* choices,
4cc4bfaf 208 void** clientData = NULL,
23324ae1
FM
209 long style = wxCHOICEDLG_STYLE,
210 const wxPoint& pos = wxDefaultPosition);
792255cc
VZ
211 /**
212 Constructor, taking an array of wxString choices and optional client
213 data.
214
215 @param parent
216 Parent window.
217 @param message
218 Message to show on the dialog.
219 @param caption
220 The dialog caption.
221 @param choices
222 An array of strings, or a string list, containing the choices.
223 @param clientData
224 An array of client data to be associated with the items. See
fc12b1f1 225 GetSelectionData().
792255cc
VZ
226 @param style
227 A dialog style (bitlist) containing flags chosen from standard
228 dialog styles and the ones listed below. The default value is
229 equivalent to wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK |
230 wxCANCEL | wxCENTRE.
231 @param pos
232 Dialog position. Not Windows.
233
234 @beginStyleTable
235 @style{wxOK}
236 Show an OK button.
237 @style{wxCANCEL}
238 Show a Cancel button.
239 @style{wxCENTRE}
240 Centre the message. Not Windows.
241 @endStyleTable
242
243 @remarks Use ShowModal() to show the dialog.
244
245 @beginWxPythonOnly
246
247 For Python the two parameters @a n and @a choices are collapsed into a
248 multi parameter @a choices which is expected to be a Python list of
249 strings.
250
251 @endWxPythonOnly
1058f652
MB
252
253 @beginWxPerlOnly
254 Use an array reference for the @a choices parameter.
255 @endWxPerlOnly
792255cc 256 */
7c913512
FM
257 wxSingleChoiceDialog(wxWindow* parent,
258 const wxString& message,
259 const wxString& caption,
260 const wxArrayString& choices,
4cc4bfaf 261 void** clientData = NULL,
7c913512
FM
262 long style = wxCHOICEDLG_STYLE,
263 const wxPoint& pos = wxDefaultPosition);
23324ae1
FM
264 //@}
265
266 /**
267 Returns the index of selected item.
268 */
328f5751 269 int GetSelection() const;
23324ae1
FM
270
271 /**
272 Returns the client data associated with the selection.
fc12b1f1
VZ
273
274 @since 2.9.4
23324ae1 275 */
fc12b1f1 276 void* GetSelectionData() const;
23324ae1
FM
277
278 /**
279 Returns the selected string.
280 */
328f5751 281 wxString GetStringSelection() const;
23324ae1
FM
282
283 /**
284 Sets the index of the initially selected item.
285 */
b7e94bd7 286 void SetSelection(int selection);
23324ae1
FM
287
288 /**
289 Shows the dialog, returning either wxID_OK or wxID_CANCEL.
290 */
291 int ShowModal();
292};
293
294
e54c96f1 295
23324ae1
FM
296// ============================================================================
297// Global functions/macros
298// ============================================================================
299
b21126db 300/** @addtogroup group_funcmacro_dialog */
23324ae1 301//@{
ba2874ff 302
23324ae1 303/**
ba2874ff
BP
304 Same as wxGetSingleChoice() but returns the index representing the
305 selected string. If the user pressed cancel, -1 is returned.
306
307 @header{wx/choicdlg.h}
1058f652
MB
308
309 @beginWxPerlOnly
310 Use an array reference for the @a aChoices parameter.
311 @endWxPerlOnly
23324ae1
FM
312*/
313int wxGetSingleChoiceIndex(const wxString& message,
314 const wxString& caption,
315 const wxArrayString& aChoices,
4cc4bfaf 316 wxWindow* parent = NULL,
23324ae1
FM
317 int x = -1,
318 int y = -1,
4cc4bfaf
FM
319 bool centre = true,
320 int width = 150,
697f4a96
VZ
321 int height = 200,
322 int initialSelection = 0);
323
7c913512
FM
324int wxGetSingleChoiceIndex(const wxString& message,
325 const wxString& caption,
326 int n,
327 const wxString& choices[],
4cc4bfaf 328 wxWindow* parent = NULL,
7c913512
FM
329 int x = -1,
330 int y = -1,
4cc4bfaf
FM
331 bool centre = true,
332 int width = 150,
697f4a96
VZ
333 int height = 200,
334 int initialSelection = 0);
335
336
337int wxGetSingleChoiceIndex(const wxString& message,
338 const wxString& caption,
339 const wxArrayString& choices,
340 int initialSelection,
341 wxWindow *parent = NULL);
ba2874ff 342
697f4a96
VZ
343int wxGetSingleChoiceIndex(const wxString& message,
344 const wxString& caption,
345 int n, const wxString *choices,
346 int initialSelection,
347 wxWindow *parent = NULL);
23324ae1
FM
348//@}
349
b21126db 350/** @addtogroup group_funcmacro_dialog */
23324ae1 351//@{
ba2874ff 352
23324ae1
FM
353/**
354 Pops up a dialog box containing a message, OK/Cancel buttons and a
ba2874ff
BP
355 single-selection listbox. The user may choose an item and press OK to
356 return a string or Cancel to return the empty string. Use
357 wxGetSingleChoiceIndex() if empty string is a valid choice and if you want
358 to be able to detect pressing Cancel reliably.
359
360 You may pass the list of strings to choose from either using @c choices
4cc4bfaf 361 which is an array of @a n strings for the listbox or by using a single
ba2874ff
BP
362 @c aChoices parameter of type wxArrayString.
363
364 If @c centre is @true, the message text (which may include new line
23324ae1 365 characters) is centred; if @false, the message is left-justified.
ba2874ff
BP
366
367 @header{wx/choicdlg.h}
1058f652
MB
368
369 @beginWxPerlOnly
370 Use an array reference for the @a choices parameter.
371 @endWxPerlOnly
23324ae1
FM
372*/
373wxString wxGetSingleChoice(const wxString& message,
374 const wxString& caption,
375 const wxArrayString& aChoices,
4cc4bfaf 376 wxWindow* parent = NULL,
23324ae1
FM
377 int x = -1,
378 int y = -1,
4cc4bfaf
FM
379 bool centre = true,
380 int width = 150,
697f4a96
VZ
381 int height = 200
382 int initialSelection = 0);
7c913512
FM
383wxString wxGetSingleChoice(const wxString& message,
384 const wxString& caption,
385 int n,
386 const wxString& choices[],
4cc4bfaf 387 wxWindow* parent = NULL,
7c913512
FM
388 int x = -1,
389 int y = -1,
4cc4bfaf
FM
390 bool centre = true,
391 int width = 150,
697f4a96
VZ
392 int height = 200
393 int initialSelection = 0);
394
395
396wxString wxGetSingleChoice(const wxString& message,
397 const wxString& caption,
398 const wxArrayString& choices,
399 int initialSelection,
400 wxWindow *parent = NULL);
401
402wxString wxGetSingleChoice(const wxString& message,
403 const wxString& caption,
404 int n, const wxString *choices,
405 int initialSelection,
406 wxWindow *parent = NULL);
ba2874ff 407
23324ae1
FM
408//@}
409
b21126db 410/** @addtogroup group_funcmacro_dialog */
23324ae1 411//@{
ba2874ff 412
23324ae1 413/**
ba2874ff
BP
414 Same as wxGetSingleChoice but takes an array of client data pointers
415 corresponding to the strings, and returns one of these pointers or @NULL
416 if Cancel was pressed. The @c client_data array must have the same number
417 of elements as @c choices or @c aChoices!
418
419 @header{wx/choicdlg.h}
1058f652
MB
420
421 @beginWxPerlOnly
422 Use an array reference for the @a aChoices and @a client_data parameters.
423 @endWxPerlOnly
23324ae1
FM
424*/
425wxString wxGetSingleChoiceData(const wxString& message,
426 const wxString& caption,
427 const wxArrayString& aChoices,
428 const wxString& client_data[],
4cc4bfaf 429 wxWindow* parent = NULL,
23324ae1
FM
430 int x = -1,
431 int y = -1,
4cc4bfaf
FM
432 bool centre = true,
433 int width = 150,
697f4a96
VZ
434 int height = 200
435 int initialSelection = 0);
436
7c913512
FM
437wxString wxGetSingleChoiceData(const wxString& message,
438 const wxString& caption,
439 int n,
440 const wxString& choices[],
441 const wxString& client_data[],
4cc4bfaf 442 wxWindow* parent = NULL,
7c913512
FM
443 int x = -1,
444 int y = -1,
4cc4bfaf
FM
445 bool centre = true,
446 int width = 150,
697f4a96
VZ
447 int height = 200
448 int initialSelection = 0);
449
450void* wxGetSingleChoiceData(const wxString& message,
451 const wxString& caption,
452 const wxArrayString& choices,
453 void **client_data,
454 int initialSelection,
455 wxWindow *parent = NULL);
456
457void* wxGetSingleChoiceData(const wxString& message,
458 const wxString& caption,
459 int n, const wxString *choices,
460 void **client_data,
461 int initialSelection,
462 wxWindow *parent = NULL);
ba2874ff 463
23324ae1
FM
464//@}
465
b21126db 466/** @addtogroup group_funcmacro_dialog */
23324ae1 467//@{
ba2874ff 468
23324ae1
FM
469/**
470 Pops up a dialog box containing a message, OK/Cancel buttons and a
471 multiple-selection listbox. The user may choose an arbitrary (including 0)
472 number of items in the listbox whose indices will be returned in
ba2874ff 473 @c selections array. The initial contents of this array will be used to
e5cfb314
VZ
474 select the items when the dialog is shown. If the user cancels the dialog,
475 the function returns -1 and @c selections array is left unchanged.
ba2874ff
BP
476
477 You may pass the list of strings to choose from either using @c choices
4cc4bfaf 478 which is an array of @a n strings for the listbox or by using a single
ba2874ff
BP
479 @c aChoices parameter of type wxArrayString.
480
481 If @c centre is @true, the message text (which may include new line
23324ae1 482 characters) is centred; if @false, the message is left-justified.
ba2874ff
BP
483
484 @header{wx/choicdlg.h}
1058f652
MB
485
486 @beginWxPerlOnly
487 Use an array reference for the @a choices parameter.
488 In wxPerl there is no @a selections parameter; the function
489 returns an array containing the user selections.
490 @endWxPerlOnly
23324ae1 491*/
e5cfb314 492int wxGetSelectedChoices(wxArrayInt& selections,
23324ae1
FM
493 const wxString& message,
494 const wxString& caption,
495 const wxArrayString& aChoices,
4cc4bfaf 496 wxWindow* parent = NULL,
23324ae1
FM
497 int x = -1,
498 int y = -1,
4cc4bfaf
FM
499 bool centre = true,
500 int width = 150,
501 int height = 200);
697f4a96 502
e5cfb314 503int wxGetSelectedChoices(wxArrayInt& selections,
7c913512
FM
504 const wxString& message,
505 const wxString& caption,
506 int n,
507 const wxString& choices[],
4cc4bfaf 508 wxWindow* parent = NULL,
7c913512
FM
509 int x = -1,
510 int y = -1,
4cc4bfaf
FM
511 bool centre = true,
512 int width = 150,
513 int height = 200);
ba2874ff 514
23324ae1
FM
515//@}
516