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