]> git.saurik.com Git - wxWidgets.git/blob - samples/dialogs/dialogs.h
my revision of o-p interface headers
[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_WXGTK) \
81 && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
82 #define USE_FONTDLG_GENERIC \
83 ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
84
85 // Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
86 // between modal and modeless dialogs (ie. not implemented it in your port yet)
87 #if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL
88 #define USE_MODAL_PRESENTATION 0
89 #else
90 #define USE_MODAL_PRESENTATION 1
91 #endif
92
93
94 // Turn USE_SETTINGS_DIALOG to 0 if supported
95 #if wxUSE_BOOKCTRL
96 #define USE_SETTINGS_DIALOG 1
97 #else
98 #define USE_SETTINGS_DIALOG 0
99 #endif
100
101
102 // Define a new application type
103 class MyApp: public wxApp
104 {
105 public:
106 bool OnInit();
107
108 wxFont m_canvasFont;
109 wxColour m_canvasTextColour;
110 };
111
112 #if USE_MODAL_PRESENTATION
113
114 // A custom modeless dialog
115 class MyModelessDialog : public wxDialog
116 {
117 public:
118 MyModelessDialog(wxWindow *parent);
119
120 void OnButton(wxCommandEvent& event);
121 void OnClose(wxCloseEvent& event);
122
123 private:
124 DECLARE_EVENT_TABLE()
125 };
126
127 // A custom modal dialog
128 class MyModalDialog : public wxDialog
129 {
130 public:
131 MyModalDialog(wxWindow *parent);
132
133 void OnButton(wxCommandEvent& event);
134
135 private:
136 wxButton *m_btnModal,
137 *m_btnModeless,
138 *m_btnDelete;
139
140 DECLARE_EVENT_TABLE()
141 };
142
143 #endif // USE_MODAL_PRESENTATION
144
145 class StdButtonSizerDialog : public wxDialog
146 {
147 public:
148 StdButtonSizerDialog(wxWindow *parent);
149
150 void OnEvent(wxCommandEvent& event);
151
152 private:
153 void EnableDisableControls();
154
155 wxCheckBox *m_chkboxAffirmativeButton;
156 wxRadioButton *m_radiobtnOk,
157 *m_radiobtnYes;
158
159 wxCheckBox *m_chkboxDismissButton;
160 wxRadioButton *m_radiobtnClose,
161 *m_radiobtnCancel;
162
163 wxCheckBox *m_chkboxApply,
164 *m_chkboxNo,
165 *m_chkboxHelp,
166 *m_chkboxNoDefault;
167
168 wxSizer *m_buttonsSizer;
169
170 DECLARE_EVENT_TABLE()
171 };
172
173 class TestDefaultActionDialog: public wxDialog
174 {
175 public:
176 TestDefaultActionDialog( wxWindow *parent );
177
178 void OnListBoxDClick(wxCommandEvent& event);
179 void OnCatchListBoxDClick(wxCommandEvent& event);
180
181 private:
182 bool m_catchListBoxDClick;
183
184 private:
185 DECLARE_EVENT_TABLE()
186 };
187
188
189 #if USE_SETTINGS_DIALOG
190 // Property sheet dialog
191 class SettingsDialog: public wxPropertySheetDialog
192 {
193 DECLARE_CLASS(SettingsDialog)
194 public:
195 SettingsDialog(wxWindow* parent, int dialogType);
196 ~SettingsDialog();
197
198 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
199 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
200
201 protected:
202
203 enum {
204 ID_SHOW_TOOLTIPS = 100,
205 ID_AUTO_SAVE,
206 ID_AUTO_SAVE_MINS,
207 ID_LOAD_LAST_PROJECT,
208
209 ID_APPLY_SETTINGS_TO,
210 ID_BACKGROUND_STYLE,
211 ID_FONT_SIZE
212 };
213
214 wxImageList* m_imageList;
215
216 DECLARE_EVENT_TABLE()
217 };
218
219 #endif // USE_SETTINGS_DIALOG
220
221 // Define a new frame type
222 class MyFrame: public wxFrame
223 {
224 public:
225 MyFrame(wxWindow *parent, const wxString& title);
226 virtual ~MyFrame();
227
228 #if wxUSE_MSGDLG
229 void MessageBox(wxCommandEvent& event);
230 void MessageBoxInfo(wxCommandEvent& event);
231 #endif // wxUSE_MSGDLG
232
233 #if wxUSE_COLOURDLG
234 void ChooseColour(wxCommandEvent& event);
235 void GetColour(wxCommandEvent& event);
236 #endif // wxUSE_COLOURDLG
237
238 #if wxUSE_FONTDLG
239 void ChooseFont(wxCommandEvent& event);
240 #endif // wxUSE_FONTDLG
241
242 #if wxUSE_LOG_DIALOG
243 void LogDialog(wxCommandEvent& event);
244 #endif // wxUSE_LOG_DIALOG
245
246 #if wxUSE_CHOICEDLG
247 void SingleChoice(wxCommandEvent& event);
248 void MultiChoice(wxCommandEvent& event);
249 #endif // wxUSE_CHOICEDLG
250
251 #if wxUSE_TEXTDLG
252 void TextEntry(wxCommandEvent& event);
253 void PasswordEntry(wxCommandEvent& event);
254 #endif // wxUSE_TEXTDLG
255
256 #if wxUSE_NUMBERDLG
257 void NumericEntry(wxCommandEvent& event);
258 #endif // wxUSE_NUMBERDLG
259
260 #if wxUSE_FILEDLG
261 void FileOpen(wxCommandEvent& event);
262 void FileOpen2(wxCommandEvent& event);
263 void FilesOpen(wxCommandEvent& event);
264 void FileSave(wxCommandEvent& event);
265 #endif // wxUSE_FILEDLG
266
267 #if USE_FILEDLG_GENERIC
268 void FileOpenGeneric(wxCommandEvent& event);
269 void FilesOpenGeneric(wxCommandEvent& event);
270 void FileSaveGeneric(wxCommandEvent& event);
271 #endif // USE_FILEDLG_GENERIC
272
273 #if wxUSE_DIRDLG
274 void DirChoose(wxCommandEvent& event);
275 void DirChooseNew(wxCommandEvent& event);
276 #endif // wxUSE_DIRDLG
277
278 #if USE_DIRDLG_GENERIC
279 void GenericDirChoose(wxCommandEvent& event);
280 #endif // USE_DIRDLG_GENERIC
281
282 #if wxUSE_STARTUP_TIPS
283 void ShowTip(wxCommandEvent& event);
284 #endif // wxUSE_STARTUP_TIPS
285
286 #if USE_MODAL_PRESENTATION
287 void ModalDlg(wxCommandEvent& event);
288 #endif // USE_MODAL_PRESENTATION
289 void ModelessDlg(wxCommandEvent& event);
290 void DlgCenteredScreen(wxCommandEvent& event);
291 void DlgCenteredParent(wxCommandEvent& event);
292 void MiniFrame(wxCommandEvent& event);
293 void DlgOnTop(wxCommandEvent& event);
294
295 #if wxUSE_PROGRESSDLG
296 void ShowProgress(wxCommandEvent& event);
297 #endif // wxUSE_PROGRESSDLG
298
299 #if wxUSE_ABOUTDLG
300 void ShowSimpleAboutDialog(wxCommandEvent& event);
301 void ShowFancyAboutDialog(wxCommandEvent& event);
302 void ShowFullAboutDialog(wxCommandEvent& event);
303 void ShowCustomAboutDialog(wxCommandEvent& event);
304 #endif // wxUSE_ABOUTDLG
305
306 #if wxUSE_BUSYINFO
307 void ShowBusyInfo(wxCommandEvent& event);
308 #endif // wxUSE_BUSYINFO
309
310 #if wxUSE_FINDREPLDLG
311 void ShowFindDialog(wxCommandEvent& event);
312 void ShowReplaceDialog(wxCommandEvent& event);
313 void OnFindDialog(wxFindDialogEvent& event);
314 #endif // wxUSE_FINDREPLDLG
315
316 #if USE_COLOURDLG_GENERIC
317 void ChooseColourGeneric(wxCommandEvent& event);
318 #endif // USE_COLOURDLG_GENERIC
319
320 #if USE_FONTDLG_GENERIC
321 void ChooseFontGeneric(wxCommandEvent& event);
322 #endif // USE_FONTDLG_GENERIC
323
324 void OnPropertySheet(wxCommandEvent& event);
325
326 void OnRequestUserAttention(wxCommandEvent& event);
327 #if wxUSE_NOTIFICATION_MESSAGE
328 void OnNotifMsgAuto(wxCommandEvent& event);
329 void OnNotifMsgShow(wxCommandEvent& event);
330 void OnNotifMsgHide(wxCommandEvent& event);
331 #endif // wxUSE_NOTIFICATION_MESSAGE
332
333 void OnStandardButtonsSizerDialog(wxCommandEvent& event);
334
335 void OnTestDefaultActionDialog(wxCommandEvent& event);
336
337 void OnExit(wxCommandEvent& event);
338
339 private:
340 #if wxUSE_DIRDLG
341 void DoDirChoose(int style);
342 #endif // wxUSE_DIRDLG
343
344 #if USE_MODAL_PRESENTATION
345 MyModelessDialog *m_dialog;
346 #endif // USE_MODAL_PRESENTATION
347
348 #if wxUSE_FINDREPLDLG
349 wxFindReplaceData m_findData;
350
351 wxFindReplaceDialog *m_dlgFind,
352 *m_dlgReplace;
353 #endif // wxUSE_FINDREPLDLG
354
355 #if wxUSE_NOTIFICATION_MESSAGE
356 wxNotificationMessage *m_notifMsg;
357 #endif // wxUSE_NOTIFICATION_MESSAGE
358
359 wxColourData m_clrData;
360
361 DECLARE_EVENT_TABLE()
362 };
363
364 class MyCanvas: public wxScrolledWindow
365 {
366 public:
367 MyCanvas(wxWindow *parent) :
368 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
369
370 void OnPaint(wxPaintEvent& event);
371
372 DECLARE_EVENT_TABLE()
373 };
374
375
376 // Menu IDs
377 enum
378 {
379 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
380 DIALOGS_GET_COLOUR,
381 DIALOGS_CHOOSE_COLOUR_GENERIC,
382 DIALOGS_CHOOSE_FONT,
383 DIALOGS_CHOOSE_FONT_GENERIC,
384 DIALOGS_MESSAGE_BOX,
385 DIALOGS_MESSAGE_BOX_WXINFO,
386 DIALOGS_SINGLE_CHOICE,
387 DIALOGS_MULTI_CHOICE,
388 DIALOGS_TEXT_ENTRY,
389 DIALOGS_PASSWORD_ENTRY,
390 DIALOGS_FILE_OPEN,
391 DIALOGS_FILE_OPEN2,
392 DIALOGS_FILES_OPEN,
393 DIALOGS_FILE_SAVE,
394 DIALOGS_FILE_OPEN_GENERIC,
395 DIALOGS_FILES_OPEN_GENERIC,
396 DIALOGS_FILE_SAVE_GENERIC,
397 DIALOGS_DIR_CHOOSE,
398 DIALOGS_DIRNEW_CHOOSE,
399 DIALOGS_GENERIC_DIR_CHOOSE,
400 DIALOGS_TIP,
401 DIALOGS_NUM_ENTRY,
402 DIALOGS_LOG_DIALOG,
403 DIALOGS_MODAL,
404 DIALOGS_MODELESS,
405 DIALOGS_CENTRE_SCREEN,
406 DIALOGS_CENTRE_PARENT,
407 DIALOGS_MINIFRAME,
408 DIALOGS_ONTOP,
409 DIALOGS_MODELESS_BTN,
410 DIALOGS_PROGRESS,
411 DIALOGS_ABOUTDLG_SIMPLE,
412 DIALOGS_ABOUTDLG_FANCY,
413 DIALOGS_ABOUTDLG_FULL,
414 DIALOGS_ABOUTDLG_CUSTOM,
415 DIALOGS_BUSYINFO,
416 DIALOGS_FIND,
417 DIALOGS_REPLACE,
418 DIALOGS_REQUEST,
419 DIALOGS_NOTIFY_AUTO,
420 DIALOGS_NOTIFY_SHOW,
421 DIALOGS_NOTIFY_HIDE,
422 DIALOGS_PROPERTY_SHEET,
423 DIALOGS_PROPERTY_SHEET_TOOLBOOK,
424 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK,
425 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG,
426 DIALOGS_TEST_DEFAULT_ACTION
427 };
428
429 #endif
430