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__)
82 #define USE_MODAL_PRESENTATION 0
84 #define USE_MODAL_PRESENTATION 1
88 // Define a new application type
89 class MyApp
: public wxApp
95 wxColour m_canvasTextColour
;
98 #if USE_MODAL_PRESENTATION
100 // A custom modeless dialog
101 class MyModelessDialog
: public wxDialog
104 MyModelessDialog(wxWindow
*parent
);
106 void OnButton(wxCommandEvent
& event
);
107 void OnClose(wxCloseEvent
& event
);
110 DECLARE_EVENT_TABLE()
113 // A custom modal dialog
114 class MyModalDialog
: public wxDialog
117 MyModalDialog(wxWindow
*parent
);
119 void OnButton(wxCommandEvent
& event
);
122 wxButton
*m_btnModal
,
126 DECLARE_EVENT_TABLE()
129 #endif // USE_MODAL_PRESENTATION
131 // Define a new frame type
132 class MyFrame
: public wxFrame
135 MyFrame(wxWindow
*parent
, const wxString
& title
);
137 void MessageBox(wxCommandEvent
& event
);
140 void ChooseColour(wxCommandEvent
& event
);
141 #endif // wxUSE_COLOURDLG
144 void ChooseFont(wxCommandEvent
& event
);
145 #endif // wxUSE_FONTDLG
148 void LogDialog(wxCommandEvent
& event
);
149 #endif // wxUSE_LOG_DIALOG
152 void SingleChoice(wxCommandEvent
& event
);
153 void MultiChoice(wxCommandEvent
& event
);
154 #endif // wxUSE_CHOICEDLG
157 void TextEntry(wxCommandEvent
& event
);
158 void PasswordEntry(wxCommandEvent
& event
);
159 #endif // wxUSE_TEXTDLG
162 void NumericEntry(wxCommandEvent
& event
);
163 #endif // wxUSE_NUMBERDLG
166 void FileOpen(wxCommandEvent
& event
);
167 void FileOpen2(wxCommandEvent
& event
);
168 void FilesOpen(wxCommandEvent
& event
);
169 void FileSave(wxCommandEvent
& event
);
170 #endif // wxUSE_FILEDLG
172 #if USE_FILEDLG_GENERIC
173 void FileOpenGeneric(wxCommandEvent
& event
);
174 void FilesOpenGeneric(wxCommandEvent
& event
);
175 void FileSaveGeneric(wxCommandEvent
& event
);
176 #endif // USE_FILEDLG_GENERIC
179 void DirChoose(wxCommandEvent
& event
);
180 void DirChooseNew(wxCommandEvent
& event
);
181 #endif // wxUSE_DIRDLG
183 #if USE_DIRDLG_GENERIC
184 void GenericDirChoose(wxCommandEvent
& event
);
185 #endif // USE_DIRDLG_GENERIC
187 #if wxUSE_STARTUP_TIPS
188 void ShowTip(wxCommandEvent
& event
);
189 #endif // wxUSE_STARTUP_TIPS
191 #if USE_MODAL_PRESENTATION
192 void ModalDlg(wxCommandEvent
& event
);
193 void ModelessDlg(wxCommandEvent
& event
);
194 #endif // USE_MODAL_PRESENTATION
196 #if wxUSE_PROGRESSDLG
197 void ShowProgress(wxCommandEvent
& event
);
198 #endif // wxUSE_PROGRESSDLG
201 void ShowBusyInfo(wxCommandEvent
& event
);
202 #endif // wxUSE_BUSYINFO
204 #if wxUSE_FINDREPLDLG
205 void ShowFindDialog(wxCommandEvent
& event
);
206 void ShowReplaceDialog(wxCommandEvent
& event
);
207 void OnFindDialog(wxFindDialogEvent
& event
);
208 #endif // wxUSE_FINDREPLDLG
210 #if USE_COLOURDLG_GENERIC
211 void ChooseColourGeneric(wxCommandEvent
& event
);
212 #endif // USE_COLOURDLG_GENERIC
214 #if USE_FONTDLG_GENERIC
215 void ChooseFontGeneric(wxCommandEvent
& event
);
216 #endif // USE_FONTDLG_GENERIC
218 void OnRequestUserAttention(wxCommandEvent
& event
);
219 void OnExit(wxCommandEvent
& event
);
223 void DoDirChoose(int style
);
224 #endif // wxUSE_DIRDLG
226 #if USE_MODAL_PRESENTATION
227 MyModelessDialog
*m_dialog
;
228 #endif // USE_MODAL_PRESENTATION
230 #if wxUSE_FINDREPLDLG
231 wxFindReplaceData m_findData
;
233 wxFindReplaceDialog
*m_dlgFind
,
235 #endif // wxUSE_FINDREPLDLG
237 wxColourData m_clrData
;
239 DECLARE_EVENT_TABLE()
242 class MyCanvas
: public wxScrolledWindow
245 MyCanvas(wxWindow
*parent
) :
246 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
248 void OnPaint(wxPaintEvent
& event
);
250 DECLARE_EVENT_TABLE()
257 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
258 DIALOGS_CHOOSE_COLOUR_GENERIC
,
260 DIALOGS_CHOOSE_FONT_GENERIC
,
262 DIALOGS_SINGLE_CHOICE
,
263 DIALOGS_MULTI_CHOICE
,
265 DIALOGS_PASSWORD_ENTRY
,
270 DIALOGS_FILE_OPEN_GENERIC
,
271 DIALOGS_FILES_OPEN_GENERIC
,
272 DIALOGS_FILE_SAVE_GENERIC
,
274 DIALOGS_DIRNEW_CHOOSE
,
275 DIALOGS_GENERIC_DIR_CHOOSE
,
281 DIALOGS_MODELESS_BTN
,