1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart
5 // Modified by: ABX (2004) - adjustementd for conditional building
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
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
25 #ifdef __WXUNIVERSAL__
26 #define USE_WXUNIVERSAL 1
28 #define USE_WXUNIVERSAL 0
37 #if defined(__WXWINCE__)
43 #if defined(__WXMSW__) && !USE_WXWINCE
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
58 #define USE_WXMACFONTDLG 0
73 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
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)
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
90 #define USE_MODAL_PRESENTATION 1
94 // Turn USE_SETTINGS_DIALOG to 0 if supported
96 #define USE_SETTINGS_DIALOG 1
98 #define USE_SETTINGS_DIALOG 0
102 // Define a new application type
103 class MyApp
: public wxApp
109 wxColour m_canvasTextColour
;
112 #if USE_MODAL_PRESENTATION
114 // A custom modeless dialog
115 class MyModelessDialog
: public wxDialog
118 MyModelessDialog(wxWindow
*parent
);
120 void OnButton(wxCommandEvent
& event
);
121 void OnClose(wxCloseEvent
& event
);
124 DECLARE_EVENT_TABLE()
127 // A custom modal dialog
128 class MyModalDialog
: public wxDialog
131 MyModalDialog(wxWindow
*parent
);
133 void OnButton(wxCommandEvent
& event
);
136 wxButton
*m_btnModal
,
140 DECLARE_EVENT_TABLE()
143 #endif // USE_MODAL_PRESENTATION
145 class StdButtonSizerDialog
: public wxDialog
148 StdButtonSizerDialog(wxWindow
*parent
);
150 void OnEvent(wxCommandEvent
& event
);
153 void EnableDisableControls();
155 wxCheckBox
*m_chkboxAffirmativeButton
;
156 wxRadioButton
*m_radiobtnOk
,
159 wxCheckBox
*m_chkboxDismissButton
;
160 wxRadioButton
*m_radiobtnClose
,
163 wxCheckBox
*m_chkboxApply
,
168 wxSizer
*m_buttonsSizer
;
170 DECLARE_EVENT_TABLE()
173 class TestDefaultActionDialog
: public wxDialog
176 TestDefaultActionDialog( wxWindow
*parent
);
178 void OnListBoxDClick(wxCommandEvent
& event
);
179 void OnCatchListBoxDClick(wxCommandEvent
& event
);
182 bool m_catchListBoxDClick
;
185 DECLARE_EVENT_TABLE()
189 #if USE_SETTINGS_DIALOG
190 // Property sheet dialog
191 class SettingsDialog
: public wxPropertySheetDialog
193 DECLARE_CLASS(SettingsDialog
)
195 SettingsDialog(wxWindow
* parent
, int dialogType
);
198 wxPanel
* CreateGeneralSettingsPage(wxWindow
* parent
);
199 wxPanel
* CreateAestheticSettingsPage(wxWindow
* parent
);
204 ID_SHOW_TOOLTIPS
= 100,
207 ID_LOAD_LAST_PROJECT
,
209 ID_APPLY_SETTINGS_TO
,
214 wxImageList
* m_imageList
;
216 DECLARE_EVENT_TABLE()
219 #endif // USE_SETTINGS_DIALOG
221 // Define a new frame type
222 class MyFrame
: public wxFrame
225 MyFrame(wxWindow
*parent
, const wxString
& title
);
229 void MessageBox(wxCommandEvent
& event
);
230 void MessageBoxInfo(wxCommandEvent
& event
);
231 #endif // wxUSE_MSGDLG
234 void ChooseColour(wxCommandEvent
& event
);
235 void GetColour(wxCommandEvent
& event
);
236 #endif // wxUSE_COLOURDLG
239 void ChooseFont(wxCommandEvent
& event
);
240 #endif // wxUSE_FONTDLG
243 void LogDialog(wxCommandEvent
& event
);
244 #endif // wxUSE_LOG_DIALOG
247 void SingleChoice(wxCommandEvent
& event
);
248 void MultiChoice(wxCommandEvent
& event
);
249 #endif // wxUSE_CHOICEDLG
252 void TextEntry(wxCommandEvent
& event
);
253 void PasswordEntry(wxCommandEvent
& event
);
254 #endif // wxUSE_TEXTDLG
257 void NumericEntry(wxCommandEvent
& event
);
258 #endif // wxUSE_NUMBERDLG
261 void FileOpen(wxCommandEvent
& event
);
262 void FileOpen2(wxCommandEvent
& event
);
263 void FilesOpen(wxCommandEvent
& event
);
264 void FileSave(wxCommandEvent
& event
);
265 #endif // wxUSE_FILEDLG
267 #if USE_FILEDLG_GENERIC
268 void FileOpenGeneric(wxCommandEvent
& event
);
269 void FilesOpenGeneric(wxCommandEvent
& event
);
270 void FileSaveGeneric(wxCommandEvent
& event
);
271 #endif // USE_FILEDLG_GENERIC
274 void DirChoose(wxCommandEvent
& event
);
275 void DirChooseNew(wxCommandEvent
& event
);
276 #endif // wxUSE_DIRDLG
278 #if USE_DIRDLG_GENERIC
279 void GenericDirChoose(wxCommandEvent
& event
);
280 #endif // USE_DIRDLG_GENERIC
282 #if wxUSE_STARTUP_TIPS
283 void ShowTip(wxCommandEvent
& event
);
284 #endif // wxUSE_STARTUP_TIPS
286 #if USE_MODAL_PRESENTATION
287 void ModalDlg(wxCommandEvent
& event
);
288 #endif // USE_MODAL_PRESENTATION
289 void ModelessDlg(wxCommandEvent
& event
);
290 void DlgCenteredScreen(wxCommandEvent
& event
);
291 void DlgCenteredParent(wxCommandEvent
& event
);
292 void MiniFrame(wxCommandEvent
& event
);
293 void DlgOnTop(wxCommandEvent
& event
);
295 #if wxUSE_PROGRESSDLG
296 void ShowProgress(wxCommandEvent
& event
);
297 #endif // wxUSE_PROGRESSDLG
300 void ShowSimpleAboutDialog(wxCommandEvent
& event
);
301 void ShowFancyAboutDialog(wxCommandEvent
& event
);
302 void ShowFullAboutDialog(wxCommandEvent
& event
);
303 void ShowCustomAboutDialog(wxCommandEvent
& event
);
304 #endif // wxUSE_ABOUTDLG
307 void ShowBusyInfo(wxCommandEvent
& event
);
308 #endif // wxUSE_BUSYINFO
310 #if wxUSE_FINDREPLDLG
311 void ShowFindDialog(wxCommandEvent
& event
);
312 void ShowReplaceDialog(wxCommandEvent
& event
);
313 void OnFindDialog(wxFindDialogEvent
& event
);
314 #endif // wxUSE_FINDREPLDLG
316 #if USE_COLOURDLG_GENERIC
317 void ChooseColourGeneric(wxCommandEvent
& event
);
318 #endif // USE_COLOURDLG_GENERIC
320 #if USE_FONTDLG_GENERIC
321 void ChooseFontGeneric(wxCommandEvent
& event
);
322 #endif // USE_FONTDLG_GENERIC
324 void OnPropertySheet(wxCommandEvent
& event
);
326 void OnRequestUserAttention(wxCommandEvent
& event
);
327 #if wxUSE_NOTIFICATION_MESSAGE
328 void OnNotifMsgAuto(wxCommandEvent
& event
);
329 void OnNotifMsgShow(wxCommandEvent
& event
);
330 void OnNotifMsgHide(wxCommandEvent
& event
);
331 #endif // wxUSE_NOTIFICATION_MESSAGE
333 void OnStandardButtonsSizerDialog(wxCommandEvent
& event
);
335 void OnTestDefaultActionDialog(wxCommandEvent
& event
);
337 void OnExit(wxCommandEvent
& event
);
341 void DoDirChoose(int style
);
342 #endif // wxUSE_DIRDLG
344 #if USE_MODAL_PRESENTATION
345 MyModelessDialog
*m_dialog
;
346 #endif // USE_MODAL_PRESENTATION
348 #if wxUSE_FINDREPLDLG
349 wxFindReplaceData m_findData
;
351 wxFindReplaceDialog
*m_dlgFind
,
353 #endif // wxUSE_FINDREPLDLG
355 #if wxUSE_NOTIFICATION_MESSAGE
356 wxNotificationMessage
*m_notifMsg
;
357 #endif // wxUSE_NOTIFICATION_MESSAGE
359 wxColourData m_clrData
;
361 DECLARE_EVENT_TABLE()
364 class MyCanvas
: public wxScrolledWindow
367 MyCanvas(wxWindow
*parent
) :
368 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
370 void OnPaint(wxPaintEvent
& event
);
372 DECLARE_EVENT_TABLE()
379 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
381 DIALOGS_CHOOSE_COLOUR_GENERIC
,
383 DIALOGS_CHOOSE_FONT_GENERIC
,
385 DIALOGS_MESSAGE_BOX_WXINFO
,
386 DIALOGS_SINGLE_CHOICE
,
387 DIALOGS_MULTI_CHOICE
,
389 DIALOGS_PASSWORD_ENTRY
,
394 DIALOGS_FILE_OPEN_GENERIC
,
395 DIALOGS_FILES_OPEN_GENERIC
,
396 DIALOGS_FILE_SAVE_GENERIC
,
398 DIALOGS_DIRNEW_CHOOSE
,
399 DIALOGS_GENERIC_DIR_CHOOSE
,
405 DIALOGS_CENTRE_SCREEN
,
406 DIALOGS_CENTRE_PARENT
,
409 DIALOGS_MODELESS_BTN
,
411 DIALOGS_ABOUTDLG_SIMPLE
,
412 DIALOGS_ABOUTDLG_FANCY
,
413 DIALOGS_ABOUTDLG_FULL
,
414 DIALOGS_ABOUTDLG_CUSTOM
,
422 DIALOGS_PROPERTY_SHEET
,
423 DIALOGS_PROPERTY_SHEET_TOOLBOOK
,
424 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
,
425 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
,
426 DIALOGS_TEST_DEFAULT_ACTION