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 #if USE_SETTINGS_DIALOG
173 // Property sheet dialog
174 class SettingsDialog
: public wxPropertySheetDialog
176 DECLARE_CLASS(SettingsDialog
)
178 SettingsDialog(wxWindow
* parent
, int dialogType
);
181 wxPanel
* CreateGeneralSettingsPage(wxWindow
* parent
);
182 wxPanel
* CreateAestheticSettingsPage(wxWindow
* parent
);
187 ID_SHOW_TOOLTIPS
= 100,
190 ID_LOAD_LAST_PROJECT
,
192 ID_APPLY_SETTINGS_TO
,
197 wxImageList
* m_imageList
;
199 DECLARE_EVENT_TABLE()
202 #endif // USE_SETTINGS_DIALOG
204 // Define a new frame type
205 class MyFrame
: public wxFrame
208 MyFrame(wxWindow
*parent
, const wxString
& title
);
212 void MessageBox(wxCommandEvent
& event
);
213 void MessageBoxInfo(wxCommandEvent
& event
);
214 #endif // wxUSE_MSGDLG
217 void ChooseColour(wxCommandEvent
& event
);
218 void GetColour(wxCommandEvent
& event
);
219 #endif // wxUSE_COLOURDLG
222 void ChooseFont(wxCommandEvent
& event
);
223 #endif // wxUSE_FONTDLG
226 void LogDialog(wxCommandEvent
& event
);
227 #endif // wxUSE_LOG_DIALOG
230 void SingleChoice(wxCommandEvent
& event
);
231 void MultiChoice(wxCommandEvent
& event
);
232 #endif // wxUSE_CHOICEDLG
235 void TextEntry(wxCommandEvent
& event
);
236 void PasswordEntry(wxCommandEvent
& event
);
237 #endif // wxUSE_TEXTDLG
240 void NumericEntry(wxCommandEvent
& event
);
241 #endif // wxUSE_NUMBERDLG
244 void FileOpen(wxCommandEvent
& event
);
245 void FileOpen2(wxCommandEvent
& event
);
246 void FilesOpen(wxCommandEvent
& event
);
247 void FileSave(wxCommandEvent
& event
);
248 #endif // wxUSE_FILEDLG
250 #if USE_FILEDLG_GENERIC
251 void FileOpenGeneric(wxCommandEvent
& event
);
252 void FilesOpenGeneric(wxCommandEvent
& event
);
253 void FileSaveGeneric(wxCommandEvent
& event
);
254 #endif // USE_FILEDLG_GENERIC
257 void DirChoose(wxCommandEvent
& event
);
258 void DirChooseNew(wxCommandEvent
& event
);
259 #endif // wxUSE_DIRDLG
261 #if USE_DIRDLG_GENERIC
262 void GenericDirChoose(wxCommandEvent
& event
);
263 #endif // USE_DIRDLG_GENERIC
265 #if wxUSE_STARTUP_TIPS
266 void ShowTip(wxCommandEvent
& event
);
267 #endif // wxUSE_STARTUP_TIPS
269 #if USE_MODAL_PRESENTATION
270 void ModalDlg(wxCommandEvent
& event
);
271 #endif // USE_MODAL_PRESENTATION
272 void ModelessDlg(wxCommandEvent
& event
);
273 void DlgCenteredScreen(wxCommandEvent
& event
);
274 void DlgCenteredParent(wxCommandEvent
& event
);
275 void MiniFrame(wxCommandEvent
& event
);
276 void DlgOnTop(wxCommandEvent
& event
);
278 #if wxUSE_PROGRESSDLG
279 void ShowProgress(wxCommandEvent
& event
);
280 #endif // wxUSE_PROGRESSDLG
283 void ShowSimpleAboutDialog(wxCommandEvent
& event
);
284 void ShowFancyAboutDialog(wxCommandEvent
& event
);
285 void ShowFullAboutDialog(wxCommandEvent
& event
);
286 void ShowCustomAboutDialog(wxCommandEvent
& event
);
287 #endif // wxUSE_ABOUTDLG
290 void ShowBusyInfo(wxCommandEvent
& event
);
291 #endif // wxUSE_BUSYINFO
293 #if wxUSE_FINDREPLDLG
294 void ShowFindDialog(wxCommandEvent
& event
);
295 void ShowReplaceDialog(wxCommandEvent
& event
);
296 void OnFindDialog(wxFindDialogEvent
& event
);
297 #endif // wxUSE_FINDREPLDLG
299 #if USE_COLOURDLG_GENERIC
300 void ChooseColourGeneric(wxCommandEvent
& event
);
301 #endif // USE_COLOURDLG_GENERIC
303 #if USE_FONTDLG_GENERIC
304 void ChooseFontGeneric(wxCommandEvent
& event
);
305 #endif // USE_FONTDLG_GENERIC
307 void OnPropertySheet(wxCommandEvent
& event
);
309 void OnRequestUserAttention(wxCommandEvent
& event
);
310 #if wxUSE_NOTIFICATION_MESSAGE
311 void OnNotifMsgAuto(wxCommandEvent
& event
);
312 void OnNotifMsgShow(wxCommandEvent
& event
);
313 void OnNotifMsgHide(wxCommandEvent
& event
);
314 #endif // wxUSE_NOTIFICATION_MESSAGE
316 void OnStandardButtonsSizerDialog(wxCommandEvent
& event
);
317 void OnExit(wxCommandEvent
& event
);
321 void DoDirChoose(int style
);
322 #endif // wxUSE_DIRDLG
324 #if USE_MODAL_PRESENTATION
325 MyModelessDialog
*m_dialog
;
326 #endif // USE_MODAL_PRESENTATION
328 #if wxUSE_FINDREPLDLG
329 wxFindReplaceData m_findData
;
331 wxFindReplaceDialog
*m_dlgFind
,
333 #endif // wxUSE_FINDREPLDLG
335 #if wxUSE_NOTIFICATION_MESSAGE
336 wxNotificationMessage
*m_notifMsg
;
337 #endif // wxUSE_NOTIFICATION_MESSAGE
339 wxColourData m_clrData
;
341 DECLARE_EVENT_TABLE()
344 class MyCanvas
: public wxScrolledWindow
347 MyCanvas(wxWindow
*parent
) :
348 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
350 void OnPaint(wxPaintEvent
& event
);
352 DECLARE_EVENT_TABLE()
359 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
361 DIALOGS_CHOOSE_COLOUR_GENERIC
,
363 DIALOGS_CHOOSE_FONT_GENERIC
,
365 DIALOGS_MESSAGE_BOX_WXINFO
,
366 DIALOGS_SINGLE_CHOICE
,
367 DIALOGS_MULTI_CHOICE
,
369 DIALOGS_PASSWORD_ENTRY
,
374 DIALOGS_FILE_OPEN_GENERIC
,
375 DIALOGS_FILES_OPEN_GENERIC
,
376 DIALOGS_FILE_SAVE_GENERIC
,
378 DIALOGS_DIRNEW_CHOOSE
,
379 DIALOGS_GENERIC_DIR_CHOOSE
,
385 DIALOGS_CENTRE_SCREEN
,
386 DIALOGS_CENTRE_PARENT
,
389 DIALOGS_MODELESS_BTN
,
391 DIALOGS_ABOUTDLG_SIMPLE
,
392 DIALOGS_ABOUTDLG_FANCY
,
393 DIALOGS_ABOUTDLG_FULL
,
394 DIALOGS_ABOUTDLG_CUSTOM
,
402 DIALOGS_PROPERTY_SHEET
,
403 DIALOGS_PROPERTY_SHEET_TOOLBOOK
,
404 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
,
405 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG