]> git.saurik.com Git - wxWidgets.git/blob - samples/dialogs/dialogs.h
Removed WXWIN_COMPATIBILITY_2_2 together with code guarded by it.
[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(__WXMSW__) && !defined(__WXWINCE__)
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
49 #if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX
50 #define USE_WXMACFONTDLG 1
51 #else
52 #define USE_WXMACFONTDLG 0
53 #endif
54
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
67 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
68
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 \
76 ((USE_WXMSW || USE_WXMACFONTDLG ||USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
77
78
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__) || !wxUSE_BOOKCTRL
82 #define USE_MODAL_PRESENTATION 0
83 #else
84 #define USE_MODAL_PRESENTATION 1
85 #endif
86
87
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
96 // Define a new application type
97 class MyApp: public wxApp
98 {
99 public:
100 bool OnInit();
101
102 wxFont m_canvasFont;
103 wxColour m_canvasTextColour;
104 };
105
106 #if USE_MODAL_PRESENTATION
107
108 // A custom modeless dialog
109 class MyModelessDialog : public wxDialog
110 {
111 public:
112 MyModelessDialog(wxWindow *parent);
113
114 void OnButton(wxCommandEvent& event);
115 void OnClose(wxCloseEvent& event);
116
117 private:
118 DECLARE_EVENT_TABLE()
119 };
120
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:
130 wxButton *m_btnModal,
131 *m_btnModeless,
132 *m_btnDelete;
133
134 DECLARE_EVENT_TABLE()
135 };
136
137 #endif // USE_MODAL_PRESENTATION
138
139 #if USE_SETTINGS_DIALOG
140 // Property sheet dialog
141 class SettingsDialog: public wxPropertySheetDialog
142 {
143 DECLARE_CLASS(SettingsDialog)
144 public:
145 SettingsDialog(wxWindow* parent);
146
147 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
148 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
149
150 protected:
151
152 enum {
153 ID_SHOW_TOOLTIPS = 100,
154 ID_AUTO_SAVE,
155 ID_AUTO_SAVE_MINS,
156 ID_LOAD_LAST_PROJECT,
157
158 ID_APPLY_SETTINGS_TO,
159 ID_BACKGROUND_STYLE,
160 ID_FONT_SIZE
161 };
162
163 DECLARE_EVENT_TABLE()
164 };
165
166 #endif // USE_SETTINGS_DIALOG
167
168 // Define a new frame type
169 class MyFrame: public wxFrame
170 {
171 public:
172 MyFrame(wxWindow *parent, const wxString& title);
173
174 void MessageBox(wxCommandEvent& event);
175
176 #if wxUSE_COLOURDLG
177 void ChooseColour(wxCommandEvent& event);
178 #endif // wxUSE_COLOURDLG
179
180 #if wxUSE_FONTDLG
181 void ChooseFont(wxCommandEvent& event);
182 #endif // wxUSE_FONTDLG
183
184 #if wxUSE_LOG_DIALOG
185 void LogDialog(wxCommandEvent& event);
186 #endif // wxUSE_LOG_DIALOG
187
188 #if wxUSE_CHOICEDLG
189 void SingleChoice(wxCommandEvent& event);
190 void MultiChoice(wxCommandEvent& event);
191 #endif // wxUSE_CHOICEDLG
192
193 #if wxUSE_TEXTDLG
194 void TextEntry(wxCommandEvent& event);
195 void PasswordEntry(wxCommandEvent& event);
196 #endif // wxUSE_TEXTDLG
197
198 #if wxUSE_NUMBERDLG
199 void NumericEntry(wxCommandEvent& event);
200 #endif // wxUSE_NUMBERDLG
201
202 #if wxUSE_FILEDLG
203 void FileOpen(wxCommandEvent& event);
204 void FileOpen2(wxCommandEvent& event);
205 void FilesOpen(wxCommandEvent& event);
206 void FileSave(wxCommandEvent& event);
207 #endif // wxUSE_FILEDLG
208
209 #if USE_FILEDLG_GENERIC
210 void FileOpenGeneric(wxCommandEvent& event);
211 void FilesOpenGeneric(wxCommandEvent& event);
212 void FileSaveGeneric(wxCommandEvent& event);
213 #endif // USE_FILEDLG_GENERIC
214
215 #if wxUSE_DIRDLG
216 void DirChoose(wxCommandEvent& event);
217 void DirChooseNew(wxCommandEvent& event);
218 #endif // wxUSE_DIRDLG
219
220 #if USE_DIRDLG_GENERIC
221 void GenericDirChoose(wxCommandEvent& event);
222 #endif // USE_DIRDLG_GENERIC
223
224 #if wxUSE_STARTUP_TIPS
225 void ShowTip(wxCommandEvent& event);
226 #endif // wxUSE_STARTUP_TIPS
227
228 #if USE_MODAL_PRESENTATION
229 void ModalDlg(wxCommandEvent& event);
230 void ModelessDlg(wxCommandEvent& event);
231 #endif // USE_MODAL_PRESENTATION
232
233 #if wxUSE_PROGRESSDLG
234 void ShowProgress(wxCommandEvent& event);
235 #endif // wxUSE_PROGRESSDLG
236
237 #if wxUSE_BUSYINFO
238 void ShowBusyInfo(wxCommandEvent& event);
239 #endif // wxUSE_BUSYINFO
240
241 #if wxUSE_FINDREPLDLG
242 void ShowFindDialog(wxCommandEvent& event);
243 void ShowReplaceDialog(wxCommandEvent& event);
244 void OnFindDialog(wxFindDialogEvent& event);
245 #endif // wxUSE_FINDREPLDLG
246
247 #if USE_COLOURDLG_GENERIC
248 void ChooseColourGeneric(wxCommandEvent& event);
249 #endif // USE_COLOURDLG_GENERIC
250
251 #if USE_FONTDLG_GENERIC
252 void ChooseFontGeneric(wxCommandEvent& event);
253 #endif // USE_FONTDLG_GENERIC
254
255 void OnPropertySheet(wxCommandEvent& event);
256 void OnRequestUserAttention(wxCommandEvent& event);
257 void OnExit(wxCommandEvent& event);
258
259 private:
260 #if wxUSE_DIRDLG
261 void DoDirChoose(int style);
262 #endif // wxUSE_DIRDLG
263
264 #if USE_MODAL_PRESENTATION
265 MyModelessDialog *m_dialog;
266 #endif // USE_MODAL_PRESENTATION
267
268 #if wxUSE_FINDREPLDLG
269 wxFindReplaceData m_findData;
270
271 wxFindReplaceDialog *m_dlgFind,
272 *m_dlgReplace;
273 #endif // wxUSE_FINDREPLDLG
274
275 wxColourData m_clrData;
276
277 DECLARE_EVENT_TABLE()
278 };
279
280 class MyCanvas: public wxScrolledWindow
281 {
282 public:
283 MyCanvas(wxWindow *parent) :
284 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
285
286 void OnPaint(wxPaintEvent& event);
287
288 DECLARE_EVENT_TABLE()
289 };
290
291
292 // Menu IDs
293 enum
294 {
295 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
296 DIALOGS_CHOOSE_COLOUR_GENERIC,
297 DIALOGS_CHOOSE_FONT,
298 DIALOGS_CHOOSE_FONT_GENERIC,
299 DIALOGS_MESSAGE_BOX,
300 DIALOGS_SINGLE_CHOICE,
301 DIALOGS_MULTI_CHOICE,
302 DIALOGS_TEXT_ENTRY,
303 DIALOGS_PASSWORD_ENTRY,
304 DIALOGS_FILE_OPEN,
305 DIALOGS_FILE_OPEN2,
306 DIALOGS_FILES_OPEN,
307 DIALOGS_FILE_SAVE,
308 DIALOGS_FILE_OPEN_GENERIC,
309 DIALOGS_FILES_OPEN_GENERIC,
310 DIALOGS_FILE_SAVE_GENERIC,
311 DIALOGS_DIR_CHOOSE,
312 DIALOGS_DIRNEW_CHOOSE,
313 DIALOGS_GENERIC_DIR_CHOOSE,
314 DIALOGS_TIP,
315 DIALOGS_NUM_ENTRY,
316 DIALOGS_LOG_DIALOG,
317 DIALOGS_MODAL,
318 DIALOGS_MODELESS,
319 DIALOGS_MODELESS_BTN,
320 DIALOGS_PROGRESS,
321 DIALOGS_BUSYINFO,
322 DIALOGS_FIND,
323 DIALOGS_REPLACE,
324 DIALOGS_REQUEST,
325 DIALOGS_PROPERTY_SHEET
326 };
327
328 #endif
329