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