]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: dialogs.h | |
3 | // Purpose: Common dialogs demo | |
4 | // Author: Julian Smart | |
5 | // Modified by: ABX (2004) - adjustementd for conditional building | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | /* | |
13 | This sample shows how to use the common dialogs available from wxWidgets. | |
14 | It also shows that generic implementations of common dialogs can be exchanged | |
15 | with native dialogs and can coexist in one application. The need for generic | |
16 | dialogs addition is recognized thanks to setup of below USE_*** setting. Their | |
17 | combinations reflects conditions of makefiles and project files to avoid unresolved | |
18 | references during linking. For now some generic dialogs are added in static builds | |
19 | of MSW, MAC and OS2 | |
20 | */ | |
21 | ||
22 | #ifndef __DIALOGSH__ | |
23 | #define __DIALOGSH__ | |
24 | ||
25 | #ifdef __WXUNIVERSAL__ | |
26 | #define USE_WXUNIVERSAL 1 | |
27 | #else | |
28 | #define USE_WXUNIVERSAL 0 | |
29 | #endif | |
30 | ||
31 | #ifdef WXUSINGDLL | |
32 | #define USE_DLL 1 | |
33 | #else | |
34 | #define USE_DLL 0 | |
35 | #endif | |
36 | ||
37 | #if defined(__WXWINCE__) | |
38 | #define USE_WXWINCE 1 | |
39 | #else | |
40 | #define USE_WXWINCE 0 | |
41 | #endif | |
42 | ||
43 | #if defined(__WXMSW__) && !USE_WXWINCE | |
44 | #define USE_WXMSW 1 | |
45 | #else | |
46 | #define USE_WXMSW 0 | |
47 | #endif | |
48 | ||
49 | #ifdef __WXMAC__ | |
50 | #define USE_WXMAC 1 | |
51 | #else | |
52 | #define USE_WXMAC 0 | |
53 | #endif | |
54 | ||
55 | #if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX | |
56 | #define USE_WXMACFONTDLG 1 | |
57 | #else | |
58 | #define USE_WXMACFONTDLG 0 | |
59 | #endif | |
60 | ||
61 | #ifdef __WXGTK__ | |
62 | #define USE_WXGTK 1 | |
63 | #else | |
64 | #define USE_WXGTK 0 | |
65 | #endif | |
66 | ||
67 | #ifdef __WXPM__ | |
68 | #define USE_WXPM 1 | |
69 | #else | |
70 | #define USE_WXPM 0 | |
71 | #endif | |
72 | ||
73 | #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL) | |
74 | ||
75 | #define USE_COLOURDLG_GENERIC \ | |
76 | ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG) | |
77 | #define USE_DIRDLG_GENERIC \ | |
78 | ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG) | |
79 | #define USE_FILEDLG_GENERIC \ | |
80 | ((((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG) | |
81 | #define USE_FONTDLG_GENERIC \ | |
82 | ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG) | |
83 | ||
84 | // Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference | |
85 | // between modal and modeless dialogs (ie. not implemented it in your port yet) | |
86 | #if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL | |
87 | #define USE_MODAL_PRESENTATION 0 | |
88 | #else | |
89 | #define USE_MODAL_PRESENTATION 1 | |
90 | #endif | |
91 | ||
92 | ||
93 | // Turn USE_SETTINGS_DIALOG to 0 if supported | |
94 | #if wxUSE_BOOKCTRL | |
95 | #define USE_SETTINGS_DIALOG 1 | |
96 | #else | |
97 | #define USE_SETTINGS_DIALOG 0 | |
98 | #endif | |
99 | ||
100 | ||
101 | // Define a new application type | |
102 | class MyApp: public wxApp | |
103 | { | |
104 | public: | |
105 | bool OnInit(); | |
106 | ||
107 | wxFont m_canvasFont; | |
108 | wxColour m_canvasTextColour; | |
109 | }; | |
110 | ||
111 | #if USE_MODAL_PRESENTATION | |
112 | ||
113 | // A custom modeless dialog | |
114 | class MyModelessDialog : public wxDialog | |
115 | { | |
116 | public: | |
117 | MyModelessDialog(wxWindow *parent); | |
118 | ||
119 | void OnButton(wxCommandEvent& event); | |
120 | void OnClose(wxCloseEvent& event); | |
121 | ||
122 | private: | |
123 | DECLARE_EVENT_TABLE() | |
124 | }; | |
125 | ||
126 | // A custom modal dialog | |
127 | class MyModalDialog : public wxDialog | |
128 | { | |
129 | public: | |
130 | MyModalDialog(wxWindow *parent); | |
131 | ||
132 | void OnButton(wxCommandEvent& event); | |
133 | ||
134 | private: | |
135 | wxButton *m_btnModal, | |
136 | *m_btnModeless, | |
137 | *m_btnDelete; | |
138 | ||
139 | DECLARE_EVENT_TABLE() | |
140 | }; | |
141 | ||
142 | #endif // USE_MODAL_PRESENTATION | |
143 | ||
144 | class StdButtonSizerDialog : public wxDialog | |
145 | { | |
146 | public: | |
147 | StdButtonSizerDialog(wxWindow *parent); | |
148 | ||
149 | void OnEvent(wxCommandEvent& event); | |
150 | ||
151 | private: | |
152 | void EnableDisableControls(); | |
153 | ||
154 | wxCheckBox *m_chkboxAffirmativeButton; | |
155 | wxRadioButton *m_radiobtnOk, | |
156 | *m_radiobtnYes; | |
157 | ||
158 | wxCheckBox *m_chkboxDismissButton; | |
159 | wxRadioButton *m_radiobtnClose, | |
160 | *m_radiobtnCancel; | |
161 | ||
162 | wxCheckBox *m_chkboxApply, | |
163 | *m_chkboxNo, | |
164 | *m_chkboxHelp, | |
165 | *m_chkboxNoDefault; | |
166 | ||
167 | wxSizer *m_buttonsSizer; | |
168 | ||
169 | DECLARE_EVENT_TABLE() | |
170 | }; | |
171 | ||
172 | #if USE_SETTINGS_DIALOG | |
173 | // Property sheet dialog | |
174 | class SettingsDialog: public wxPropertySheetDialog | |
175 | { | |
176 | DECLARE_CLASS(SettingsDialog) | |
177 | public: | |
178 | SettingsDialog(wxWindow* parent, int dialogType); | |
179 | ~SettingsDialog(); | |
180 | ||
181 | wxPanel* CreateGeneralSettingsPage(wxWindow* parent); | |
182 | wxPanel* CreateAestheticSettingsPage(wxWindow* parent); | |
183 | ||
184 | protected: | |
185 | ||
186 | enum { | |
187 | ID_SHOW_TOOLTIPS = 100, | |
188 | ID_AUTO_SAVE, | |
189 | ID_AUTO_SAVE_MINS, | |
190 | ID_LOAD_LAST_PROJECT, | |
191 | ||
192 | ID_APPLY_SETTINGS_TO, | |
193 | ID_BACKGROUND_STYLE, | |
194 | ID_FONT_SIZE | |
195 | }; | |
196 | ||
197 | wxImageList* m_imageList; | |
198 | ||
199 | DECLARE_EVENT_TABLE() | |
200 | }; | |
201 | ||
202 | #endif // USE_SETTINGS_DIALOG | |
203 | ||
204 | // Define a new frame type | |
205 | class MyFrame: public wxFrame | |
206 | { | |
207 | public: | |
208 | MyFrame(wxWindow *parent, const wxString& title); | |
209 | virtual ~MyFrame(); | |
210 | ||
211 | #if wxUSE_MSGDLG | |
212 | void MessageBox(wxCommandEvent& event); | |
213 | void MessageBoxInfo(wxCommandEvent& event); | |
214 | #endif // wxUSE_MSGDLG | |
215 | ||
216 | #if wxUSE_COLOURDLG | |
217 | void ChooseColour(wxCommandEvent& event); | |
218 | void GetColour(wxCommandEvent& event); | |
219 | #endif // wxUSE_COLOURDLG | |
220 | ||
221 | #if wxUSE_FONTDLG | |
222 | void ChooseFont(wxCommandEvent& event); | |
223 | #endif // wxUSE_FONTDLG | |
224 | ||
225 | #if wxUSE_LOG_DIALOG | |
226 | void LogDialog(wxCommandEvent& event); | |
227 | #endif // wxUSE_LOG_DIALOG | |
228 | ||
229 | #if wxUSE_CHOICEDLG | |
230 | void SingleChoice(wxCommandEvent& event); | |
231 | void MultiChoice(wxCommandEvent& event); | |
232 | #endif // wxUSE_CHOICEDLG | |
233 | ||
234 | #if wxUSE_TEXTDLG | |
235 | void TextEntry(wxCommandEvent& event); | |
236 | void PasswordEntry(wxCommandEvent& event); | |
237 | #endif // wxUSE_TEXTDLG | |
238 | ||
239 | #if wxUSE_NUMBERDLG | |
240 | void NumericEntry(wxCommandEvent& event); | |
241 | #endif // wxUSE_NUMBERDLG | |
242 | ||
243 | #if wxUSE_FILEDLG | |
244 | void FileOpen(wxCommandEvent& event); | |
245 | void FileOpen2(wxCommandEvent& event); | |
246 | void FilesOpen(wxCommandEvent& event); | |
247 | void FileSave(wxCommandEvent& event); | |
248 | #endif // wxUSE_FILEDLG | |
249 | ||
250 | #if USE_FILEDLG_GENERIC | |
251 | void FileOpenGeneric(wxCommandEvent& event); | |
252 | void FilesOpenGeneric(wxCommandEvent& event); | |
253 | void FileSaveGeneric(wxCommandEvent& event); | |
254 | #endif // USE_FILEDLG_GENERIC | |
255 | ||
256 | #if wxUSE_DIRDLG | |
257 | void DirChoose(wxCommandEvent& event); | |
258 | void DirChooseNew(wxCommandEvent& event); | |
259 | #endif // wxUSE_DIRDLG | |
260 | ||
261 | #if USE_DIRDLG_GENERIC | |
262 | void GenericDirChoose(wxCommandEvent& event); | |
263 | #endif // USE_DIRDLG_GENERIC | |
264 | ||
265 | #if wxUSE_STARTUP_TIPS | |
266 | void ShowTip(wxCommandEvent& event); | |
267 | #endif // wxUSE_STARTUP_TIPS | |
268 | ||
269 | #if USE_MODAL_PRESENTATION | |
270 | void ModalDlg(wxCommandEvent& event); | |
271 | #endif // USE_MODAL_PRESENTATION | |
272 | void ModelessDlg(wxCommandEvent& event); | |
273 | void DlgCenteredScreen(wxCommandEvent& event); | |
274 | void DlgCenteredParent(wxCommandEvent& event); | |
275 | void MiniFrame(wxCommandEvent& event); | |
276 | void DlgOnTop(wxCommandEvent& event); | |
277 | ||
278 | #if wxUSE_PROGRESSDLG | |
279 | void ShowProgress(wxCommandEvent& event); | |
280 | #endif // wxUSE_PROGRESSDLG | |
281 | ||
282 | #if wxUSE_ABOUTDLG | |
283 | void ShowSimpleAboutDialog(wxCommandEvent& event); | |
284 | void ShowFancyAboutDialog(wxCommandEvent& event); | |
285 | void ShowFullAboutDialog(wxCommandEvent& event); | |
286 | void ShowCustomAboutDialog(wxCommandEvent& event); | |
287 | #endif // wxUSE_ABOUTDLG | |
288 | ||
289 | #if wxUSE_BUSYINFO | |
290 | void ShowBusyInfo(wxCommandEvent& event); | |
291 | #endif // wxUSE_BUSYINFO | |
292 | ||
293 | #if wxUSE_FINDREPLDLG | |
294 | void ShowFindDialog(wxCommandEvent& event); | |
295 | void ShowReplaceDialog(wxCommandEvent& event); | |
296 | void OnFindDialog(wxFindDialogEvent& event); | |
297 | #endif // wxUSE_FINDREPLDLG | |
298 | ||
299 | #if USE_COLOURDLG_GENERIC | |
300 | void ChooseColourGeneric(wxCommandEvent& event); | |
301 | #endif // USE_COLOURDLG_GENERIC | |
302 | ||
303 | #if USE_FONTDLG_GENERIC | |
304 | void ChooseFontGeneric(wxCommandEvent& event); | |
305 | #endif // USE_FONTDLG_GENERIC | |
306 | ||
307 | void OnPropertySheet(wxCommandEvent& event); | |
308 | ||
309 | void OnRequestUserAttention(wxCommandEvent& event); | |
310 | #if wxUSE_NOTIFICATION_MESSAGE | |
311 | void OnNotifMsgAuto(wxCommandEvent& event); | |
312 | void OnNotifMsgShow(wxCommandEvent& event); | |
313 | void OnNotifMsgHide(wxCommandEvent& event); | |
314 | #endif // wxUSE_NOTIFICATION_MESSAGE | |
315 | ||
316 | void OnStandardButtonsSizerDialog(wxCommandEvent& event); | |
317 | void OnExit(wxCommandEvent& event); | |
318 | ||
319 | private: | |
320 | #if wxUSE_DIRDLG | |
321 | void DoDirChoose(int style); | |
322 | #endif // wxUSE_DIRDLG | |
323 | ||
324 | #if USE_MODAL_PRESENTATION | |
325 | MyModelessDialog *m_dialog; | |
326 | #endif // USE_MODAL_PRESENTATION | |
327 | ||
328 | #if wxUSE_FINDREPLDLG | |
329 | wxFindReplaceData m_findData; | |
330 | ||
331 | wxFindReplaceDialog *m_dlgFind, | |
332 | *m_dlgReplace; | |
333 | #endif // wxUSE_FINDREPLDLG | |
334 | ||
335 | #if wxUSE_NOTIFICATION_MESSAGE | |
336 | wxNotificationMessage *m_notifMsg; | |
337 | #endif // wxUSE_NOTIFICATION_MESSAGE | |
338 | ||
339 | wxColourData m_clrData; | |
340 | ||
341 | DECLARE_EVENT_TABLE() | |
342 | }; | |
343 | ||
344 | class MyCanvas: public wxScrolledWindow | |
345 | { | |
346 | public: | |
347 | MyCanvas(wxWindow *parent) : | |
348 | wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { } | |
349 | ||
350 | void OnPaint(wxPaintEvent& event); | |
351 | ||
352 | DECLARE_EVENT_TABLE() | |
353 | }; | |
354 | ||
355 | ||
356 | // Menu IDs | |
357 | enum | |
358 | { | |
359 | DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST, | |
360 | DIALOGS_GET_COLOUR, | |
361 | DIALOGS_CHOOSE_COLOUR_GENERIC, | |
362 | DIALOGS_CHOOSE_FONT, | |
363 | DIALOGS_CHOOSE_FONT_GENERIC, | |
364 | DIALOGS_MESSAGE_BOX, | |
365 | DIALOGS_MESSAGE_BOX_WXINFO, | |
366 | DIALOGS_SINGLE_CHOICE, | |
367 | DIALOGS_MULTI_CHOICE, | |
368 | DIALOGS_TEXT_ENTRY, | |
369 | DIALOGS_PASSWORD_ENTRY, | |
370 | DIALOGS_FILE_OPEN, | |
371 | DIALOGS_FILE_OPEN2, | |
372 | DIALOGS_FILES_OPEN, | |
373 | DIALOGS_FILE_SAVE, | |
374 | DIALOGS_FILE_OPEN_GENERIC, | |
375 | DIALOGS_FILES_OPEN_GENERIC, | |
376 | DIALOGS_FILE_SAVE_GENERIC, | |
377 | DIALOGS_DIR_CHOOSE, | |
378 | DIALOGS_DIRNEW_CHOOSE, | |
379 | DIALOGS_GENERIC_DIR_CHOOSE, | |
380 | DIALOGS_TIP, | |
381 | DIALOGS_NUM_ENTRY, | |
382 | DIALOGS_LOG_DIALOG, | |
383 | DIALOGS_MODAL, | |
384 | DIALOGS_MODELESS, | |
385 | DIALOGS_CENTRE_SCREEN, | |
386 | DIALOGS_CENTRE_PARENT, | |
387 | DIALOGS_MINIFRAME, | |
388 | DIALOGS_ONTOP, | |
389 | DIALOGS_MODELESS_BTN, | |
390 | DIALOGS_PROGRESS, | |
391 | DIALOGS_ABOUTDLG_SIMPLE, | |
392 | DIALOGS_ABOUTDLG_FANCY, | |
393 | DIALOGS_ABOUTDLG_FULL, | |
394 | DIALOGS_ABOUTDLG_CUSTOM, | |
395 | DIALOGS_BUSYINFO, | |
396 | DIALOGS_FIND, | |
397 | DIALOGS_REPLACE, | |
398 | DIALOGS_REQUEST, | |
399 | DIALOGS_NOTIFY_AUTO, | |
400 | DIALOGS_NOTIFY_SHOW, | |
401 | DIALOGS_NOTIFY_HIDE, | |
402 | DIALOGS_PROPERTY_SHEET, | |
403 | DIALOGS_PROPERTY_SHEET_TOOLBOOK, | |
404 | DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, | |
405 | DIALOGS_STANDARD_BUTTON_SIZER_DIALOG | |
406 | }; | |
407 | ||
408 | #endif | |
409 |