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