initial implementation of wxAboutBox()
[wxWidgets.git] / samples / dialogs / dialogs.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dialogs.h
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart
5 // Modified by: ABX (2004) - adjustementd for conditional building
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 /*
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
19 of MSW, MAC and OS2
20 */
21
22 #ifndef __DIALOGSH__
23 #define __DIALOGSH__
24
25 #ifdef __WXUNIVERSAL__
26 #define USE_WXUNIVERSAL 1
27 #else
28 #define USE_WXUNIVERSAL 0
29 #endif
30
31 #ifdef WXUSINGDLL
32 #define USE_DLL 1
33 #else
34 #define USE_DLL 0
35 #endif
36
37 #if defined(__WXWINCE__)
38 #define USE_WXWINCE 1
39 #else
40 #define USE_WXWINCE 0
41 #endif
42
43 #if defined(__WXMSW__) && !USE_WXWINCE
44 #define USE_WXMSW 1
45 #else
46 #define USE_WXMSW 0
47 #endif
48
49 #ifdef __WXMAC__
50 #define USE_WXMAC 1
51 #else
52 #define USE_WXMAC 0
53 #endif
54
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
57 #else
58 #define USE_WXMACFONTDLG 0
59 #endif
60
61 #ifdef __WXGTK__
62 #define USE_WXGTK 1
63 #else
64 #define USE_WXGTK 0
65 #endif
66
67 #ifdef __WXPM__
68 #define USE_WXPM 1
69 #else
70 #define USE_WXPM 0
71 #endif
72
73 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
74
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)
83
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
88 #else
89 #define USE_MODAL_PRESENTATION 1
90 #endif
91
92
93 // Turn USE_SETTINGS_DIALOG to 0 if supported
94 #if wxUSE_BOOKCTRL
95 #define USE_SETTINGS_DIALOG 1
96 #else
97 #define USE_SETTINGS_DIALOG 0
98 #endif
99
100
101 // Define a new application type
102 class MyApp: public wxApp
103 {
104 public:
105 bool OnInit();
106
107 wxFont m_canvasFont;
108 wxColour m_canvasTextColour;
109 };
110
111 #if USE_MODAL_PRESENTATION
112
113 // A custom modeless dialog
114 class MyModelessDialog : public wxDialog
115 {
116 public:
117 MyModelessDialog(wxWindow *parent);
118
119 void OnButton(wxCommandEvent& event);
120 void OnClose(wxCloseEvent& event);
121
122 private:
123 DECLARE_EVENT_TABLE()
124 };
125
126 // A custom modal dialog
127 class MyModalDialog : public wxDialog
128 {
129 public:
130 MyModalDialog(wxWindow *parent);
131
132 void OnButton(wxCommandEvent& event);
133
134 private:
135 wxButton *m_btnModal,
136 *m_btnModeless,
137 *m_btnDelete;
138
139 DECLARE_EVENT_TABLE()
140 };
141
142 #endif // USE_MODAL_PRESENTATION
143
144 #if USE_SETTINGS_DIALOG
145 // Property sheet dialog
146 class SettingsDialog: public wxPropertySheetDialog
147 {
148 DECLARE_CLASS(SettingsDialog)
149 public:
150 SettingsDialog(wxWindow* parent, int dialogType);
151 ~SettingsDialog();
152
153 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
154 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
155
156 protected:
157
158 enum {
159 ID_SHOW_TOOLTIPS = 100,
160 ID_AUTO_SAVE,
161 ID_AUTO_SAVE_MINS,
162 ID_LOAD_LAST_PROJECT,
163
164 ID_APPLY_SETTINGS_TO,
165 ID_BACKGROUND_STYLE,
166 ID_FONT_SIZE
167 };
168
169 wxImageList* m_imageList;
170
171 DECLARE_EVENT_TABLE()
172 };
173
174 #endif // USE_SETTINGS_DIALOG
175
176 // Define a new frame type
177 class MyFrame: public wxFrame
178 {
179 public:
180 MyFrame(wxWindow *parent, const wxString& title);
181
182 void MessageBox(wxCommandEvent& event);
183
184 #if wxUSE_COLOURDLG
185 void ChooseColour(wxCommandEvent& event);
186 #endif // wxUSE_COLOURDLG
187
188 #if wxUSE_FONTDLG
189 void ChooseFont(wxCommandEvent& event);
190 #endif // wxUSE_FONTDLG
191
192 #if wxUSE_LOG_DIALOG
193 void LogDialog(wxCommandEvent& event);
194 #endif // wxUSE_LOG_DIALOG
195
196 #if wxUSE_CHOICEDLG
197 void SingleChoice(wxCommandEvent& event);
198 void MultiChoice(wxCommandEvent& event);
199 #endif // wxUSE_CHOICEDLG
200
201 #if wxUSE_TEXTDLG
202 void TextEntry(wxCommandEvent& event);
203 void PasswordEntry(wxCommandEvent& event);
204 #endif // wxUSE_TEXTDLG
205
206 #if wxUSE_NUMBERDLG
207 void NumericEntry(wxCommandEvent& event);
208 #endif // wxUSE_NUMBERDLG
209
210 #if wxUSE_FILEDLG
211 void FileOpen(wxCommandEvent& event);
212 void FileOpen2(wxCommandEvent& event);
213 void FilesOpen(wxCommandEvent& event);
214 void FileSave(wxCommandEvent& event);
215 #endif // wxUSE_FILEDLG
216
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
222
223 #if wxUSE_DIRDLG
224 void DirChoose(wxCommandEvent& event);
225 void DirChooseNew(wxCommandEvent& event);
226 #endif // wxUSE_DIRDLG
227
228 #if USE_DIRDLG_GENERIC
229 void GenericDirChoose(wxCommandEvent& event);
230 #endif // USE_DIRDLG_GENERIC
231
232 #if wxUSE_STARTUP_TIPS
233 void ShowTip(wxCommandEvent& event);
234 #endif // wxUSE_STARTUP_TIPS
235
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
242
243 #if wxUSE_PROGRESSDLG
244 void ShowProgress(wxCommandEvent& event);
245 #endif // wxUSE_PROGRESSDLG
246
247 #if wxUSE_ABOUTDLG
248 void ShowSimpleAboutDialog(wxCommandEvent& event);
249 void ShowFancyAboutDialog(wxCommandEvent& event);
250 #endif // wxUSE_ABOUTDLG
251
252 #if wxUSE_BUSYINFO
253 void ShowBusyInfo(wxCommandEvent& event);
254 #endif // wxUSE_BUSYINFO
255
256 #if wxUSE_FINDREPLDLG
257 void ShowFindDialog(wxCommandEvent& event);
258 void ShowReplaceDialog(wxCommandEvent& event);
259 void OnFindDialog(wxFindDialogEvent& event);
260 #endif // wxUSE_FINDREPLDLG
261
262 #if USE_COLOURDLG_GENERIC
263 void ChooseColourGeneric(wxCommandEvent& event);
264 #endif // USE_COLOURDLG_GENERIC
265
266 #if USE_FONTDLG_GENERIC
267 void ChooseFontGeneric(wxCommandEvent& event);
268 #endif // USE_FONTDLG_GENERIC
269
270 void OnPropertySheet(wxCommandEvent& event);
271 void OnRequestUserAttention(wxCommandEvent& event);
272 void OnExit(wxCommandEvent& event);
273
274 private:
275 #if wxUSE_DIRDLG
276 void DoDirChoose(int style);
277 #endif // wxUSE_DIRDLG
278
279 #if USE_MODAL_PRESENTATION
280 MyModelessDialog *m_dialog;
281 #endif // USE_MODAL_PRESENTATION
282
283 #if wxUSE_FINDREPLDLG
284 wxFindReplaceData m_findData;
285
286 wxFindReplaceDialog *m_dlgFind,
287 *m_dlgReplace;
288 #endif // wxUSE_FINDREPLDLG
289
290 wxColourData m_clrData;
291
292 DECLARE_EVENT_TABLE()
293 };
294
295 class MyCanvas: public wxScrolledWindow
296 {
297 public:
298 MyCanvas(wxWindow *parent) :
299 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
300
301 void OnPaint(wxPaintEvent& event);
302
303 DECLARE_EVENT_TABLE()
304 };
305
306
307 // Menu IDs
308 enum
309 {
310 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
311 DIALOGS_CHOOSE_COLOUR_GENERIC,
312 DIALOGS_CHOOSE_FONT,
313 DIALOGS_CHOOSE_FONT_GENERIC,
314 DIALOGS_MESSAGE_BOX,
315 DIALOGS_SINGLE_CHOICE,
316 DIALOGS_MULTI_CHOICE,
317 DIALOGS_TEXT_ENTRY,
318 DIALOGS_PASSWORD_ENTRY,
319 DIALOGS_FILE_OPEN,
320 DIALOGS_FILE_OPEN2,
321 DIALOGS_FILES_OPEN,
322 DIALOGS_FILE_SAVE,
323 DIALOGS_FILE_OPEN_GENERIC,
324 DIALOGS_FILES_OPEN_GENERIC,
325 DIALOGS_FILE_SAVE_GENERIC,
326 DIALOGS_DIR_CHOOSE,
327 DIALOGS_DIRNEW_CHOOSE,
328 DIALOGS_GENERIC_DIR_CHOOSE,
329 DIALOGS_TIP,
330 DIALOGS_NUM_ENTRY,
331 DIALOGS_LOG_DIALOG,
332 DIALOGS_MODAL,
333 DIALOGS_MODELESS,
334 DIALOGS_CENTRE_SCREEN,
335 DIALOGS_CENTRE_PARENT,
336 DIALOGS_MODELESS_BTN,
337 DIALOGS_PROGRESS,
338 DIALOGS_ABOUTDLG_SIMPLE,
339 DIALOGS_ABOUTDLG_FANCY,
340 DIALOGS_BUSYINFO,
341 DIALOGS_FIND,
342 DIALOGS_REPLACE,
343 DIALOGS_REQUEST,
344 DIALOGS_PROPERTY_SHEET,
345 DIALOGS_PROPERTY_SHEET_TOOLBOOK,
346 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
347 };
348
349 #endif
350