]>
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) | |
81 | #if defined(__SMARTPHONE__) | |
82 | #define USE_MODAL_PRESENTATION 0 | |
83 | #else | |
84 | #define USE_MODAL_PRESENTATION 1 | |
85 | #endif | |
4c8fc4d6 | 86 | |
13188def | 87 | |
457814b5 JS |
88 | // Define a new application type |
89 | class MyApp: public wxApp | |
c49245f8 VZ |
90 | { |
91 | public: | |
92 | bool OnInit(); | |
457814b5 JS |
93 | |
94 | wxFont m_canvasFont; | |
95 | wxColour m_canvasTextColour; | |
96 | }; | |
97 | ||
b4954d19 WS |
98 | #if USE_MODAL_PRESENTATION |
99 | ||
f6bcfd97 | 100 | // A custom modeless dialog |
4c45f240 VZ |
101 | class MyModelessDialog : public wxDialog |
102 | { | |
103 | public: | |
104 | MyModelessDialog(wxWindow *parent); | |
abceee76 | 105 | |
5d987909 | 106 | void OnButton(wxCommandEvent& event); |
abceee76 VZ |
107 | void OnClose(wxCloseEvent& event); |
108 | ||
109 | private: | |
110 | DECLARE_EVENT_TABLE() | |
4c45f240 VZ |
111 | }; |
112 | ||
f6bcfd97 BP |
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: | |
5315ebfa VZ |
122 | wxButton *m_btnModal, |
123 | *m_btnModeless, | |
124 | *m_btnDelete; | |
f6bcfd97 BP |
125 | |
126 | DECLARE_EVENT_TABLE() | |
127 | }; | |
128 | ||
b4954d19 WS |
129 | #endif // USE_MODAL_PRESENTATION |
130 | ||
457814b5 JS |
131 | // Define a new frame type |
132 | class MyFrame: public wxFrame | |
c49245f8 VZ |
133 | { |
134 | public: | |
13188def WS |
135 | MyFrame(wxWindow *parent, const wxString& title); |
136 | ||
137 | void MessageBox(wxCommandEvent& event); | |
457814b5 | 138 | |
13188def | 139 | #if wxUSE_COLOURDLG |
329e86bf | 140 | void ChooseColour(wxCommandEvent& event); |
13188def WS |
141 | #endif // wxUSE_COLOURDLG |
142 | ||
143 | #if wxUSE_FONTDLG | |
329e86bf | 144 | void ChooseFont(wxCommandEvent& event); |
13188def WS |
145 | #endif // wxUSE_FONTDLG |
146 | ||
147 | #if wxUSE_LOG_DIALOG | |
d93c719a | 148 | void LogDialog(wxCommandEvent& event); |
13188def WS |
149 | #endif // wxUSE_LOG_DIALOG |
150 | ||
151 | #if wxUSE_CHOICEDLG | |
457814b5 | 152 | void SingleChoice(wxCommandEvent& event); |
d6c9c1b7 | 153 | void MultiChoice(wxCommandEvent& event); |
13188def WS |
154 | #endif // wxUSE_CHOICEDLG |
155 | ||
156 | #if wxUSE_TEXTDLG | |
457814b5 | 157 | void TextEntry(wxCommandEvent& event); |
a294c6d5 | 158 | void PasswordEntry(wxCommandEvent& event); |
13188def WS |
159 | #endif // wxUSE_TEXTDLG |
160 | ||
161 | #if wxUSE_NUMBERDLG | |
c49245f8 | 162 | void NumericEntry(wxCommandEvent& event); |
13188def WS |
163 | #endif // wxUSE_NUMBERDLG |
164 | ||
165 | #if wxUSE_FILEDLG | |
457814b5 | 166 | void FileOpen(wxCommandEvent& event); |
35b45b33 | 167 | void FileOpen2(wxCommandEvent& event); |
c61f4f6d | 168 | void FilesOpen(wxCommandEvent& event); |
457814b5 | 169 | void FileSave(wxCommandEvent& event); |
13188def WS |
170 | #endif // wxUSE_FILEDLG |
171 | ||
695fe764 WS |
172 | #if USE_FILEDLG_GENERIC |
173 | void FileOpenGeneric(wxCommandEvent& event); | |
174 | void FilesOpenGeneric(wxCommandEvent& event); | |
175 | void FileSaveGeneric(wxCommandEvent& event); | |
176 | #endif // USE_FILEDLG_GENERIC | |
177 | ||
13188def | 178 | #if wxUSE_DIRDLG |
457814b5 | 179 | void DirChoose(wxCommandEvent& event); |
f09c8393 | 180 | void DirChooseNew(wxCommandEvent& event); |
13188def WS |
181 | #endif // wxUSE_DIRDLG |
182 | ||
183 | #if USE_DIRDLG_GENERIC | |
51a58d8b | 184 | void GenericDirChoose(wxCommandEvent& event); |
13188def WS |
185 | #endif // USE_DIRDLG_GENERIC |
186 | ||
187 | #if wxUSE_STARTUP_TIPS | |
c50f1fb9 | 188 | void ShowTip(wxCommandEvent& event); |
13188def WS |
189 | #endif // wxUSE_STARTUP_TIPS |
190 | ||
191 | #if USE_MODAL_PRESENTATION | |
f6bcfd97 | 192 | void ModalDlg(wxCommandEvent& event); |
4c45f240 | 193 | void ModelessDlg(wxCommandEvent& event); |
13188def WS |
194 | #endif // USE_MODAL_PRESENTATION |
195 | ||
761989ff | 196 | #if wxUSE_PROGRESSDLG |
abceee76 | 197 | void ShowProgress(wxCommandEvent& event); |
761989ff | 198 | #endif // wxUSE_PROGRESSDLG |
13188def | 199 | |
a62b0bcc VZ |
200 | #if wxUSE_BUSYINFO |
201 | void ShowBusyInfo(wxCommandEvent& event); | |
202 | #endif // wxUSE_BUSYINFO | |
13188def | 203 | |
761989ff VZ |
204 | #if wxUSE_FINDREPLDLG |
205 | void ShowFindDialog(wxCommandEvent& event); | |
206 | void ShowReplaceDialog(wxCommandEvent& event); | |
761989ff VZ |
207 | void OnFindDialog(wxFindDialogEvent& event); |
208 | #endif // wxUSE_FINDREPLDLG | |
457814b5 | 209 | |
13188def | 210 | #if USE_COLOURDLG_GENERIC |
329e86bf | 211 | void ChooseColourGeneric(wxCommandEvent& event); |
13188def WS |
212 | #endif // USE_COLOURDLG_GENERIC |
213 | ||
214 | #if USE_FONTDLG_GENERIC | |
329e86bf | 215 | void ChooseFontGeneric(wxCommandEvent& event); |
13188def | 216 | #endif // USE_FONTDLG_GENERIC |
c49245f8 | 217 | |
29e3d1f9 | 218 | void OnRequestUserAttention(wxCommandEvent& event); |
329e86bf | 219 | void OnExit(wxCommandEvent& event); |
c49245f8 | 220 | |
4c45f240 | 221 | private: |
13188def | 222 | #if wxUSE_DIRDLG |
f09c8393 | 223 | void DoDirChoose(int style); |
13188def | 224 | #endif // wxUSE_DIRDLG |
f09c8393 | 225 | |
13188def | 226 | #if USE_MODAL_PRESENTATION |
4c45f240 | 227 | MyModelessDialog *m_dialog; |
13188def | 228 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 229 | |
761989ff VZ |
230 | #if wxUSE_FINDREPLDLG |
231 | wxFindReplaceData m_findData; | |
14fca738 VZ |
232 | |
233 | wxFindReplaceDialog *m_dlgFind, | |
234 | *m_dlgReplace; | |
761989ff VZ |
235 | #endif // wxUSE_FINDREPLDLG |
236 | ||
d33dd9ef VS |
237 | wxColourData m_clrData; |
238 | ||
4c45f240 | 239 | DECLARE_EVENT_TABLE() |
457814b5 JS |
240 | }; |
241 | ||
242 | class MyCanvas: public wxScrolledWindow | |
243 | { | |
c49245f8 | 244 | public: |
08375332 | 245 | MyCanvas(wxWindow *parent) : |
13188def | 246 | wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { } |
c49245f8 VZ |
247 | |
248 | void OnPaint(wxPaintEvent& event); | |
249 | ||
250 | DECLARE_EVENT_TABLE() | |
457814b5 JS |
251 | }; |
252 | ||
253 | ||
254 | // Menu IDs | |
a294c6d5 VZ |
255 | enum |
256 | { | |
13188def | 257 | DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST, |
a294c6d5 VZ |
258 | DIALOGS_CHOOSE_COLOUR_GENERIC, |
259 | DIALOGS_CHOOSE_FONT, | |
260 | DIALOGS_CHOOSE_FONT_GENERIC, | |
261 | DIALOGS_MESSAGE_BOX, | |
262 | DIALOGS_SINGLE_CHOICE, | |
d6c9c1b7 | 263 | DIALOGS_MULTI_CHOICE, |
a294c6d5 VZ |
264 | DIALOGS_TEXT_ENTRY, |
265 | DIALOGS_PASSWORD_ENTRY, | |
266 | DIALOGS_FILE_OPEN, | |
35b45b33 | 267 | DIALOGS_FILE_OPEN2, |
a294c6d5 VZ |
268 | DIALOGS_FILES_OPEN, |
269 | DIALOGS_FILE_SAVE, | |
695fe764 WS |
270 | DIALOGS_FILE_OPEN_GENERIC, |
271 | DIALOGS_FILES_OPEN_GENERIC, | |
272 | DIALOGS_FILE_SAVE_GENERIC, | |
a294c6d5 | 273 | DIALOGS_DIR_CHOOSE, |
f09c8393 | 274 | DIALOGS_DIRNEW_CHOOSE, |
51a58d8b | 275 | DIALOGS_GENERIC_DIR_CHOOSE, |
a294c6d5 VZ |
276 | DIALOGS_TIP, |
277 | DIALOGS_NUM_ENTRY, | |
4c45f240 | 278 | DIALOGS_LOG_DIALOG, |
f6bcfd97 | 279 | DIALOGS_MODAL, |
4c45f240 | 280 | DIALOGS_MODELESS, |
abceee76 | 281 | DIALOGS_MODELESS_BTN, |
761989ff | 282 | DIALOGS_PROGRESS, |
a62b0bcc | 283 | DIALOGS_BUSYINFO, |
761989ff | 284 | DIALOGS_FIND, |
29e3d1f9 VZ |
285 | DIALOGS_REPLACE, |
286 | DIALOGS_REQUEST | |
a294c6d5 | 287 | }; |
457814b5 JS |
288 | |
289 | #endif | |
290 |