]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/choicdgg.h
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / include / wx / generic / choicdgg.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
d6c9c1b7 2// Name: wx/generic/choicdgg.h
c801d85f
KB
3// Purpose: Generic choice dialogs
4// Author: Julian Smart
d6c9c1b7 5// Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions
c801d85f 6// Created: 01/02/97
77ffb593 7// Copyright: (c) wxWidgets team
65571936 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
84498436
VZ
11#ifndef _WX_GENERIC_CHOICDGG_H_
12#define _WX_GENERIC_CHOICDGG_H_
c801d85f 13
d6c9c1b7 14#include "wx/dynarray.h"
c801d85f 15#include "wx/dialog.h"
8ee9d618 16
b5dbe15d 17class WXDLLIMPEXP_FWD_CORE wxListBoxBase;
c801d85f 18
d6c9c1b7
VZ
19// ----------------------------------------------------------------------------
20// some (ugly...) constants
21// ----------------------------------------------------------------------------
22
c801d85f
KB
23#define wxCHOICE_HEIGHT 150
24#define wxCHOICE_WIDTH 200
25
259a6e38
JS
26#ifdef __WXWINCE__
27#define wxCHOICEDLG_STYLE \
28 (wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE)
29#else
abd9b10e
VZ
30#define wxCHOICEDLG_STYLE \
31 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
259a6e38 32#endif
c801d85f 33
d6c9c1b7
VZ
34// ----------------------------------------------------------------------------
35// wxAnyChoiceDialog: a base class for dialogs containing a listbox
36// ----------------------------------------------------------------------------
37
53a2db12 38class WXDLLIMPEXP_CORE wxAnyChoiceDialog : public wxDialog
c801d85f 39{
d6c9c1b7 40public:
6463b9f5 41 wxAnyChoiceDialog() { }
d6c9c1b7
VZ
42
43 wxAnyChoiceDialog(wxWindow *parent,
44 const wxString& message,
45 const wxString& caption,
46 int n, const wxString *choices,
47 long styleDlg = wxCHOICEDLG_STYLE,
48 const wxPoint& pos = wxDefaultPosition,
6463b9f5
JS
49 long styleLbox = wxLB_ALWAYS_SB)
50 {
51 (void)Create(parent, message, caption, n, choices,
52 styleDlg, pos, styleLbox);
53 }
584ad2a3
MB
54 wxAnyChoiceDialog(wxWindow *parent,
55 const wxString& message,
56 const wxString& caption,
57 const wxArrayString& choices,
58 long styleDlg = wxCHOICEDLG_STYLE,
59 const wxPoint& pos = wxDefaultPosition,
60 long styleLbox = wxLB_ALWAYS_SB)
61 {
62 (void)Create(parent, message, caption, choices,
63 styleDlg, pos, styleLbox);
64 }
d6c9c1b7
VZ
65
66 bool Create(wxWindow *parent,
67 const wxString& message,
68 const wxString& caption,
69 int n, const wxString *choices,
70 long styleDlg = wxCHOICEDLG_STYLE,
71 const wxPoint& pos = wxDefaultPosition,
72 long styleLbox = wxLB_ALWAYS_SB);
584ad2a3
MB
73 bool Create(wxWindow *parent,
74 const wxString& message,
75 const wxString& caption,
76 const wxArrayString& choices,
77 long styleDlg = wxCHOICEDLG_STYLE,
78 const wxPoint& pos = wxDefaultPosition,
79 long styleLbox = wxLB_ALWAYS_SB);
d6c9c1b7
VZ
80
81protected:
60104cba
WS
82 wxListBoxBase *m_listbox;
83
84 virtual wxListBoxBase *CreateList(int n,
85 const wxString *choices,
86 long styleLbox);
22f3361e 87
c0c133e1 88 wxDECLARE_NO_COPY_CLASS(wxAnyChoiceDialog);
d6c9c1b7 89};
257bf510 90
d6c9c1b7
VZ
91// ----------------------------------------------------------------------------
92// wxSingleChoiceDialog: a dialog with single selection listbox
93// ----------------------------------------------------------------------------
94
53a2db12 95class WXDLLIMPEXP_CORE wxSingleChoiceDialog : public wxAnyChoiceDialog
d6c9c1b7 96{
c801d85f 97public:
6463b9f5
JS
98 wxSingleChoiceDialog()
99 {
100 m_selection = -1;
101 }
d6c9c1b7 102
257bf510
VZ
103 wxSingleChoiceDialog(wxWindow *parent,
104 const wxString& message,
105 const wxString& caption,
106 int n,
107 const wxString *choices,
fc12b1f1 108 void **clientData = NULL,
257bf510 109 long style = wxCHOICEDLG_STYLE,
fc12b1f1
VZ
110 const wxPoint& pos = wxDefaultPosition)
111 {
112 Create(parent, message, caption, n, choices, clientData, style, pos);
113 }
114
584ad2a3
MB
115 wxSingleChoiceDialog(wxWindow *parent,
116 const wxString& message,
117 const wxString& caption,
118 const wxArrayString& choices,
fc12b1f1 119 void **clientData = NULL,
584ad2a3 120 long style = wxCHOICEDLG_STYLE,
fc12b1f1
VZ
121 const wxPoint& pos = wxDefaultPosition)
122 {
123 Create(parent, message, caption, choices, clientData, style, pos);
124 }
257bf510 125
d6c9c1b7
VZ
126 bool Create(wxWindow *parent,
127 const wxString& message,
128 const wxString& caption,
129 int n,
130 const wxString *choices,
fc12b1f1 131 void **clientData = NULL,
d6c9c1b7
VZ
132 long style = wxCHOICEDLG_STYLE,
133 const wxPoint& pos = wxDefaultPosition);
584ad2a3
MB
134 bool Create(wxWindow *parent,
135 const wxString& message,
136 const wxString& caption,
137 const wxArrayString& choices,
fc12b1f1 138 void **clientData = NULL,
584ad2a3
MB
139 long style = wxCHOICEDLG_STYLE,
140 const wxPoint& pos = wxDefaultPosition);
d6c9c1b7
VZ
141
142 void SetSelection(int sel);
143 int GetSelection() const { return m_selection; }
144 wxString GetStringSelection() const { return m_stringSelection; }
805b7b21 145 void* GetSelectionData() const { return m_clientData; }
fc12b1f1
VZ
146
147#if WXWIN_COMPATIBILITY_2_8
148 // Deprecated overloads taking "char**" client data.
149 wxDEPRECATED_CONSTRUCTOR
150 (
151 wxSingleChoiceDialog(wxWindow *parent,
152 const wxString& message,
153 const wxString& caption,
154 int n,
155 const wxString *choices,
156 char **clientData,
157 long style = wxCHOICEDLG_STYLE,
158 const wxPoint& pos = wxDefaultPosition)
159 )
160 {
161 Create(parent, message, caption, n, choices,
162 (void**)clientData, style, pos);
163 }
164
165 wxDEPRECATED_CONSTRUCTOR
166 (
167 wxSingleChoiceDialog(wxWindow *parent,
168 const wxString& message,
169 const wxString& caption,
170 const wxArrayString& choices,
171 char **clientData,
172 long style = wxCHOICEDLG_STYLE,
173 const wxPoint& pos = wxDefaultPosition)
174 )
175 {
176 Create(parent, message, caption, choices,
177 (void**)clientData, style, pos);
178 }
d6c9c1b7 179
fc12b1f1
VZ
180 wxDEPRECATED_INLINE
181 (
182 bool Create(wxWindow *parent,
183 const wxString& message,
184 const wxString& caption,
185 int n,
186 const wxString *choices,
187 char **clientData,
188 long style = wxCHOICEDLG_STYLE,
189 const wxPoint& pos = wxDefaultPosition),
190 return Create(parent, message, caption, n, choices,
191 (void**)clientData, style, pos);
192 )
193
194 wxDEPRECATED_INLINE
195 (
196 bool Create(wxWindow *parent,
197 const wxString& message,
198 const wxString& caption,
199 const wxArrayString& choices,
200 char **clientData,
201 long style = wxCHOICEDLG_STYLE,
202 const wxPoint& pos = wxDefaultPosition),
203 return Create(parent, message, caption, choices,
204 (void**)clientData, style, pos);
205 )
206
207 // NB: no need to make it return wxChar, it's untyped
208 wxDEPRECATED_ACCESSOR
209 (
805b7b21
VZ
210 char* GetSelectionClientData() const,
211 (char*)GetSelectionData()
fc12b1f1
VZ
212 )
213#endif // WXWIN_COMPATIBILITY_2_8
d6c9c1b7
VZ
214
215 // implementation from now on
216 void OnOK(wxCommandEvent& event);
7b504551 217#ifndef __SMARTPHONE__
d6c9c1b7 218 void OnListBoxDClick(wxCommandEvent& event);
7b504551
WS
219#endif
220#ifdef __WXWINCE__
221 void OnJoystickButtonDown(wxJoystickEvent& event);
222#endif
d6c9c1b7 223
d6c9c1b7
VZ
224protected:
225 int m_selection;
226 wxString m_stringSelection;
227
7b504551
WS
228 void DoChoice();
229
d6c9c1b7 230private:
fc7a2a60 231 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
d6c9c1b7
VZ
232 DECLARE_EVENT_TABLE()
233};
234
235// ----------------------------------------------------------------------------
236// wxMultiChoiceDialog: a dialog with multi selection listbox
237// ----------------------------------------------------------------------------
238
53a2db12 239class WXDLLIMPEXP_CORE wxMultiChoiceDialog : public wxAnyChoiceDialog
d6c9c1b7
VZ
240{
241public:
6463b9f5 242 wxMultiChoiceDialog() { }
d6c9c1b7
VZ
243
244 wxMultiChoiceDialog(wxWindow *parent,
245 const wxString& message,
246 const wxString& caption,
247 int n,
248 const wxString *choices,
249 long style = wxCHOICEDLG_STYLE,
6463b9f5
JS
250 const wxPoint& pos = wxDefaultPosition)
251 {
252 (void)Create(parent, message, caption, n, choices, style, pos);
253 }
584ad2a3
MB
254 wxMultiChoiceDialog(wxWindow *parent,
255 const wxString& message,
256 const wxString& caption,
257 const wxArrayString& choices,
258 long style = wxCHOICEDLG_STYLE,
259 const wxPoint& pos = wxDefaultPosition)
260 {
261 (void)Create(parent, message, caption, choices, style, pos);
262 }
257bf510
VZ
263
264 bool Create(wxWindow *parent,
265 const wxString& message,
266 const wxString& caption,
d6c9c1b7
VZ
267 int n,
268 const wxString *choices,
257bf510
VZ
269 long style = wxCHOICEDLG_STYLE,
270 const wxPoint& pos = wxDefaultPosition);
584ad2a3
MB
271 bool Create(wxWindow *parent,
272 const wxString& message,
273 const wxString& caption,
274 const wxArrayString& choices,
275 long style = wxCHOICEDLG_STYLE,
276 const wxPoint& pos = wxDefaultPosition);
c801d85f 277
d6c9c1b7
VZ
278 void SetSelections(const wxArrayInt& selections);
279 wxArrayInt GetSelections() const { return m_selections; }
c801d85f 280
257bf510 281 // implementation from now on
3d49ce44 282 virtual bool TransferDataFromWindow();
c801d85f 283
c801d85f 284protected:
60104cba
WS
285#if wxUSE_CHECKLISTBOX
286 virtual wxListBoxBase *CreateList(int n,
287 const wxString *choices,
288 long styleLbox);
289#endif // wxUSE_CHECKLISTBOX
290
d6c9c1b7 291 wxArrayInt m_selections;
257bf510
VZ
292
293private:
fc7a2a60 294 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
c801d85f
KB
295};
296
d6c9c1b7
VZ
297// ----------------------------------------------------------------------------
298// wrapper functions which can be used to get selection(s) from the user
299// ----------------------------------------------------------------------------
300
301// get the user selection as a string
53a2db12 302WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
d6c9c1b7
VZ
303 const wxString& caption,
304 const wxArrayString& choices,
84498436 305 wxWindow *parent = NULL,
422d0ff0
WS
306 int x = wxDefaultCoord,
307 int y = wxDefaultCoord,
ca65c044 308 bool centre = true,
d6c9c1b7 309 int width = wxCHOICE_WIDTH,
697f4a96
VZ
310 int height = wxCHOICE_HEIGHT,
311 int initialSelection = 0);
c801d85f 312
53a2db12 313WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
d6c9c1b7
VZ
314 const wxString& caption,
315 int n, const wxString *choices,
84498436 316 wxWindow *parent = NULL,
422d0ff0
WS
317 int x = wxDefaultCoord,
318 int y = wxDefaultCoord,
ca65c044 319 bool centre = true,
d6c9c1b7 320 int width = wxCHOICE_WIDTH,
697f4a96
VZ
321 int height = wxCHOICE_HEIGHT,
322 int initialSelection = 0);
323
324WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
325 const wxString& caption,
326 const wxArrayString& choices,
327 int initialSelection,
328 wxWindow *parent = NULL);
329
330WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
331 const wxString& caption,
332 int n, const wxString *choices,
333 int initialSelection,
334 wxWindow *parent = NULL);
c801d85f
KB
335
336// Same as above but gets position in list of strings, instead of string,
337// or -1 if no selection
53a2db12 338WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
d6c9c1b7
VZ
339 const wxString& caption,
340 const wxArrayString& choices,
84498436 341 wxWindow *parent = NULL,
422d0ff0
WS
342 int x = wxDefaultCoord,
343 int y = wxDefaultCoord,
ca65c044 344 bool centre = true,
d6c9c1b7 345 int width = wxCHOICE_WIDTH,
697f4a96
VZ
346 int height = wxCHOICE_HEIGHT,
347 int initialSelection = 0);
d6c9c1b7 348
53a2db12 349WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
d6c9c1b7
VZ
350 const wxString& caption,
351 int n, const wxString *choices,
84498436 352 wxWindow *parent = NULL,
422d0ff0
WS
353 int x = wxDefaultCoord,
354 int y = wxDefaultCoord,
ca65c044 355 bool centre = true,
d6c9c1b7 356 int width = wxCHOICE_WIDTH,
697f4a96
VZ
357 int height = wxCHOICE_HEIGHT,
358 int initialSelection = 0);
d6c9c1b7 359
697f4a96
VZ
360WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
361 const wxString& caption,
362 const wxArrayString& choices,
363 int initialSelection,
364 wxWindow *parent = NULL);
365
366WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
367 const wxString& caption,
368 int n, const wxString *choices,
369 int initialSelection,
370 wxWindow *parent = NULL);
371
372// Return client data instead or NULL if canceled
53a2db12 373WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
d6c9c1b7
VZ
374 const wxString& caption,
375 const wxArrayString& choices,
376 void **client_data,
84498436 377 wxWindow *parent = NULL,
422d0ff0
WS
378 int x = wxDefaultCoord,
379 int y = wxDefaultCoord,
ca65c044 380 bool centre = true,
d6c9c1b7 381 int width = wxCHOICE_WIDTH,
697f4a96
VZ
382 int height = wxCHOICE_HEIGHT,
383 int initialSelection = 0);
d6c9c1b7 384
53a2db12 385WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
d6c9c1b7
VZ
386 const wxString& caption,
387 int n, const wxString *choices,
388 void **client_data,
84498436 389 wxWindow *parent = NULL,
422d0ff0
WS
390 int x = wxDefaultCoord,
391 int y = wxDefaultCoord,
ca65c044 392 bool centre = true,
d6c9c1b7 393 int width = wxCHOICE_WIDTH,
697f4a96
VZ
394 int height = wxCHOICE_HEIGHT,
395 int initialSelection = 0);
396
397WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
398 const wxString& caption,
399 const wxArrayString& choices,
400 void **client_data,
401 int initialSelection,
402 wxWindow *parent = NULL);
403
404
405WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
406 const wxString& caption,
407 int n, const wxString *choices,
408 void **client_data,
409 int initialSelection,
410 wxWindow *parent = NULL);
d6c9c1b7
VZ
411
412// fill the array with the indices of the chosen items, it will be empty
413// if no items were selected or Cancel was pressed - return the number of
e5cfb314
VZ
414// selections or -1 if cancelled
415WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections,
d6c9c1b7
VZ
416 const wxString& message,
417 const wxString& caption,
418 int n, const wxString *choices,
84498436 419 wxWindow *parent = NULL,
422d0ff0
WS
420 int x = wxDefaultCoord,
421 int y = wxDefaultCoord,
ca65c044 422 bool centre = true,
d6c9c1b7
VZ
423 int width = wxCHOICE_WIDTH,
424 int height = wxCHOICE_HEIGHT);
425
e5cfb314 426WXDLLIMPEXP_CORE int wxGetSelectedChoices(wxArrayInt& selections,
d6c9c1b7
VZ
427 const wxString& message,
428 const wxString& caption,
429 const wxArrayString& choices,
84498436 430 wxWindow *parent = NULL,
422d0ff0
WS
431 int x = wxDefaultCoord,
432 int y = wxDefaultCoord,
ca65c044 433 bool centre = true,
d6c9c1b7
VZ
434 int width = wxCHOICE_WIDTH,
435 int height = wxCHOICE_HEIGHT);
436
e5cfb314
VZ
437#if WXWIN_COMPATIBILITY_2_8
438// fill the array with the indices of the chosen items, it will be empty
439// if no items were selected or Cancel was pressed - return the number of
440// selections
441wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
442 const wxString& message,
443 const wxString& caption,
444 int n, const wxString *choices,
445 wxWindow *parent = NULL,
446 int x = wxDefaultCoord,
447 int y = wxDefaultCoord,
448 bool centre = true,
449 int width = wxCHOICE_WIDTH,
450 int height = wxCHOICE_HEIGHT) );
451
452wxDEPRECATED( WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
453 const wxString& message,
454 const wxString& caption,
455 const wxArrayString& choices,
456 wxWindow *parent = NULL,
457 int x = wxDefaultCoord,
458 int y = wxDefaultCoord,
459 bool centre = true,
460 int width = wxCHOICE_WIDTH,
461 int height = wxCHOICE_HEIGHT));
462#endif // WXWIN_COMPATIBILITY_2_8
463
84498436 464#endif // _WX_GENERIC_CHOICDGG_H_