]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
d6c9c1b7 | 2 | // Name: wx/generic/choicdgg.h |
c801d85f KB |
3 | // Purpose: Generic choice dialogs |
4 | // Author: Julian Smart | |
d6c9c1b7 | 5 | // Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions |
c801d85f KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
d6c9c1b7 | 8 | // Copyright: (c) wxWindows team |
c50f1fb9 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef __CHOICEDLGH_G__ | |
13 | #define __CHOICEDLGH_G__ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
257bf510 | 16 | #pragma interface "choicdgg.h" |
c801d85f KB |
17 | #endif |
18 | ||
d6c9c1b7 | 19 | #include "wx/dynarray.h" |
c801d85f | 20 | #include "wx/dialog.h" |
8ee9d618 VZ |
21 | |
22 | class WXDLLEXPORT wxListBox; | |
c801d85f | 23 | |
d6c9c1b7 VZ |
24 | // ---------------------------------------------------------------------------- |
25 | // some (ugly...) constants | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
c801d85f KB |
28 | #define wxCHOICE_HEIGHT 150 |
29 | #define wxCHOICE_WIDTH 200 | |
30 | ||
abd9b10e VZ |
31 | #define wxCHOICEDLG_STYLE \ |
32 | (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE) | |
c801d85f | 33 | |
d6c9c1b7 VZ |
34 | // ---------------------------------------------------------------------------- |
35 | // wxAnyChoiceDialog: a base class for dialogs containing a listbox | |
36 | // ---------------------------------------------------------------------------- | |
37 | ||
38 | class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog | |
c801d85f | 39 | { |
d6c9c1b7 | 40 | public: |
1169a919 | 41 | wxAnyChoiceDialog(); |
d6c9c1b7 VZ |
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, | |
1169a919 | 49 | long styleLbox = wxLB_ALWAYS_SB); |
d6c9c1b7 VZ |
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 | ||
59 | protected: | |
60 | wxListBox *m_listbox; | |
22f3361e VZ |
61 | |
62 | DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog) | |
d6c9c1b7 | 63 | }; |
257bf510 | 64 | |
d6c9c1b7 VZ |
65 | // ---------------------------------------------------------------------------- |
66 | // wxSingleChoiceDialog: a dialog with single selection listbox | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
69 | class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog | |
70 | { | |
c801d85f | 71 | public: |
1169a919 | 72 | wxSingleChoiceDialog(); |
d6c9c1b7 | 73 | |
257bf510 VZ |
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 | ||
d6c9c1b7 VZ |
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 | ||
d6c9c1b7 VZ |
103 | protected: |
104 | int m_selection; | |
105 | wxString m_stringSelection; | |
106 | ||
107 | private: | |
fc7a2a60 | 108 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog) |
d6c9c1b7 VZ |
109 | DECLARE_EVENT_TABLE() |
110 | }; | |
111 | ||
112 | // ---------------------------------------------------------------------------- | |
113 | // wxMultiChoiceDialog: a dialog with multi selection listbox | |
114 | // ---------------------------------------------------------------------------- | |
115 | ||
116 | class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog | |
117 | { | |
118 | public: | |
1169a919 | 119 | wxMultiChoiceDialog(); |
d6c9c1b7 VZ |
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, | |
1169a919 | 127 | const wxPoint& pos = wxDefaultPosition); |
257bf510 VZ |
128 | |
129 | bool Create(wxWindow *parent, | |
130 | const wxString& message, | |
131 | const wxString& caption, | |
d6c9c1b7 VZ |
132 | int n, |
133 | const wxString *choices, | |
257bf510 VZ |
134 | long style = wxCHOICEDLG_STYLE, |
135 | const wxPoint& pos = wxDefaultPosition); | |
c801d85f | 136 | |
d6c9c1b7 VZ |
137 | void SetSelections(const wxArrayInt& selections); |
138 | wxArrayInt GetSelections() const { return m_selections; } | |
c801d85f | 139 | |
257bf510 | 140 | // implementation from now on |
3d49ce44 | 141 | virtual bool TransferDataFromWindow(); |
c801d85f | 142 | |
c801d85f | 143 | protected: |
d6c9c1b7 | 144 | wxArrayInt m_selections; |
257bf510 VZ |
145 | |
146 | private: | |
fc7a2a60 | 147 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog) |
c801d85f KB |
148 | }; |
149 | ||
d6c9c1b7 VZ |
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 | |
155 | WXDLLEXPORT 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); | |
c801d85f | 164 | |
d6c9c1b7 VZ |
165 | WXDLLEXPORT 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); | |
c801d85f KB |
174 | |
175 | // Same as above but gets position in list of strings, instead of string, | |
176 | // or -1 if no selection | |
d6c9c1b7 VZ |
177 | WXDLLEXPORT 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 | ||
187 | WXDLLEXPORT 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 | |
198 | WXDLLEXPORT 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 | ||
208 | WXDLLEXPORT 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 | |
221 | WXDLLEXPORT 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 | ||
232 | WXDLLEXPORT 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 | ||
d6c9c1b7 | 243 | #endif // __CHOICEDLGH_G__ |
c801d85f | 244 |