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