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__)
61 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
63 #define USE_COLOURDLG_GENERIC \
64 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
65 #define USE_DIRDLG_GENERIC \
66 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
67 #define USE_FILEDLG_GENERIC \
68 ((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG)
69 #define USE_FONTDLG_GENERIC \
70 ((USE_WXMSW || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
73 // Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
74 // between modal and modeless dialogs (ie. not implemented it in your port yet)
75 #if defined(__SMARTPHONE__)
76 #define USE_MODAL_PRESENTATION 0
78 #define USE_MODAL_PRESENTATION 1
82 // Define a new application type
83 class MyApp
: public wxApp
89 wxColour m_canvasTextColour
;
92 #if USE_MODAL_PRESENTATION
94 // A custom modeless dialog
95 class MyModelessDialog
: public wxDialog
98 MyModelessDialog(wxWindow
*parent
);
100 void OnButton(wxCommandEvent
& event
);
101 void OnClose(wxCloseEvent
& event
);
104 DECLARE_EVENT_TABLE()
107 // A custom modal dialog
108 class MyModalDialog
: public wxDialog
111 MyModalDialog(wxWindow
*parent
);
113 void OnButton(wxCommandEvent
& event
);
116 wxButton
*m_btnModal
,
120 DECLARE_EVENT_TABLE()
123 #endif // USE_MODAL_PRESENTATION
125 // Define a new frame type
126 class MyFrame
: public wxFrame
129 MyFrame(wxWindow
*parent
, const wxString
& title
);
131 void MessageBox(wxCommandEvent
& event
);
134 void ChooseColour(wxCommandEvent
& event
);
135 #endif // wxUSE_COLOURDLG
138 void ChooseFont(wxCommandEvent
& event
);
139 #endif // wxUSE_FONTDLG
142 void LogDialog(wxCommandEvent
& event
);
143 #endif // wxUSE_LOG_DIALOG
146 void SingleChoice(wxCommandEvent
& event
);
147 void MultiChoice(wxCommandEvent
& event
);
148 #endif // wxUSE_CHOICEDLG
151 void TextEntry(wxCommandEvent
& event
);
152 void PasswordEntry(wxCommandEvent
& event
);
153 #endif // wxUSE_TEXTDLG
156 void NumericEntry(wxCommandEvent
& event
);
157 #endif // wxUSE_NUMBERDLG
160 void FileOpen(wxCommandEvent
& event
);
161 void FileOpen2(wxCommandEvent
& event
);
162 void FilesOpen(wxCommandEvent
& event
);
163 void FileSave(wxCommandEvent
& event
);
164 #endif // wxUSE_FILEDLG
166 #if USE_FILEDLG_GENERIC
167 void FileOpenGeneric(wxCommandEvent
& event
);
168 void FilesOpenGeneric(wxCommandEvent
& event
);
169 void FileSaveGeneric(wxCommandEvent
& event
);
170 #endif // USE_FILEDLG_GENERIC
173 void DirChoose(wxCommandEvent
& event
);
174 void DirChooseNew(wxCommandEvent
& event
);
175 #endif // wxUSE_DIRDLG
177 #if USE_DIRDLG_GENERIC
178 void GenericDirChoose(wxCommandEvent
& event
);
179 #endif // USE_DIRDLG_GENERIC
181 #if wxUSE_STARTUP_TIPS
182 void ShowTip(wxCommandEvent
& event
);
183 #endif // wxUSE_STARTUP_TIPS
185 #if USE_MODAL_PRESENTATION
186 void ModalDlg(wxCommandEvent
& event
);
187 void ModelessDlg(wxCommandEvent
& event
);
188 #endif // USE_MODAL_PRESENTATION
190 #if wxUSE_PROGRESSDLG
191 void ShowProgress(wxCommandEvent
& event
);
192 #endif // wxUSE_PROGRESSDLG
195 void ShowBusyInfo(wxCommandEvent
& event
);
196 #endif // wxUSE_BUSYINFO
198 #if wxUSE_FINDREPLDLG
199 void ShowFindDialog(wxCommandEvent
& event
);
200 void ShowReplaceDialog(wxCommandEvent
& event
);
201 void OnFindDialog(wxFindDialogEvent
& event
);
202 #endif // wxUSE_FINDREPLDLG
204 #if USE_COLOURDLG_GENERIC
205 void ChooseColourGeneric(wxCommandEvent
& event
);
206 #endif // USE_COLOURDLG_GENERIC
208 #if USE_FONTDLG_GENERIC
209 void ChooseFontGeneric(wxCommandEvent
& event
);
210 #endif // USE_FONTDLG_GENERIC
212 void OnRequestUserAttention(wxCommandEvent
& event
);
213 void OnExit(wxCommandEvent
& event
);
217 void DoDirChoose(int style
);
218 #endif // wxUSE_DIRDLG
220 #if USE_MODAL_PRESENTATION
221 MyModelessDialog
*m_dialog
;
222 #endif // USE_MODAL_PRESENTATION
224 #if wxUSE_FINDREPLDLG
225 wxFindReplaceData m_findData
;
227 wxFindReplaceDialog
*m_dlgFind
,
229 #endif // wxUSE_FINDREPLDLG
231 wxColourData m_clrData
;
233 DECLARE_EVENT_TABLE()
236 class MyCanvas
: public wxScrolledWindow
239 MyCanvas(wxWindow
*parent
) :
240 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
242 void OnPaint(wxPaintEvent
& event
);
244 DECLARE_EVENT_TABLE()
251 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
252 DIALOGS_CHOOSE_COLOUR_GENERIC
,
254 DIALOGS_CHOOSE_FONT_GENERIC
,
256 DIALOGS_SINGLE_CHOICE
,
257 DIALOGS_MULTI_CHOICE
,
259 DIALOGS_PASSWORD_ENTRY
,
264 DIALOGS_FILE_OPEN_GENERIC
,
265 DIALOGS_FILES_OPEN_GENERIC
,
266 DIALOGS_FILE_SAVE_GENERIC
,
268 DIALOGS_DIRNEW_CHOOSE
,
269 DIALOGS_GENERIC_DIR_CHOOSE
,
275 DIALOGS_MODELESS_BTN
,