]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dialogs.h | |
3 | // Purpose: Common dialogs demo | |
4 | // Author: Julian Smart | |
13188def | 5 | // Modified by: ABX (2004) - adjustementd for conditional building |
457814b5 JS |
6 | // Created: 04/01/98 |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
c49245f8 | 9 | // Licence: wxWindows license |
457814b5 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
4c8fc4d6 | 12 | /* |
08375332 | 13 | This sample shows how to use the common dialogs available from wxWidgets. |
4c8fc4d6 WS |
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 | |
08375332 WS |
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 | |
4c8fc4d6 WS |
19 | of MSW, MAC and OS2 |
20 | */ | |
21 | ||
457814b5 JS |
22 | #ifndef __DIALOGSH__ |
23 | #define __DIALOGSH__ | |
24 | ||
da7a8602 WS |
25 | #ifdef __WXUNIVERSAL__ |
26 | #define USE_WXUNIVERSAL 1 | |
27 | #else | |
28 | #define USE_WXUNIVERSAL 0 | |
29 | #endif | |
30 | ||
f50ff87b WS |
31 | #ifdef WXUSINGDLL |
32 | #define USE_DLL 1 | |
33 | #else | |
34 | #define USE_DLL 0 | |
35 | #endif | |
36 | ||
684883e3 WS |
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 | |
da7a8602 WS |
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 | ||
cea9c5b1 | 55 | #if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX |
71622a68 RN |
56 | #define USE_WXMACFONTDLG 1 |
57 | #else | |
58 | #define USE_WXMACFONTDLG 0 | |
59 | #endif | |
60 | ||
da7a8602 WS |
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 | ||
29e3d1f9 | 73 | #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL) |
13188def | 74 | |
29e3d1f9 VZ |
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 \ | |
8ce68f7f VZ |
80 | ((((USE_WXMSW || USE_WXMAC || USE_WXPM || USE_WXGTK) \ |
81 | && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG) | |
29e3d1f9 | 82 | #define USE_FONTDLG_GENERIC \ |
684883e3 | 83 | ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG) |
4c8fc4d6 | 84 | |
08375332 WS |
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) | |
532d575b | 87 | #if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL |
08375332 WS |
88 | #define USE_MODAL_PRESENTATION 0 |
89 | #else | |
90 | #define USE_MODAL_PRESENTATION 1 | |
91 | #endif | |
4c8fc4d6 | 92 | |
13188def | 93 | |
532d575b WS |
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 | ||
457814b5 JS |
102 | // Define a new application type |
103 | class MyApp: public wxApp | |
c49245f8 VZ |
104 | { |
105 | public: | |
106 | bool OnInit(); | |
457814b5 JS |
107 | |
108 | wxFont m_canvasFont; | |
109 | wxColour m_canvasTextColour; | |
110 | }; | |
111 | ||
b4954d19 WS |
112 | #if USE_MODAL_PRESENTATION |
113 | ||
f6bcfd97 | 114 | // A custom modeless dialog |
4c45f240 VZ |
115 | class MyModelessDialog : public wxDialog |
116 | { | |
117 | public: | |
118 | MyModelessDialog(wxWindow *parent); | |
abceee76 | 119 | |
5d987909 | 120 | void OnButton(wxCommandEvent& event); |
abceee76 VZ |
121 | void OnClose(wxCloseEvent& event); |
122 | ||
123 | private: | |
124 | DECLARE_EVENT_TABLE() | |
4c45f240 VZ |
125 | }; |
126 | ||
f6bcfd97 BP |
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: | |
5315ebfa VZ |
136 | wxButton *m_btnModal, |
137 | *m_btnModeless, | |
138 | *m_btnDelete; | |
f6bcfd97 BP |
139 | |
140 | DECLARE_EVENT_TABLE() | |
141 | }; | |
142 | ||
b4954d19 WS |
143 | #endif // USE_MODAL_PRESENTATION |
144 | ||
8e1dac82 VZ |
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 | ||
a625c5b6 RR |
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 | ||
532d575b | 189 | #if USE_SETTINGS_DIALOG |
0f5d8ecf JS |
190 | // Property sheet dialog |
191 | class SettingsDialog: public wxPropertySheetDialog | |
192 | { | |
193 | DECLARE_CLASS(SettingsDialog) | |
194 | public: | |
64d3ed17 | 195 | SettingsDialog(wxWindow* parent, int dialogType); |
cc8bc5aa | 196 | ~SettingsDialog(); |
0f5d8ecf JS |
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 | ||
cc8bc5aa JS |
214 | wxImageList* m_imageList; |
215 | ||
0f5d8ecf JS |
216 | DECLARE_EVENT_TABLE() |
217 | }; | |
218 | ||
532d575b WS |
219 | #endif // USE_SETTINGS_DIALOG |
220 | ||
457814b5 JS |
221 | // Define a new frame type |
222 | class MyFrame: public wxFrame | |
c49245f8 VZ |
223 | { |
224 | public: | |
13188def | 225 | MyFrame(wxWindow *parent, const wxString& title); |
e36a1739 | 226 | virtual ~MyFrame(); |
13188def | 227 | |
8cf304f8 | 228 | #if wxUSE_MSGDLG |
13188def | 229 | void MessageBox(wxCommandEvent& event); |
8cf304f8 VZ |
230 | void MessageBoxInfo(wxCommandEvent& event); |
231 | #endif // wxUSE_MSGDLG | |
457814b5 | 232 | |
13188def | 233 | #if wxUSE_COLOURDLG |
329e86bf | 234 | void ChooseColour(wxCommandEvent& event); |
e6ef9ea4 | 235 | void GetColour(wxCommandEvent& event); |
13188def WS |
236 | #endif // wxUSE_COLOURDLG |
237 | ||
238 | #if wxUSE_FONTDLG | |
329e86bf | 239 | void ChooseFont(wxCommandEvent& event); |
13188def WS |
240 | #endif // wxUSE_FONTDLG |
241 | ||
242 | #if wxUSE_LOG_DIALOG | |
d93c719a | 243 | void LogDialog(wxCommandEvent& event); |
13188def WS |
244 | #endif // wxUSE_LOG_DIALOG |
245 | ||
246 | #if wxUSE_CHOICEDLG | |
457814b5 | 247 | void SingleChoice(wxCommandEvent& event); |
d6c9c1b7 | 248 | void MultiChoice(wxCommandEvent& event); |
13188def WS |
249 | #endif // wxUSE_CHOICEDLG |
250 | ||
251 | #if wxUSE_TEXTDLG | |
457814b5 | 252 | void TextEntry(wxCommandEvent& event); |
a294c6d5 | 253 | void PasswordEntry(wxCommandEvent& event); |
13188def WS |
254 | #endif // wxUSE_TEXTDLG |
255 | ||
256 | #if wxUSE_NUMBERDLG | |
c49245f8 | 257 | void NumericEntry(wxCommandEvent& event); |
13188def WS |
258 | #endif // wxUSE_NUMBERDLG |
259 | ||
260 | #if wxUSE_FILEDLG | |
457814b5 | 261 | void FileOpen(wxCommandEvent& event); |
35b45b33 | 262 | void FileOpen2(wxCommandEvent& event); |
c61f4f6d | 263 | void FilesOpen(wxCommandEvent& event); |
457814b5 | 264 | void FileSave(wxCommandEvent& event); |
13188def WS |
265 | #endif // wxUSE_FILEDLG |
266 | ||
695fe764 WS |
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 | ||
13188def | 273 | #if wxUSE_DIRDLG |
457814b5 | 274 | void DirChoose(wxCommandEvent& event); |
f09c8393 | 275 | void DirChooseNew(wxCommandEvent& event); |
13188def WS |
276 | #endif // wxUSE_DIRDLG |
277 | ||
278 | #if USE_DIRDLG_GENERIC | |
51a58d8b | 279 | void GenericDirChoose(wxCommandEvent& event); |
13188def WS |
280 | #endif // USE_DIRDLG_GENERIC |
281 | ||
282 | #if wxUSE_STARTUP_TIPS | |
c50f1fb9 | 283 | void ShowTip(wxCommandEvent& event); |
13188def WS |
284 | #endif // wxUSE_STARTUP_TIPS |
285 | ||
286 | #if USE_MODAL_PRESENTATION | |
f6bcfd97 | 287 | void ModalDlg(wxCommandEvent& event); |
1baa0a9d | 288 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 289 | void ModelessDlg(wxCommandEvent& event); |
cae50e6b VZ |
290 | void DlgCenteredScreen(wxCommandEvent& event); |
291 | void DlgCenteredParent(wxCommandEvent& event); | |
1baa0a9d | 292 | void MiniFrame(wxCommandEvent& event); |
8e5dbcdd | 293 | void DlgOnTop(wxCommandEvent& event); |
13188def | 294 | |
761989ff | 295 | #if wxUSE_PROGRESSDLG |
abceee76 | 296 | void ShowProgress(wxCommandEvent& event); |
761989ff | 297 | #endif // wxUSE_PROGRESSDLG |
13188def | 298 | |
ca7adbf8 VZ |
299 | #if wxUSE_ABOUTDLG |
300 | void ShowSimpleAboutDialog(wxCommandEvent& event); | |
301 | void ShowFancyAboutDialog(wxCommandEvent& event); | |
453c9e3b VZ |
302 | void ShowFullAboutDialog(wxCommandEvent& event); |
303 | void ShowCustomAboutDialog(wxCommandEvent& event); | |
ca7adbf8 VZ |
304 | #endif // wxUSE_ABOUTDLG |
305 | ||
a62b0bcc VZ |
306 | #if wxUSE_BUSYINFO |
307 | void ShowBusyInfo(wxCommandEvent& event); | |
308 | #endif // wxUSE_BUSYINFO | |
13188def | 309 | |
761989ff VZ |
310 | #if wxUSE_FINDREPLDLG |
311 | void ShowFindDialog(wxCommandEvent& event); | |
312 | void ShowReplaceDialog(wxCommandEvent& event); | |
761989ff VZ |
313 | void OnFindDialog(wxFindDialogEvent& event); |
314 | #endif // wxUSE_FINDREPLDLG | |
457814b5 | 315 | |
13188def | 316 | #if USE_COLOURDLG_GENERIC |
329e86bf | 317 | void ChooseColourGeneric(wxCommandEvent& event); |
13188def WS |
318 | #endif // USE_COLOURDLG_GENERIC |
319 | ||
320 | #if USE_FONTDLG_GENERIC | |
329e86bf | 321 | void ChooseFontGeneric(wxCommandEvent& event); |
13188def | 322 | #endif // USE_FONTDLG_GENERIC |
c49245f8 | 323 | |
0f5d8ecf | 324 | void OnPropertySheet(wxCommandEvent& event); |
e36a1739 | 325 | |
29e3d1f9 | 326 | void OnRequestUserAttention(wxCommandEvent& event); |
e36a1739 VZ |
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 | ||
8e1dac82 | 333 | void OnStandardButtonsSizerDialog(wxCommandEvent& event); |
a625c5b6 RR |
334 | |
335 | void OnTestDefaultActionDialog(wxCommandEvent& event); | |
336 | ||
329e86bf | 337 | void OnExit(wxCommandEvent& event); |
c49245f8 | 338 | |
4c45f240 | 339 | private: |
13188def | 340 | #if wxUSE_DIRDLG |
f09c8393 | 341 | void DoDirChoose(int style); |
13188def | 342 | #endif // wxUSE_DIRDLG |
f09c8393 | 343 | |
13188def | 344 | #if USE_MODAL_PRESENTATION |
4c45f240 | 345 | MyModelessDialog *m_dialog; |
13188def | 346 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 347 | |
761989ff VZ |
348 | #if wxUSE_FINDREPLDLG |
349 | wxFindReplaceData m_findData; | |
14fca738 VZ |
350 | |
351 | wxFindReplaceDialog *m_dlgFind, | |
352 | *m_dlgReplace; | |
761989ff VZ |
353 | #endif // wxUSE_FINDREPLDLG |
354 | ||
e36a1739 VZ |
355 | #if wxUSE_NOTIFICATION_MESSAGE |
356 | wxNotificationMessage *m_notifMsg; | |
357 | #endif // wxUSE_NOTIFICATION_MESSAGE | |
358 | ||
d33dd9ef VS |
359 | wxColourData m_clrData; |
360 | ||
4c45f240 | 361 | DECLARE_EVENT_TABLE() |
457814b5 JS |
362 | }; |
363 | ||
364 | class MyCanvas: public wxScrolledWindow | |
365 | { | |
c49245f8 | 366 | public: |
08375332 | 367 | MyCanvas(wxWindow *parent) : |
13188def | 368 | wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { } |
c49245f8 VZ |
369 | |
370 | void OnPaint(wxPaintEvent& event); | |
371 | ||
372 | DECLARE_EVENT_TABLE() | |
457814b5 JS |
373 | }; |
374 | ||
375 | ||
376 | // Menu IDs | |
a294c6d5 VZ |
377 | enum |
378 | { | |
13188def | 379 | DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST, |
e6ef9ea4 | 380 | DIALOGS_GET_COLOUR, |
a294c6d5 VZ |
381 | DIALOGS_CHOOSE_COLOUR_GENERIC, |
382 | DIALOGS_CHOOSE_FONT, | |
383 | DIALOGS_CHOOSE_FONT_GENERIC, | |
384 | DIALOGS_MESSAGE_BOX, | |
8cf304f8 | 385 | DIALOGS_MESSAGE_BOX_WXINFO, |
a294c6d5 | 386 | DIALOGS_SINGLE_CHOICE, |
d6c9c1b7 | 387 | DIALOGS_MULTI_CHOICE, |
a294c6d5 VZ |
388 | DIALOGS_TEXT_ENTRY, |
389 | DIALOGS_PASSWORD_ENTRY, | |
390 | DIALOGS_FILE_OPEN, | |
35b45b33 | 391 | DIALOGS_FILE_OPEN2, |
a294c6d5 VZ |
392 | DIALOGS_FILES_OPEN, |
393 | DIALOGS_FILE_SAVE, | |
695fe764 WS |
394 | DIALOGS_FILE_OPEN_GENERIC, |
395 | DIALOGS_FILES_OPEN_GENERIC, | |
396 | DIALOGS_FILE_SAVE_GENERIC, | |
a294c6d5 | 397 | DIALOGS_DIR_CHOOSE, |
f09c8393 | 398 | DIALOGS_DIRNEW_CHOOSE, |
51a58d8b | 399 | DIALOGS_GENERIC_DIR_CHOOSE, |
a294c6d5 VZ |
400 | DIALOGS_TIP, |
401 | DIALOGS_NUM_ENTRY, | |
4c45f240 | 402 | DIALOGS_LOG_DIALOG, |
f6bcfd97 | 403 | DIALOGS_MODAL, |
4c45f240 | 404 | DIALOGS_MODELESS, |
cae50e6b VZ |
405 | DIALOGS_CENTRE_SCREEN, |
406 | DIALOGS_CENTRE_PARENT, | |
1baa0a9d | 407 | DIALOGS_MINIFRAME, |
8e5dbcdd | 408 | DIALOGS_ONTOP, |
abceee76 | 409 | DIALOGS_MODELESS_BTN, |
761989ff | 410 | DIALOGS_PROGRESS, |
ca7adbf8 VZ |
411 | DIALOGS_ABOUTDLG_SIMPLE, |
412 | DIALOGS_ABOUTDLG_FANCY, | |
453c9e3b VZ |
413 | DIALOGS_ABOUTDLG_FULL, |
414 | DIALOGS_ABOUTDLG_CUSTOM, | |
a62b0bcc | 415 | DIALOGS_BUSYINFO, |
761989ff | 416 | DIALOGS_FIND, |
29e3d1f9 | 417 | DIALOGS_REPLACE, |
0f5d8ecf | 418 | DIALOGS_REQUEST, |
e36a1739 VZ |
419 | DIALOGS_NOTIFY_AUTO, |
420 | DIALOGS_NOTIFY_SHOW, | |
421 | DIALOGS_NOTIFY_HIDE, | |
cc8bc5aa | 422 | DIALOGS_PROPERTY_SHEET, |
64d3ed17 | 423 | DIALOGS_PROPERTY_SHEET_TOOLBOOK, |
8e1dac82 | 424 | DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, |
a625c5b6 RR |
425 | DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, |
426 | DIALOGS_TEST_DEFAULT_ACTION | |
a294c6d5 | 427 | }; |
457814b5 JS |
428 | |
429 | #endif | |
430 |