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