added a dialog for wxMessageBox testing
[wxWidgets.git] / samples / dialogs / dialogs.h
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_WXGTK) \
81 && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
82 #define USE_FONTDLG_GENERIC \
83 ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
84
85 // Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
86 // between modal and modeless dialogs (ie. not implemented it in your port yet)
87 #if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL
88 #define USE_MODAL_PRESENTATION 0
89 #else
90 #define USE_MODAL_PRESENTATION 1
91 #endif
92
93
94 // Turn USE_SETTINGS_DIALOG to 0 if supported
95 #if wxUSE_BOOKCTRL
96 #define USE_SETTINGS_DIALOG 1
97 #else
98 #define USE_SETTINGS_DIALOG 0
99 #endif
100
101
102 // Define a new application type
103 class MyApp: public wxApp
104 {
105 public:
106 bool OnInit();
107
108 wxFont m_canvasFont;
109 wxColour m_canvasTextColour;
110 };
111
112 #if USE_MODAL_PRESENTATION
113
114 // A custom modeless dialog
115 class MyModelessDialog : public wxDialog
116 {
117 public:
118 MyModelessDialog(wxWindow *parent);
119
120 void OnButton(wxCommandEvent& event);
121 void OnClose(wxCloseEvent& event);
122
123 private:
124 DECLARE_EVENT_TABLE()
125 };
126
127 // A custom modal dialog
128 class MyModalDialog : public wxDialog
129 {
130 public:
131 MyModalDialog(wxWindow *parent);
132
133 void OnButton(wxCommandEvent& event);
134
135 private:
136 wxButton *m_btnModal,
137 *m_btnModeless,
138 *m_btnDelete;
139
140 DECLARE_EVENT_TABLE()
141 };
142
143 #endif // USE_MODAL_PRESENTATION
144
145 // A class demonstrating CreateStdDialogButtonSizer()
146 class StdButtonSizerDialog : public wxDialog
147 {
148 public:
149 StdButtonSizerDialog(wxWindow *parent);
150
151 void OnEvent(wxCommandEvent& event);
152
153 private:
154 void EnableDisableControls();
155
156 wxCheckBox *m_chkboxAffirmativeButton;
157 wxRadioButton *m_radiobtnOk,
158 *m_radiobtnYes;
159
160 wxCheckBox *m_chkboxDismissButton;
161 wxRadioButton *m_radiobtnClose,
162 *m_radiobtnCancel;
163
164 wxCheckBox *m_chkboxApply,
165 *m_chkboxNo,
166 *m_chkboxHelp,
167 *m_chkboxNoDefault;
168
169 wxSizer *m_buttonsSizer;
170
171 DECLARE_EVENT_TABLE()
172 };
173
174 // Test harness for wxMessageDialog.
175 class TestMessageBoxDialog : public wxDialog
176 {
177 public:
178 TestMessageBoxDialog(wxWindow *parent);
179
180 private:
181 void OnApply(wxCommandEvent& event);
182 void OnClose(wxCommandEvent& event);
183 void OnUpdateLabelUI(wxUpdateUIEvent& event);
184
185 enum
186 {
187 Btn_Yes,
188 Btn_No,
189 Btn_Ok,
190 Btn_Cancel,
191 Btn_Max
192 };
193
194 struct BtnInfo
195 {
196 int flag;
197 wxString name;
198 };
199
200 static BtnInfo ms_btnInfo[Btn_Max];
201
202 wxTextCtrl *m_textMsg,
203 *m_textExtMsg;
204
205 wxCheckBox *m_buttons[Btn_Max];
206 wxTextCtrl *m_labels[Btn_Max];
207
208 wxRadioBox *m_icons;
209
210 DECLARE_EVENT_TABLE()
211 DECLARE_NO_COPY_CLASS(TestMessageBoxDialog)
212 };
213
214 class TestDefaultActionDialog: public wxDialog
215 {
216 public:
217 TestDefaultActionDialog( wxWindow *parent );
218
219 void OnListBoxDClick(wxCommandEvent& event);
220 void OnCatchListBoxDClick(wxCommandEvent& event);
221
222 private:
223 bool m_catchListBoxDClick;
224
225 private:
226 DECLARE_EVENT_TABLE()
227 };
228
229
230 #if USE_SETTINGS_DIALOG
231 // Property sheet dialog
232 class SettingsDialog: public wxPropertySheetDialog
233 {
234 DECLARE_CLASS(SettingsDialog)
235 public:
236 SettingsDialog(wxWindow* parent, int dialogType);
237 ~SettingsDialog();
238
239 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
240 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
241
242 protected:
243
244 enum {
245 ID_SHOW_TOOLTIPS = 100,
246 ID_AUTO_SAVE,
247 ID_AUTO_SAVE_MINS,
248 ID_LOAD_LAST_PROJECT,
249
250 ID_APPLY_SETTINGS_TO,
251 ID_BACKGROUND_STYLE,
252 ID_FONT_SIZE
253 };
254
255 wxImageList* m_imageList;
256
257 DECLARE_EVENT_TABLE()
258 };
259
260 #endif // USE_SETTINGS_DIALOG
261
262 // Define a new frame type
263 class MyFrame: public wxFrame
264 {
265 public:
266 MyFrame(wxWindow *parent, const wxString& title);
267 virtual ~MyFrame();
268
269 #if wxUSE_MSGDLG
270 void MessageBox(wxCommandEvent& event);
271 void MessageBoxDialog(wxCommandEvent& event);
272 void MessageBoxInfo(wxCommandEvent& event);
273 #endif // wxUSE_MSGDLG
274
275 #if wxUSE_COLOURDLG
276 void ChooseColour(wxCommandEvent& event);
277 void GetColour(wxCommandEvent& event);
278 #endif // wxUSE_COLOURDLG
279
280 #if wxUSE_FONTDLG
281 void ChooseFont(wxCommandEvent& event);
282 #endif // wxUSE_FONTDLG
283
284 #if wxUSE_LOG_DIALOG
285 void LogDialog(wxCommandEvent& event);
286 #endif // wxUSE_LOG_DIALOG
287
288 #if wxUSE_CHOICEDLG
289 void SingleChoice(wxCommandEvent& event);
290 void MultiChoice(wxCommandEvent& event);
291 #endif // wxUSE_CHOICEDLG
292
293 #if wxUSE_TEXTDLG
294 void TextEntry(wxCommandEvent& event);
295 void PasswordEntry(wxCommandEvent& event);
296 #endif // wxUSE_TEXTDLG
297
298 #if wxUSE_NUMBERDLG
299 void NumericEntry(wxCommandEvent& event);
300 #endif // wxUSE_NUMBERDLG
301
302 #if wxUSE_FILEDLG
303 void FileOpen(wxCommandEvent& event);
304 void FileOpen2(wxCommandEvent& event);
305 void FilesOpen(wxCommandEvent& event);
306 void FileSave(wxCommandEvent& event);
307 #endif // wxUSE_FILEDLG
308
309 #if USE_FILEDLG_GENERIC
310 void FileOpenGeneric(wxCommandEvent& event);
311 void FilesOpenGeneric(wxCommandEvent& event);
312 void FileSaveGeneric(wxCommandEvent& event);
313 #endif // USE_FILEDLG_GENERIC
314
315 #if wxUSE_DIRDLG
316 void DirChoose(wxCommandEvent& event);
317 void DirChooseNew(wxCommandEvent& event);
318 #endif // wxUSE_DIRDLG
319
320 #if USE_DIRDLG_GENERIC
321 void GenericDirChoose(wxCommandEvent& event);
322 #endif // USE_DIRDLG_GENERIC
323
324 #if wxUSE_STARTUP_TIPS
325 void ShowTip(wxCommandEvent& event);
326 #endif // wxUSE_STARTUP_TIPS
327
328 #if USE_MODAL_PRESENTATION
329 void ModalDlg(wxCommandEvent& event);
330 #endif // USE_MODAL_PRESENTATION
331 void ModelessDlg(wxCommandEvent& event);
332 void DlgCenteredScreen(wxCommandEvent& event);
333 void DlgCenteredParent(wxCommandEvent& event);
334 void MiniFrame(wxCommandEvent& event);
335 void DlgOnTop(wxCommandEvent& event);
336
337 #if wxUSE_PROGRESSDLG
338 void ShowProgress(wxCommandEvent& event);
339 #endif // wxUSE_PROGRESSDLG
340
341 #if wxUSE_ABOUTDLG
342 void ShowSimpleAboutDialog(wxCommandEvent& event);
343 void ShowFancyAboutDialog(wxCommandEvent& event);
344 void ShowFullAboutDialog(wxCommandEvent& event);
345 void ShowCustomAboutDialog(wxCommandEvent& event);
346 #endif // wxUSE_ABOUTDLG
347
348 #if wxUSE_BUSYINFO
349 void ShowBusyInfo(wxCommandEvent& event);
350 #endif // wxUSE_BUSYINFO
351
352 #if wxUSE_FINDREPLDLG
353 void ShowFindDialog(wxCommandEvent& event);
354 void ShowReplaceDialog(wxCommandEvent& event);
355 void OnFindDialog(wxFindDialogEvent& event);
356 #endif // wxUSE_FINDREPLDLG
357
358 #if USE_COLOURDLG_GENERIC
359 void ChooseColourGeneric(wxCommandEvent& event);
360 #endif // USE_COLOURDLG_GENERIC
361
362 #if USE_FONTDLG_GENERIC
363 void ChooseFontGeneric(wxCommandEvent& event);
364 #endif // USE_FONTDLG_GENERIC
365
366 void OnPropertySheet(wxCommandEvent& event);
367
368 void OnRequestUserAttention(wxCommandEvent& event);
369 #if wxUSE_NOTIFICATION_MESSAGE
370 void OnNotifMsgAuto(wxCommandEvent& event);
371 void OnNotifMsgShow(wxCommandEvent& event);
372 void OnNotifMsgHide(wxCommandEvent& event);
373 #endif // wxUSE_NOTIFICATION_MESSAGE
374
375 void OnStandardButtonsSizerDialog(wxCommandEvent& event);
376
377 void OnTestDefaultActionDialog(wxCommandEvent& event);
378
379 void OnExit(wxCommandEvent& event);
380
381 private:
382 #if wxUSE_DIRDLG
383 void DoDirChoose(int style);
384 #endif // wxUSE_DIRDLG
385
386 #if USE_MODAL_PRESENTATION
387 MyModelessDialog *m_dialog;
388 #endif // USE_MODAL_PRESENTATION
389
390 #if wxUSE_FINDREPLDLG
391 wxFindReplaceData m_findData;
392
393 wxFindReplaceDialog *m_dlgFind,
394 *m_dlgReplace;
395 #endif // wxUSE_FINDREPLDLG
396
397 #if wxUSE_NOTIFICATION_MESSAGE
398 wxNotificationMessage *m_notifMsg;
399 #endif // wxUSE_NOTIFICATION_MESSAGE
400
401 wxColourData m_clrData;
402
403 DECLARE_EVENT_TABLE()
404 };
405
406 class MyCanvas: public wxScrolledWindow
407 {
408 public:
409 MyCanvas(wxWindow *parent) :
410 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
411
412 void OnPaint(wxPaintEvent& event);
413
414 DECLARE_EVENT_TABLE()
415 };
416
417
418 // Menu IDs
419 enum
420 {
421 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
422 DIALOGS_GET_COLOUR,
423 DIALOGS_CHOOSE_COLOUR_GENERIC,
424 DIALOGS_CHOOSE_FONT,
425 DIALOGS_CHOOSE_FONT_GENERIC,
426 DIALOGS_MESSAGE_BOX,
427 DIALOGS_MESSAGE_DIALOG,
428 DIALOGS_MESSAGE_BOX_WXINFO,
429 DIALOGS_SINGLE_CHOICE,
430 DIALOGS_MULTI_CHOICE,
431 DIALOGS_TEXT_ENTRY,
432 DIALOGS_PASSWORD_ENTRY,
433 DIALOGS_FILE_OPEN,
434 DIALOGS_FILE_OPEN2,
435 DIALOGS_FILES_OPEN,
436 DIALOGS_FILE_SAVE,
437 DIALOGS_FILE_OPEN_GENERIC,
438 DIALOGS_FILES_OPEN_GENERIC,
439 DIALOGS_FILE_SAVE_GENERIC,
440 DIALOGS_DIR_CHOOSE,
441 DIALOGS_DIRNEW_CHOOSE,
442 DIALOGS_GENERIC_DIR_CHOOSE,
443 DIALOGS_TIP,
444 DIALOGS_NUM_ENTRY,
445 DIALOGS_LOG_DIALOG,
446 DIALOGS_MODAL,
447 DIALOGS_MODELESS,
448 DIALOGS_CENTRE_SCREEN,
449 DIALOGS_CENTRE_PARENT,
450 DIALOGS_MINIFRAME,
451 DIALOGS_ONTOP,
452 DIALOGS_MODELESS_BTN,
453 DIALOGS_PROGRESS,
454 DIALOGS_ABOUTDLG_SIMPLE,
455 DIALOGS_ABOUTDLG_FANCY,
456 DIALOGS_ABOUTDLG_FULL,
457 DIALOGS_ABOUTDLG_CUSTOM,
458 DIALOGS_BUSYINFO,
459 DIALOGS_FIND,
460 DIALOGS_REPLACE,
461 DIALOGS_REQUEST,
462 DIALOGS_NOTIFY_AUTO,
463 DIALOGS_NOTIFY_SHOW,
464 DIALOGS_NOTIFY_HIDE,
465 DIALOGS_PROPERTY_SHEET,
466 DIALOGS_PROPERTY_SHEET_TOOLBOOK,
467 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK,
468 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG,
469 DIALOGS_TEST_DEFAULT_ACTION
470 };
471
472 #endif
473