]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dialogs.cpp | |
3 | // Purpose: Common dialogs demo | |
4 | // Author: Julian Smart | |
695fe764 | 5 | // Modified by: ABX (2004) - adjustements for conditional building + new menu |
457814b5 JS |
6 | // Created: 04/01/98 |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
c50f1fb9 | 9 | // Licence: wxWindows license |
457814b5 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
457814b5 JS |
12 | // For compilers that support precompilation, includes "wx/wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/wx.h" | |
21 | #endif | |
22 | ||
0f5d8ecf JS |
23 | #include "../sample.xpm" |
24 | ||
fb8a56b7 | 25 | #include "wx/datetime.h" |
f517634c | 26 | #include "wx/image.h" |
5378558e | 27 | #include "wx/bookctrl.h" |
cc8bc5aa | 28 | #include "wx/artprov.h" |
2b923807 | 29 | #include "wx/imaglist.h" |
684883e3 | 30 | #include "wx/sysopt.h" |
457814b5 | 31 | |
13188def WS |
32 | #if wxUSE_COLOURDLG |
33 | #include "wx/colordlg.h" | |
34 | #endif // wxUSE_COLOURDLG | |
dfad0599 | 35 | |
13188def WS |
36 | #if wxUSE_CHOICEDLG |
37 | #include "wx/choicdlg.h" | |
38 | #endif // wxUSE_CHOICEDLG | |
457814b5 | 39 | |
13188def WS |
40 | #if wxUSE_STARTUP_TIPS |
41 | #include "wx/tipdlg.h" | |
42 | #endif // wxUSE_STARTUP_TIPS | |
d7d17624 | 43 | |
13188def | 44 | #if wxUSE_PROGRESSDLG |
9b16ffef | 45 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
b20edf8b | 46 | #include "wx/datetime.h" // wxDateTime |
9b16ffef VZ |
47 | #endif |
48 | ||
13188def WS |
49 | #include "wx/progdlg.h" |
50 | #endif // wxUSE_PROGRESSDLG | |
51 | ||
52 | #if wxUSE_BUSYINFO | |
53 | #include "wx/busyinfo.h" | |
54 | #endif // wxUSE_BUSYINFO | |
55 | ||
56 | #if wxUSE_NUMBERDLG | |
57 | #include "wx/numdlg.h" | |
58 | #endif // wxUSE_NUMBERDLG | |
59 | ||
60 | #if wxUSE_FILEDLG | |
61 | #include "wx/filedlg.h" | |
62 | #endif // wxUSE_FILEDLG | |
63 | ||
64 | #if wxUSE_DIRDLG | |
65 | #include "wx/dirdlg.h" | |
66 | #endif // wxUSE_DIRDLG | |
67 | ||
68 | #if wxUSE_FONTDLG | |
69 | #include "wx/fontdlg.h" | |
70 | #endif // wxUSE_FONTDLG | |
71 | ||
72 | #if wxUSE_FINDREPLDLG | |
73 | #include "wx/fdrepdlg.h" | |
74 | #endif // wxUSE_FINDREPLDLG | |
4ad3c82f | 75 | |
62675ef3 | 76 | #if wxUSE_SPINCTRL |
0f5d8ecf | 77 | #include "wx/spinctrl.h" |
62675ef3 JS |
78 | #endif |
79 | ||
0f5d8ecf JS |
80 | #include "wx/propdlg.h" |
81 | ||
457814b5 JS |
82 | #include "dialogs.h" |
83 | ||
13188def WS |
84 | #if USE_COLOURDLG_GENERIC |
85 | #include "wx/generic/colrdlgg.h" | |
86 | #endif // USE_COLOURDLG_GENERIC | |
87 | ||
13188def WS |
88 | #if USE_DIRDLG_GENERIC |
89 | #include "wx/generic/dirdlgg.h" | |
90 | #endif // USE_DIRDLG_GENERIC | |
91 | ||
695fe764 WS |
92 | #if USE_FILEDLG_GENERIC |
93 | #include "wx/generic/filedlgg.h" | |
94 | #endif // USE_FILEDLG_GENERIC | |
95 | ||
96 | #if USE_FONTDLG_GENERIC | |
97 | #include "wx/generic/fontdlgg.h" | |
98 | #endif // USE_FONTDLG_GENERIC | |
99 | ||
457814b5 JS |
100 | IMPLEMENT_APP(MyApp) |
101 | ||
4c45f240 VZ |
102 | BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) |
103 | EVT_PAINT(MyCanvas::OnPaint) | |
104 | END_EVENT_TABLE() | |
105 | ||
13188def WS |
106 | |
107 | ||
4c45f240 | 108 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
13188def WS |
109 | EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox) |
110 | ||
111 | #if wxUSE_COLOURDLG | |
4c45f240 | 112 | EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour) |
13188def WS |
113 | #endif // wxUSE_COLOURDLG |
114 | ||
115 | #if wxUSE_FONTDLG | |
4c45f240 | 116 | EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont) |
13188def WS |
117 | #endif // wxUSE_FONTDLG |
118 | ||
119 | #if wxUSE_LOG_DIALOG | |
4c45f240 | 120 | EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog) |
13188def WS |
121 | #endif // wxUSE_LOG_DIALOG |
122 | ||
123 | #if wxUSE_TEXTDLG | |
4c45f240 VZ |
124 | EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry) |
125 | EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry) | |
13188def WS |
126 | #endif // wxUSE_TEXTDLG |
127 | ||
128 | #if wxUSE_NUMBERDLG | |
4c45f240 | 129 | EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry) |
13188def WS |
130 | #endif // wxUSE_NUMBERDLG |
131 | ||
132 | #if wxUSE_CHOICEDLG | |
4c45f240 | 133 | EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice) |
d6c9c1b7 | 134 | EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice) |
13188def WS |
135 | #endif // wxUSE_CHOICEDLG |
136 | ||
137 | #if wxUSE_FILEDLG | |
4c45f240 | 138 | EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen) |
35b45b33 | 139 | EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2) |
4c45f240 VZ |
140 | EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen) |
141 | EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave) | |
13188def WS |
142 | #endif // wxUSE_FILEDLG |
143 | ||
695fe764 WS |
144 | #if USE_FILEDLG_GENERIC |
145 | EVT_MENU(DIALOGS_FILE_OPEN_GENERIC, MyFrame::FileOpenGeneric) | |
146 | EVT_MENU(DIALOGS_FILES_OPEN_GENERIC, MyFrame::FilesOpenGeneric) | |
147 | EVT_MENU(DIALOGS_FILE_SAVE_GENERIC, MyFrame::FileSaveGeneric) | |
148 | #endif // USE_FILEDLG_GENERIC | |
149 | ||
13188def | 150 | #if wxUSE_DIRDLG |
4c45f240 | 151 | EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose) |
f09c8393 | 152 | EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew) |
13188def WS |
153 | #endif // wxUSE_DIRDLG |
154 | ||
155 | #if USE_MODAL_PRESENTATION | |
f6bcfd97 | 156 | EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg) |
4c45f240 | 157 | EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg) |
cae50e6b VZ |
158 | EVT_MENU(DIALOGS_CENTRE_SCREEN, MyFrame::DlgCenteredScreen) |
159 | EVT_MENU(DIALOGS_CENTRE_PARENT, MyFrame::DlgCenteredParent) | |
13188def WS |
160 | #endif // USE_MODAL |
161 | ||
162 | #if wxUSE_STARTUP_TIPS | |
4c45f240 | 163 | EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip) |
13188def WS |
164 | #endif // wxUSE_STARTUP_TIPS |
165 | ||
166 | #if USE_FONTDLG_GENERIC | |
4c45f240 | 167 | EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric) |
13188def WS |
168 | #endif // USE_FONTDLG_GENERIC |
169 | ||
170 | #if USE_DIRDLG_GENERIC | |
171 | EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose) | |
172 | #endif // wxMSW || wxMAC | |
173 | ||
174 | #if USE_COLOURDLG_GENERIC | |
175 | EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric) | |
176 | #endif // USE_COLOURDLG_GENERIC | |
a62b0bcc | 177 | |
abceee76 VZ |
178 | #if wxUSE_PROGRESSDLG |
179 | EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress) | |
761989ff | 180 | #endif // wxUSE_PROGRESSDLG |
a62b0bcc VZ |
181 | |
182 | #if wxUSE_BUSYINFO | |
183 | EVT_MENU(DIALOGS_BUSYINFO, MyFrame::ShowBusyInfo) | |
184 | #endif // wxUSE_BUSYINFO | |
185 | ||
761989ff VZ |
186 | #if wxUSE_FINDREPLDLG |
187 | EVT_MENU(DIALOGS_FIND, MyFrame::ShowFindDialog) | |
188 | EVT_MENU(DIALOGS_REPLACE, MyFrame::ShowReplaceDialog) | |
189 | ||
13188def WS |
190 | EVT_FIND(wxID_ANY, MyFrame::OnFindDialog) |
191 | EVT_FIND_NEXT(wxID_ANY, MyFrame::OnFindDialog) | |
192 | EVT_FIND_REPLACE(wxID_ANY, MyFrame::OnFindDialog) | |
193 | EVT_FIND_REPLACE_ALL(wxID_ANY, MyFrame::OnFindDialog) | |
194 | EVT_FIND_CLOSE(wxID_ANY, MyFrame::OnFindDialog) | |
761989ff | 195 | #endif // wxUSE_FINDREPLDLG |
13188def | 196 | |
532d575b | 197 | #if USE_SETTINGS_DIALOG |
0f5d8ecf | 198 | EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet) |
64d3ed17 JS |
199 | EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheet) |
200 | EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, MyFrame::OnPropertySheet) | |
532d575b WS |
201 | #endif |
202 | ||
0f5d8ecf | 203 | EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention) |
9b16ffef | 204 | |
4c45f240 | 205 | EVT_MENU(wxID_EXIT, MyFrame::OnExit) |
4c45f240 | 206 | END_EVENT_TABLE() |
abceee76 | 207 | |
13188def | 208 | #if USE_MODAL_PRESENTATION |
f6bcfd97 | 209 | |
13188def WS |
210 | BEGIN_EVENT_TABLE(MyModalDialog, wxDialog) |
211 | EVT_BUTTON(wxID_ANY, MyModalDialog::OnButton) | |
212 | END_EVENT_TABLE() | |
5d987909 | 213 | |
13188def WS |
214 | BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog) |
215 | EVT_BUTTON(DIALOGS_MODELESS_BTN, MyModelessDialog::OnButton) | |
216 | EVT_CLOSE(MyModelessDialog::OnClose) | |
217 | END_EVENT_TABLE() | |
218 | ||
219 | #endif // USE_MODAL_PRESENTATION | |
abceee76 | 220 | |
c67daf87 | 221 | MyCanvas *myCanvas = (MyCanvas *) NULL; |
457814b5 | 222 | |
457814b5 | 223 | // `Main program' equivalent, creating windows and returning main app frame |
4c45f240 | 224 | bool MyApp::OnInit() |
457814b5 | 225 | { |
f517634c | 226 | #if wxUSE_IMAGE |
013e1fee | 227 | wxInitAllImageHandlers(); |
f517634c | 228 | #endif |
013e1fee | 229 | |
13188def WS |
230 | m_canvasTextColour = wxColour(_T("BLACK")); |
231 | m_canvasFont = *wxNORMAL_FONT; | |
457814b5 | 232 | |
13188def WS |
233 | // Create the main frame window |
234 | MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example")); | |
457814b5 | 235 | |
13188def WS |
236 | // Make a menubar |
237 | wxMenu *file_menu = new wxMenu; | |
dabbc6a5 | 238 | |
13188def | 239 | file_menu->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M")); |
457814b5 | 240 | |
457814b5 | 241 | |
33bcca32 | 242 | #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG |
f09c8393 | 243 | |
33bcca32 | 244 | wxMenu *choices_menu = new wxMenu; |
f09c8393 | 245 | |
33bcca32 VZ |
246 | #if wxUSE_COLOURDLG |
247 | choices_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour")); | |
248 | #endif // wxUSE_COLOURDLG | |
f09c8393 | 249 | |
33bcca32 VZ |
250 | #if wxUSE_FONTDLG |
251 | choices_menu->Append(DIALOGS_CHOOSE_FONT, _T("Choose &font")); | |
252 | #endif // wxUSE_FONTDLG | |
457814b5 | 253 | |
33bcca32 VZ |
254 | #if wxUSE_CHOICEDLG |
255 | choices_menu->Append(DIALOGS_SINGLE_CHOICE, _T("&Single choice\tCtrl-C")); | |
256 | choices_menu->Append(DIALOGS_MULTI_CHOICE, _T("M&ultiple choice\tCtrl-U")); | |
257 | #endif // wxUSE_CHOICEDLG | |
695fe764 | 258 | |
33bcca32 VZ |
259 | #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC |
260 | choices_menu->AppendSeparator(); | |
261 | #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC | |
695fe764 | 262 | |
33bcca32 VZ |
263 | #if USE_COLOURDLG_GENERIC |
264 | choices_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, _T("&Choose colour (generic)")); | |
265 | #endif // USE_COLOURDLG_GENERIC | |
695fe764 | 266 | |
33bcca32 VZ |
267 | #if USE_FONTDLG_GENERIC |
268 | choices_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose &font (generic)")); | |
269 | #endif // USE_FONTDLG_GENERIC | |
d93c719a | 270 | |
33bcca32 VZ |
271 | file_menu->Append(wxID_ANY,_T("&Choices and selectors"),choices_menu); |
272 | #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG | |
457814b5 | 273 | |
457814b5 | 274 | |
33bcca32 | 275 | #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG |
13188def | 276 | |
33bcca32 | 277 | wxMenu *entry_menu = new wxMenu; |
13188def | 278 | |
33bcca32 VZ |
279 | #if wxUSE_TEXTDLG |
280 | entry_menu->Append(DIALOGS_TEXT_ENTRY, _T("Text &entry\tCtrl-E")); | |
281 | entry_menu->Append(DIALOGS_PASSWORD_ENTRY, _T("&Password entry\tCtrl-P")); | |
282 | #endif // wxUSE_TEXTDLG | |
13188def | 283 | |
33bcca32 VZ |
284 | #if wxUSE_NUMBERDLG |
285 | entry_menu->Append(DIALOGS_NUM_ENTRY, _T("&Numeric entry\tCtrl-N")); | |
286 | #endif // wxUSE_NUMBERDLG | |
13188def | 287 | |
33bcca32 | 288 | file_menu->Append(wxID_ANY,_T("&Entry dialogs"),entry_menu); |
13188def | 289 | |
33bcca32 | 290 | #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG |
13188def WS |
291 | |
292 | ||
33bcca32 | 293 | #if wxUSE_FILEDLG |
13188def | 294 | |
33bcca32 VZ |
295 | wxMenu *filedlg_menu = new wxMenu; |
296 | filedlg_menu->Append(DIALOGS_FILE_OPEN, _T("&Open file\tCtrl-O")); | |
297 | filedlg_menu->Append(DIALOGS_FILE_OPEN2, _T("&Second open file\tCtrl-2")); | |
298 | filedlg_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q")); | |
299 | filedlg_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S")); | |
695fe764 | 300 | |
33bcca32 VZ |
301 | #if USE_FILEDLG_GENERIC |
302 | filedlg_menu->AppendSeparator(); | |
303 | filedlg_menu->Append(DIALOGS_FILE_OPEN_GENERIC, _T("&Open file (generic)")); | |
304 | filedlg_menu->Append(DIALOGS_FILES_OPEN_GENERIC, _T("Open &files (generic)")); | |
305 | filedlg_menu->Append(DIALOGS_FILE_SAVE_GENERIC, _T("Sa&ve file (generic)")); | |
306 | #endif // USE_FILEDLG_GENERIC | |
695fe764 | 307 | |
33bcca32 | 308 | file_menu->Append(wxID_ANY,_T("&File operations"),filedlg_menu); |
13188def | 309 | |
33bcca32 | 310 | #endif // wxUSE_FILEDLG |
13188def | 311 | |
33bcca32 VZ |
312 | #if wxUSE_DIRDLG |
313 | wxMenu *dir_menu = new wxMenu; | |
13188def | 314 | |
33bcca32 VZ |
315 | dir_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D")); |
316 | dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D")); | |
317 | file_menu->Append(wxID_ANY,_T("&Directory operations"),dir_menu); | |
13188def | 318 | |
33bcca32 VZ |
319 | #if USE_DIRDLG_GENERIC |
320 | dir_menu->AppendSeparator(); | |
321 | dir_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic)")); | |
322 | #endif // USE_DIRDLG_GENERIC | |
13188def | 323 | |
33bcca32 | 324 | #endif // wxUSE_DIRDLG |
13188def WS |
325 | |
326 | ||
33bcca32 | 327 | #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG |
13188def | 328 | |
33bcca32 | 329 | wxMenu *info_menu = new wxMenu; |
13188def | 330 | |
33bcca32 VZ |
331 | #if wxUSE_STARTUP_TIPS |
332 | info_menu->Append(DIALOGS_TIP, _T("&Tip of the day\tCtrl-T")); | |
333 | #endif // wxUSE_STARTUP_TIPS | |
13188def | 334 | |
33bcca32 VZ |
335 | #if wxUSE_PROGRESSDLG |
336 | info_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G")); | |
337 | #endif // wxUSE_PROGRESSDLG | |
13188def | 338 | |
33bcca32 VZ |
339 | #if wxUSE_BUSYINFO |
340 | info_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B")); | |
341 | #endif // wxUSE_BUSYINFO | |
13188def | 342 | |
33bcca32 VZ |
343 | #if wxUSE_LOG_DIALOG |
344 | info_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L")); | |
345 | #endif // wxUSE_LOG_DIALOG | |
13188def | 346 | |
33bcca32 | 347 | file_menu->Append(wxID_ANY,_T("&Informative dialogs"),info_menu); |
13188def | 348 | |
33bcca32 | 349 | #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG |
13188def WS |
350 | |
351 | ||
33bcca32 VZ |
352 | #if wxUSE_FINDREPLDLG |
353 | wxMenu *find_menu = new wxMenu; | |
354 | find_menu->AppendCheckItem(DIALOGS_FIND, _T("&Find dialog\tCtrl-F")); | |
355 | find_menu->AppendCheckItem(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F")); | |
356 | file_menu->Append(wxID_ANY,_T("&Searching"),find_menu); | |
357 | #endif // wxUSE_FINDREPLDLG | |
13188def | 358 | |
33bcca32 | 359 | #if USE_MODAL_PRESENTATION |
cae50e6b VZ |
360 | wxMenu *dialogs_menu = new wxMenu; |
361 | dialogs_menu->Append(DIALOGS_MODAL, _T("&Modal dialog\tCtrl-W")); | |
362 | dialogs_menu->AppendCheckItem(DIALOGS_MODELESS, _T("Mode&less dialog\tCtrl-Z")); | |
363 | dialogs_menu->AppendCheckItem(DIALOGS_CENTRE_SCREEN, _T("Centered on &screen\tShift-Ctrl-1")); | |
364 | dialogs_menu->AppendCheckItem(DIALOGS_CENTRE_PARENT, _T("Centered on &parent\tShift-Ctrl-2")); | |
365 | file_menu->Append(wxID_ANY, _T("&Generic dialogs"), dialogs_menu); | |
33bcca32 | 366 | #endif // USE_MODAL_PRESENTATION |
13188def | 367 | |
532d575b | 368 | #if USE_SETTINGS_DIALOG |
b40bb73e VZ |
369 | wxMenu *sheet_menu = new wxMenu; |
370 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Standard property sheet\tShift-Ctrl-P")); | |
371 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("&Toolbook sheet\tShift-Ctrl-T")); | |
230c9077 JS |
372 | |
373 | if (wxPlatformIs(wxMac)) | |
374 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U")); | |
375 | /* | |
b887dc7b | 376 | #ifdef __WXMAC__ |
64d3ed17 | 377 | sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U")); |
b887dc7b | 378 | #endif |
230c9077 | 379 | */ |
b40bb73e VZ |
380 | file_menu->Append(wxID_ANY, _T("&Property sheets"), sheet_menu); |
381 | #endif // USE_SETTINGS_DIALOG | |
532d575b | 382 | |
9b16ffef VZ |
383 | file_menu->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R")); |
384 | ||
13188def WS |
385 | file_menu->AppendSeparator(); |
386 | file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X")); | |
387 | ||
388 | wxMenuBar *menu_bar = new wxMenuBar; | |
389 | menu_bar->Append(file_menu, _T("&File")); | |
390 | frame->SetMenuBar(menu_bar); | |
391 | ||
392 | myCanvas = new MyCanvas(frame); | |
393 | myCanvas->SetBackgroundColour(*wxWHITE); | |
394 | ||
395 | frame->Centre(wxBOTH); | |
396 | ||
397 | // Show the frame | |
398 | frame->Show(true); | |
399 | ||
400 | SetTopWindow(frame); | |
401 | ||
402 | return true; | |
457814b5 JS |
403 | } |
404 | ||
405 | // My frame constructor | |
4c45f240 | 406 | MyFrame::MyFrame(wxWindow *parent, |
13188def WS |
407 | const wxString& title) |
408 | : wxFrame(parent, wxID_ANY, title) | |
4c45f240 | 409 | { |
0f5d8ecf | 410 | SetIcon(sample_xpm); |
532d575b | 411 | |
13188def | 412 | #if USE_MODAL_PRESENTATION |
4c45f240 | 413 | m_dialog = (MyModelessDialog *)NULL; |
13188def | 414 | #endif // USE_MODAL_PRESENTATION |
f1e1ed3b | 415 | |
043dcdaa | 416 | #if wxUSE_FINDREPLDLG |
14fca738 VZ |
417 | m_dlgFind = |
418 | m_dlgReplace = NULL; | |
043dcdaa | 419 | #endif |
dabbc6a5 DS |
420 | |
421 | #if wxUSE_COLOURDLG | |
d33dd9ef VS |
422 | m_clrData.SetChooseFull(true); |
423 | for (int i = 0; i < 16; i++) | |
424 | { | |
8f6eaec9 WS |
425 | m_clrData.SetCustomColour( |
426 | i, | |
427 | wxColour( | |
428 | (unsigned char)(i*16), | |
429 | (unsigned char)(i*16), | |
430 | (unsigned char)(i*16) | |
431 | ) | |
432 | ); | |
d33dd9ef | 433 | } |
13188def | 434 | #endif // wxUSE_COLOURDLG |
4c45f240 | 435 | } |
457814b5 | 436 | |
13188def | 437 | #if wxUSE_COLOURDLG |
d355d3fe | 438 | void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 439 | { |
d33dd9ef | 440 | m_clrData.SetColour(myCanvas->GetBackgroundColour()); |
d93c719a | 441 | |
d33dd9ef | 442 | wxColourDialog dialog(this, &m_clrData); |
9f84eccd | 443 | dialog.SetTitle(_T("Choose the background colour")); |
afbd36dd | 444 | if (dialog.ShowModal() == wxID_OK) |
f6bcfd97 | 445 | { |
d33dd9ef VS |
446 | m_clrData = dialog.GetColourData(); |
447 | myCanvas->SetBackgroundColour(m_clrData.GetColour()); | |
1d14c005 | 448 | myCanvas->ClearBackground(); |
457814b5 | 449 | myCanvas->Refresh(); |
f6bcfd97 | 450 | } |
457814b5 | 451 | } |
13188def | 452 | #endif // wxUSE_COLOURDLG |
457814b5 | 453 | |
1e72e3cc RN |
454 | #if USE_COLOURDLG_GENERIC |
455 | void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) | |
456 | { | |
457 | m_clrData.SetColour(myCanvas->GetBackgroundColour()); | |
458 | ||
459 | //FIXME:TODO:This has no effect... | |
460 | m_clrData.SetChooseFull(true); | |
461 | ||
462 | for (int i = 0; i < 16; i++) | |
463 | { | |
464 | wxColour colour( | |
465 | (unsigned char)(i*16), | |
466 | (unsigned char)(i*16), | |
467 | (unsigned char)(i*16) | |
468 | ); | |
469 | m_clrData.SetCustomColour(i, colour); | |
470 | } | |
471 | ||
472 | wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &m_clrData); | |
473 | if (dialog->ShowModal() == wxID_OK) | |
474 | { | |
475 | m_clrData = dialog->GetColourData(); | |
476 | myCanvas->SetBackgroundColour(m_clrData.GetColour()); | |
477 | myCanvas->ClearBackground(); | |
478 | myCanvas->Refresh(); | |
479 | } | |
480 | dialog->Destroy(); | |
481 | } | |
482 | #endif // USE_COLOURDLG_GENERIC | |
483 | ||
13188def | 484 | #if wxUSE_FONTDLG |
d355d3fe | 485 | void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 486 | { |
dbc65e27 VZ |
487 | wxFontData data; |
488 | data.SetInitialFont(wxGetApp().m_canvasFont); | |
489 | data.SetColour(wxGetApp().m_canvasTextColour); | |
d93c719a | 490 | |
dbc65e27 VZ |
491 | // you might also do this: |
492 | // | |
493 | // wxFontDialog dialog; | |
494 | // if ( !dialog.Create(this, data) { ... error ... } | |
495 | // | |
496 | wxFontDialog dialog(this, data); | |
497 | ||
498 | if (dialog.ShowModal() == wxID_OK) | |
499 | { | |
500 | wxFontData retData = dialog.GetFontData(); | |
457814b5 JS |
501 | wxGetApp().m_canvasFont = retData.GetChosenFont(); |
502 | wxGetApp().m_canvasTextColour = retData.GetColour(); | |
503 | myCanvas->Refresh(); | |
dbc65e27 VZ |
504 | } |
505 | //else: cancelled by the user, don't change the font | |
457814b5 | 506 | } |
13188def | 507 | #endif // wxUSE_FONTDLG |
457814b5 | 508 | |
13188def | 509 | #if USE_FONTDLG_GENERIC |
d355d3fe | 510 | void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 511 | { |
13188def WS |
512 | wxFontData data; |
513 | data.SetInitialFont(wxGetApp().m_canvasFont); | |
514 | data.SetColour(wxGetApp().m_canvasTextColour); | |
457814b5 | 515 | |
ca3e85cf | 516 | wxGenericFontDialog *dialog = new wxGenericFontDialog(this, data); |
13188def WS |
517 | if (dialog->ShowModal() == wxID_OK) |
518 | { | |
457814b5 JS |
519 | wxFontData retData = dialog->GetFontData(); |
520 | wxGetApp().m_canvasFont = retData.GetChosenFont(); | |
521 | wxGetApp().m_canvasTextColour = retData.GetColour(); | |
522 | myCanvas->Refresh(); | |
13188def WS |
523 | } |
524 | dialog->Destroy(); | |
457814b5 | 525 | } |
13188def | 526 | #endif // USE_FONTDLG_GENERIC |
d93c719a | 527 | |
b4954d19 | 528 | #if wxUSE_LOG_DIALOG |
87728739 | 529 | void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event)) |
d93c719a | 530 | { |
2c8e4738 VZ |
531 | // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages |
532 | // being flushed -- test it | |
533 | { | |
534 | wxBusyCursor bc; | |
4693b20c MB |
535 | wxLogMessage(wxT("This is some message - everything is ok so far.")); |
536 | wxLogMessage(wxT("Another message...\n... this one is on multiple lines")); | |
537 | wxLogWarning(wxT("And then something went wrong!")); | |
9fe52545 VZ |
538 | |
539 | // and if ~wxBusyCursor doesn't do it, then call it manually | |
540 | wxYield(); | |
2c8e4738 VZ |
541 | } |
542 | ||
4693b20c MB |
543 | wxLogError(wxT("Intermediary error handler decided to abort.")); |
544 | wxLogError(wxT("The top level caller detected an unrecoverable error.")); | |
5888ef1e | 545 | |
7923c649 VZ |
546 | wxLog::FlushActive(); |
547 | ||
4693b20c | 548 | wxLogMessage(wxT("And this is the same dialog but with only one message.")); |
d93c719a | 549 | } |
b4954d19 | 550 | #endif // wxUSE_LOG_DIALOG |
457814b5 | 551 | |
d355d3fe | 552 | void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 553 | { |
13188def WS |
554 | wxMessageDialog dialog( NULL, _T("This is a message box\nA long, long string to test out the message box properly"), |
555 | _T("Message box text"), wxNO_DEFAULT|wxYES_NO|wxCANCEL|wxICON_INFORMATION); | |
457814b5 | 556 | |
13188def WS |
557 | switch ( dialog.ShowModal() ) |
558 | { | |
559 | case wxID_YES: | |
560 | wxLogStatus(wxT("You pressed \"Yes\"")); | |
561 | break; | |
49b957be | 562 | |
13188def WS |
563 | case wxID_NO: |
564 | wxLogStatus(wxT("You pressed \"No\"")); | |
565 | break; | |
49b957be | 566 | |
13188def WS |
567 | case wxID_CANCEL: |
568 | wxLogStatus(wxT("You pressed \"Cancel\"")); | |
569 | break; | |
49b957be | 570 | |
13188def WS |
571 | default: |
572 | wxLogError(wxT("Unexpected wxMessageDialog return code!")); | |
573 | } | |
457814b5 JS |
574 | } |
575 | ||
13188def | 576 | #if wxUSE_NUMBERDLG |
c49245f8 VZ |
577 | void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) ) |
578 | { | |
78a189c9 VZ |
579 | long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n") |
580 | _T("Even two rows of text."), | |
581 | _T("Enter a number:"), _T("Numeric input test"), | |
e65cc56a | 582 | 50, 0, 100, this ); |
c49245f8 VZ |
583 | |
584 | wxString msg; | |
585 | int icon; | |
586 | if ( res == -1 ) | |
587 | { | |
78a189c9 | 588 | msg = _T("Invalid number entered or dialog cancelled."); |
c49245f8 VZ |
589 | icon = wxICON_HAND; |
590 | } | |
591 | else | |
d93c719a VZ |
592 | { |
593 | msg.Printf(_T("You've entered %lu"), res ); | |
c49245f8 VZ |
594 | icon = wxICON_INFORMATION; |
595 | } | |
596 | ||
78a189c9 | 597 | wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this); |
c49245f8 | 598 | } |
13188def | 599 | #endif // wxUSE_NUMBERDLG |
c49245f8 | 600 | |
13188def | 601 | #if wxUSE_TEXTDLG |
a294c6d5 | 602 | void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 603 | { |
2f1cd905 | 604 | wxString pwd = wxGetPasswordFromUser(_T("Enter password:"), |
78a189c9 | 605 | _T("Password entry dialog"), |
dabbc6a5 | 606 | wxEmptyString, |
a294c6d5 | 607 | this); |
ecda9475 | 608 | if ( !pwd.empty() ) |
a294c6d5 | 609 | { |
4693b20c | 610 | wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()), |
78a189c9 | 611 | _T("Got password"), wxOK | wxICON_INFORMATION, this); |
a294c6d5 VZ |
612 | } |
613 | } | |
614 | ||
615 | void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event)) | |
616 | { | |
13188def WS |
617 | wxTextEntryDialog dialog(this, |
618 | _T("This is a small sample\n") | |
619 | _T("A long, long string to test out the text entrybox"), | |
620 | _T("Please enter a string"), | |
621 | _T("Default value"), | |
622 | wxOK | wxCANCEL); | |
457814b5 | 623 | |
13188def WS |
624 | if (dialog.ShowModal() == wxID_OK) |
625 | { | |
b4954d19 | 626 | wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this); |
13188def | 627 | } |
457814b5 | 628 | } |
13188def | 629 | #endif // wxUSE_TEXTDLG |
457814b5 | 630 | |
13188def | 631 | #if wxUSE_CHOICEDLG |
d355d3fe | 632 | void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 633 | { |
78a189c9 | 634 | const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ; |
457814b5 | 635 | |
5f95bb70 | 636 | wxSingleChoiceDialog dialog(this, |
78a189c9 VZ |
637 | _T("This is a small sample\n") |
638 | _T("A single-choice convenience dialog"), | |
639 | _T("Please select a value"), | |
5f95bb70 | 640 | WXSIZEOF(choices), choices); |
457814b5 | 641 | |
ef77f91e JS |
642 | dialog.SetSelection(2); |
643 | ||
644 | if (dialog.ShowModal() == wxID_OK) | |
645 | { | |
78a189c9 | 646 | wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string")); |
ef77f91e JS |
647 | dialog2.ShowModal(); |
648 | } | |
457814b5 JS |
649 | } |
650 | ||
d6c9c1b7 VZ |
651 | void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) ) |
652 | { | |
5f95bb70 VZ |
653 | const wxString choices[] = |
654 | { | |
78a189c9 VZ |
655 | _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"), |
656 | _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"), | |
657 | _T("Eleven"), _T("Twelve"), _T("Seventeen"), | |
5f95bb70 | 658 | }; |
d6c9c1b7 VZ |
659 | |
660 | wxArrayInt selections; | |
661 | size_t count = wxGetMultipleChoices(selections, | |
78a189c9 VZ |
662 | _T("This is a small sample\n") |
663 | _T("A multi-choice convenience dialog"), | |
664 | _T("Please select a value"), | |
5f95bb70 | 665 | WXSIZEOF(choices), choices, |
d6c9c1b7 VZ |
666 | this); |
667 | if ( count ) | |
668 | { | |
3d49ce44 | 669 | wxString msg; |
fba1b53b | 670 | msg.Printf(wxT("You selected %u items:\n"), (unsigned)count); |
d6c9c1b7 VZ |
671 | for ( size_t n = 0; n < count; n++ ) |
672 | { | |
fba1b53b VZ |
673 | msg += wxString::Format(wxT("\t%u: %u (%s)\n"), |
674 | (unsigned)n, (unsigned)selections[n], | |
3d49ce44 | 675 | choices[selections[n]].c_str()); |
d6c9c1b7 | 676 | } |
3d49ce44 | 677 | wxLogMessage(msg); |
d6c9c1b7 VZ |
678 | } |
679 | //else: cancelled or nothing selected | |
680 | } | |
13188def | 681 | #endif // wxUSE_CHOICEDLG |
d6c9c1b7 | 682 | |
13188def | 683 | #if wxUSE_FILEDLG |
d355d3fe | 684 | void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 685 | { |
fbf4eacb VZ |
686 | wxFileDialog dialog |
687 | ( | |
688 | this, | |
689 | _T("Testing open file dialog"), | |
dabbc6a5 DS |
690 | wxEmptyString, |
691 | wxEmptyString, | |
a4e64fb5 MB |
692 | #ifdef __WXMOTIF__ |
693 | _T("C++ files (*.cpp)|*.cpp") | |
694 | #else | |
daf32463 | 695 | _T("C++ files (*.cpp;*.h)|*.cpp;*.h") |
a4e64fb5 | 696 | #endif |
fbf4eacb | 697 | ); |
457814b5 | 698 | |
3b6c3fc8 | 699 | dialog.CentreOnParent(); |
cd7afaff | 700 | dialog.SetDirectory(wxGetHomeDir()); |
5b636c67 | 701 | |
c50f1fb9 VZ |
702 | if (dialog.ShowModal() == wxID_OK) |
703 | { | |
5919d76b | 704 | wxString info; |
13393ab6 RR |
705 | info.Printf(_T("Full file name: %s\n") |
706 | _T("Path: %s\n") | |
707 | _T("Name: %s"), | |
5919d76b VZ |
708 | dialog.GetPath().c_str(), |
709 | dialog.GetDirectory().c_str(), | |
710 | dialog.GetFilename().c_str()); | |
78a189c9 | 711 | wxMessageDialog dialog2(this, info, _T("Selected file")); |
c50f1fb9 VZ |
712 | dialog2.ShowModal(); |
713 | } | |
457814b5 JS |
714 | } |
715 | ||
35b45b33 VZ |
716 | // this shows how to take advantage of specifying a default extension in the |
717 | // call to wxFileSelector: it is remembered after each new call and the next | |
718 | // one will use it by default | |
719 | void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) ) | |
720 | { | |
721 | static wxString s_extDef; | |
722 | wxString path = wxFileSelector( | |
723 | _T("Select the file to load"), | |
dabbc6a5 | 724 | wxEmptyString, wxEmptyString, |
35b45b33 | 725 | s_extDef, |
3601f639 VZ |
726 | wxString::Format |
727 | ( | |
728 | _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"), | |
729 | wxFileSelectorDefaultWildcardStr, | |
730 | wxFileSelectorDefaultWildcardStr | |
731 | ), | |
fbf4eacb | 732 | wxCHANGE_DIR, |
35b45b33 VZ |
733 | this |
734 | ); | |
735 | ||
736 | if ( !path ) | |
737 | return; | |
738 | ||
739 | // it is just a sample, would use wxSplitPath in real program | |
740 | s_extDef = path.AfterLast(_T('.')); | |
741 | ||
742 | wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"), | |
37d403aa | 743 | (const wxChar*) path, (const wxChar*) s_extDef); |
35b45b33 VZ |
744 | } |
745 | ||
c61f4f6d VZ |
746 | void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) ) |
747 | { | |
dabbc6a5 | 748 | wxString wildcards = |
f0f43012 JS |
749 | #ifdef __WXMOTIF__ |
750 | _T("C++ files (*.cpp)|*.cpp"); | |
751 | #else | |
3601f639 VZ |
752 | wxString::Format |
753 | ( | |
754 | _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"), | |
755 | wxFileSelectorDefaultWildcardStr, | |
756 | wxFileSelectorDefaultWildcardStr | |
757 | ); | |
f0f43012 | 758 | #endif |
78a189c9 | 759 | wxFileDialog dialog(this, _T("Testing open multiple file dialog"), |
dabbc6a5 | 760 | wxEmptyString, wxEmptyString, wildcards, |
470caaf9 | 761 | wxMULTIPLE); |
c61f4f6d VZ |
762 | |
763 | if (dialog.ShowModal() == wxID_OK) | |
764 | { | |
765 | wxArrayString paths, filenames; | |
766 | ||
767 | dialog.GetPaths(paths); | |
768 | dialog.GetFilenames(filenames); | |
769 | ||
770 | wxString msg, s; | |
771 | size_t count = paths.GetCount(); | |
772 | for ( size_t n = 0; n < count; n++ ) | |
773 | { | |
774 | s.Printf(_T("File %d: %s (%s)\n"), | |
fba1b53b | 775 | (int)n, paths[n].c_str(), filenames[n].c_str()); |
c61f4f6d VZ |
776 | |
777 | msg += s; | |
778 | } | |
f0f43012 JS |
779 | s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); |
780 | msg += s; | |
c61f4f6d | 781 | |
78a189c9 | 782 | wxMessageDialog dialog2(this, msg, _T("Selected files")); |
c61f4f6d VZ |
783 | dialog2.ShowModal(); |
784 | } | |
785 | } | |
786 | ||
d355d3fe | 787 | void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 788 | { |
2f1cd905 VZ |
789 | wxFileDialog dialog(this, |
790 | _T("Testing save file dialog"), | |
dabbc6a5 | 791 | wxEmptyString, |
2b5f62a0 | 792 | _T("myletter.doc"), |
2f1cd905 VZ |
793 | _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"), |
794 | wxSAVE|wxOVERWRITE_PROMPT); | |
c50f1fb9 | 795 | |
2b5f62a0 VZ |
796 | dialog.SetFilterIndex(1); |
797 | ||
c50f1fb9 VZ |
798 | if (dialog.ShowModal() == wxID_OK) |
799 | { | |
2b5f62a0 VZ |
800 | wxLogMessage(_T("%s, filter %d"), |
801 | dialog.GetPath().c_str(), dialog.GetFilterIndex()); | |
c50f1fb9 | 802 | } |
457814b5 | 803 | } |
13188def | 804 | #endif // wxUSE_FILEDLG |
457814b5 | 805 | |
695fe764 WS |
806 | #if USE_FILEDLG_GENERIC |
807 | void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) ) | |
808 | { | |
809 | wxGenericFileDialog dialog | |
810 | ( | |
811 | this, | |
812 | _T("Testing open file dialog"), | |
813 | wxEmptyString, | |
814 | wxEmptyString, | |
daf32463 | 815 | _T("C++ files (*.cpp;*.h)|*.cpp;*.h") |
695fe764 WS |
816 | ); |
817 | ||
818 | dialog.SetDirectory(wxGetHomeDir()); | |
819 | ||
820 | if (dialog.ShowModal() == wxID_OK) | |
821 | { | |
822 | wxString info; | |
823 | info.Printf(_T("Full file name: %s\n") | |
824 | _T("Path: %s\n") | |
825 | _T("Name: %s"), | |
826 | dialog.GetPath().c_str(), | |
827 | dialog.GetDirectory().c_str(), | |
828 | dialog.GetFilename().c_str()); | |
829 | wxMessageDialog dialog2(this, info, _T("Selected file")); | |
830 | dialog2.ShowModal(); | |
831 | } | |
832 | } | |
833 | ||
834 | void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) ) | |
835 | { | |
684883e3 WS |
836 | // On PocketPC you can disable OK-only dialogs policy using system option |
837 | int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel")); | |
838 | wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1); | |
839 | ||
daf32463 | 840 | wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h"); |
695fe764 WS |
841 | wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"), |
842 | wxEmptyString, wxEmptyString, wildcards, | |
843 | wxMULTIPLE); | |
844 | ||
845 | if (dialog.ShowModal() == wxID_OK) | |
846 | { | |
847 | wxArrayString paths, filenames; | |
848 | ||
849 | dialog.GetPaths(paths); | |
850 | dialog.GetFilenames(filenames); | |
851 | ||
852 | wxString msg, s; | |
853 | size_t count = paths.GetCount(); | |
854 | for ( size_t n = 0; n < count; n++ ) | |
855 | { | |
856 | s.Printf(_T("File %d: %s (%s)\n"), | |
857 | (int)n, paths[n].c_str(), filenames[n].c_str()); | |
858 | ||
859 | msg += s; | |
860 | } | |
861 | s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); | |
862 | msg += s; | |
863 | ||
864 | wxMessageDialog dialog2(this, msg, _T("Selected files")); | |
865 | dialog2.ShowModal(); | |
866 | } | |
684883e3 WS |
867 | |
868 | // restore system option | |
869 | wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons); | |
695fe764 WS |
870 | } |
871 | ||
872 | void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) ) | |
873 | { | |
874 | wxGenericFileDialog dialog(this, | |
875 | _T("Testing save file dialog"), | |
876 | wxEmptyString, | |
877 | _T("myletter.doc"), | |
878 | _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"), | |
879 | wxSAVE|wxOVERWRITE_PROMPT); | |
880 | ||
881 | dialog.SetFilterIndex(1); | |
882 | ||
883 | if (dialog.ShowModal() == wxID_OK) | |
884 | { | |
885 | wxLogMessage(_T("%s, filter %d"), | |
886 | dialog.GetPath().c_str(), dialog.GetFilterIndex()); | |
887 | } | |
888 | } | |
889 | #endif // USE_FILEDLG_GENERIC | |
890 | ||
13188def | 891 | #if wxUSE_DIRDLG |
f09c8393 | 892 | void MyFrame::DoDirChoose(int style) |
457814b5 | 893 | { |
3f2711d5 VZ |
894 | // pass some initial dir to wxDirDialog |
895 | wxString dirHome; | |
896 | wxGetHomeDir(&dirHome); | |
897 | ||
f09c8393 | 898 | wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style); |
c50f1fb9 VZ |
899 | |
900 | if (dialog.ShowModal() == wxID_OK) | |
901 | { | |
2b5f62a0 | 902 | wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str()); |
c50f1fb9 VZ |
903 | } |
904 | } | |
905 | ||
f09c8393 VZ |
906 | void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) |
907 | { | |
908 | DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_NEW_DIR_BUTTON); | |
909 | } | |
910 | ||
911 | void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) ) | |
912 | { | |
8768548b | 913 | DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON); |
f09c8393 | 914 | } |
13188def | 915 | #endif // wxUSE_DIRDLG |
f09c8393 | 916 | |
13188def | 917 | #if USE_DIRDLG_GENERIC |
51a58d8b JS |
918 | void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) ) |
919 | { | |
920 | // pass some initial dir to wxDirDialog | |
921 | wxString dirHome; | |
922 | wxGetHomeDir(&dirHome); | |
923 | ||
78a189c9 | 924 | wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome); |
51a58d8b JS |
925 | |
926 | if (dialog.ShowModal() == wxID_OK) | |
927 | { | |
78a189c9 | 928 | wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path")); |
51a58d8b JS |
929 | dialog2.ShowModal(); |
930 | } | |
931 | } | |
13188def | 932 | #endif // USE_DIRDLG_GENERIC |
51a58d8b | 933 | |
13188def | 934 | #if USE_MODAL_PRESENTATION |
f6bcfd97 BP |
935 | void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event)) |
936 | { | |
937 | MyModalDialog dlg(this); | |
938 | dlg.ShowModal(); | |
939 | } | |
940 | ||
4c45f240 VZ |
941 | void MyFrame::ModelessDlg(wxCommandEvent& event) |
942 | { | |
2f82899b | 943 | bool show = GetMenuBar()->IsChecked(event.GetId()); |
4c45f240 VZ |
944 | |
945 | if ( show ) | |
946 | { | |
947 | if ( !m_dialog ) | |
948 | { | |
949 | m_dialog = new MyModelessDialog(this); | |
950 | } | |
951 | ||
13188def | 952 | m_dialog->Show(true); |
4c45f240 VZ |
953 | } |
954 | else // hide | |
955 | { | |
26a12ab3 JS |
956 | // If m_dialog is NULL, then possibly the system |
957 | // didn't report the checked menu item status correctly. | |
958 | // It should be true just after the menu item was selected, | |
959 | // if there was no modeless dialog yet. | |
960 | ||
961 | wxASSERT( m_dialog != NULL ); | |
962 | if (m_dialog) | |
963 | m_dialog->Hide(); | |
4c45f240 VZ |
964 | } |
965 | } | |
cae50e6b VZ |
966 | |
967 | void MyFrame::DlgCenteredScreen(wxCommandEvent& WXUNUSED(event)) | |
968 | { | |
969 | wxDialog dlg(this, wxID_ANY, _T("Dialog centered on screen"), | |
970 | wxDefaultPosition, wxSize(200, 100)); | |
cd7afaff | 971 | (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre(); |
cae50e6b VZ |
972 | dlg.CentreOnScreen(); |
973 | dlg.ShowModal(); | |
974 | } | |
975 | ||
976 | void MyFrame::DlgCenteredParent(wxCommandEvent& WXUNUSED(event)) | |
977 | { | |
978 | wxDialog dlg(this, wxID_ANY, _T("Dialog centered on parent"), | |
979 | wxDefaultPosition, wxSize(200, 100)); | |
cd7afaff | 980 | (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre(); |
cae50e6b VZ |
981 | dlg.CentreOnParent(); |
982 | dlg.ShowModal(); | |
983 | } | |
984 | ||
13188def | 985 | #endif // USE_MODAL_PRESENTATION |
4c45f240 | 986 | |
13188def | 987 | #if wxUSE_STARTUP_TIPS |
87728739 | 988 | void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) |
c50f1fb9 VZ |
989 | { |
990 | static size_t s_index = (size_t)-1; | |
991 | ||
992 | if ( s_index == (size_t)-1 ) | |
993 | { | |
994 | srand(time(NULL)); | |
995 | ||
996 | // this is completely bogus, we don't know how many lines are there | |
997 | // in the file, but who cares, it's a demo only... | |
998 | s_index = rand() % 5; | |
999 | } | |
1000 | ||
2f1cd905 | 1001 | wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index); |
c50f1fb9 VZ |
1002 | |
1003 | bool showAtStartup = wxShowTip(this, tipProvider); | |
1004 | ||
1005 | if ( showAtStartup ) | |
1006 | { | |
2f1cd905 | 1007 | wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"), |
c50f1fb9 VZ |
1008 | wxOK | wxICON_INFORMATION, this); |
1009 | } | |
457814b5 | 1010 | |
c50f1fb9 VZ |
1011 | s_index = tipProvider->GetCurrentTip(); |
1012 | delete tipProvider; | |
457814b5 | 1013 | } |
13188def | 1014 | #endif // wxUSE_STARTUP_TIPS |
457814b5 | 1015 | |
532d575b | 1016 | #if USE_SETTINGS_DIALOG |
64d3ed17 | 1017 | void MyFrame::OnPropertySheet(wxCommandEvent& event) |
0f5d8ecf | 1018 | { |
64d3ed17 | 1019 | SettingsDialog dialog(this, event.GetId()); |
cc8bc5aa JS |
1020 | dialog.ShowModal(); |
1021 | } | |
532d575b | 1022 | #endif // USE_SETTINGS_DIALOG |
0f5d8ecf | 1023 | |
9b16ffef VZ |
1024 | void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event)) |
1025 | { | |
1026 | wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window")); | |
1027 | ||
1028 | wxSleep(3); | |
1029 | ||
1030 | RequestUserAttention(wxUSER_ATTENTION_ERROR); | |
1031 | } | |
1032 | ||
d355d3fe | 1033 | void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) ) |
457814b5 | 1034 | { |
13188def | 1035 | Close(true); |
457814b5 JS |
1036 | } |
1037 | ||
abceee76 VZ |
1038 | #if wxUSE_PROGRESSDLG |
1039 | ||
1040 | void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) ) | |
1041 | { | |
9b16ffef VZ |
1042 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
1043 | // check the performance | |
1044 | int countrandomnumbers = 0, count = 0; | |
1045 | wxTimeSpan tsTest(0,0,0,250); | |
1046 | wxDateTime DT2, DT1 = wxDateTime::UNow(); | |
1047 | srand(0); | |
1048 | while(1) | |
1049 | { | |
1050 | rand(); | |
1051 | ++countrandomnumbers; | |
1052 | if ( countrandomnumbers == 1000 ) | |
1053 | { | |
1054 | srand(0); | |
1055 | countrandomnumbers = 0; | |
1056 | ++count; | |
1057 | DT2 = wxDateTime::UNow(); | |
1058 | wxTimeSpan ts = DT2.Subtract( DT1 ); | |
1059 | if ( ts.IsLongerThan( tsTest ) ) | |
1060 | { | |
1061 | break; | |
1062 | } | |
1063 | } | |
1064 | } | |
1065 | const int max = 40 * count; | |
1066 | #else | |
abceee76 | 1067 | static const int max = 10; |
9b16ffef | 1068 | #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG |
abceee76 | 1069 | |
2f1cd905 | 1070 | wxProgressDialog dialog(_T("Progress dialog example"), |
78a189c9 | 1071 | _T("An informative message"), |
abceee76 VZ |
1072 | max, // range |
1073 | this, // parent | |
1074 | wxPD_CAN_ABORT | | |
ecda9475 | 1075 | wxPD_CAN_SKIP | |
abceee76 | 1076 | wxPD_APP_MODAL | |
df26c4c6 | 1077 | // wxPD_AUTO_HIDE | -- try this as well |
abceee76 VZ |
1078 | wxPD_ELAPSED_TIME | |
1079 | wxPD_ESTIMATED_TIME | | |
ecda9475 WS |
1080 | wxPD_REMAINING_TIME | |
1081 | wxPD_SMOOTH); | |
abceee76 | 1082 | |
13188def | 1083 | bool cont = true; |
ecda9475 WS |
1084 | bool skip = false; |
1085 | // each skip will move progress about quarter forward | |
1086 | for ( int i = 0; i <= max; i = wxMin(i+(skip?int(max/4):1), max+1), skip = false ) | |
abceee76 | 1087 | { |
9b16ffef VZ |
1088 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG |
1089 | // do (almost) the same operations as we did for the performance test | |
1090 | srand(0); | |
1091 | for ( int j = 0; j < 1000; j++ ) | |
1092 | { | |
1093 | rand(); | |
1094 | if ( j == 999 ) | |
1095 | { | |
1096 | DT2 = wxDateTime::UNow(); | |
1097 | wxTimeSpan ts = DT2.Subtract( DT1 ); | |
1098 | if ( ts.IsLongerThan( tsTest ) ) | |
1099 | { | |
1100 | // nothing to do | |
1101 | } | |
1102 | } | |
1103 | } | |
1104 | #else | |
abceee76 | 1105 | wxSleep(1); |
9b16ffef | 1106 | #endif |
ecda9475 WS |
1107 | |
1108 | wxString msg; | |
1109 | ||
abceee76 VZ |
1110 | if ( i == max ) |
1111 | { | |
ecda9475 | 1112 | msg = _T("That's all, folks!"); |
abceee76 | 1113 | } |
ecda9475 | 1114 | else if ( i > max / 2 ) |
abceee76 | 1115 | { |
ecda9475 | 1116 | msg = _T("Only a half left (very long message)!"); |
abceee76 | 1117 | } |
ecda9475 WS |
1118 | |
1119 | #if wxUSE_STOPWATCH && wxUSE_LONGLONG | |
1120 | if ( (i % (max/100)) == 0 ) // // only 100 updates, this makes it much faster | |
abceee76 | 1121 | { |
ecda9475 | 1122 | cont = dialog.Update(i, msg, &skip); |
abceee76 | 1123 | } |
ecda9475 WS |
1124 | #else |
1125 | cont = dialog.Update(i, msg, &skip); | |
1126 | #endif | |
1127 | ||
d8ddee9c VZ |
1128 | if ( !cont ) |
1129 | { | |
78a189c9 VZ |
1130 | if ( wxMessageBox(_T("Do you really want to cancel?"), |
1131 | _T("Progress dialog question"), // caption | |
1132 | wxYES_NO | wxICON_QUESTION) == wxYES ) | |
d8ddee9c VZ |
1133 | break; |
1134 | ||
9b16ffef | 1135 | cont = true; |
d8ddee9c VZ |
1136 | dialog.Resume(); |
1137 | } | |
abceee76 VZ |
1138 | } |
1139 | ||
1140 | if ( !cont ) | |
1141 | { | |
4693b20c | 1142 | wxLogStatus(wxT("Progress dialog aborted!")); |
abceee76 VZ |
1143 | } |
1144 | else | |
1145 | { | |
4693b20c | 1146 | wxLogStatus(wxT("Countdown from %d finished"), max); |
abceee76 VZ |
1147 | } |
1148 | } | |
1149 | ||
1150 | #endif // wxUSE_PROGRESSDLG | |
1151 | ||
a62b0bcc VZ |
1152 | #if wxUSE_BUSYINFO |
1153 | ||
1154 | void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event)) | |
1155 | { | |
21977bac VZ |
1156 | wxWindowDisabler disableAll; |
1157 | ||
9f84eccd | 1158 | wxBusyInfo info(_T("Working, please wait..."), this); |
a62b0bcc | 1159 | |
5b636c67 | 1160 | for ( int i = 0; i < 18; i++ ) |
a62b0bcc | 1161 | { |
5b636c67 | 1162 | //wxUsleep(100); |
a62b0bcc VZ |
1163 | wxTheApp->Yield(); |
1164 | } | |
5b636c67 VZ |
1165 | |
1166 | wxSleep(2); | |
1167 | //wxWakeUpIdle(); | |
a62b0bcc VZ |
1168 | } |
1169 | ||
1170 | #endif // wxUSE_BUSYINFO | |
1171 | ||
761989ff VZ |
1172 | #if wxUSE_FINDREPLDLG |
1173 | ||
1174 | void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) ) | |
1175 | { | |
14fca738 VZ |
1176 | if ( m_dlgReplace ) |
1177 | { | |
1178 | delete m_dlgReplace; | |
1179 | m_dlgReplace = NULL; | |
1180 | } | |
1181 | else | |
1182 | { | |
1183 | m_dlgReplace = new wxFindReplaceDialog | |
1184 | ( | |
1185 | this, | |
1186 | &m_findData, | |
78a189c9 | 1187 | _T("Find and replace dialog"), |
14fca738 VZ |
1188 | wxFR_REPLACEDIALOG |
1189 | ); | |
1190 | ||
13188def | 1191 | m_dlgReplace->Show(true); |
14fca738 | 1192 | } |
761989ff VZ |
1193 | } |
1194 | ||
1195 | void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) ) | |
1196 | { | |
14fca738 VZ |
1197 | if ( m_dlgFind ) |
1198 | { | |
1199 | delete m_dlgFind; | |
1200 | m_dlgFind = NULL; | |
1201 | } | |
1202 | else | |
1203 | { | |
1204 | m_dlgFind = new wxFindReplaceDialog | |
1205 | ( | |
1206 | this, | |
1207 | &m_findData, | |
78a189c9 | 1208 | _T("Find dialog"), |
14fca738 VZ |
1209 | // just for testing |
1210 | wxFR_NOWHOLEWORD | |
1211 | ); | |
1212 | ||
13188def | 1213 | m_dlgFind->Show(true); |
14fca738 | 1214 | } |
761989ff VZ |
1215 | } |
1216 | ||
1217 | static wxString DecodeFindDialogEventFlags(int flags) | |
1218 | { | |
1219 | wxString str; | |
78a189c9 | 1220 | str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ") |
2f1cd905 VZ |
1221 | << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T("")) |
1222 | << (flags & wxFR_MATCHCASE ? _T("") : _T("not ")) | |
78a189c9 | 1223 | << _T("case sensitive"); |
761989ff VZ |
1224 | |
1225 | return str; | |
1226 | } | |
1227 | ||
1228 | void MyFrame::OnFindDialog(wxFindDialogEvent& event) | |
1229 | { | |
1230 | wxEventType type = event.GetEventType(); | |
1231 | ||
1232 | if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT ) | |
1233 | { | |
4693b20c | 1234 | wxLogMessage(wxT("Find %s'%s' (flags: %s)"), |
eba33006 | 1235 | type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""), |
761989ff VZ |
1236 | event.GetFindString().c_str(), |
1237 | DecodeFindDialogEventFlags(event.GetFlags()).c_str()); | |
1238 | } | |
1239 | else if ( type == wxEVT_COMMAND_FIND_REPLACE || | |
1240 | type == wxEVT_COMMAND_FIND_REPLACE_ALL ) | |
1241 | { | |
4693b20c | 1242 | wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"), |
eba33006 | 1243 | type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""), |
761989ff VZ |
1244 | event.GetFindString().c_str(), |
1245 | event.GetReplaceString().c_str(), | |
1246 | DecodeFindDialogEventFlags(event.GetFlags()).c_str()); | |
1247 | } | |
1248 | else if ( type == wxEVT_COMMAND_FIND_CLOSE ) | |
1249 | { | |
14fca738 VZ |
1250 | wxFindReplaceDialog *dlg = event.GetDialog(); |
1251 | ||
df26c4c6 | 1252 | int idMenu; |
14fca738 VZ |
1253 | const wxChar *txt; |
1254 | if ( dlg == m_dlgFind ) | |
1255 | { | |
1256 | txt = _T("Find"); | |
df26c4c6 | 1257 | idMenu = DIALOGS_FIND; |
14fca738 VZ |
1258 | m_dlgFind = NULL; |
1259 | } | |
1260 | else if ( dlg == m_dlgReplace ) | |
1261 | { | |
1262 | txt = _T("Replace"); | |
df26c4c6 | 1263 | idMenu = DIALOGS_REPLACE; |
14fca738 VZ |
1264 | m_dlgReplace = NULL; |
1265 | } | |
1266 | else | |
1267 | { | |
1268 | txt = _T("Unknown"); | |
13188def | 1269 | idMenu = wxID_ANY; |
14fca738 | 1270 | |
2f1cd905 | 1271 | wxFAIL_MSG( _T("unexpected event") ); |
14fca738 VZ |
1272 | } |
1273 | ||
df26c4c6 VZ |
1274 | wxLogMessage(wxT("%s dialog is being closed."), txt); |
1275 | ||
13188def | 1276 | if ( idMenu != wxID_ANY ) |
df26c4c6 | 1277 | { |
13188def | 1278 | GetMenuBar()->Check(idMenu, false); |
df26c4c6 | 1279 | } |
761989ff | 1280 | |
14fca738 | 1281 | dlg->Destroy(); |
761989ff VZ |
1282 | } |
1283 | else | |
1284 | { | |
4693b20c | 1285 | wxLogError(wxT("Unknown find dialog event!")); |
761989ff VZ |
1286 | } |
1287 | } | |
1288 | ||
1289 | #endif // wxUSE_FINDREPLDLG | |
1290 | ||
abceee76 VZ |
1291 | // ---------------------------------------------------------------------------- |
1292 | // MyCanvas | |
1293 | // ---------------------------------------------------------------------------- | |
1294 | ||
d355d3fe | 1295 | void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) ) |
457814b5 | 1296 | { |
c50f1fb9 | 1297 | wxPaintDC dc(this); |
457814b5 JS |
1298 | dc.SetFont(wxGetApp().m_canvasFont); |
1299 | dc.SetTextForeground(wxGetApp().m_canvasTextColour); | |
1300 | dc.SetBackgroundMode(wxTRANSPARENT); | |
dc96b1b6 WS |
1301 | dc.DrawText( |
1302 | _T("wxWidgets common dialogs") | |
1303 | #if !defined(__SMARTPHONE__) | |
1304 | _T(" test application") | |
1305 | #endif | |
1306 | , 10, 10); | |
457814b5 JS |
1307 | } |
1308 | ||
b4954d19 WS |
1309 | #if USE_MODAL_PRESENTATION |
1310 | ||
4c45f240 VZ |
1311 | // ---------------------------------------------------------------------------- |
1312 | // MyModelessDialog | |
1313 | // ---------------------------------------------------------------------------- | |
457814b5 | 1314 | |
4c45f240 | 1315 | MyModelessDialog::MyModelessDialog(wxWindow *parent) |
13188def | 1316 | : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog"))) |
4c45f240 | 1317 | { |
cbc66a27 VZ |
1318 | wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); |
1319 | ||
78a189c9 | 1320 | wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me")); |
13188def | 1321 | wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled")); |
cbc66a27 VZ |
1322 | check->Disable(); |
1323 | ||
1324 | sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5); | |
1325 | sizerTop->Add(check, 1, wxEXPAND | wxALL, 5); | |
1326 | ||
cbc66a27 VZ |
1327 | SetSizer(sizerTop); |
1328 | ||
1329 | sizerTop->SetSizeHints(this); | |
1330 | sizerTop->Fit(this); | |
4c45f240 | 1331 | } |
abceee76 | 1332 | |
5d987909 VZ |
1333 | void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event)) |
1334 | { | |
2f1cd905 | 1335 | wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"), |
5d987909 VZ |
1336 | wxOK | wxICON_INFORMATION, this); |
1337 | } | |
1338 | ||
abceee76 VZ |
1339 | void MyModelessDialog::OnClose(wxCloseEvent& event) |
1340 | { | |
1341 | if ( event.CanVeto() ) | |
1342 | { | |
2f1cd905 | 1343 | wxMessageBox(_T("Use the menu item to close this dialog"), |
78a189c9 | 1344 | _T("Modeless dialog"), |
abceee76 VZ |
1345 | wxOK | wxICON_INFORMATION, this); |
1346 | ||
1347 | event.Veto(); | |
1348 | } | |
1349 | } | |
1350 | ||
f6bcfd97 BP |
1351 | // ---------------------------------------------------------------------------- |
1352 | // MyModalDialog | |
1353 | // ---------------------------------------------------------------------------- | |
1354 | ||
1355 | MyModalDialog::MyModalDialog(wxWindow *parent) | |
13188def | 1356 | : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog"))) |
f6bcfd97 BP |
1357 | { |
1358 | wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); | |
1359 | ||
13188def WS |
1360 | m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog...")); |
1361 | m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog")); | |
1362 | m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button")); | |
5315ebfa | 1363 | |
78a189c9 | 1364 | wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close")); |
5315ebfa VZ |
1365 | sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5); |
1366 | sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5); | |
f6bcfd97 | 1367 | sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5); |
9b70bb91 | 1368 | sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5); |
f6bcfd97 | 1369 | |
f6bcfd97 BP |
1370 | SetSizer(sizerTop); |
1371 | ||
1372 | sizerTop->SetSizeHints(this); | |
1373 | sizerTop->Fit(this); | |
1374 | ||
5315ebfa VZ |
1375 | m_btnModal->SetFocus(); |
1376 | m_btnModal->SetDefault(); | |
f6bcfd97 BP |
1377 | } |
1378 | ||
1379 | void MyModalDialog::OnButton(wxCommandEvent& event) | |
1380 | { | |
1381 | if ( event.GetEventObject() == m_btnDelete ) | |
1382 | { | |
5315ebfa VZ |
1383 | delete m_btnModal; |
1384 | m_btnModal = NULL; | |
f6bcfd97 BP |
1385 | |
1386 | m_btnDelete->Disable(); | |
1387 | } | |
5315ebfa | 1388 | else if ( event.GetEventObject() == m_btnModal ) |
f6bcfd97 | 1389 | { |
13188def | 1390 | #if wxUSE_TEXTDLG |
78a189c9 VZ |
1391 | wxGetTextFromUser(_T("Dummy prompt"), |
1392 | _T("Modal dialog called from dialog"), | |
dabbc6a5 | 1393 | wxEmptyString, this); |
13188def WS |
1394 | #else |
1395 | wxMessageBox(_T("Modal dialog called from dialog")); | |
1396 | #endif // wxUSE_TEXTDLG | |
f6bcfd97 | 1397 | } |
5315ebfa VZ |
1398 | else if ( event.GetEventObject() == m_btnModeless ) |
1399 | { | |
1400 | (new MyModelessDialog(this))->Show(); | |
1401 | } | |
f6bcfd97 BP |
1402 | else |
1403 | { | |
1404 | event.Skip(); | |
1405 | } | |
1406 | } | |
b4954d19 WS |
1407 | |
1408 | #endif // USE_MODAL_PRESENTATION | |
1409 | ||
532d575b | 1410 | #if USE_SETTINGS_DIALOG |
0f5d8ecf JS |
1411 | // ---------------------------------------------------------------------------- |
1412 | // SettingsDialog | |
1413 | // ---------------------------------------------------------------------------- | |
1414 | ||
1415 | IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog) | |
1416 | ||
1417 | BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog) | |
1418 | END_EVENT_TABLE() | |
1419 | ||
64d3ed17 | 1420 | SettingsDialog::SettingsDialog(wxWindow* win, int dialogType) |
0f5d8ecf | 1421 | { |
0f4991f4 | 1422 | SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); |
0f5d8ecf | 1423 | |
cc8bc5aa JS |
1424 | int tabImage1 = -1; |
1425 | int tabImage2 = -1; | |
64d3ed17 JS |
1426 | |
1427 | bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK); | |
77631b1d | 1428 | int resizeBorder = wxRESIZE_BORDER; |
684883e3 | 1429 | |
cc8bc5aa JS |
1430 | if (useToolBook) |
1431 | { | |
77631b1d | 1432 | resizeBorder = 0; |
cc8bc5aa JS |
1433 | tabImage1 = 0; |
1434 | tabImage2 = 1; | |
64d3ed17 JS |
1435 | |
1436 | int sheetStyle = wxPROPSHEET_SHRINKTOFIT; | |
1437 | if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK) | |
1438 | sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK; | |
1439 | else | |
1440 | sheetStyle |= wxPROPSHEET_TOOLBOOK; | |
1441 | ||
1442 | SetSheetStyle(sheetStyle); | |
77631b1d JS |
1443 | SetSheetInnerBorder(0); |
1444 | SetSheetOuterBorder(0); | |
cc8bc5aa JS |
1445 | |
1446 | // create a dummy image list with a few icons | |
1447 | const wxSize imageSize(32, 32); | |
1448 | ||
1449 | m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight()); | |
1450 | m_imageList-> | |
1451 | Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize)); | |
1452 | m_imageList-> | |
1453 | Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize)); | |
1454 | m_imageList-> | |
1455 | Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize)); | |
1456 | m_imageList-> | |
1457 | Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize)); | |
1458 | } | |
1459 | else | |
1460 | m_imageList = NULL; | |
1461 | ||
532d575b | 1462 | Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize, |
4bfec179 | 1463 | wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxWinCE, resizeBorder) |
230c9077 | 1464 | /* |
3103e8a9 | 1465 | #ifndef __WXWINCE__ |
77631b1d | 1466 | |resizeBorder |
532d575b | 1467 | #endif |
230c9077 | 1468 | */ |
3103e8a9 | 1469 | ); |
cc8bc5aa | 1470 | |
684883e3 | 1471 | // If using a toolbook, also follow Mac style and don't create buttons |
cc8bc5aa | 1472 | if (!useToolBook) |
4bfec179 | 1473 | CreateButtons(wxOK|wxCANCEL| (int)wxPlatform::IfNot(wxWinPocketPC, wxHELP) |
230c9077 | 1474 | /* |
897b24cf | 1475 | #ifndef __POCKETPC__ |
cc8bc5aa | 1476 | |wxHELP |
897b24cf | 1477 | #endif |
230c9077 | 1478 | */ |
897b24cf | 1479 | ); |
0f5d8ecf JS |
1480 | |
1481 | wxBookCtrlBase* notebook = GetBookCtrl(); | |
cc8bc5aa | 1482 | notebook->SetImageList(m_imageList); |
0f5d8ecf JS |
1483 | |
1484 | wxPanel* generalSettings = CreateGeneralSettingsPage(notebook); | |
1485 | wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook); | |
1486 | ||
cc8bc5aa JS |
1487 | notebook->AddPage(generalSettings, _("General"), true, tabImage1); |
1488 | notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2); | |
0f5d8ecf JS |
1489 | |
1490 | LayoutDialog(); | |
1491 | } | |
1492 | ||
cc8bc5aa JS |
1493 | SettingsDialog::~SettingsDialog() |
1494 | { | |
1495 | delete m_imageList; | |
1496 | } | |
1497 | ||
0f5d8ecf JS |
1498 | wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent) |
1499 | { | |
1500 | wxPanel* panel = new wxPanel(parent, wxID_ANY); | |
1501 | ||
1502 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); | |
1503 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); | |
1504 | ||
1505 | //// LOAD LAST FILE | |
1506 | ||
1507 | wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL ); | |
1508 | wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize); | |
1509 | itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1510 | item0->Add(itemSizer3, 0, wxGROW|wxALL, 0); | |
1511 | ||
1512 | //// AUTOSAVE | |
1513 | ||
1514 | wxString autoSaveLabel = _("&Auto-save every"); | |
1515 | wxString minsLabel = _("mins"); | |
1516 | ||
1517 | wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL ); | |
1518 | wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize); | |
62675ef3 JS |
1519 | |
1520 | #if wxUSE_SPINCTRL | |
0f5d8ecf | 1521 | wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString, |
532d575b | 1522 | wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1); |
62675ef3 | 1523 | #endif |
532d575b | 1524 | |
0f5d8ecf | 1525 | itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
62675ef3 | 1526 | #if wxUSE_SPINCTRL |
0f5d8ecf | 1527 | itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
62675ef3 | 1528 | #endif |
0f5d8ecf JS |
1529 | itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
1530 | item0->Add(itemSizer12, 0, wxGROW|wxALL, 0); | |
1531 | ||
1532 | //// TOOLTIPS | |
532d575b | 1533 | |
0f5d8ecf JS |
1534 | wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL ); |
1535 | wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize); | |
1536 | itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1537 | item0->Add(itemSizer8, 0, wxGROW|wxALL, 0); | |
1538 | ||
1539 | topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 ); | |
1540 | ||
1541 | panel->SetSizer(topSizer); | |
1542 | topSizer->Fit(panel); | |
532d575b | 1543 | |
0f5d8ecf JS |
1544 | return panel; |
1545 | } | |
1546 | ||
1547 | wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) | |
1548 | { | |
1549 | wxPanel* panel = new wxPanel(parent, wxID_ANY); | |
1550 | ||
1551 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); | |
1552 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); | |
1553 | ||
1554 | //// PROJECT OR GLOBAL | |
1555 | wxString globalOrProjectChoices[2]; | |
1556 | globalOrProjectChoices[0] = _("&New projects"); | |
1557 | globalOrProjectChoices[1] = _("&This project"); | |
1558 | ||
1559 | wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"), | |
1560 | wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices); | |
1561 | item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5); | |
1562 | ||
1563 | projectOrGlobal->SetSelection(0); | |
1564 | ||
1565 | //// BACKGROUND STYLE | |
1566 | wxArrayString backgroundStyleChoices; | |
1567 | backgroundStyleChoices.Add(wxT("Colour")); | |
1568 | backgroundStyleChoices.Add(wxT("Image")); | |
532d575b | 1569 | wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:")); |
0f5d8ecf JS |
1570 | |
1571 | wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL ); | |
1572 | item0->Add(styleSizer, 0, wxGROW|wxALL, 5); | |
1573 | ||
1574 | wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL ); | |
1575 | ||
1576 | wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices); | |
1577 | ||
1578 | itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1579 | itemSizer2->Add(5, 5, 1, wxALL, 0); | |
1580 | itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
1581 | ||
1582 | styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5); | |
1583 | ||
62675ef3 | 1584 | #if wxUSE_SPINCTRL |
0f5d8ecf JS |
1585 | //// FONT SIZE SELECTION |
1586 | ||
532d575b | 1587 | wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:")); |
0f5d8ecf JS |
1588 | wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL ); |
1589 | ||
1590 | wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition, | |
532d575b | 1591 | wxSize(80, wxDefaultCoord)); |
0f5d8ecf JS |
1592 | itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); |
1593 | ||
1594 | item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5); | |
62675ef3 | 1595 | #endif |
0f5d8ecf JS |
1596 | |
1597 | topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 ); | |
0f4991f4 | 1598 | topSizer->AddSpacer(5); |
0f5d8ecf JS |
1599 | |
1600 | panel->SetSizer(topSizer); | |
1601 | topSizer->Fit(panel); | |
532d575b | 1602 | |
0f5d8ecf JS |
1603 | return panel; |
1604 | } | |
1605 | ||
532d575b | 1606 | #endif // USE_SETTINGS_DIALOG |