Smartphone fix.
[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 #ifdef __WXGTK__
50 #define USE_WXGTK 1
51 #else
52 #define USE_WXGTK 0
53 #endif
54
55 #ifdef __WXPM__
56 #define USE_WXPM 1
57 #else
58 #define USE_WXPM 0
59 #endif
60
61 #define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
62
63 #define USE_COLOURDLG_GENERIC \
64 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
65 #define USE_DIRDLG_GENERIC \
66 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
67 #define USE_FILEDLG_GENERIC \
68 ((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG)
69 #define USE_FONTDLG_GENERIC \
70 ((USE_WXMSW || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
71
72
73 // Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
74 // between modal and modeless dialogs (ie. not implemented it in your port yet)
75 #if defined(__SMARTPHONE__)
76 #define USE_MODAL_PRESENTATION 0
77 #else
78 #define USE_MODAL_PRESENTATION 1
79 #endif
80
81
82 // Define a new application type
83 class MyApp: public wxApp
84 {
85 public:
86 bool OnInit();
87
88 wxFont m_canvasFont;
89 wxColour m_canvasTextColour;
90 };
91
92 #if USE_MODAL_PRESENTATION
93
94 // A custom modeless dialog
95 class MyModelessDialog : public wxDialog
96 {
97 public:
98 MyModelessDialog(wxWindow *parent);
99
100 void OnButton(wxCommandEvent& event);
101 void OnClose(wxCloseEvent& event);
102
103 private:
104 DECLARE_EVENT_TABLE()
105 };
106
107 // A custom modal dialog
108 class MyModalDialog : public wxDialog
109 {
110 public:
111 MyModalDialog(wxWindow *parent);
112
113 void OnButton(wxCommandEvent& event);
114
115 private:
116 wxButton *m_btnModal,
117 *m_btnModeless,
118 *m_btnDelete;
119
120 DECLARE_EVENT_TABLE()
121 };
122
123 #endif // USE_MODAL_PRESENTATION
124
125 // Define a new frame type
126 class MyFrame: public wxFrame
127 {
128 public:
129 MyFrame(wxWindow *parent, const wxString& title);
130
131 void MessageBox(wxCommandEvent& event);
132
133 #if wxUSE_COLOURDLG
134 void ChooseColour(wxCommandEvent& event);
135 #endif // wxUSE_COLOURDLG
136
137 #if wxUSE_FONTDLG
138 void ChooseFont(wxCommandEvent& event);
139 #endif // wxUSE_FONTDLG
140
141 #if wxUSE_LOG_DIALOG
142 void LogDialog(wxCommandEvent& event);
143 #endif // wxUSE_LOG_DIALOG
144
145 #if wxUSE_CHOICEDLG
146 void SingleChoice(wxCommandEvent& event);
147 void MultiChoice(wxCommandEvent& event);
148 #endif // wxUSE_CHOICEDLG
149
150 #if wxUSE_TEXTDLG
151 void TextEntry(wxCommandEvent& event);
152 void PasswordEntry(wxCommandEvent& event);
153 #endif // wxUSE_TEXTDLG
154
155 #if wxUSE_NUMBERDLG
156 void NumericEntry(wxCommandEvent& event);
157 #endif // wxUSE_NUMBERDLG
158
159 #if wxUSE_FILEDLG
160 void FileOpen(wxCommandEvent& event);
161 void FileOpen2(wxCommandEvent& event);
162 void FilesOpen(wxCommandEvent& event);
163 void FileSave(wxCommandEvent& event);
164 #endif // wxUSE_FILEDLG
165
166 #if USE_FILEDLG_GENERIC
167 void FileOpenGeneric(wxCommandEvent& event);
168 void FilesOpenGeneric(wxCommandEvent& event);
169 void FileSaveGeneric(wxCommandEvent& event);
170 #endif // USE_FILEDLG_GENERIC
171
172 #if wxUSE_DIRDLG
173 void DirChoose(wxCommandEvent& event);
174 void DirChooseNew(wxCommandEvent& event);
175 #endif // wxUSE_DIRDLG
176
177 #if USE_DIRDLG_GENERIC
178 void GenericDirChoose(wxCommandEvent& event);
179 #endif // USE_DIRDLG_GENERIC
180
181 #if wxUSE_STARTUP_TIPS
182 void ShowTip(wxCommandEvent& event);
183 #endif // wxUSE_STARTUP_TIPS
184
185 #if USE_MODAL_PRESENTATION
186 void ModalDlg(wxCommandEvent& event);
187 void ModelessDlg(wxCommandEvent& event);
188 #endif // USE_MODAL_PRESENTATION
189
190 #if wxUSE_PROGRESSDLG
191 void ShowProgress(wxCommandEvent& event);
192 #endif // wxUSE_PROGRESSDLG
193
194 #if wxUSE_BUSYINFO
195 void ShowBusyInfo(wxCommandEvent& event);
196 #endif // wxUSE_BUSYINFO
197
198 #if wxUSE_FINDREPLDLG
199 void ShowFindDialog(wxCommandEvent& event);
200 void ShowReplaceDialog(wxCommandEvent& event);
201 void OnFindDialog(wxFindDialogEvent& event);
202 #endif // wxUSE_FINDREPLDLG
203
204 #if USE_COLOURDLG_GENERIC
205 void ChooseColourGeneric(wxCommandEvent& event);
206 #endif // USE_COLOURDLG_GENERIC
207
208 #if USE_FONTDLG_GENERIC
209 void ChooseFontGeneric(wxCommandEvent& event);
210 #endif // USE_FONTDLG_GENERIC
211
212 void OnRequestUserAttention(wxCommandEvent& event);
213 void OnExit(wxCommandEvent& event);
214
215 private:
216 #if wxUSE_DIRDLG
217 void DoDirChoose(int style);
218 #endif // wxUSE_DIRDLG
219
220 #if USE_MODAL_PRESENTATION
221 MyModelessDialog *m_dialog;
222 #endif // USE_MODAL_PRESENTATION
223
224 #if wxUSE_FINDREPLDLG
225 wxFindReplaceData m_findData;
226
227 wxFindReplaceDialog *m_dlgFind,
228 *m_dlgReplace;
229 #endif // wxUSE_FINDREPLDLG
230
231 wxColourData m_clrData;
232
233 DECLARE_EVENT_TABLE()
234 };
235
236 class MyCanvas: public wxScrolledWindow
237 {
238 public:
239 MyCanvas(wxWindow *parent) :
240 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
241
242 void OnPaint(wxPaintEvent& event);
243
244 DECLARE_EVENT_TABLE()
245 };
246
247
248 // Menu IDs
249 enum
250 {
251 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
252 DIALOGS_CHOOSE_COLOUR_GENERIC,
253 DIALOGS_CHOOSE_FONT,
254 DIALOGS_CHOOSE_FONT_GENERIC,
255 DIALOGS_MESSAGE_BOX,
256 DIALOGS_SINGLE_CHOICE,
257 DIALOGS_MULTI_CHOICE,
258 DIALOGS_TEXT_ENTRY,
259 DIALOGS_PASSWORD_ENTRY,
260 DIALOGS_FILE_OPEN,
261 DIALOGS_FILE_OPEN2,
262 DIALOGS_FILES_OPEN,
263 DIALOGS_FILE_SAVE,
264 DIALOGS_FILE_OPEN_GENERIC,
265 DIALOGS_FILES_OPEN_GENERIC,
266 DIALOGS_FILE_SAVE_GENERIC,
267 DIALOGS_DIR_CHOOSE,
268 DIALOGS_DIRNEW_CHOOSE,
269 DIALOGS_GENERIC_DIR_CHOOSE,
270 DIALOGS_TIP,
271 DIALOGS_NUM_ENTRY,
272 DIALOGS_LOG_DIALOG,
273 DIALOGS_MODAL,
274 DIALOGS_MODELESS,
275 DIALOGS_MODELESS_BTN,
276 DIALOGS_PROGRESS,
277 DIALOGS_BUSYINFO,
278 DIALOGS_FIND,
279 DIALOGS_REPLACE,
280 DIALOGS_REQUEST
281 };
282
283 #endif
284