]> git.saurik.com Git - wxWidgets.git/blame - samples/dialogs/dialogs.h
add SetCharIncludes and SetCharExcludes utilities to wxTextValidator; use iterators...
[wxWidgets.git] / samples / dialogs / dialogs.h
CommitLineData
457814b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: dialogs.h
3// Purpose: Common dialogs demo
4// Author: Julian Smart
13188def 5// Modified by: ABX (2004) - adjustementd for conditional building
457814b5
JS
6// Created: 04/01/98
7// RCS-ID: $Id$
6aa89a22 8// Copyright: (c) Julian Smart
c49245f8 9// Licence: wxWindows license
457814b5
JS
10/////////////////////////////////////////////////////////////////////////////
11
4c8fc4d6 12/*
08375332 13This sample shows how to use the common dialogs available from wxWidgets.
4c8fc4d6
WS
14It also shows that generic implementations of common dialogs can be exchanged
15with native dialogs and can coexist in one application. The need for generic
16dialogs addition is recognized thanks to setup of below USE_*** setting. Their
08375332
WS
17combinations reflects conditions of makefiles and project files to avoid unresolved
18references during linking. For now some generic dialogs are added in static builds
4c8fc4d6
WS
19of MSW, MAC and OS2
20*/
21
457814b5
JS
22#ifndef __DIALOGSH__
23#define __DIALOGSH__
24
da7a8602
WS
25#ifdef __WXUNIVERSAL__
26 #define USE_WXUNIVERSAL 1
27#else
28 #define USE_WXUNIVERSAL 0
29#endif
30
f50ff87b
WS
31#ifdef WXUSINGDLL
32 #define USE_DLL 1
33#else
34 #define USE_DLL 0
35#endif
36
684883e3
WS
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
da7a8602
WS
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
cea9c5b1 55#if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX
71622a68
RN
56 #define USE_WXMACFONTDLG 1
57#else
58 #define USE_WXMACFONTDLG 0
59#endif
60
da7a8602
WS
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
29e3d1f9 73#define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
13188def 74
29e3d1f9
VZ
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 \
8ce68f7f
VZ
80 ((((USE_WXMSW || USE_WXMAC || USE_WXPM || USE_WXGTK) \
81 && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
29e3d1f9 82#define USE_FONTDLG_GENERIC \
684883e3 83 ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
4c8fc4d6 84
08375332
WS
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)
532d575b 87#if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL
08375332
WS
88 #define USE_MODAL_PRESENTATION 0
89#else
90 #define USE_MODAL_PRESENTATION 1
91#endif
4c8fc4d6 92
13188def 93
532d575b
WS
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
9ad2fe62
VZ
101#if wxUSE_LOG
102
103// Custom application traits class which we use to override the default log
104// target creation
105class MyAppTraits : public wxGUIAppTraits
106{
107public:
108 virtual wxLog *CreateLogTarget();
109};
110
111#endif // wxUSE_LOG
532d575b 112
457814b5
JS
113// Define a new application type
114class MyApp: public wxApp
c49245f8
VZ
115{
116public:
9ad2fe62 117 virtual bool OnInit();
457814b5
JS
118
119 wxFont m_canvasFont;
120 wxColour m_canvasTextColour;
9ad2fe62
VZ
121
122protected:
123#if wxUSE_LOG
124 virtual wxAppTraits *CreateTraits() { return new MyAppTraits; }
125#endif // wxUSE_LOG
457814b5
JS
126};
127
b4954d19
WS
128#if USE_MODAL_PRESENTATION
129
f6bcfd97 130// A custom modeless dialog
4c45f240
VZ
131class MyModelessDialog : public wxDialog
132{
133public:
134 MyModelessDialog(wxWindow *parent);
abceee76 135
5d987909 136 void OnButton(wxCommandEvent& event);
abceee76
VZ
137 void OnClose(wxCloseEvent& event);
138
139private:
140 DECLARE_EVENT_TABLE()
4c45f240
VZ
141};
142
f6bcfd97
BP
143// A custom modal dialog
144class MyModalDialog : public wxDialog
145{
146public:
147 MyModalDialog(wxWindow *parent);
148
149 void OnButton(wxCommandEvent& event);
150
151private:
5315ebfa
VZ
152 wxButton *m_btnModal,
153 *m_btnModeless,
154 *m_btnDelete;
f6bcfd97
BP
155
156 DECLARE_EVENT_TABLE()
157};
158
b4954d19
WS
159#endif // USE_MODAL_PRESENTATION
160
44b25eac 161// A class demonstrating CreateStdDialogButtonSizer()
8e1dac82
VZ
162class StdButtonSizerDialog : public wxDialog
163{
164public:
165 StdButtonSizerDialog(wxWindow *parent);
166
167 void OnEvent(wxCommandEvent& event);
168
169private:
170 void EnableDisableControls();
171
172 wxCheckBox *m_chkboxAffirmativeButton;
173 wxRadioButton *m_radiobtnOk,
174 *m_radiobtnYes;
175
176 wxCheckBox *m_chkboxDismissButton;
177 wxRadioButton *m_radiobtnClose,
178 *m_radiobtnCancel;
179
180 wxCheckBox *m_chkboxApply,
181 *m_chkboxNo,
182 *m_chkboxHelp,
183 *m_chkboxNoDefault;
184
185 wxSizer *m_buttonsSizer;
186
187 DECLARE_EVENT_TABLE()
188};
189
44b25eac
VZ
190// Test harness for wxMessageDialog.
191class TestMessageBoxDialog : public wxDialog
192{
193public:
194 TestMessageBoxDialog(wxWindow *parent);
195
196private:
197 void OnApply(wxCommandEvent& event);
198 void OnClose(wxCommandEvent& event);
199 void OnUpdateLabelUI(wxUpdateUIEvent& event);
4e2dc789 200 void OnUpdateNoDefaultUI(wxUpdateUIEvent& event);
44b25eac
VZ
201
202 enum
203 {
204 Btn_Yes,
205 Btn_No,
206 Btn_Ok,
207 Btn_Cancel,
208 Btn_Max
209 };
210
211 struct BtnInfo
212 {
213 int flag;
b3ca7c85 214 const char *name;
44b25eac
VZ
215 };
216
b3ca7c85 217 static const BtnInfo ms_btnInfo[Btn_Max];
44b25eac
VZ
218
219 wxTextCtrl *m_textMsg,
220 *m_textExtMsg;
221
222 wxCheckBox *m_buttons[Btn_Max];
223 wxTextCtrl *m_labels[Btn_Max];
224
225 wxRadioBox *m_icons;
226
4e2dc789
VZ
227 wxCheckBox *m_chkNoDefault,
228 *m_chkCentre;
229
44b25eac
VZ
230 DECLARE_EVENT_TABLE()
231 DECLARE_NO_COPY_CLASS(TestMessageBoxDialog)
232};
233
a625c5b6
RR
234class TestDefaultActionDialog: public wxDialog
235{
236public:
237 TestDefaultActionDialog( wxWindow *parent );
44b25eac 238
a625c5b6
RR
239 void OnListBoxDClick(wxCommandEvent& event);
240 void OnCatchListBoxDClick(wxCommandEvent& event);
44b25eac 241
a625c5b6
RR
242private:
243 bool m_catchListBoxDClick;
244
245private:
246 DECLARE_EVENT_TABLE()
247};
248
249
532d575b 250#if USE_SETTINGS_DIALOG
0f5d8ecf
JS
251// Property sheet dialog
252class SettingsDialog: public wxPropertySheetDialog
253{
254DECLARE_CLASS(SettingsDialog)
255public:
64d3ed17 256 SettingsDialog(wxWindow* parent, int dialogType);
cc8bc5aa 257 ~SettingsDialog();
0f5d8ecf
JS
258
259 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
260 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
261
262protected:
263
264 enum {
265 ID_SHOW_TOOLTIPS = 100,
266 ID_AUTO_SAVE,
267 ID_AUTO_SAVE_MINS,
268 ID_LOAD_LAST_PROJECT,
269
270 ID_APPLY_SETTINGS_TO,
271 ID_BACKGROUND_STYLE,
272 ID_FONT_SIZE
273 };
274
cc8bc5aa
JS
275 wxImageList* m_imageList;
276
0f5d8ecf
JS
277DECLARE_EVENT_TABLE()
278};
279
532d575b
WS
280#endif // USE_SETTINGS_DIALOG
281
457814b5
JS
282// Define a new frame type
283class MyFrame: public wxFrame
c49245f8
VZ
284{
285public:
13188def 286 MyFrame(wxWindow *parent, const wxString& title);
e36a1739 287 virtual ~MyFrame();
13188def 288
8cf304f8 289#if wxUSE_MSGDLG
13188def 290 void MessageBox(wxCommandEvent& event);
44b25eac 291 void MessageBoxDialog(wxCommandEvent& event);
8cf304f8
VZ
292 void MessageBoxInfo(wxCommandEvent& event);
293#endif // wxUSE_MSGDLG
457814b5 294
13188def 295#if wxUSE_COLOURDLG
329e86bf 296 void ChooseColour(wxCommandEvent& event);
e6ef9ea4 297 void GetColour(wxCommandEvent& event);
13188def
WS
298#endif // wxUSE_COLOURDLG
299
300#if wxUSE_FONTDLG
329e86bf 301 void ChooseFont(wxCommandEvent& event);
13188def
WS
302#endif // wxUSE_FONTDLG
303
304#if wxUSE_LOG_DIALOG
d93c719a 305 void LogDialog(wxCommandEvent& event);
13188def
WS
306#endif // wxUSE_LOG_DIALOG
307
308#if wxUSE_CHOICEDLG
457814b5 309 void SingleChoice(wxCommandEvent& event);
d6c9c1b7 310 void MultiChoice(wxCommandEvent& event);
13188def
WS
311#endif // wxUSE_CHOICEDLG
312
5a5f305a
VZ
313 void Rearrange(wxCommandEvent& event);
314
13188def 315#if wxUSE_TEXTDLG
457814b5 316 void TextEntry(wxCommandEvent& event);
a294c6d5 317 void PasswordEntry(wxCommandEvent& event);
13188def
WS
318#endif // wxUSE_TEXTDLG
319
320#if wxUSE_NUMBERDLG
c49245f8 321 void NumericEntry(wxCommandEvent& event);
13188def
WS
322#endif // wxUSE_NUMBERDLG
323
324#if wxUSE_FILEDLG
457814b5 325 void FileOpen(wxCommandEvent& event);
35b45b33 326 void FileOpen2(wxCommandEvent& event);
c61f4f6d 327 void FilesOpen(wxCommandEvent& event);
457814b5 328 void FileSave(wxCommandEvent& event);
13188def
WS
329#endif // wxUSE_FILEDLG
330
695fe764
WS
331#if USE_FILEDLG_GENERIC
332 void FileOpenGeneric(wxCommandEvent& event);
333 void FilesOpenGeneric(wxCommandEvent& event);
334 void FileSaveGeneric(wxCommandEvent& event);
335#endif // USE_FILEDLG_GENERIC
336
13188def 337#if wxUSE_DIRDLG
457814b5 338 void DirChoose(wxCommandEvent& event);
f09c8393 339 void DirChooseNew(wxCommandEvent& event);
13188def
WS
340#endif // wxUSE_DIRDLG
341
342#if USE_DIRDLG_GENERIC
51a58d8b 343 void GenericDirChoose(wxCommandEvent& event);
13188def
WS
344#endif // USE_DIRDLG_GENERIC
345
346#if wxUSE_STARTUP_TIPS
c50f1fb9 347 void ShowTip(wxCommandEvent& event);
13188def
WS
348#endif // wxUSE_STARTUP_TIPS
349
350#if USE_MODAL_PRESENTATION
f6bcfd97 351 void ModalDlg(wxCommandEvent& event);
1baa0a9d 352#endif // USE_MODAL_PRESENTATION
4c45f240 353 void ModelessDlg(wxCommandEvent& event);
cae50e6b
VZ
354 void DlgCenteredScreen(wxCommandEvent& event);
355 void DlgCenteredParent(wxCommandEvent& event);
1baa0a9d 356 void MiniFrame(wxCommandEvent& event);
8e5dbcdd 357 void DlgOnTop(wxCommandEvent& event);
13188def 358
761989ff 359#if wxUSE_PROGRESSDLG
abceee76 360 void ShowProgress(wxCommandEvent& event);
761989ff 361#endif // wxUSE_PROGRESSDLG
13188def 362
ca7adbf8
VZ
363#if wxUSE_ABOUTDLG
364 void ShowSimpleAboutDialog(wxCommandEvent& event);
365 void ShowFancyAboutDialog(wxCommandEvent& event);
453c9e3b
VZ
366 void ShowFullAboutDialog(wxCommandEvent& event);
367 void ShowCustomAboutDialog(wxCommandEvent& event);
ca7adbf8
VZ
368#endif // wxUSE_ABOUTDLG
369
a62b0bcc
VZ
370#if wxUSE_BUSYINFO
371 void ShowBusyInfo(wxCommandEvent& event);
372#endif // wxUSE_BUSYINFO
13188def 373
761989ff
VZ
374#if wxUSE_FINDREPLDLG
375 void ShowFindDialog(wxCommandEvent& event);
376 void ShowReplaceDialog(wxCommandEvent& event);
761989ff
VZ
377 void OnFindDialog(wxFindDialogEvent& event);
378#endif // wxUSE_FINDREPLDLG
457814b5 379
13188def 380#if USE_COLOURDLG_GENERIC
329e86bf 381 void ChooseColourGeneric(wxCommandEvent& event);
13188def
WS
382#endif // USE_COLOURDLG_GENERIC
383
384#if USE_FONTDLG_GENERIC
329e86bf 385 void ChooseFontGeneric(wxCommandEvent& event);
13188def 386#endif // USE_FONTDLG_GENERIC
c49245f8 387
0f5d8ecf 388 void OnPropertySheet(wxCommandEvent& event);
e36a1739 389
29e3d1f9 390 void OnRequestUserAttention(wxCommandEvent& event);
e36a1739
VZ
391#if wxUSE_NOTIFICATION_MESSAGE
392 void OnNotifMsgAuto(wxCommandEvent& event);
393 void OnNotifMsgShow(wxCommandEvent& event);
394 void OnNotifMsgHide(wxCommandEvent& event);
395#endif // wxUSE_NOTIFICATION_MESSAGE
396
8e1dac82 397 void OnStandardButtonsSizerDialog(wxCommandEvent& event);
44b25eac 398
a625c5b6 399 void OnTestDefaultActionDialog(wxCommandEvent& event);
44b25eac 400
329e86bf 401 void OnExit(wxCommandEvent& event);
c49245f8 402
4c45f240 403private:
13188def 404#if wxUSE_DIRDLG
f09c8393 405 void DoDirChoose(int style);
13188def 406#endif // wxUSE_DIRDLG
f09c8393 407
13188def 408#if USE_MODAL_PRESENTATION
4c45f240 409 MyModelessDialog *m_dialog;
13188def 410#endif // USE_MODAL_PRESENTATION
4c45f240 411
761989ff
VZ
412#if wxUSE_FINDREPLDLG
413 wxFindReplaceData m_findData;
14fca738
VZ
414
415 wxFindReplaceDialog *m_dlgFind,
416 *m_dlgReplace;
761989ff
VZ
417#endif // wxUSE_FINDREPLDLG
418
e36a1739
VZ
419#if wxUSE_NOTIFICATION_MESSAGE
420 wxNotificationMessage *m_notifMsg;
421#endif // wxUSE_NOTIFICATION_MESSAGE
422
d33dd9ef
VS
423 wxColourData m_clrData;
424
4c45f240 425 DECLARE_EVENT_TABLE()
457814b5
JS
426};
427
428class MyCanvas: public wxScrolledWindow
429{
c49245f8 430public:
08375332 431 MyCanvas(wxWindow *parent) :
13188def 432 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
c49245f8
VZ
433
434 void OnPaint(wxPaintEvent& event);
435
436 DECLARE_EVENT_TABLE()
457814b5
JS
437};
438
439
440// Menu IDs
a294c6d5
VZ
441enum
442{
13188def 443 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
e6ef9ea4 444 DIALOGS_GET_COLOUR,
a294c6d5
VZ
445 DIALOGS_CHOOSE_COLOUR_GENERIC,
446 DIALOGS_CHOOSE_FONT,
447 DIALOGS_CHOOSE_FONT_GENERIC,
448 DIALOGS_MESSAGE_BOX,
44b25eac 449 DIALOGS_MESSAGE_DIALOG,
8cf304f8 450 DIALOGS_MESSAGE_BOX_WXINFO,
a294c6d5 451 DIALOGS_SINGLE_CHOICE,
d6c9c1b7 452 DIALOGS_MULTI_CHOICE,
5a5f305a 453 DIALOGS_REARRANGE,
a294c6d5
VZ
454 DIALOGS_TEXT_ENTRY,
455 DIALOGS_PASSWORD_ENTRY,
456 DIALOGS_FILE_OPEN,
35b45b33 457 DIALOGS_FILE_OPEN2,
a294c6d5
VZ
458 DIALOGS_FILES_OPEN,
459 DIALOGS_FILE_SAVE,
695fe764
WS
460 DIALOGS_FILE_OPEN_GENERIC,
461 DIALOGS_FILES_OPEN_GENERIC,
462 DIALOGS_FILE_SAVE_GENERIC,
a294c6d5 463 DIALOGS_DIR_CHOOSE,
f09c8393 464 DIALOGS_DIRNEW_CHOOSE,
51a58d8b 465 DIALOGS_GENERIC_DIR_CHOOSE,
a294c6d5
VZ
466 DIALOGS_TIP,
467 DIALOGS_NUM_ENTRY,
4c45f240 468 DIALOGS_LOG_DIALOG,
f6bcfd97 469 DIALOGS_MODAL,
4c45f240 470 DIALOGS_MODELESS,
cae50e6b
VZ
471 DIALOGS_CENTRE_SCREEN,
472 DIALOGS_CENTRE_PARENT,
1baa0a9d 473 DIALOGS_MINIFRAME,
8e5dbcdd 474 DIALOGS_ONTOP,
abceee76 475 DIALOGS_MODELESS_BTN,
761989ff 476 DIALOGS_PROGRESS,
ca7adbf8
VZ
477 DIALOGS_ABOUTDLG_SIMPLE,
478 DIALOGS_ABOUTDLG_FANCY,
453c9e3b
VZ
479 DIALOGS_ABOUTDLG_FULL,
480 DIALOGS_ABOUTDLG_CUSTOM,
a62b0bcc 481 DIALOGS_BUSYINFO,
761989ff 482 DIALOGS_FIND,
29e3d1f9 483 DIALOGS_REPLACE,
0f5d8ecf 484 DIALOGS_REQUEST,
e36a1739
VZ
485 DIALOGS_NOTIFY_AUTO,
486 DIALOGS_NOTIFY_SHOW,
487 DIALOGS_NOTIFY_HIDE,
cc8bc5aa 488 DIALOGS_PROPERTY_SHEET,
64d3ed17 489 DIALOGS_PROPERTY_SHEET_TOOLBOOK,
8e1dac82 490 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK,
a625c5b6
RR
491 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG,
492 DIALOGS_TEST_DEFAULT_ACTION
a294c6d5 493};
457814b5
JS
494
495#endif
496