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