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 #if USE_SETTINGS_DIALOG
145 // Property sheet dialog
146 class SettingsDialog
: public wxPropertySheetDialog
148 DECLARE_CLASS(SettingsDialog
)
150 SettingsDialog(wxWindow
* parent
, int dialogType
);
153 wxPanel
* CreateGeneralSettingsPage(wxWindow
* parent
);
154 wxPanel
* CreateAestheticSettingsPage(wxWindow
* parent
);
159 ID_SHOW_TOOLTIPS
= 100,
162 ID_LOAD_LAST_PROJECT
,
164 ID_APPLY_SETTINGS_TO
,
169 wxImageList
* m_imageList
;
171 DECLARE_EVENT_TABLE()
174 #endif // USE_SETTINGS_DIALOG
176 // Define a new frame type
177 class MyFrame
: public wxFrame
180 MyFrame(wxWindow
*parent
, const wxString
& title
);
182 void MessageBox(wxCommandEvent
& event
);
185 void ChooseColour(wxCommandEvent
& event
);
186 #endif // wxUSE_COLOURDLG
189 void ChooseFont(wxCommandEvent
& event
);
190 #endif // wxUSE_FONTDLG
193 void LogDialog(wxCommandEvent
& event
);
194 #endif // wxUSE_LOG_DIALOG
197 void SingleChoice(wxCommandEvent
& event
);
198 void MultiChoice(wxCommandEvent
& event
);
199 #endif // wxUSE_CHOICEDLG
202 void TextEntry(wxCommandEvent
& event
);
203 void PasswordEntry(wxCommandEvent
& event
);
204 #endif // wxUSE_TEXTDLG
207 void NumericEntry(wxCommandEvent
& event
);
208 #endif // wxUSE_NUMBERDLG
211 void FileOpen(wxCommandEvent
& event
);
212 void FileOpen2(wxCommandEvent
& event
);
213 void FilesOpen(wxCommandEvent
& event
);
214 void FileSave(wxCommandEvent
& event
);
215 #endif // wxUSE_FILEDLG
217 #if USE_FILEDLG_GENERIC
218 void FileOpenGeneric(wxCommandEvent
& event
);
219 void FilesOpenGeneric(wxCommandEvent
& event
);
220 void FileSaveGeneric(wxCommandEvent
& event
);
221 #endif // USE_FILEDLG_GENERIC
224 void DirChoose(wxCommandEvent
& event
);
225 void DirChooseNew(wxCommandEvent
& event
);
226 #endif // wxUSE_DIRDLG
228 #if USE_DIRDLG_GENERIC
229 void GenericDirChoose(wxCommandEvent
& event
);
230 #endif // USE_DIRDLG_GENERIC
232 #if wxUSE_STARTUP_TIPS
233 void ShowTip(wxCommandEvent
& event
);
234 #endif // wxUSE_STARTUP_TIPS
236 #if USE_MODAL_PRESENTATION
237 void ModalDlg(wxCommandEvent
& event
);
238 void ModelessDlg(wxCommandEvent
& event
);
239 void DlgCenteredScreen(wxCommandEvent
& event
);
240 void DlgCenteredParent(wxCommandEvent
& event
);
241 #endif // USE_MODAL_PRESENTATION
243 #if wxUSE_PROGRESSDLG
244 void ShowProgress(wxCommandEvent
& event
);
245 #endif // wxUSE_PROGRESSDLG
248 void ShowSimpleAboutDialog(wxCommandEvent
& event
);
249 void ShowFancyAboutDialog(wxCommandEvent
& event
);
250 void ShowFullAboutDialog(wxCommandEvent
& event
);
251 void ShowCustomAboutDialog(wxCommandEvent
& event
);
252 #endif // wxUSE_ABOUTDLG
255 void ShowBusyInfo(wxCommandEvent
& event
);
256 #endif // wxUSE_BUSYINFO
258 #if wxUSE_FINDREPLDLG
259 void ShowFindDialog(wxCommandEvent
& event
);
260 void ShowReplaceDialog(wxCommandEvent
& event
);
261 void OnFindDialog(wxFindDialogEvent
& event
);
262 #endif // wxUSE_FINDREPLDLG
264 #if USE_COLOURDLG_GENERIC
265 void ChooseColourGeneric(wxCommandEvent
& event
);
266 #endif // USE_COLOURDLG_GENERIC
268 #if USE_FONTDLG_GENERIC
269 void ChooseFontGeneric(wxCommandEvent
& event
);
270 #endif // USE_FONTDLG_GENERIC
272 void OnPropertySheet(wxCommandEvent
& event
);
273 void OnRequestUserAttention(wxCommandEvent
& event
);
274 void OnExit(wxCommandEvent
& event
);
278 void DoDirChoose(int style
);
279 #endif // wxUSE_DIRDLG
281 #if USE_MODAL_PRESENTATION
282 MyModelessDialog
*m_dialog
;
283 #endif // USE_MODAL_PRESENTATION
285 #if wxUSE_FINDREPLDLG
286 wxFindReplaceData m_findData
;
288 wxFindReplaceDialog
*m_dlgFind
,
290 #endif // wxUSE_FINDREPLDLG
292 wxColourData m_clrData
;
294 DECLARE_EVENT_TABLE()
297 class MyCanvas
: public wxScrolledWindow
300 MyCanvas(wxWindow
*parent
) :
301 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
303 void OnPaint(wxPaintEvent
& event
);
305 DECLARE_EVENT_TABLE()
312 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
313 DIALOGS_CHOOSE_COLOUR_GENERIC
,
315 DIALOGS_CHOOSE_FONT_GENERIC
,
317 DIALOGS_SINGLE_CHOICE
,
318 DIALOGS_MULTI_CHOICE
,
320 DIALOGS_PASSWORD_ENTRY
,
325 DIALOGS_FILE_OPEN_GENERIC
,
326 DIALOGS_FILES_OPEN_GENERIC
,
327 DIALOGS_FILE_SAVE_GENERIC
,
329 DIALOGS_DIRNEW_CHOOSE
,
330 DIALOGS_GENERIC_DIR_CHOOSE
,
336 DIALOGS_CENTRE_SCREEN
,
337 DIALOGS_CENTRE_PARENT
,
338 DIALOGS_MODELESS_BTN
,
340 DIALOGS_ABOUTDLG_SIMPLE
,
341 DIALOGS_ABOUTDLG_FANCY
,
342 DIALOGS_ABOUTDLG_FULL
,
343 DIALOGS_ABOUTDLG_CUSTOM
,
348 DIALOGS_PROPERTY_SHEET
,
349 DIALOGS_PROPERTY_SHEET_TOOLBOOK
,
350 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK