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(__WXMSW__) && !defined(__WXWINCE__)
49 #if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX
50 #define USE_WXMACFONTDLG 1
52 #define USE_WXMACFONTDLG 0
67 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
69 #define USE_COLOURDLG_GENERIC \
70 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
71 #define USE_DIRDLG_GENERIC \
72 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
73 #define USE_FILEDLG_GENERIC \
74 ((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG)
75 #define USE_FONTDLG_GENERIC \
76 ((USE_WXMSW || USE_WXMACFONTDLG ||USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
79 // Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
80 // between modal and modeless dialogs (ie. not implemented it in your port yet)
81 #if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL
82 #define USE_MODAL_PRESENTATION 0
84 #define USE_MODAL_PRESENTATION 1
88 // Turn USE_SETTINGS_DIALOG to 0 if supported
90 #define USE_SETTINGS_DIALOG 1
92 #define USE_SETTINGS_DIALOG 0
96 // Define a new application type
97 class MyApp
: public wxApp
103 wxColour m_canvasTextColour
;
106 #if USE_MODAL_PRESENTATION
108 // A custom modeless dialog
109 class MyModelessDialog
: public wxDialog
112 MyModelessDialog(wxWindow
*parent
);
114 void OnButton(wxCommandEvent
& event
);
115 void OnClose(wxCloseEvent
& event
);
118 DECLARE_EVENT_TABLE()
121 // A custom modal dialog
122 class MyModalDialog
: public wxDialog
125 MyModalDialog(wxWindow
*parent
);
127 void OnButton(wxCommandEvent
& event
);
130 wxButton
*m_btnModal
,
134 DECLARE_EVENT_TABLE()
137 #endif // USE_MODAL_PRESENTATION
139 #if USE_SETTINGS_DIALOG
140 // Property sheet dialog
141 class SettingsDialog
: public wxPropertySheetDialog
143 DECLARE_CLASS(SettingsDialog
)
145 SettingsDialog(wxWindow
* parent
, bool useToolBook
= false);
148 wxPanel
* CreateGeneralSettingsPage(wxWindow
* parent
);
149 wxPanel
* CreateAestheticSettingsPage(wxWindow
* parent
);
154 ID_SHOW_TOOLTIPS
= 100,
157 ID_LOAD_LAST_PROJECT
,
159 ID_APPLY_SETTINGS_TO
,
164 wxImageList
* m_imageList
;
166 DECLARE_EVENT_TABLE()
169 #endif // USE_SETTINGS_DIALOG
171 // Define a new frame type
172 class MyFrame
: public wxFrame
175 MyFrame(wxWindow
*parent
, const wxString
& title
);
177 void MessageBox(wxCommandEvent
& event
);
180 void ChooseColour(wxCommandEvent
& event
);
181 #endif // wxUSE_COLOURDLG
184 void ChooseFont(wxCommandEvent
& event
);
185 #endif // wxUSE_FONTDLG
188 void LogDialog(wxCommandEvent
& event
);
189 #endif // wxUSE_LOG_DIALOG
192 void SingleChoice(wxCommandEvent
& event
);
193 void MultiChoice(wxCommandEvent
& event
);
194 #endif // wxUSE_CHOICEDLG
197 void TextEntry(wxCommandEvent
& event
);
198 void PasswordEntry(wxCommandEvent
& event
);
199 #endif // wxUSE_TEXTDLG
202 void NumericEntry(wxCommandEvent
& event
);
203 #endif // wxUSE_NUMBERDLG
206 void FileOpen(wxCommandEvent
& event
);
207 void FileOpen2(wxCommandEvent
& event
);
208 void FilesOpen(wxCommandEvent
& event
);
209 void FileSave(wxCommandEvent
& event
);
210 #endif // wxUSE_FILEDLG
212 #if USE_FILEDLG_GENERIC
213 void FileOpenGeneric(wxCommandEvent
& event
);
214 void FilesOpenGeneric(wxCommandEvent
& event
);
215 void FileSaveGeneric(wxCommandEvent
& event
);
216 #endif // USE_FILEDLG_GENERIC
219 void DirChoose(wxCommandEvent
& event
);
220 void DirChooseNew(wxCommandEvent
& event
);
221 #endif // wxUSE_DIRDLG
223 #if USE_DIRDLG_GENERIC
224 void GenericDirChoose(wxCommandEvent
& event
);
225 #endif // USE_DIRDLG_GENERIC
227 #if wxUSE_STARTUP_TIPS
228 void ShowTip(wxCommandEvent
& event
);
229 #endif // wxUSE_STARTUP_TIPS
231 #if USE_MODAL_PRESENTATION
232 void ModalDlg(wxCommandEvent
& event
);
233 void ModelessDlg(wxCommandEvent
& event
);
234 void DlgCenteredScreen(wxCommandEvent
& event
);
235 void DlgCenteredParent(wxCommandEvent
& event
);
236 #endif // USE_MODAL_PRESENTATION
238 #if wxUSE_PROGRESSDLG
239 void ShowProgress(wxCommandEvent
& event
);
240 #endif // wxUSE_PROGRESSDLG
243 void ShowBusyInfo(wxCommandEvent
& event
);
244 #endif // wxUSE_BUSYINFO
246 #if wxUSE_FINDREPLDLG
247 void ShowFindDialog(wxCommandEvent
& event
);
248 void ShowReplaceDialog(wxCommandEvent
& event
);
249 void OnFindDialog(wxFindDialogEvent
& event
);
250 #endif // wxUSE_FINDREPLDLG
252 #if USE_COLOURDLG_GENERIC
253 void ChooseColourGeneric(wxCommandEvent
& event
);
254 #endif // USE_COLOURDLG_GENERIC
256 #if USE_FONTDLG_GENERIC
257 void ChooseFontGeneric(wxCommandEvent
& event
);
258 #endif // USE_FONTDLG_GENERIC
260 void OnPropertySheet(wxCommandEvent
& event
);
261 void OnPropertySheetToolBook(wxCommandEvent
& event
);
262 void OnRequestUserAttention(wxCommandEvent
& event
);
263 void OnExit(wxCommandEvent
& event
);
267 void DoDirChoose(int style
);
268 #endif // wxUSE_DIRDLG
270 #if USE_MODAL_PRESENTATION
271 MyModelessDialog
*m_dialog
;
272 #endif // USE_MODAL_PRESENTATION
274 #if wxUSE_FINDREPLDLG
275 wxFindReplaceData m_findData
;
277 wxFindReplaceDialog
*m_dlgFind
,
279 #endif // wxUSE_FINDREPLDLG
281 wxColourData m_clrData
;
283 DECLARE_EVENT_TABLE()
286 class MyCanvas
: public wxScrolledWindow
289 MyCanvas(wxWindow
*parent
) :
290 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
292 void OnPaint(wxPaintEvent
& event
);
294 DECLARE_EVENT_TABLE()
301 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
302 DIALOGS_CHOOSE_COLOUR_GENERIC
,
304 DIALOGS_CHOOSE_FONT_GENERIC
,
306 DIALOGS_SINGLE_CHOICE
,
307 DIALOGS_MULTI_CHOICE
,
309 DIALOGS_PASSWORD_ENTRY
,
314 DIALOGS_FILE_OPEN_GENERIC
,
315 DIALOGS_FILES_OPEN_GENERIC
,
316 DIALOGS_FILE_SAVE_GENERIC
,
318 DIALOGS_DIRNEW_CHOOSE
,
319 DIALOGS_GENERIC_DIR_CHOOSE
,
325 DIALOGS_CENTRE_SCREEN
,
326 DIALOGS_CENTRE_PARENT
,
327 DIALOGS_MODELESS_BTN
,
333 DIALOGS_PROPERTY_SHEET
,
334 DIALOGS_PROPERTY_SHEET_TOOLBOOK