]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/choicdgg.h
Applied patch [ 858324 ] Calling EndModal inside an EVT_INIT_DIALOG event handler
[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#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
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 \
32 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
33
34// ----------------------------------------------------------------------------
35// wxAnyChoiceDialog: a base class for dialogs containing a listbox
36// ----------------------------------------------------------------------------
37
38class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
39{
40public:
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 bool Create(wxWindow *parent,
52 const wxString& message,
53 const wxString& caption,
54 int n, const wxString *choices,
55 long styleDlg = wxCHOICEDLG_STYLE,
56 const wxPoint& pos = wxDefaultPosition,
57 long styleLbox = wxLB_ALWAYS_SB);
58
59protected:
60 wxListBox *m_listbox;
61
62 DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
63};
64
65// ----------------------------------------------------------------------------
66// wxSingleChoiceDialog: a dialog with single selection listbox
67// ----------------------------------------------------------------------------
68
69class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
70{
71public:
72 wxSingleChoiceDialog();
73
74 wxSingleChoiceDialog(wxWindow *parent,
75 const wxString& message,
76 const wxString& caption,
77 int n,
78 const wxString *choices,
79 char **clientData = (char **)NULL,
80 long style = wxCHOICEDLG_STYLE,
81 const wxPoint& pos = wxDefaultPosition);
82
83 bool Create(wxWindow *parent,
84 const wxString& message,
85 const wxString& caption,
86 int n,
87 const wxString *choices,
88 char **clientData = (char **)NULL,
89 long style = wxCHOICEDLG_STYLE,
90 const wxPoint& pos = wxDefaultPosition);
91
92 void SetSelection(int sel);
93 int GetSelection() const { return m_selection; }
94 wxString GetStringSelection() const { return m_stringSelection; }
95
96 // obsolete function (NB: no need to make it return wxChar, it's untyped)
97 char *GetSelectionClientData() const { return (char *)m_clientData; }
98
99 // implementation from now on
100 void OnOK(wxCommandEvent& event);
101 void OnListBoxDClick(wxCommandEvent& event);
102
103protected:
104 int m_selection;
105 wxString m_stringSelection;
106
107private:
108 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
109 DECLARE_EVENT_TABLE()
110};
111
112// ----------------------------------------------------------------------------
113// wxMultiChoiceDialog: a dialog with multi selection listbox
114// ----------------------------------------------------------------------------
115
116class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
117{
118public:
119 wxMultiChoiceDialog();
120
121 wxMultiChoiceDialog(wxWindow *parent,
122 const wxString& message,
123 const wxString& caption,
124 int n,
125 const wxString *choices,
126 long style = wxCHOICEDLG_STYLE,
127 const wxPoint& pos = wxDefaultPosition);
128
129 bool Create(wxWindow *parent,
130 const wxString& message,
131 const wxString& caption,
132 int n,
133 const wxString *choices,
134 long style = wxCHOICEDLG_STYLE,
135 const wxPoint& pos = wxDefaultPosition);
136
137 void SetSelections(const wxArrayInt& selections);
138 wxArrayInt GetSelections() const { return m_selections; }
139
140 // implementation from now on
141 virtual bool TransferDataFromWindow();
142
143protected:
144 wxArrayInt m_selections;
145
146private:
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
148};
149
150// ----------------------------------------------------------------------------
151// wrapper functions which can be used to get selection(s) from the user
152// ----------------------------------------------------------------------------
153
154// get the user selection as a string
155WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
156 const wxString& caption,
157 const wxArrayString& choices,
158 wxWindow *parent = (wxWindow *) NULL,
159 int x = -1,
160 int y = -1,
161 bool centre = TRUE,
162 int width = wxCHOICE_WIDTH,
163 int height = wxCHOICE_HEIGHT);
164
165WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
166 const wxString& caption,
167 int n, const wxString *choices,
168 wxWindow *parent = (wxWindow *) NULL,
169 int x = -1,
170 int y = -1,
171 bool centre = TRUE,
172 int width = wxCHOICE_WIDTH,
173 int height = wxCHOICE_HEIGHT);
174
175// Same as above but gets position in list of strings, instead of string,
176// or -1 if no selection
177WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
178 const wxString& caption,
179 const wxArrayString& choices,
180 wxWindow *parent = (wxWindow *) NULL,
181 int x = -1,
182 int y = -1,
183 bool centre = TRUE,
184 int width = wxCHOICE_WIDTH,
185 int height = wxCHOICE_HEIGHT);
186
187WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
188 const wxString& caption,
189 int n, const wxString *choices,
190 wxWindow *parent = (wxWindow *) NULL,
191 int x = -1,
192 int y = -1,
193 bool centre = TRUE,
194 int width = wxCHOICE_WIDTH,
195 int height = wxCHOICE_HEIGHT);
196
197// Return client data instead or NULL if cancelled
198WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
199 const wxString& caption,
200 const wxArrayString& choices,
201 void **client_data,
202 wxWindow *parent = (wxWindow *) NULL,
203 int x = -1, int y = -1,
204 bool centre = TRUE,
205 int width = wxCHOICE_WIDTH,
206 int height = wxCHOICE_HEIGHT);
207
208WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
209 const wxString& caption,
210 int n, const wxString *choices,
211 void **client_data,
212 wxWindow *parent = (wxWindow *) NULL,
213 int x = -1, int y = -1,
214 bool centre = TRUE,
215 int width = wxCHOICE_WIDTH,
216 int height = wxCHOICE_HEIGHT);
217
218// fill the array with the indices of the chosen items, it will be empty
219// if no items were selected or Cancel was pressed - return the number of
220// selections
221WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
222 const wxString& message,
223 const wxString& caption,
224 int n, const wxString *choices,
225 wxWindow *parent = (wxWindow *) NULL,
226 int x = -1,
227 int y = -1,
228 bool centre = TRUE,
229 int width = wxCHOICE_WIDTH,
230 int height = wxCHOICE_HEIGHT);
231
232WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
233 const wxString& message,
234 const wxString& caption,
235 const wxArrayString& choices,
236 wxWindow *parent = (wxWindow *) NULL,
237 int x = -1,
238 int y = -1,
239 bool centre = TRUE,
240 int width = wxCHOICE_WIDTH,
241 int height = wxCHOICE_HEIGHT);
242
243#endif // __CHOICEDLGH_G__
244