Added wxPropertySheetDialog demo
[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(__WXMSW__) && !defined(__WXWINCE__)
38 #define USE_WXMSW 1
39 #else
40 #define USE_WXMSW 0
41 #endif
42
43 #ifdef __WXMAC__
44 #define USE_WXMAC 1
45 #else
46 #define USE_WXMAC 0
47 #endif
48
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
51 #else
52 #define USE_WXMACFONTDLG 0
53 #endif
54
55 #ifdef __WXGTK__
56 #define USE_WXGTK 1
57 #else
58 #define USE_WXGTK 0
59 #endif
60
61 #ifdef __WXPM__
62 #define USE_WXPM 1
63 #else
64 #define USE_WXPM 0
65 #endif
66
67 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
68
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)
77
78
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
83 #else
84 #define USE_MODAL_PRESENTATION 1
85 #endif
86
87
88 // Define a new application type
89 class MyApp: public wxApp
90 {
91 public:
92 bool OnInit();
93
94 wxFont m_canvasFont;
95 wxColour m_canvasTextColour;
96 };
97
98 #if USE_MODAL_PRESENTATION
99
100 // A custom modeless dialog
101 class MyModelessDialog : public wxDialog
102 {
103 public:
104 MyModelessDialog(wxWindow *parent);
105
106 void OnButton(wxCommandEvent& event);
107 void OnClose(wxCloseEvent& event);
108
109 private:
110 DECLARE_EVENT_TABLE()
111 };
112
113 // A custom modal dialog
114 class MyModalDialog : public wxDialog
115 {
116 public:
117 MyModalDialog(wxWindow *parent);
118
119 void OnButton(wxCommandEvent& event);
120
121 private:
122 wxButton *m_btnModal,
123 *m_btnModeless,
124 *m_btnDelete;
125
126 DECLARE_EVENT_TABLE()
127 };
128
129 #endif // USE_MODAL_PRESENTATION
130
131 // Property sheet dialog
132 class SettingsDialog: public wxPropertySheetDialog
133 {
134 DECLARE_CLASS(SettingsDialog)
135 public:
136 SettingsDialog(wxWindow* parent);
137
138 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
139 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
140
141 protected:
142
143 enum {
144 ID_SHOW_TOOLTIPS = 100,
145 ID_AUTO_SAVE,
146 ID_AUTO_SAVE_MINS,
147 ID_LOAD_LAST_PROJECT,
148
149 ID_APPLY_SETTINGS_TO,
150 ID_BACKGROUND_STYLE,
151 ID_FONT_SIZE
152 };
153
154 DECLARE_EVENT_TABLE()
155 };
156
157 // Define a new frame type
158 class MyFrame: public wxFrame
159 {
160 public:
161 MyFrame(wxWindow *parent, const wxString& title);
162
163 void MessageBox(wxCommandEvent& event);
164
165 #if wxUSE_COLOURDLG
166 void ChooseColour(wxCommandEvent& event);
167 #endif // wxUSE_COLOURDLG
168
169 #if wxUSE_FONTDLG
170 void ChooseFont(wxCommandEvent& event);
171 #endif // wxUSE_FONTDLG
172
173 #if wxUSE_LOG_DIALOG
174 void LogDialog(wxCommandEvent& event);
175 #endif // wxUSE_LOG_DIALOG
176
177 #if wxUSE_CHOICEDLG
178 void SingleChoice(wxCommandEvent& event);
179 void MultiChoice(wxCommandEvent& event);
180 #endif // wxUSE_CHOICEDLG
181
182 #if wxUSE_TEXTDLG
183 void TextEntry(wxCommandEvent& event);
184 void PasswordEntry(wxCommandEvent& event);
185 #endif // wxUSE_TEXTDLG
186
187 #if wxUSE_NUMBERDLG
188 void NumericEntry(wxCommandEvent& event);
189 #endif // wxUSE_NUMBERDLG
190
191 #if wxUSE_FILEDLG
192 void FileOpen(wxCommandEvent& event);
193 void FileOpen2(wxCommandEvent& event);
194 void FilesOpen(wxCommandEvent& event);
195 void FileSave(wxCommandEvent& event);
196 #endif // wxUSE_FILEDLG
197
198 #if USE_FILEDLG_GENERIC
199 void FileOpenGeneric(wxCommandEvent& event);
200 void FilesOpenGeneric(wxCommandEvent& event);
201 void FileSaveGeneric(wxCommandEvent& event);
202 #endif // USE_FILEDLG_GENERIC
203
204 #if wxUSE_DIRDLG
205 void DirChoose(wxCommandEvent& event);
206 void DirChooseNew(wxCommandEvent& event);
207 #endif // wxUSE_DIRDLG
208
209 #if USE_DIRDLG_GENERIC
210 void GenericDirChoose(wxCommandEvent& event);
211 #endif // USE_DIRDLG_GENERIC
212
213 #if wxUSE_STARTUP_TIPS
214 void ShowTip(wxCommandEvent& event);
215 #endif // wxUSE_STARTUP_TIPS
216
217 #if USE_MODAL_PRESENTATION
218 void ModalDlg(wxCommandEvent& event);
219 void ModelessDlg(wxCommandEvent& event);
220 #endif // USE_MODAL_PRESENTATION
221
222 #if wxUSE_PROGRESSDLG
223 void ShowProgress(wxCommandEvent& event);
224 #endif // wxUSE_PROGRESSDLG
225
226 #if wxUSE_BUSYINFO
227 void ShowBusyInfo(wxCommandEvent& event);
228 #endif // wxUSE_BUSYINFO
229
230 #if wxUSE_FINDREPLDLG
231 void ShowFindDialog(wxCommandEvent& event);
232 void ShowReplaceDialog(wxCommandEvent& event);
233 void OnFindDialog(wxFindDialogEvent& event);
234 #endif // wxUSE_FINDREPLDLG
235
236 #if USE_COLOURDLG_GENERIC
237 void ChooseColourGeneric(wxCommandEvent& event);
238 #endif // USE_COLOURDLG_GENERIC
239
240 #if USE_FONTDLG_GENERIC
241 void ChooseFontGeneric(wxCommandEvent& event);
242 #endif // USE_FONTDLG_GENERIC
243
244 void OnPropertySheet(wxCommandEvent& event);
245 void OnRequestUserAttention(wxCommandEvent& event);
246 void OnExit(wxCommandEvent& event);
247
248 private:
249 #if wxUSE_DIRDLG
250 void DoDirChoose(int style);
251 #endif // wxUSE_DIRDLG
252
253 #if USE_MODAL_PRESENTATION
254 MyModelessDialog *m_dialog;
255 #endif // USE_MODAL_PRESENTATION
256
257 #if wxUSE_FINDREPLDLG
258 wxFindReplaceData m_findData;
259
260 wxFindReplaceDialog *m_dlgFind,
261 *m_dlgReplace;
262 #endif // wxUSE_FINDREPLDLG
263
264 wxColourData m_clrData;
265
266 DECLARE_EVENT_TABLE()
267 };
268
269 class MyCanvas: public wxScrolledWindow
270 {
271 public:
272 MyCanvas(wxWindow *parent) :
273 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
274
275 void OnPaint(wxPaintEvent& event);
276
277 DECLARE_EVENT_TABLE()
278 };
279
280
281 // Menu IDs
282 enum
283 {
284 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
285 DIALOGS_CHOOSE_COLOUR_GENERIC,
286 DIALOGS_CHOOSE_FONT,
287 DIALOGS_CHOOSE_FONT_GENERIC,
288 DIALOGS_MESSAGE_BOX,
289 DIALOGS_SINGLE_CHOICE,
290 DIALOGS_MULTI_CHOICE,
291 DIALOGS_TEXT_ENTRY,
292 DIALOGS_PASSWORD_ENTRY,
293 DIALOGS_FILE_OPEN,
294 DIALOGS_FILE_OPEN2,
295 DIALOGS_FILES_OPEN,
296 DIALOGS_FILE_SAVE,
297 DIALOGS_FILE_OPEN_GENERIC,
298 DIALOGS_FILES_OPEN_GENERIC,
299 DIALOGS_FILE_SAVE_GENERIC,
300 DIALOGS_DIR_CHOOSE,
301 DIALOGS_DIRNEW_CHOOSE,
302 DIALOGS_GENERIC_DIR_CHOOSE,
303 DIALOGS_TIP,
304 DIALOGS_NUM_ENTRY,
305 DIALOGS_LOG_DIALOG,
306 DIALOGS_MODAL,
307 DIALOGS_MODELESS,
308 DIALOGS_MODELESS_BTN,
309 DIALOGS_PROGRESS,
310 DIALOGS_BUSYINFO,
311 DIALOGS_FIND,
312 DIALOGS_REPLACE,
313 DIALOGS_REQUEST,
314 DIALOGS_PROPERTY_SHEET
315 };
316
317 #endif
318