]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/choicdgg.h
Minor corrections to make dist after reports
[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$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
84498436
VZ
12#ifndef _WX_GENERIC_CHOICDGG_H_
13#define _WX_GENERIC_CHOICDGG_H_
c801d85f 14
d6c9c1b7 15#include "wx/dynarray.h"
c801d85f 16#include "wx/dialog.h"
8ee9d618 17
b5dbe15d 18class WXDLLIMPEXP_FWD_CORE wxListBoxBase;
c801d85f 19
d6c9c1b7
VZ
20// ----------------------------------------------------------------------------
21// some (ugly...) constants
22// ----------------------------------------------------------------------------
23
c801d85f
KB
24#define wxCHOICE_HEIGHT 150
25#define wxCHOICE_WIDTH 200
26
259a6e38
JS
27#ifdef __WXWINCE__
28#define wxCHOICEDLG_STYLE \
29 (wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE)
30#else
abd9b10e
VZ
31#define wxCHOICEDLG_STYLE \
32 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
259a6e38 33#endif
c801d85f 34
d6c9c1b7
VZ
35// ----------------------------------------------------------------------------
36// wxAnyChoiceDialog: a base class for dialogs containing a listbox
37// ----------------------------------------------------------------------------
38
53a2db12 39class WXDLLIMPEXP_CORE wxAnyChoiceDialog : public wxDialog
c801d85f 40{
d6c9c1b7 41public:
6463b9f5 42 wxAnyChoiceDialog() { }
d6c9c1b7
VZ
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,
6463b9f5
JS
50 long styleLbox = wxLB_ALWAYS_SB)
51 {
52 (void)Create(parent, message, caption, n, choices,
53 styleDlg, pos, styleLbox);
54 }
584ad2a3
MB
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 }
d6c9c1b7
VZ
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);
584ad2a3
MB
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);
d6c9c1b7
VZ
81
82protected:
60104cba
WS
83 wxListBoxBase *m_listbox;
84
85 virtual wxListBoxBase *CreateList(int n,
86 const wxString *choices,
87 long styleLbox);
22f3361e
VZ
88
89 DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
d6c9c1b7 90};
257bf510 91
d6c9c1b7
VZ
92// ----------------------------------------------------------------------------
93// wxSingleChoiceDialog: a dialog with single selection listbox
94// ----------------------------------------------------------------------------
95
53a2db12 96class WXDLLIMPEXP_CORE wxSingleChoiceDialog : public wxAnyChoiceDialog
d6c9c1b7 97{
c801d85f 98public:
6463b9f5
JS
99 wxSingleChoiceDialog()
100 {
101 m_selection = -1;
102 }
d6c9c1b7 103
257bf510
VZ
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);
584ad2a3
MB
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);
257bf510 119
d6c9c1b7
VZ
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);
584ad2a3
MB
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);
d6c9c1b7
VZ
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);
7b504551 145#ifndef __SMARTPHONE__
d6c9c1b7 146 void OnListBoxDClick(wxCommandEvent& event);
7b504551
WS
147#endif
148#ifdef __WXWINCE__
149 void OnJoystickButtonDown(wxJoystickEvent& event);
150#endif
d6c9c1b7 151
d6c9c1b7
VZ
152protected:
153 int m_selection;
154 wxString m_stringSelection;
155
7b504551
WS
156 void DoChoice();
157
d6c9c1b7 158private:
fc7a2a60 159 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
d6c9c1b7
VZ
160 DECLARE_EVENT_TABLE()
161};
162
163// ----------------------------------------------------------------------------
164// wxMultiChoiceDialog: a dialog with multi selection listbox
165// ----------------------------------------------------------------------------
166
53a2db12 167class WXDLLIMPEXP_CORE wxMultiChoiceDialog : public wxAnyChoiceDialog
d6c9c1b7
VZ
168{
169public:
6463b9f5 170 wxMultiChoiceDialog() { }
d6c9c1b7
VZ
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,
6463b9f5
JS
178 const wxPoint& pos = wxDefaultPosition)
179 {
180 (void)Create(parent, message, caption, n, choices, style, pos);
181 }
584ad2a3
MB
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 }
257bf510
VZ
191
192 bool Create(wxWindow *parent,
193 const wxString& message,
194 const wxString& caption,
d6c9c1b7
VZ
195 int n,
196 const wxString *choices,
257bf510
VZ
197 long style = wxCHOICEDLG_STYLE,
198 const wxPoint& pos = wxDefaultPosition);
584ad2a3
MB
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);
c801d85f 205
d6c9c1b7
VZ
206 void SetSelections(const wxArrayInt& selections);
207 wxArrayInt GetSelections() const { return m_selections; }
c801d85f 208
257bf510 209 // implementation from now on
3d49ce44 210 virtual bool TransferDataFromWindow();
c801d85f 211
c801d85f 212protected:
60104cba
WS
213#if wxUSE_CHECKLISTBOX
214 virtual wxListBoxBase *CreateList(int n,
215 const wxString *choices,
216 long styleLbox);
217#endif // wxUSE_CHECKLISTBOX
218
d6c9c1b7 219 wxArrayInt m_selections;
257bf510
VZ
220
221private:
fc7a2a60 222 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
c801d85f
KB
223};
224
d6c9c1b7
VZ
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
53a2db12 230WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
d6c9c1b7
VZ
231 const wxString& caption,
232 const wxArrayString& choices,
84498436 233 wxWindow *parent = NULL,
422d0ff0
WS
234 int x = wxDefaultCoord,
235 int y = wxDefaultCoord,
ca65c044 236 bool centre = true,
d6c9c1b7
VZ
237 int width = wxCHOICE_WIDTH,
238 int height = wxCHOICE_HEIGHT);
c801d85f 239
53a2db12 240WXDLLIMPEXP_CORE wxString wxGetSingleChoice(const wxString& message,
d6c9c1b7
VZ
241 const wxString& caption,
242 int n, const wxString *choices,
84498436 243 wxWindow *parent = NULL,
422d0ff0
WS
244 int x = wxDefaultCoord,
245 int y = wxDefaultCoord,
ca65c044 246 bool centre = true,
d6c9c1b7
VZ
247 int width = wxCHOICE_WIDTH,
248 int height = wxCHOICE_HEIGHT);
c801d85f
KB
249
250// Same as above but gets position in list of strings, instead of string,
251// or -1 if no selection
53a2db12 252WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
d6c9c1b7
VZ
253 const wxString& caption,
254 const wxArrayString& choices,
84498436 255 wxWindow *parent = NULL,
422d0ff0
WS
256 int x = wxDefaultCoord,
257 int y = wxDefaultCoord,
ca65c044 258 bool centre = true,
d6c9c1b7
VZ
259 int width = wxCHOICE_WIDTH,
260 int height = wxCHOICE_HEIGHT);
261
53a2db12 262WXDLLIMPEXP_CORE int wxGetSingleChoiceIndex(const wxString& message,
d6c9c1b7
VZ
263 const wxString& caption,
264 int n, const wxString *choices,
84498436 265 wxWindow *parent = NULL,
422d0ff0
WS
266 int x = wxDefaultCoord,
267 int y = wxDefaultCoord,
ca65c044 268 bool centre = true,
d6c9c1b7
VZ
269 int width = wxCHOICE_WIDTH,
270 int height = wxCHOICE_HEIGHT);
271
272// Return client data instead or NULL if cancelled
53a2db12 273WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
d6c9c1b7
VZ
274 const wxString& caption,
275 const wxArrayString& choices,
276 void **client_data,
84498436 277 wxWindow *parent = NULL,
422d0ff0
WS
278 int x = wxDefaultCoord,
279 int y = wxDefaultCoord,
ca65c044 280 bool centre = true,
d6c9c1b7
VZ
281 int width = wxCHOICE_WIDTH,
282 int height = wxCHOICE_HEIGHT);
283
53a2db12 284WXDLLIMPEXP_CORE void* wxGetSingleChoiceData(const wxString& message,
d6c9c1b7
VZ
285 const wxString& caption,
286 int n, const wxString *choices,
287 void **client_data,
84498436 288 wxWindow *parent = NULL,
422d0ff0
WS
289 int x = wxDefaultCoord,
290 int y = wxDefaultCoord,
ca65c044 291 bool centre = true,
d6c9c1b7
VZ
292 int width = wxCHOICE_WIDTH,
293 int height = wxCHOICE_HEIGHT);
294
295// fill the array with the indices of the chosen items, it will be empty
296// if no items were selected or Cancel was pressed - return the number of
297// selections
53a2db12 298WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
d6c9c1b7
VZ
299 const wxString& message,
300 const wxString& caption,
301 int n, const wxString *choices,
84498436 302 wxWindow *parent = NULL,
422d0ff0
WS
303 int x = wxDefaultCoord,
304 int y = wxDefaultCoord,
ca65c044 305 bool centre = true,
d6c9c1b7
VZ
306 int width = wxCHOICE_WIDTH,
307 int height = wxCHOICE_HEIGHT);
308
53a2db12 309WXDLLIMPEXP_CORE size_t wxGetMultipleChoices(wxArrayInt& selections,
d6c9c1b7
VZ
310 const wxString& message,
311 const wxString& caption,
312 const wxArrayString& choices,
84498436 313 wxWindow *parent = NULL,
422d0ff0
WS
314 int x = wxDefaultCoord,
315 int y = wxDefaultCoord,
ca65c044 316 bool centre = true,
d6c9c1b7
VZ
317 int width = wxCHOICE_WIDTH,
318 int height = wxCHOICE_HEIGHT);
319
84498436 320#endif // _WX_GENERIC_CHOICDGG_H_