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 to 0 if there is any reason for not presenting difference between
74 // modal and modeless dialogs (ie. not implemented it in your port yet)
75 #define USE_MODAL_PRESENTATION 1
78 // Define a new application type
79 class MyApp
: public wxApp
85 wxColour m_canvasTextColour
;
88 #if USE_MODAL_PRESENTATION
90 // A custom modeless dialog
91 class MyModelessDialog
: public wxDialog
94 MyModelessDialog(wxWindow
*parent
);
96 void OnButton(wxCommandEvent
& event
);
97 void OnClose(wxCloseEvent
& event
);
100 DECLARE_EVENT_TABLE()
103 // A custom modal dialog
104 class MyModalDialog
: public wxDialog
107 MyModalDialog(wxWindow
*parent
);
109 void OnButton(wxCommandEvent
& event
);
112 wxButton
*m_btnModal
,
116 DECLARE_EVENT_TABLE()
119 #endif // USE_MODAL_PRESENTATION
121 // Define a new frame type
122 class MyFrame
: public wxFrame
125 MyFrame(wxWindow
*parent
, const wxString
& title
);
127 void MessageBox(wxCommandEvent
& event
);
130 void ChooseColour(wxCommandEvent
& event
);
131 #endif // wxUSE_COLOURDLG
134 void ChooseFont(wxCommandEvent
& event
);
135 #endif // wxUSE_FONTDLG
138 void LogDialog(wxCommandEvent
& event
);
139 #endif // wxUSE_LOG_DIALOG
142 void SingleChoice(wxCommandEvent
& event
);
143 void MultiChoice(wxCommandEvent
& event
);
144 #endif // wxUSE_CHOICEDLG
147 void TextEntry(wxCommandEvent
& event
);
148 void PasswordEntry(wxCommandEvent
& event
);
149 #endif // wxUSE_TEXTDLG
152 void NumericEntry(wxCommandEvent
& event
);
153 #endif // wxUSE_NUMBERDLG
156 void FileOpen(wxCommandEvent
& event
);
157 void FileOpen2(wxCommandEvent
& event
);
158 void FilesOpen(wxCommandEvent
& event
);
159 void FileSave(wxCommandEvent
& event
);
160 #endif // wxUSE_FILEDLG
162 #if USE_FILEDLG_GENERIC
163 void FileOpenGeneric(wxCommandEvent
& event
);
164 void FilesOpenGeneric(wxCommandEvent
& event
);
165 void FileSaveGeneric(wxCommandEvent
& event
);
166 #endif // USE_FILEDLG_GENERIC
169 void DirChoose(wxCommandEvent
& event
);
170 void DirChooseNew(wxCommandEvent
& event
);
171 #endif // wxUSE_DIRDLG
173 #if USE_DIRDLG_GENERIC
174 void GenericDirChoose(wxCommandEvent
& event
);
175 #endif // USE_DIRDLG_GENERIC
177 #if wxUSE_STARTUP_TIPS
178 void ShowTip(wxCommandEvent
& event
);
179 #endif // wxUSE_STARTUP_TIPS
181 #if USE_MODAL_PRESENTATION
182 void ModalDlg(wxCommandEvent
& event
);
183 void ModelessDlg(wxCommandEvent
& event
);
184 #endif // USE_MODAL_PRESENTATION
186 #if wxUSE_PROGRESSDLG
187 void ShowProgress(wxCommandEvent
& event
);
188 #endif // wxUSE_PROGRESSDLG
191 void ShowBusyInfo(wxCommandEvent
& event
);
192 #endif // wxUSE_BUSYINFO
194 #if wxUSE_FINDREPLDLG
195 void ShowFindDialog(wxCommandEvent
& event
);
196 void ShowReplaceDialog(wxCommandEvent
& event
);
197 void OnFindDialog(wxFindDialogEvent
& event
);
198 #endif // wxUSE_FINDREPLDLG
200 #if USE_COLOURDLG_GENERIC
201 void ChooseColourGeneric(wxCommandEvent
& event
);
202 #endif // USE_COLOURDLG_GENERIC
204 #if USE_FONTDLG_GENERIC
205 void ChooseFontGeneric(wxCommandEvent
& event
);
206 #endif // USE_FONTDLG_GENERIC
208 void OnRequestUserAttention(wxCommandEvent
& event
);
209 void OnExit(wxCommandEvent
& event
);
213 void DoDirChoose(int style
);
214 #endif // wxUSE_DIRDLG
216 #if USE_MODAL_PRESENTATION
217 MyModelessDialog
*m_dialog
;
218 #endif // USE_MODAL_PRESENTATION
220 #if wxUSE_FINDREPLDLG
221 wxFindReplaceData m_findData
;
223 wxFindReplaceDialog
*m_dlgFind
,
225 #endif // wxUSE_FINDREPLDLG
227 wxColourData m_clrData
;
229 DECLARE_EVENT_TABLE()
232 class MyCanvas
: public wxScrolledWindow
235 MyCanvas(wxWindow
*parent
) :
236 wxScrolledWindow(parent
,wxID_ANY
,wxDefaultPosition
,wxDefaultSize
,wxNO_FULL_REPAINT_ON_RESIZE
) { }
238 void OnPaint(wxPaintEvent
& event
);
240 DECLARE_EVENT_TABLE()
247 DIALOGS_CHOOSE_COLOUR
= wxID_HIGHEST
,
248 DIALOGS_CHOOSE_COLOUR_GENERIC
,
250 DIALOGS_CHOOSE_FONT_GENERIC
,
252 DIALOGS_SINGLE_CHOICE
,
253 DIALOGS_MULTI_CHOICE
,
255 DIALOGS_PASSWORD_ENTRY
,
260 DIALOGS_FILE_OPEN_GENERIC
,
261 DIALOGS_FILES_OPEN_GENERIC
,
262 DIALOGS_FILE_SAVE_GENERIC
,
264 DIALOGS_DIRNEW_CHOOSE
,
265 DIALOGS_GENERIC_DIR_CHOOSE
,
271 DIALOGS_MODELESS_BTN
,