]>
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 \ | |
684883e3 | 80 | ((((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG) |
29e3d1f9 | 81 | #define USE_FONTDLG_GENERIC \ |
684883e3 | 82 | ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG) |
4c8fc4d6 | 83 | |
08375332 WS |
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) | |
532d575b | 86 | #if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL |
08375332 WS |
87 | #define USE_MODAL_PRESENTATION 0 |
88 | #else | |
89 | #define USE_MODAL_PRESENTATION 1 | |
90 | #endif | |
4c8fc4d6 | 91 | |
13188def | 92 | |
532d575b WS |
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 | ||
457814b5 JS |
101 | // Define a new application type |
102 | class MyApp: public wxApp | |
c49245f8 VZ |
103 | { |
104 | public: | |
105 | bool OnInit(); | |
457814b5 JS |
106 | |
107 | wxFont m_canvasFont; | |
108 | wxColour m_canvasTextColour; | |
109 | }; | |
110 | ||
b4954d19 WS |
111 | #if USE_MODAL_PRESENTATION |
112 | ||
f6bcfd97 | 113 | // A custom modeless dialog |
4c45f240 VZ |
114 | class MyModelessDialog : public wxDialog |
115 | { | |
116 | public: | |
117 | MyModelessDialog(wxWindow *parent); | |
abceee76 | 118 | |
5d987909 | 119 | void OnButton(wxCommandEvent& event); |
abceee76 VZ |
120 | void OnClose(wxCloseEvent& event); |
121 | ||
122 | private: | |
123 | DECLARE_EVENT_TABLE() | |
4c45f240 VZ |
124 | }; |
125 | ||
f6bcfd97 BP |
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: | |
5315ebfa VZ |
135 | wxButton *m_btnModal, |
136 | *m_btnModeless, | |
137 | *m_btnDelete; | |
f6bcfd97 BP |
138 | |
139 | DECLARE_EVENT_TABLE() | |
140 | }; | |
141 | ||
b4954d19 WS |
142 | #endif // USE_MODAL_PRESENTATION |
143 | ||
532d575b | 144 | #if USE_SETTINGS_DIALOG |
0f5d8ecf JS |
145 | // Property sheet dialog |
146 | class SettingsDialog: public wxPropertySheetDialog | |
147 | { | |
148 | DECLARE_CLASS(SettingsDialog) | |
149 | public: | |
64d3ed17 | 150 | SettingsDialog(wxWindow* parent, int dialogType); |
cc8bc5aa | 151 | ~SettingsDialog(); |
0f5d8ecf JS |
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 | ||
cc8bc5aa JS |
169 | wxImageList* m_imageList; |
170 | ||
0f5d8ecf JS |
171 | DECLARE_EVENT_TABLE() |
172 | }; | |
173 | ||
532d575b WS |
174 | #endif // USE_SETTINGS_DIALOG |
175 | ||
457814b5 JS |
176 | // Define a new frame type |
177 | class MyFrame: public wxFrame | |
c49245f8 VZ |
178 | { |
179 | public: | |
13188def WS |
180 | MyFrame(wxWindow *parent, const wxString& title); |
181 | ||
182 | void MessageBox(wxCommandEvent& event); | |
457814b5 | 183 | |
13188def | 184 | #if wxUSE_COLOURDLG |
329e86bf | 185 | void ChooseColour(wxCommandEvent& event); |
13188def WS |
186 | #endif // wxUSE_COLOURDLG |
187 | ||
188 | #if wxUSE_FONTDLG | |
329e86bf | 189 | void ChooseFont(wxCommandEvent& event); |
13188def WS |
190 | #endif // wxUSE_FONTDLG |
191 | ||
192 | #if wxUSE_LOG_DIALOG | |
d93c719a | 193 | void LogDialog(wxCommandEvent& event); |
13188def WS |
194 | #endif // wxUSE_LOG_DIALOG |
195 | ||
196 | #if wxUSE_CHOICEDLG | |
457814b5 | 197 | void SingleChoice(wxCommandEvent& event); |
d6c9c1b7 | 198 | void MultiChoice(wxCommandEvent& event); |
13188def WS |
199 | #endif // wxUSE_CHOICEDLG |
200 | ||
201 | #if wxUSE_TEXTDLG | |
457814b5 | 202 | void TextEntry(wxCommandEvent& event); |
a294c6d5 | 203 | void PasswordEntry(wxCommandEvent& event); |
13188def WS |
204 | #endif // wxUSE_TEXTDLG |
205 | ||
206 | #if wxUSE_NUMBERDLG | |
c49245f8 | 207 | void NumericEntry(wxCommandEvent& event); |
13188def WS |
208 | #endif // wxUSE_NUMBERDLG |
209 | ||
210 | #if wxUSE_FILEDLG | |
457814b5 | 211 | void FileOpen(wxCommandEvent& event); |
35b45b33 | 212 | void FileOpen2(wxCommandEvent& event); |
c61f4f6d | 213 | void FilesOpen(wxCommandEvent& event); |
457814b5 | 214 | void FileSave(wxCommandEvent& event); |
13188def WS |
215 | #endif // wxUSE_FILEDLG |
216 | ||
695fe764 WS |
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 | ||
13188def | 223 | #if wxUSE_DIRDLG |
457814b5 | 224 | void DirChoose(wxCommandEvent& event); |
f09c8393 | 225 | void DirChooseNew(wxCommandEvent& event); |
13188def WS |
226 | #endif // wxUSE_DIRDLG |
227 | ||
228 | #if USE_DIRDLG_GENERIC | |
51a58d8b | 229 | void GenericDirChoose(wxCommandEvent& event); |
13188def WS |
230 | #endif // USE_DIRDLG_GENERIC |
231 | ||
232 | #if wxUSE_STARTUP_TIPS | |
c50f1fb9 | 233 | void ShowTip(wxCommandEvent& event); |
13188def WS |
234 | #endif // wxUSE_STARTUP_TIPS |
235 | ||
236 | #if USE_MODAL_PRESENTATION | |
f6bcfd97 | 237 | void ModalDlg(wxCommandEvent& event); |
4c45f240 | 238 | void ModelessDlg(wxCommandEvent& event); |
cae50e6b VZ |
239 | void DlgCenteredScreen(wxCommandEvent& event); |
240 | void DlgCenteredParent(wxCommandEvent& event); | |
13188def WS |
241 | #endif // USE_MODAL_PRESENTATION |
242 | ||
761989ff | 243 | #if wxUSE_PROGRESSDLG |
abceee76 | 244 | void ShowProgress(wxCommandEvent& event); |
761989ff | 245 | #endif // wxUSE_PROGRESSDLG |
13188def | 246 | |
a62b0bcc VZ |
247 | #if wxUSE_BUSYINFO |
248 | void ShowBusyInfo(wxCommandEvent& event); | |
249 | #endif // wxUSE_BUSYINFO | |
13188def | 250 | |
761989ff VZ |
251 | #if wxUSE_FINDREPLDLG |
252 | void ShowFindDialog(wxCommandEvent& event); | |
253 | void ShowReplaceDialog(wxCommandEvent& event); | |
761989ff VZ |
254 | void OnFindDialog(wxFindDialogEvent& event); |
255 | #endif // wxUSE_FINDREPLDLG | |
457814b5 | 256 | |
13188def | 257 | #if USE_COLOURDLG_GENERIC |
329e86bf | 258 | void ChooseColourGeneric(wxCommandEvent& event); |
13188def WS |
259 | #endif // USE_COLOURDLG_GENERIC |
260 | ||
261 | #if USE_FONTDLG_GENERIC | |
329e86bf | 262 | void ChooseFontGeneric(wxCommandEvent& event); |
13188def | 263 | #endif // USE_FONTDLG_GENERIC |
c49245f8 | 264 | |
0f5d8ecf | 265 | void OnPropertySheet(wxCommandEvent& event); |
29e3d1f9 | 266 | void OnRequestUserAttention(wxCommandEvent& event); |
329e86bf | 267 | void OnExit(wxCommandEvent& event); |
c49245f8 | 268 | |
4c45f240 | 269 | private: |
13188def | 270 | #if wxUSE_DIRDLG |
f09c8393 | 271 | void DoDirChoose(int style); |
13188def | 272 | #endif // wxUSE_DIRDLG |
f09c8393 | 273 | |
13188def | 274 | #if USE_MODAL_PRESENTATION |
4c45f240 | 275 | MyModelessDialog *m_dialog; |
13188def | 276 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 277 | |
761989ff VZ |
278 | #if wxUSE_FINDREPLDLG |
279 | wxFindReplaceData m_findData; | |
14fca738 VZ |
280 | |
281 | wxFindReplaceDialog *m_dlgFind, | |
282 | *m_dlgReplace; | |
761989ff VZ |
283 | #endif // wxUSE_FINDREPLDLG |
284 | ||
d33dd9ef VS |
285 | wxColourData m_clrData; |
286 | ||
4c45f240 | 287 | DECLARE_EVENT_TABLE() |
457814b5 JS |
288 | }; |
289 | ||
290 | class MyCanvas: public wxScrolledWindow | |
291 | { | |
c49245f8 | 292 | public: |
08375332 | 293 | MyCanvas(wxWindow *parent) : |
13188def | 294 | wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { } |
c49245f8 VZ |
295 | |
296 | void OnPaint(wxPaintEvent& event); | |
297 | ||
298 | DECLARE_EVENT_TABLE() | |
457814b5 JS |
299 | }; |
300 | ||
301 | ||
302 | // Menu IDs | |
a294c6d5 VZ |
303 | enum |
304 | { | |
13188def | 305 | DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST, |
a294c6d5 VZ |
306 | DIALOGS_CHOOSE_COLOUR_GENERIC, |
307 | DIALOGS_CHOOSE_FONT, | |
308 | DIALOGS_CHOOSE_FONT_GENERIC, | |
309 | DIALOGS_MESSAGE_BOX, | |
310 | DIALOGS_SINGLE_CHOICE, | |
d6c9c1b7 | 311 | DIALOGS_MULTI_CHOICE, |
a294c6d5 VZ |
312 | DIALOGS_TEXT_ENTRY, |
313 | DIALOGS_PASSWORD_ENTRY, | |
314 | DIALOGS_FILE_OPEN, | |
35b45b33 | 315 | DIALOGS_FILE_OPEN2, |
a294c6d5 VZ |
316 | DIALOGS_FILES_OPEN, |
317 | DIALOGS_FILE_SAVE, | |
695fe764 WS |
318 | DIALOGS_FILE_OPEN_GENERIC, |
319 | DIALOGS_FILES_OPEN_GENERIC, | |
320 | DIALOGS_FILE_SAVE_GENERIC, | |
a294c6d5 | 321 | DIALOGS_DIR_CHOOSE, |
f09c8393 | 322 | DIALOGS_DIRNEW_CHOOSE, |
51a58d8b | 323 | DIALOGS_GENERIC_DIR_CHOOSE, |
a294c6d5 VZ |
324 | DIALOGS_TIP, |
325 | DIALOGS_NUM_ENTRY, | |
4c45f240 | 326 | DIALOGS_LOG_DIALOG, |
f6bcfd97 | 327 | DIALOGS_MODAL, |
4c45f240 | 328 | DIALOGS_MODELESS, |
cae50e6b VZ |
329 | DIALOGS_CENTRE_SCREEN, |
330 | DIALOGS_CENTRE_PARENT, | |
abceee76 | 331 | DIALOGS_MODELESS_BTN, |
761989ff | 332 | DIALOGS_PROGRESS, |
a62b0bcc | 333 | DIALOGS_BUSYINFO, |
761989ff | 334 | DIALOGS_FIND, |
29e3d1f9 | 335 | DIALOGS_REPLACE, |
0f5d8ecf | 336 | DIALOGS_REQUEST, |
cc8bc5aa | 337 | DIALOGS_PROPERTY_SHEET, |
64d3ed17 JS |
338 | DIALOGS_PROPERTY_SHEET_TOOLBOOK, |
339 | DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK | |
a294c6d5 | 340 | }; |
457814b5 JS |
341 | |
342 | #endif | |
343 |