]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/choicdgg.h
fixed typo in wxString::swap() which was completely broken
[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
KB
6// Created: 01/02/97
7// RCS-ID: $Id$
d6c9c1b7 8// Copyright: (c) wxWindows team
c50f1fb9 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __CHOICEDLGH_G__
13#define __CHOICEDLGH_G__
14
15#ifdef __GNUG__
257bf510 16 #pragma interface "choicdgg.h"
c801d85f
KB
17#endif
18
d6c9c1b7 19#include "wx/dynarray.h"
c801d85f 20#include "wx/dialog.h"
8ee9d618
VZ
21
22class WXDLLEXPORT wxListBox;
c801d85f 23
d6c9c1b7
VZ
24// ----------------------------------------------------------------------------
25// some (ugly...) constants
26// ----------------------------------------------------------------------------
27
c801d85f
KB
28#define wxCHOICE_HEIGHT 150
29#define wxCHOICE_WIDTH 200
30
7ac080a1 31#define wxCHOICEDLG_STYLE (wxDEFAULT_DIALOG_STYLE|wxOK | wxCANCEL | wxCENTRE)
c801d85f 32
d6c9c1b7
VZ
33// ----------------------------------------------------------------------------
34// wxAnyChoiceDialog: a base class for dialogs containing a listbox
35// ----------------------------------------------------------------------------
36
37class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
c801d85f 38{
d6c9c1b7
VZ
39public:
40 wxAnyChoiceDialog() { }
41
42 wxAnyChoiceDialog(wxWindow *parent,
43 const wxString& message,
44 const wxString& caption,
45 int n, const wxString *choices,
46 long styleDlg = wxCHOICEDLG_STYLE,
47 const wxPoint& pos = wxDefaultPosition,
48 long styleLbox = wxLB_ALWAYS_SB)
49 {
50 (void)Create(parent, message, caption, n, choices,
51 styleDlg, pos, styleLbox);
52 }
53
54 bool Create(wxWindow *parent,
55 const wxString& message,
56 const wxString& caption,
57 int n, const wxString *choices,
58 long styleDlg = wxCHOICEDLG_STYLE,
59 const wxPoint& pos = wxDefaultPosition,
60 long styleLbox = wxLB_ALWAYS_SB);
61
62protected:
63 wxListBox *m_listbox;
64};
257bf510 65
d6c9c1b7
VZ
66// ----------------------------------------------------------------------------
67// wxSingleChoiceDialog: a dialog with single selection listbox
68// ----------------------------------------------------------------------------
69
70class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
71{
c801d85f 72public:
d6c9c1b7
VZ
73 wxSingleChoiceDialog()
74 {
75 m_selection = -1;
76 }
77
257bf510
VZ
78 wxSingleChoiceDialog(wxWindow *parent,
79 const wxString& message,
80 const wxString& caption,
81 int n,
82 const wxString *choices,
83 char **clientData = (char **)NULL,
84 long style = wxCHOICEDLG_STYLE,
85 const wxPoint& pos = wxDefaultPosition);
86
d6c9c1b7
VZ
87 bool Create(wxWindow *parent,
88 const wxString& message,
89 const wxString& caption,
90 int n,
91 const wxString *choices,
92 char **clientData = (char **)NULL,
93 long style = wxCHOICEDLG_STYLE,
94 const wxPoint& pos = wxDefaultPosition);
95
96 void SetSelection(int sel);
97 int GetSelection() const { return m_selection; }
98 wxString GetStringSelection() const { return m_stringSelection; }
99
100 // obsolete function (NB: no need to make it return wxChar, it's untyped)
101 char *GetSelectionClientData() const { return (char *)m_clientData; }
102
103 // implementation from now on
104 void OnOK(wxCommandEvent& event);
105 void OnListBoxDClick(wxCommandEvent& event);
106
107 // old, deprecated methods
1d79bd3e 108#if WXWIN_COMPATIBILITY_2
257bf510
VZ
109 wxSingleChoiceDialog(wxWindow *parent,
110 const wxString& message,
111 const wxString& caption,
112 const wxStringList& choices,
113 char **clientData = (char **)NULL,
114 long style = wxCHOICEDLG_STYLE,
115 const wxPoint& pos = wxDefaultPosition);
116
117 bool Create(wxWindow *parent,
118 const wxString& message,
119 const wxString& caption,
d6c9c1b7 120 const wxStringList& choices,
257bf510
VZ
121 char **clientData = (char **)NULL,
122 long style = wxCHOICEDLG_STYLE,
123 const wxPoint& pos = wxDefaultPosition);
d6c9c1b7
VZ
124#endif // WXWIN_COMPATIBILITY_2
125
126protected:
127 int m_selection;
128 wxString m_stringSelection;
129
130private:
131 DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog)
132 DECLARE_EVENT_TABLE()
133};
134
135// ----------------------------------------------------------------------------
136// wxMultiChoiceDialog: a dialog with multi selection listbox
137// ----------------------------------------------------------------------------
138
139class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
140{
141public:
142 wxMultiChoiceDialog() { }
143
144 wxMultiChoiceDialog(wxWindow *parent,
145 const wxString& message,
146 const wxString& caption,
147 int n,
148 const wxString *choices,
149 long style = wxCHOICEDLG_STYLE,
150 const wxPoint& pos = wxDefaultPosition)
151 {
152 (void)Create(parent, message, caption, n, choices, style, pos);
153 }
257bf510
VZ
154
155 bool Create(wxWindow *parent,
156 const wxString& message,
157 const wxString& caption,
d6c9c1b7
VZ
158 int n,
159 const wxString *choices,
257bf510
VZ
160 long style = wxCHOICEDLG_STYLE,
161 const wxPoint& pos = wxDefaultPosition);
c801d85f 162
d6c9c1b7
VZ
163 void SetSelections(const wxArrayInt& selections);
164 wxArrayInt GetSelections() const { return m_selections; }
c801d85f 165
257bf510 166 // implementation from now on
3d49ce44 167 virtual bool TransferDataFromWindow();
c801d85f 168
c801d85f 169protected:
d6c9c1b7 170 wxArrayInt m_selections;
257bf510
VZ
171
172private:
d6c9c1b7 173 DECLARE_DYNAMIC_CLASS(wxMultiChoiceDialog)
c801d85f
KB
174};
175
d6c9c1b7
VZ
176// ----------------------------------------------------------------------------
177// wrapper functions which can be used to get selection(s) from the user
178// ----------------------------------------------------------------------------
179
180// get the user selection as a string
181WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
182 const wxString& caption,
183 const wxArrayString& choices,
184 wxWindow *parent = (wxWindow *) NULL,
185 int x = -1,
186 int y = -1,
187 bool centre = TRUE,
188 int width = wxCHOICE_WIDTH,
189 int height = wxCHOICE_HEIGHT);
c801d85f 190
d6c9c1b7
VZ
191WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
192 const wxString& caption,
193 int n, const wxString *choices,
194 wxWindow *parent = (wxWindow *) NULL,
195 int x = -1,
196 int y = -1,
197 bool centre = TRUE,
198 int width = wxCHOICE_WIDTH,
199 int height = wxCHOICE_HEIGHT);
c801d85f
KB
200
201// Same as above but gets position in list of strings, instead of string,
202// or -1 if no selection
d6c9c1b7
VZ
203WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
204 const wxString& caption,
205 const wxArrayString& choices,
206 wxWindow *parent = (wxWindow *) NULL,
207 int x = -1,
208 int y = -1,
209 bool centre = TRUE,
210 int width = wxCHOICE_WIDTH,
211 int height = wxCHOICE_HEIGHT);
212
213WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
214 const wxString& caption,
215 int n, const wxString *choices,
216 wxWindow *parent = (wxWindow *) NULL,
217 int x = -1,
218 int y = -1,
219 bool centre = TRUE,
220 int width = wxCHOICE_WIDTH,
221 int height = wxCHOICE_HEIGHT);
222
223// Return client data instead or NULL if cancelled
224WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
225 const wxString& caption,
226 const wxArrayString& choices,
227 void **client_data,
228 wxWindow *parent = (wxWindow *) NULL,
229 int x = -1, int y = -1,
230 bool centre = TRUE,
231 int width = wxCHOICE_WIDTH,
232 int height = wxCHOICE_HEIGHT);
233
234WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
235 const wxString& caption,
236 int n, const wxString *choices,
237 void **client_data,
238 wxWindow *parent = (wxWindow *) NULL,
239 int x = -1, int y = -1,
240 bool centre = TRUE,
241 int width = wxCHOICE_WIDTH,
242 int height = wxCHOICE_HEIGHT);
243
244// fill the array with the indices of the chosen items, it will be empty
245// if no items were selected or Cancel was pressed - return the number of
246// selections
247WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
248 const wxString& message,
249 const wxString& caption,
250 int n, const wxString *choices,
251 wxWindow *parent = (wxWindow *) NULL,
252 int x = -1,
253 int y = -1,
254 bool centre = TRUE,
255 int width = wxCHOICE_WIDTH,
256 int height = wxCHOICE_HEIGHT);
257
258WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
259 const wxString& message,
260 const wxString& caption,
261 const wxArrayString& choices,
262 wxWindow *parent = (wxWindow *) NULL,
263 int x = -1,
264 int y = -1,
265 bool centre = TRUE,
266 int width = wxCHOICE_WIDTH,
267 int height = wxCHOICE_HEIGHT);
268
269// ----------------------------------------------------------------------------
270// these methods are for backwards compatibility only, not documented and
271// deprecated
272// ----------------------------------------------------------------------------
273
1d79bd3e 274#if WXWIN_COMPATIBILITY_2
96bcf4f9 275
d6c9c1b7
VZ
276WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
277 const wxString& caption,
278 int n, wxChar *choices[],
279 wxWindow *parent = (wxWindow *) NULL,
280 int x = -1,
281 int y = -1,
282 bool centre = TRUE,
283 int width = wxCHOICE_WIDTH,
284 int height = wxCHOICE_HEIGHT);
285
286WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
287 const wxString& caption,
288 int n, wxChar *choices[],
289 wxWindow *parent = (wxWindow *) NULL,
290 int x = -1,
291 int y = -1,
292 bool centre = TRUE,
293 int width = wxCHOICE_WIDTH,
294 int height = wxCHOICE_HEIGHT);
295
296WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
297 const wxString& caption,
298 int n, wxChar **choices,
299 void **client_data,
300 wxWindow *parent = (wxWindow *) NULL,
301 int x = -1, int y = -1,
302 bool centre = TRUE,
303 int width = wxCHOICE_WIDTH,
304 int height = wxCHOICE_HEIGHT);
305
306
96bcf4f9
VZ
307#endif // WXWIN_COMPATIBILITY_2
308
d6c9c1b7 309#endif // __CHOICEDLGH_G__
c801d85f 310