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_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
81 #define USE_FONTDLG_GENERIC \
82 ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
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
89 #define USE_MODAL_PRESENTATION 1
93 // Turn USE_SETTINGS_DIALOG to 0 if supported
95 #define USE_SETTINGS_DIALOG 1
97 #define USE_SETTINGS_DIALOG 0
101 // Define a new application type
102 class MyApp
: public wxApp
108 wxColour m_canvasTextColour
;
111 #if USE_MODAL_PRESENTATION
113 // A custom modeless dialog
114 class MyModelessDialog
: public wxDialog
117 MyModelessDialog(wxWindow
*parent
);
119 void OnButton(wxCommandEvent
& event
);
120 void OnClose(wxCloseEvent
& event
);
123 DECLARE_EVENT_TABLE()
126 // A custom modal dialog
127 class MyModalDialog
: public wxDialog
130 MyModalDialog(wxWindow
*parent
);
132 void OnButton(wxCommandEvent
& event
);
135 wxButton
*m_btnModal
,
139 DECLARE_EVENT_TABLE()
142 #endif // USE_MODAL_PRESENTATION
144 class StdButtonSizerDialog
: public wxDialog
147 StdButtonSizerDialog(wxWindow
*parent
);
149 void OnEvent(wxCommandEvent
& event
);
152 void EnableDisableControls();
154 wxCheckBox
*m_chkboxAffirmativeButton
;
155 wxRadioButton
*m_radiobtnOk
,
158 wxCheckBox
*m_chkboxDismissButton
;
159 wxRadioButton
*m_radiobtnClose
,
162 wxCheckBox
*m_chkboxApply
,
167 wxSizer
*m_buttonsSizer
;
169 DECLARE_EVENT_TABLE()
172 class TestDefaultActionDialog
: public wxDialog
175 TestDefaultActionDialog( wxWindow
*parent
);
177 void OnListBoxDClick(wxCommandEvent
& event
);
178 void OnCatchListBoxDClick(wxCommandEvent
& event
);
181 bool m_catchListBoxDClick
;
184 DECLARE_EVENT_TABLE()
188 #if USE_SETTINGS_DIALOG
189 // Property sheet dialog
190 class SettingsDialog
: public wxPropertySheetDialog
192 DECLARE_CLASS(SettingsDialog
)
194 SettingsDialog(wxWindow
* parent
, int dialogType
);
197 wxPanel
* CreateGeneralSettingsPage(wxWindow
* parent
);
198 wxPanel
* CreateAestheticSettingsPage(wxWindow
* parent
);
203 ID_SHOW_TOOLTIPS
= 100,
206 ID_LOAD_LAST_PROJECT
,
208 ID_APPLY_SETTINGS_TO
,
213 wxImageList
* m_imageList
;
215 DECLARE_EVENT_TABLE()
218 #endif // USE_SETTINGS_DIALOG
220 // Define a new frame type
221 class MyFrame
: public wxFrame
224 MyFrame(wxWindow
*parent
, const wxString
& title
);
228 void MessageBox(wxCommandEvent
& event
);
229 void MessageBoxInfo(wxCommandEvent
& event
);
230 #endif // wxUSE_MSGDLG
233 void ChooseColour(wxCommandEvent
& event
);
234 void GetColour(wxCommandEvent
& event
);
235 #endif // wxUSE_COLOURDLG
238 void ChooseFont(wxCommandEvent
& event
);
239 #endif // wxUSE_FONTDLG
242 void LogDialog(wxCommandEvent
& event
);
243 #endif // wxUSE_LOG_DIALOG
246 void SingleChoice(wxCommandEvent
& event
);
247 void MultiChoice(wxCommandEvent
& event
);
248 #endif // wxUSE_CHOICEDLG
251 void TextEntry(wxCommandEvent
& event
);
252 void PasswordEntry(wxCommandEvent
& event
);
253 #endif // wxUSE_TEXTDLG
256 void NumericEntry(wxCommandEvent
& event
);
257 #endif // wxUSE_NUMBERDLG
260 void FileOpen(wxCommandEvent
& event
);
261 void FileOpen2(wxCommandEvent
& event
);
262 void FilesOpen(wxCommandEvent
& event
);
263 void FileSave(wxCommandEvent
& event
);
264 #endif // wxUSE_FILEDLG
266 #if USE_FILEDLG_GENERIC
267 void FileOpenGeneric(wxCommandEvent
& event
);
268 void FilesOpenGeneric(wxCommandEvent
& event
);
269 void FileSaveGeneric(wxCommandEvent
& event
);
270 #endif // USE_FILEDLG_GENERIC
273 void DirChoose(wxCommandEvent
& event
);
274 void DirChooseNew(wxCommandEvent
& event
);
275 #endif // wxUSE_DIRDLG
277 #if USE_DIRDLG_GENERIC
278 void GenericDirChoose(wxCommandEvent
& event
);
279 #endif // USE_DIRDLG_GENERIC
281 #if wxUSE_STARTUP_TIPS
282 void ShowTip(wxCommandEvent
& event
);
283 #endif // wxUSE_STARTUP_TIPS
285 #if USE_MODAL_PRESENTATION
286 void ModalDlg(wxCommandEvent
& event
);
287 #endif // USE_MODAL_PRESENTATION
288 void ModelessDlg(wxCommandEvent
& event
);
289 void DlgCenteredScreen(wxCommandEvent
& event
);
290 void DlgCenteredParent(wxCommandEvent
& event
);
291 void MiniFrame(wxCommandEvent
& event
);
292 void DlgOnTop(wxCommandEvent
& event
);
294 #if wxUSE_PROGRESSDLG
295 void ShowProgress(wxCommandEvent
& event
);
296 #endif // wxUSE_PROGRESSDLG
299 void ShowSimpleAboutDialog(wxCommandEvent
& event
);
300 void ShowFancyAboutDialog(wxCommandEvent
& event
);
301 void ShowFullAboutDialog(wxCommandEvent
& event
);
302 void ShowCustomAboutDialog(wxCommandEvent
& event
);
303 #endif // wxUSE_ABOUTDLG
306 void ShowBusyInfo(wxCommandEvent
& event
);
307 #endif // wxUSE_BUSYINFO
309 #if wxUSE_FINDREPLDLG
310 void ShowFindDialog(wxCommandEvent
& event
);
311 void ShowReplaceDialog(wxCommandEvent
& event
);
312 void OnFindDialog(wxFindDialogEvent
& event
);
313 #endif // wxUSE_FINDREPLDLG
315 #if USE_COLOURDLG_GENERIC
316 void ChooseColourGeneric(wxCommandEvent
& event
);
317 #endif // USE_COLOURDLG_GENERIC
319 #if USE_FONTDLG_GENERIC
320 void ChooseFontGeneric(wxCommandEvent
& event
);
321 #endif // USE_FONTDLG_GENERIC
323 void OnPropertySheet(wxCommandEvent
& event
);
325 void OnRequestUserAttention(wxCommandEvent
& event
);
326 #if wxUSE_NOTIFICATION_MESSAGE
327 void OnNotifMsgAuto(wxCommandEvent
& event
);
328 void OnNotifMsgShow(wxCommandEvent
& event
);
329 void OnNotifMsgHide(wxCommandEvent
& event
);
330 #endif // wxUSE_NOTIFICATION_MESSAGE
332 void OnStandardButtonsSizerDialog(wxCommandEvent
& event
);
334 void OnTestDefaultActionDialog(wxCommandEvent
& event
);
336 void OnExit(wxCommandEvent
& event
);
340 void DoDirChoose(int style
);
341 #endif // wxUSE_DIRDLG
343 #if USE_MODAL_PRESENTATION
344 MyModelessDialog
*m_dialog
;
345 #endif // USE_MODAL_PRESENTATION
347 #if wxUSE_FINDREPLDLG
348 wxFindReplaceData m_findData
;
350 wxFindReplaceDialog
*m_dlgFind
,
352 #endif // wxUSE_FINDREPLDLG
354 #if wxUSE_NOTIFICATION_MESSAGE
355 wxNotificationMessage
*m_notifMsg
;
356 #endif // wxUSE_NOTIFICATION_MESSAGE
358 wxColourData m_clrData
;
360 DECLARE_EVENT_TABLE()
363 class MyCanvas
: public wxScrolledWindow
366 MyCanvas(wxWindow
*parent
) :
367 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
369 void OnPaint(wxPaintEvent
& event
);
371 DECLARE_EVENT_TABLE()
378 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
380 DIALOGS_CHOOSE_COLOUR_GENERIC
,
382 DIALOGS_CHOOSE_FONT_GENERIC
,
384 DIALOGS_MESSAGE_BOX_WXINFO
,
385 DIALOGS_SINGLE_CHOICE
,
386 DIALOGS_MULTI_CHOICE
,
388 DIALOGS_PASSWORD_ENTRY
,
393 DIALOGS_FILE_OPEN_GENERIC
,
394 DIALOGS_FILES_OPEN_GENERIC
,
395 DIALOGS_FILE_SAVE_GENERIC
,
397 DIALOGS_DIRNEW_CHOOSE
,
398 DIALOGS_GENERIC_DIR_CHOOSE
,
404 DIALOGS_CENTRE_SCREEN
,
405 DIALOGS_CENTRE_PARENT
,
408 DIALOGS_MODELESS_BTN
,
410 DIALOGS_ABOUTDLG_SIMPLE
,
411 DIALOGS_ABOUTDLG_FANCY
,
412 DIALOGS_ABOUTDLG_FULL
,
413 DIALOGS_ABOUTDLG_CUSTOM
,
421 DIALOGS_PROPERTY_SHEET
,
422 DIALOGS_PROPERTY_SHEET_TOOLBOOK
,
423 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
,
424 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
,
425 DIALOGS_TEST_DEFAULT_ACTION