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