]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/choicdgg.h
added wxDynamicLibrary::GetSymbolAorW()
[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) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __CHOICEDLGH_G__
13 #define __CHOICEDLGH_G__
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 #ifdef __WXWINCE__
32 #define wxCHOICEDLG_STYLE \
33 (wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE)
34 #else
35 #define wxCHOICEDLG_STYLE \
36 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
37 #endif
38
39 // ----------------------------------------------------------------------------
40 // wxAnyChoiceDialog: a base class for dialogs containing a listbox
41 // ----------------------------------------------------------------------------
42
43 class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
44 {
45 public:
46 wxAnyChoiceDialog() { }
47
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)
55 {
56 (void)Create(parent, message, caption, n, choices,
57 styleDlg, pos, styleLbox);
58 }
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)
66 {
67 (void)Create(parent, message, caption, choices,
68 styleDlg, pos, styleLbox);
69 }
70
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);
85
86 protected:
87 wxListBox *m_listbox;
88
89 DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
90 };
91
92 // ----------------------------------------------------------------------------
93 // wxSingleChoiceDialog: a dialog with single selection listbox
94 // ----------------------------------------------------------------------------
95
96 class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
97 {
98 public:
99 wxSingleChoiceDialog()
100 {
101 m_selection = -1;
102 }
103
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);
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);
119
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);
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);
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);
145 void OnListBoxDClick(wxCommandEvent& event);
146
147 protected:
148 int m_selection;
149 wxString m_stringSelection;
150
151 private:
152 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
153 DECLARE_EVENT_TABLE()
154 };
155
156 // ----------------------------------------------------------------------------
157 // wxMultiChoiceDialog: a dialog with multi selection listbox
158 // ----------------------------------------------------------------------------
159
160 class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
161 {
162 public:
163 wxMultiChoiceDialog() { }
164
165 wxMultiChoiceDialog(wxWindow *parent,
166 const wxString& message,
167 const wxString& caption,
168 int n,
169 const wxString *choices,
170 long style = wxCHOICEDLG_STYLE,
171 const wxPoint& pos = wxDefaultPosition)
172 {
173 (void)Create(parent, message, caption, n, choices, style, pos);
174 }
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)
181 {
182 (void)Create(parent, message, caption, choices, style, pos);
183 }
184
185 bool Create(wxWindow *parent,
186 const wxString& message,
187 const wxString& caption,
188 int n,
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);
198
199 void SetSelections(const wxArrayInt& selections);
200 wxArrayInt GetSelections() const { return m_selections; }
201
202 // implementation from now on
203 virtual bool TransferDataFromWindow();
204
205 protected:
206 wxArrayInt m_selections;
207
208 private:
209 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
210 };
211
212 // ----------------------------------------------------------------------------
213 // wrapper functions which can be used to get selection(s) from the user
214 // ----------------------------------------------------------------------------
215
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,
223 bool centre = true,
224 int width = wxCHOICE_WIDTH,
225 int height = wxCHOICE_HEIGHT);
226
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,
233 bool centre = true,
234 int width = wxCHOICE_WIDTH,
235 int height = wxCHOICE_HEIGHT);
236
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,
245 bool centre = true,
246 int width = wxCHOICE_WIDTH,
247 int height = wxCHOICE_HEIGHT);
248
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,
255 bool centre = true,
256 int width = wxCHOICE_WIDTH,
257 int height = wxCHOICE_HEIGHT);
258
259 // Return client data instead or NULL if cancelled
260 WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
261 const wxString& caption,
262 const wxArrayString& choices,
263 void **client_data,
264 wxWindow *parent = (wxWindow *) NULL,
265 int x = wxDefaultCoord,
266 int y = wxDefaultCoord,
267 bool centre = true,
268 int width = wxCHOICE_WIDTH,
269 int height = wxCHOICE_HEIGHT);
270
271 WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
272 const wxString& caption,
273 int n, const wxString *choices,
274 void **client_data,
275 wxWindow *parent = (wxWindow *) NULL,
276 int x = wxDefaultCoord,
277 int y = wxDefaultCoord,
278 bool centre = true,
279 int width = wxCHOICE_WIDTH,
280 int height = wxCHOICE_HEIGHT);
281
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
284 // selections
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,
292 bool centre = true,
293 int width = wxCHOICE_WIDTH,
294 int height = wxCHOICE_HEIGHT);
295
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,
303 bool centre = true,
304 int width = wxCHOICE_WIDTH,
305 int height = wxCHOICE_HEIGHT);
306
307 #endif // __CHOICEDLGH_G__
308