]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/choicdgg.h
Header change for smooth Aqua buttons in wxTreeCtrl.
[wxWidgets.git] / include / wx / generic / choicdgg.h
... / ...
CommitLineData
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#ifdef __GNUG__
16 #pragma interface "choicdgg.h"
17#endif
18
19#include "wx/dynarray.h"
20#include "wx/dialog.h"
21
22class 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
37class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
38{
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};
65
66// ----------------------------------------------------------------------------
67// wxSingleChoiceDialog: a dialog with single selection listbox
68// ----------------------------------------------------------------------------
69
70class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
71{
72public:
73 wxSingleChoiceDialog()
74 {
75 m_selection = -1;
76 }
77
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
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
108#if WXWIN_COMPATIBILITY_2
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,
120 const wxStringList& choices,
121 char **clientData = (char **)NULL,
122 long style = wxCHOICEDLG_STYLE,
123 const wxPoint& pos = wxDefaultPosition);
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 }
154
155 bool Create(wxWindow *parent,
156 const wxString& message,
157 const wxString& caption,
158 int n,
159 const wxString *choices,
160 long style = wxCHOICEDLG_STYLE,
161 const wxPoint& pos = wxDefaultPosition);
162
163 void SetSelections(const wxArrayInt& selections);
164 wxArrayInt GetSelections() const { return m_selections; }
165
166 // implementation from now on
167 virtual bool TransferDataFromWindow();
168
169protected:
170 wxArrayInt m_selections;
171
172private:
173 DECLARE_DYNAMIC_CLASS(wxMultiChoiceDialog)
174};
175
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);
190
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);
200
201// Same as above but gets position in list of strings, instead of string,
202// or -1 if no selection
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
274#if WXWIN_COMPATIBILITY_2
275
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
307#endif // WXWIN_COMPATIBILITY_2
308
309#endif // __CHOICEDLGH_G__
310