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
7
// RCS-ID: $Id: choicdgg.h,v 1.34 2005/04/02 21:39:53 JS Exp $
8
// Copyright: (c) wxWidgets team
9
// Licence: wxWindows licence
10
/////////////////////////////////////////////////////////////////////////////
12
#ifndef __CHOICEDLGH_G__
13
#define __CHOICEDLGH_G__
15
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16
#pragma interface "choicdgg.h"
19
#include "wx/dynarray.h"
20
#include "wx/dialog.h"
22
class WXDLLEXPORT wxListBox;
24
// ----------------------------------------------------------------------------
25
// some (ugly...) constants
26
// ----------------------------------------------------------------------------
28
#define wxCHOICE_HEIGHT 150
29
#define wxCHOICE_WIDTH 200
32
#define wxCHOICEDLG_STYLE \
33
(wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE)
35
#define wxCHOICEDLG_STYLE \
36
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
39
// ----------------------------------------------------------------------------
40
// wxAnyChoiceDialog: a base class for dialogs containing a listbox
41
// ----------------------------------------------------------------------------
43
class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
46
wxAnyChoiceDialog() { }
48
wxAnyChoiceDialog(wxWindow *parent,
49
const wxString& message,
50
const wxString& caption,
51
int n, const wxString *choices,
52
long styleDlg = wxCHOICEDLG_STYLE,
53
const wxPoint& pos = wxDefaultPosition,
54
long styleLbox = wxLB_ALWAYS_SB)
56
(void)Create(parent, message, caption, n, choices,
57
styleDlg, pos, styleLbox);
59
wxAnyChoiceDialog(wxWindow *parent,
60
const wxString& message,
61
const wxString& caption,
62
const wxArrayString& choices,
63
long styleDlg = wxCHOICEDLG_STYLE,
64
const wxPoint& pos = wxDefaultPosition,
65
long styleLbox = wxLB_ALWAYS_SB)
67
(void)Create(parent, message, caption, choices,
68
styleDlg, pos, styleLbox);
71
bool Create(wxWindow *parent,
72
const wxString& message,
73
const wxString& caption,
74
int n, const wxString *choices,
75
long styleDlg = wxCHOICEDLG_STYLE,
76
const wxPoint& pos = wxDefaultPosition,
77
long styleLbox = wxLB_ALWAYS_SB);
78
bool Create(wxWindow *parent,
79
const wxString& message,
80
const wxString& caption,
81
const wxArrayString& choices,
82
long styleDlg = wxCHOICEDLG_STYLE,
83
const wxPoint& pos = wxDefaultPosition,
84
long styleLbox = wxLB_ALWAYS_SB);
89
DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
92
// ----------------------------------------------------------------------------
93
// wxSingleChoiceDialog: a dialog with single selection listbox
94
// ----------------------------------------------------------------------------
96
class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
99
wxSingleChoiceDialog()
104
wxSingleChoiceDialog(wxWindow *parent,
105
const wxString& message,
106
const wxString& caption,
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);
120
bool Create(wxWindow *parent,
121
const wxString& message,
122
const wxString& caption,
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);
136
void SetSelection(int sel);
137
int GetSelection() const { return m_selection; }
138
wxString GetStringSelection() const { return m_stringSelection; }
140
// obsolete function (NB: no need to make it return wxChar, it's untyped)
141
char *GetSelectionClientData() const { return (char *)m_clientData; }
143
// implementation from now on
144
void OnOK(wxCommandEvent& event);
145
void OnListBoxDClick(wxCommandEvent& event);
149
wxString m_stringSelection;
152
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
153
DECLARE_EVENT_TABLE()
156
// ----------------------------------------------------------------------------
157
// wxMultiChoiceDialog: a dialog with multi selection listbox
158
// ----------------------------------------------------------------------------
160
class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
163
wxMultiChoiceDialog() { }
165
wxMultiChoiceDialog(wxWindow *parent,
166
const wxString& message,
167
const wxString& caption,
169
const wxString *choices,
170
long style = wxCHOICEDLG_STYLE,
171
const wxPoint& pos = wxDefaultPosition)
173
(void)Create(parent, message, caption, n, choices, style, pos);
175
wxMultiChoiceDialog(wxWindow *parent,
176
const wxString& message,
177
const wxString& caption,
178
const wxArrayString& choices,
179
long style = wxCHOICEDLG_STYLE,
180
const wxPoint& pos = wxDefaultPosition)
182
(void)Create(parent, message, caption, choices, style, pos);
185
bool Create(wxWindow *parent,
186
const wxString& message,
187
const wxString& caption,
189
const wxString *choices,
190
long style = wxCHOICEDLG_STYLE,
191
const wxPoint& pos = wxDefaultPosition);
192
bool Create(wxWindow *parent,
193
const wxString& message,
194
const wxString& caption,
195
const wxArrayString& choices,
196
long style = wxCHOICEDLG_STYLE,
197
const wxPoint& pos = wxDefaultPosition);
199
void SetSelections(const wxArrayInt& selections);
200
wxArrayInt GetSelections() const { return m_selections; }
202
// implementation from now on
203
virtual bool TransferDataFromWindow();
206
wxArrayInt m_selections;
209
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
212
// ----------------------------------------------------------------------------
213
// wrapper functions which can be used to get selection(s) from the user
214
// ----------------------------------------------------------------------------
216
// get the user selection as a string
217
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
218
const wxString& caption,
219
const wxArrayString& choices,
220
wxWindow *parent = (wxWindow *) NULL,
221
int x = wxDefaultCoord,
222
int y = wxDefaultCoord,
224
int width = wxCHOICE_WIDTH,
225
int height = wxCHOICE_HEIGHT);
227
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
228
const wxString& caption,
229
int n, const wxString *choices,
230
wxWindow *parent = (wxWindow *) NULL,
231
int x = wxDefaultCoord,
232
int y = wxDefaultCoord,
234
int width = wxCHOICE_WIDTH,
235
int height = wxCHOICE_HEIGHT);
237
// Same as above but gets position in list of strings, instead of string,
238
// or -1 if no selection
239
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
240
const wxString& caption,
241
const wxArrayString& choices,
242
wxWindow *parent = (wxWindow *) NULL,
243
int x = wxDefaultCoord,
244
int y = wxDefaultCoord,
246
int width = wxCHOICE_WIDTH,
247
int height = wxCHOICE_HEIGHT);
249
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
250
const wxString& caption,
251
int n, const wxString *choices,
252
wxWindow *parent = (wxWindow *) NULL,
253
int x = wxDefaultCoord,
254
int y = wxDefaultCoord,
256
int width = wxCHOICE_WIDTH,
257
int height = wxCHOICE_HEIGHT);
259
// Return client data instead or NULL if cancelled
260
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
261
const wxString& caption,
262
const wxArrayString& choices,
264
wxWindow *parent = (wxWindow *) NULL,
265
int x = wxDefaultCoord,
266
int y = wxDefaultCoord,
268
int width = wxCHOICE_WIDTH,
269
int height = wxCHOICE_HEIGHT);
271
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
272
const wxString& caption,
273
int n, const wxString *choices,
275
wxWindow *parent = (wxWindow *) NULL,
276
int x = wxDefaultCoord,
277
int y = wxDefaultCoord,
279
int width = wxCHOICE_WIDTH,
280
int height = wxCHOICE_HEIGHT);
282
// fill the array with the indices of the chosen items, it will be empty
283
// if no items were selected or Cancel was pressed - return the number of
285
WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
286
const wxString& message,
287
const wxString& caption,
288
int n, const wxString *choices,
289
wxWindow *parent = (wxWindow *) NULL,
290
int x = wxDefaultCoord,
291
int y = wxDefaultCoord,
293
int width = wxCHOICE_WIDTH,
294
int height = wxCHOICE_HEIGHT);
296
WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
297
const wxString& message,
298
const wxString& caption,
299
const wxArrayString& choices,
300
wxWindow *parent = (wxWindow *) NULL,
301
int x = wxDefaultCoord,
302
int y = wxDefaultCoord,
304
int width = wxCHOICE_WIDTH,
305
int height = wxCHOICE_HEIGHT);
307
#endif // __CHOICEDLGH_G__