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