]> git.saurik.com Git - wxWidgets.git/blob - samples/dialogs/dialogs.cpp
extracted MSW-specific setup.h options to their own wx/msw/setup_inc.h file which...
[wxWidgets.git] / samples / dialogs / dialogs.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dialogs.cpp
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart
5 // Modified by: ABX (2004) - adjustements for conditional building + new menu
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
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
23 #include "../sample.xpm"
24
25 #include "wx/datetime.h"
26 #include "wx/image.h"
27 #include "wx/bookctrl.h"
28 #include "wx/artprov.h"
29 #include "wx/imaglist.h"
30 #include "wx/sysopt.h"
31
32 #if wxUSE_COLOURDLG
33 #include "wx/colordlg.h"
34 #endif // wxUSE_COLOURDLG
35
36 #if wxUSE_CHOICEDLG
37 #include "wx/choicdlg.h"
38 #endif // wxUSE_CHOICEDLG
39
40 #if wxUSE_STARTUP_TIPS
41 #include "wx/tipdlg.h"
42 #endif // wxUSE_STARTUP_TIPS
43
44 #if wxUSE_PROGRESSDLG
45 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
46 #include "wx/datetime.h" // wxDateTime
47 #endif
48
49 #include "wx/progdlg.h"
50 #endif // wxUSE_PROGRESSDLG
51
52 #if wxUSE_ABOUTDLG
53 #include "wx/aboutdlg.h"
54
55 // these headers are only needed for custom about dialog
56 #include "wx/statline.h"
57 #include "wx/generic/aboutdlgg.h"
58 #endif // wxUSE_ABOUTDLG
59
60 #if wxUSE_BUSYINFO
61 #include "wx/busyinfo.h"
62 #endif // wxUSE_BUSYINFO
63
64 #if wxUSE_NUMBERDLG
65 #include "wx/numdlg.h"
66 #endif // wxUSE_NUMBERDLG
67
68 #if wxUSE_FILEDLG
69 #include "wx/filedlg.h"
70 #endif // wxUSE_FILEDLG
71
72 #if wxUSE_DIRDLG
73 #include "wx/dirdlg.h"
74 #endif // wxUSE_DIRDLG
75
76 #if wxUSE_FONTDLG
77 #include "wx/fontdlg.h"
78 #endif // wxUSE_FONTDLG
79
80 #if wxUSE_FINDREPLDLG
81 #include "wx/fdrepdlg.h"
82 #endif // wxUSE_FINDREPLDLG
83
84 #if wxUSE_SPINCTRL
85 #include "wx/spinctrl.h"
86 #endif
87
88 #include "wx/propdlg.h"
89
90 #include "dialogs.h"
91
92 #if USE_COLOURDLG_GENERIC
93 #include "wx/generic/colrdlgg.h"
94 #endif // USE_COLOURDLG_GENERIC
95
96 #if USE_DIRDLG_GENERIC
97 #include "wx/generic/dirdlgg.h"
98 #endif // USE_DIRDLG_GENERIC
99
100 #if USE_FILEDLG_GENERIC
101 #include "wx/generic/filedlgg.h"
102 #endif // USE_FILEDLG_GENERIC
103
104 #if USE_FONTDLG_GENERIC
105 #include "wx/generic/fontdlgg.h"
106 #endif // USE_FONTDLG_GENERIC
107
108 IMPLEMENT_APP(MyApp)
109
110 BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
111 EVT_PAINT(MyCanvas::OnPaint)
112 END_EVENT_TABLE()
113
114
115
116 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
117 EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
118
119 #if wxUSE_COLOURDLG
120 EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
121 #endif // wxUSE_COLOURDLG
122
123 #if wxUSE_FONTDLG
124 EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
125 #endif // wxUSE_FONTDLG
126
127 #if wxUSE_LOG_DIALOG
128 EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
129 #endif // wxUSE_LOG_DIALOG
130
131 #if wxUSE_TEXTDLG
132 EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
133 EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
134 #endif // wxUSE_TEXTDLG
135
136 #if wxUSE_NUMBERDLG
137 EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
138 #endif // wxUSE_NUMBERDLG
139
140 #if wxUSE_CHOICEDLG
141 EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
142 EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice)
143 #endif // wxUSE_CHOICEDLG
144
145 #if wxUSE_FILEDLG
146 EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
147 EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2)
148 EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
149 EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
150 #endif // wxUSE_FILEDLG
151
152 #if USE_FILEDLG_GENERIC
153 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC, MyFrame::FileOpenGeneric)
154 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC, MyFrame::FilesOpenGeneric)
155 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC, MyFrame::FileSaveGeneric)
156 #endif // USE_FILEDLG_GENERIC
157
158 #if wxUSE_DIRDLG
159 EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
160 EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew)
161 #endif // wxUSE_DIRDLG
162
163 #if USE_MODAL_PRESENTATION
164 EVT_MENU(DIALOGS_MODAL, MyFrame::ModalDlg)
165 EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg)
166 EVT_MENU(DIALOGS_CENTRE_SCREEN, MyFrame::DlgCenteredScreen)
167 EVT_MENU(DIALOGS_CENTRE_PARENT, MyFrame::DlgCenteredParent)
168 #endif // USE_MODAL
169
170 #if wxUSE_STARTUP_TIPS
171 EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
172 #endif // wxUSE_STARTUP_TIPS
173
174 #if USE_FONTDLG_GENERIC
175 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
176 #endif // USE_FONTDLG_GENERIC
177
178 #if USE_DIRDLG_GENERIC
179 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose)
180 #endif // wxMSW || wxMAC
181
182 #if USE_COLOURDLG_GENERIC
183 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
184 #endif // USE_COLOURDLG_GENERIC
185
186 #if wxUSE_PROGRESSDLG
187 EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress)
188 #endif // wxUSE_PROGRESSDLG
189
190 #if wxUSE_ABOUTDLG
191 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE, MyFrame::ShowSimpleAboutDialog)
192 EVT_MENU(DIALOGS_ABOUTDLG_FANCY, MyFrame::ShowFancyAboutDialog)
193 EVT_MENU(DIALOGS_ABOUTDLG_FULL, MyFrame::ShowFullAboutDialog)
194 EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM, MyFrame::ShowCustomAboutDialog)
195 #endif // wxUSE_ABOUTDLG
196
197 #if wxUSE_BUSYINFO
198 EVT_MENU(DIALOGS_BUSYINFO, MyFrame::ShowBusyInfo)
199 #endif // wxUSE_BUSYINFO
200
201 #if wxUSE_FINDREPLDLG
202 EVT_MENU(DIALOGS_FIND, MyFrame::ShowFindDialog)
203 EVT_MENU(DIALOGS_REPLACE, MyFrame::ShowReplaceDialog)
204
205 EVT_FIND(wxID_ANY, MyFrame::OnFindDialog)
206 EVT_FIND_NEXT(wxID_ANY, MyFrame::OnFindDialog)
207 EVT_FIND_REPLACE(wxID_ANY, MyFrame::OnFindDialog)
208 EVT_FIND_REPLACE_ALL(wxID_ANY, MyFrame::OnFindDialog)
209 EVT_FIND_CLOSE(wxID_ANY, MyFrame::OnFindDialog)
210 #endif // wxUSE_FINDREPLDLG
211
212 #if USE_SETTINGS_DIALOG
213 EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet)
214 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheet)
215 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, MyFrame::OnPropertySheet)
216 #endif
217
218 EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, MyFrame::OnStandardButtonsSizerDialog)
219 EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention)
220
221 EVT_MENU(wxID_EXIT, MyFrame::OnExit)
222 END_EVENT_TABLE()
223
224 #if USE_MODAL_PRESENTATION
225
226 BEGIN_EVENT_TABLE(MyModalDialog, wxDialog)
227 EVT_BUTTON(wxID_ANY, MyModalDialog::OnButton)
228 END_EVENT_TABLE()
229
230 BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog)
231 EVT_BUTTON(DIALOGS_MODELESS_BTN, MyModelessDialog::OnButton)
232 EVT_CLOSE(MyModelessDialog::OnClose)
233 END_EVENT_TABLE()
234
235 #endif // USE_MODAL_PRESENTATION
236
237 BEGIN_EVENT_TABLE(StdButtonSizerDialog, wxDialog)
238 EVT_CHECKBOX(wxID_ANY, StdButtonSizerDialog::OnEvent)
239 EVT_RADIOBUTTON(wxID_ANY, StdButtonSizerDialog::OnEvent)
240 END_EVENT_TABLE()
241
242 MyCanvas *myCanvas = (MyCanvas *) NULL;
243
244 // `Main program' equivalent, creating windows and returning main app frame
245 bool MyApp::OnInit()
246 {
247 if ( !wxApp::OnInit() )
248 return false;
249
250 #if wxUSE_IMAGE
251 wxInitAllImageHandlers();
252 #endif
253
254 m_canvasTextColour = *wxBLACK;
255 m_canvasFont = *wxNORMAL_FONT;
256
257 // Create the main frame window
258 MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example"));
259
260 // Make a menubar
261 wxMenu *menuDlg = new wxMenu;
262
263 menuDlg->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M"));
264
265
266 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
267
268 wxMenu *choices_menu = new wxMenu;
269
270 #if wxUSE_COLOURDLG
271 choices_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour"));
272 #endif // wxUSE_COLOURDLG
273
274 #if wxUSE_FONTDLG
275 choices_menu->Append(DIALOGS_CHOOSE_FONT, _T("Choose &font"));
276 #endif // wxUSE_FONTDLG
277
278 #if wxUSE_CHOICEDLG
279 choices_menu->Append(DIALOGS_SINGLE_CHOICE, _T("&Single choice\tCtrl-C"));
280 choices_menu->Append(DIALOGS_MULTI_CHOICE, _T("M&ultiple choice\tCtrl-U"));
281 #endif // wxUSE_CHOICEDLG
282
283 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
284 choices_menu->AppendSeparator();
285 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
286
287 #if USE_COLOURDLG_GENERIC
288 choices_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, _T("&Choose colour (generic)"));
289 #endif // USE_COLOURDLG_GENERIC
290
291 #if USE_FONTDLG_GENERIC
292 choices_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose &font (generic)"));
293 #endif // USE_FONTDLG_GENERIC
294
295 menuDlg->Append(wxID_ANY,_T("&Choices and selectors"),choices_menu);
296 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
297
298
299 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
300
301 wxMenu *entry_menu = new wxMenu;
302
303 #if wxUSE_TEXTDLG
304 entry_menu->Append(DIALOGS_TEXT_ENTRY, _T("Text &entry\tCtrl-E"));
305 entry_menu->Append(DIALOGS_PASSWORD_ENTRY, _T("&Password entry\tCtrl-P"));
306 #endif // wxUSE_TEXTDLG
307
308 #if wxUSE_NUMBERDLG
309 entry_menu->Append(DIALOGS_NUM_ENTRY, _T("&Numeric entry\tCtrl-N"));
310 #endif // wxUSE_NUMBERDLG
311
312 menuDlg->Append(wxID_ANY,_T("&Entry dialogs"),entry_menu);
313
314 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
315
316
317 #if wxUSE_FILEDLG
318
319 wxMenu *filedlg_menu = new wxMenu;
320 filedlg_menu->Append(DIALOGS_FILE_OPEN, _T("&Open file\tCtrl-O"));
321 filedlg_menu->Append(DIALOGS_FILE_OPEN2, _T("&Second open file\tCtrl-2"));
322 filedlg_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q"));
323 filedlg_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S"));
324
325 #if USE_FILEDLG_GENERIC
326 filedlg_menu->AppendSeparator();
327 filedlg_menu->Append(DIALOGS_FILE_OPEN_GENERIC, _T("&Open file (generic)"));
328 filedlg_menu->Append(DIALOGS_FILES_OPEN_GENERIC, _T("Open &files (generic)"));
329 filedlg_menu->Append(DIALOGS_FILE_SAVE_GENERIC, _T("Sa&ve file (generic)"));
330 #endif // USE_FILEDLG_GENERIC
331
332 menuDlg->Append(wxID_ANY,_T("&File operations"),filedlg_menu);
333
334 #endif // wxUSE_FILEDLG
335
336 #if wxUSE_DIRDLG
337 wxMenu *dir_menu = new wxMenu;
338
339 dir_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D"));
340 dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
341 menuDlg->Append(wxID_ANY,_T("&Directory operations"),dir_menu);
342
343 #if USE_DIRDLG_GENERIC
344 dir_menu->AppendSeparator();
345 dir_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic)"));
346 #endif // USE_DIRDLG_GENERIC
347
348 #endif // wxUSE_DIRDLG
349
350
351 #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
352
353 wxMenu *info_menu = new wxMenu;
354
355 #if wxUSE_STARTUP_TIPS
356 info_menu->Append(DIALOGS_TIP, _T("&Tip of the day\tCtrl-T"));
357 #endif // wxUSE_STARTUP_TIPS
358
359 #if wxUSE_PROGRESSDLG
360 info_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G"));
361 #endif // wxUSE_PROGRESSDLG
362
363 #if wxUSE_BUSYINFO
364 info_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B"));
365 #endif // wxUSE_BUSYINFO
366
367 #if wxUSE_LOG_DIALOG
368 info_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L"));
369 #endif // wxUSE_LOG_DIALOG
370
371 menuDlg->Append(wxID_ANY,_T("&Informative dialogs"),info_menu);
372
373 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
374
375
376 #if wxUSE_FINDREPLDLG
377 wxMenu *find_menu = new wxMenu;
378 find_menu->AppendCheckItem(DIALOGS_FIND, _T("&Find dialog\tCtrl-F"));
379 find_menu->AppendCheckItem(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"));
380 menuDlg->Append(wxID_ANY,_T("&Searching"),find_menu);
381 #endif // wxUSE_FINDREPLDLG
382
383 #if USE_MODAL_PRESENTATION
384 wxMenu *dialogs_menu = new wxMenu;
385 dialogs_menu->Append(DIALOGS_MODAL, _T("&Modal dialog\tCtrl-W"));
386 dialogs_menu->AppendCheckItem(DIALOGS_MODELESS, _T("Mode&less dialog\tCtrl-Z"));
387 dialogs_menu->Append(DIALOGS_CENTRE_SCREEN, _T("Centered on &screen\tShift-Ctrl-1"));
388 dialogs_menu->Append(DIALOGS_CENTRE_PARENT, _T("Centered on &parent\tShift-Ctrl-2"));
389 menuDlg->Append(wxID_ANY, _T("&Generic dialogs"), dialogs_menu);
390 #endif // USE_MODAL_PRESENTATION
391
392 #if USE_SETTINGS_DIALOG
393 wxMenu *sheet_menu = new wxMenu;
394 sheet_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Standard property sheet\tShift-Ctrl-P"));
395 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("&Toolbook sheet\tShift-Ctrl-T"));
396
397 if (wxPlatformIs(wxPORT_MAC))
398 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
399 /*
400 #ifdef __WXMAC__
401 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
402 #endif
403 */
404 menuDlg->Append(wxID_ANY, _T("&Property sheets"), sheet_menu);
405 #endif // USE_SETTINGS_DIALOG
406
407 menuDlg->Append(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG, _T("&Standard Buttons Sizer Dialog"));
408
409 menuDlg->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R"));
410
411 menuDlg->AppendSeparator();
412 menuDlg->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
413
414 #if wxUSE_ABOUTDLG
415 wxMenu *menuHelp = new wxMenu;
416 menuHelp->Append(DIALOGS_ABOUTDLG_SIMPLE, _T("&About (simple)...\tF1"));
417 menuHelp->Append(DIALOGS_ABOUTDLG_FANCY, _T("About (&fancy)...\tShift-F1"));
418 menuHelp->Append(DIALOGS_ABOUTDLG_FULL, _T("About (f&ull)...\tCtrl-F1"));
419 menuHelp->Append(DIALOGS_ABOUTDLG_CUSTOM, _T("About (&custom)...\tCtrl-Shift-F1"));
420 #endif // wxUSE_ABOUTDLG
421
422 wxMenuBar *menubar = new wxMenuBar;
423 menubar->Append(menuDlg, _T("&Dialogs"));
424 #if wxUSE_ABOUTDLG
425 menubar->Append(menuHelp, _T("&Help"));
426 #endif // wxUSE_ABOUTDLG
427
428 frame->SetMenuBar(menubar);
429
430 myCanvas = new MyCanvas(frame);
431 myCanvas->SetBackgroundColour(*wxWHITE);
432
433 frame->Centre(wxBOTH);
434
435 // Show the frame
436 frame->Show(true);
437
438 SetTopWindow(frame);
439
440 return true;
441 }
442
443 // My frame constructor
444 MyFrame::MyFrame(wxWindow *parent,
445 const wxString& title)
446 : wxFrame(parent, wxID_ANY, title)
447 {
448 SetIcon(sample_xpm);
449
450 #if USE_MODAL_PRESENTATION
451 m_dialog = (MyModelessDialog *)NULL;
452 #endif // USE_MODAL_PRESENTATION
453
454 #if wxUSE_FINDREPLDLG
455 m_dlgFind =
456 m_dlgReplace = NULL;
457 #endif
458
459 #if wxUSE_COLOURDLG
460 m_clrData.SetChooseFull(true);
461 for (int i = 0; i < 16; i++)
462 {
463 m_clrData.SetCustomColour(
464 i,
465 wxColour(
466 (unsigned char)(i*16),
467 (unsigned char)(i*16),
468 (unsigned char)(i*16)
469 )
470 );
471 }
472 #endif // wxUSE_COLOURDLG
473
474 #if wxUSE_STATUSBAR
475 CreateStatusBar();
476 #endif // wxUSE_STATUSBAR
477 }
478
479 #if wxUSE_COLOURDLG
480 void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
481 {
482 m_clrData.SetColour(myCanvas->GetBackgroundColour());
483
484 wxColourDialog dialog(this, &m_clrData);
485 dialog.SetTitle(_T("Choose the background colour"));
486 if (dialog.ShowModal() == wxID_OK)
487 {
488 m_clrData = dialog.GetColourData();
489 myCanvas->SetBackgroundColour(m_clrData.GetColour());
490 myCanvas->ClearBackground();
491 myCanvas->Refresh();
492 }
493 }
494 #endif // wxUSE_COLOURDLG
495
496 #if USE_COLOURDLG_GENERIC
497 void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
498 {
499 m_clrData.SetColour(myCanvas->GetBackgroundColour());
500
501 //FIXME:TODO:This has no effect...
502 m_clrData.SetChooseFull(true);
503
504 for (int i = 0; i < 16; i++)
505 {
506 wxColour colour(
507 (unsigned char)(i*16),
508 (unsigned char)(i*16),
509 (unsigned char)(i*16)
510 );
511 m_clrData.SetCustomColour(i, colour);
512 }
513
514 wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &m_clrData);
515 if (dialog->ShowModal() == wxID_OK)
516 {
517 m_clrData = dialog->GetColourData();
518 myCanvas->SetBackgroundColour(m_clrData.GetColour());
519 myCanvas->ClearBackground();
520 myCanvas->Refresh();
521 }
522 dialog->Destroy();
523 }
524 #endif // USE_COLOURDLG_GENERIC
525
526 #if wxUSE_FONTDLG
527 void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
528 {
529 wxFontData data;
530 data.SetInitialFont(wxGetApp().m_canvasFont);
531 data.SetColour(wxGetApp().m_canvasTextColour);
532
533 // you might also do this:
534 //
535 // wxFontDialog dialog;
536 // if ( !dialog.Create(this, data) { ... error ... }
537 //
538 wxFontDialog dialog(this, data);
539
540 if (dialog.ShowModal() == wxID_OK)
541 {
542 wxFontData retData = dialog.GetFontData();
543 wxGetApp().m_canvasFont = retData.GetChosenFont();
544 wxGetApp().m_canvasTextColour = retData.GetColour();
545 myCanvas->Refresh();
546 }
547 //else: cancelled by the user, don't change the font
548 }
549 #endif // wxUSE_FONTDLG
550
551 #if USE_FONTDLG_GENERIC
552 void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
553 {
554 wxFontData data;
555 data.SetInitialFont(wxGetApp().m_canvasFont);
556 data.SetColour(wxGetApp().m_canvasTextColour);
557
558 wxGenericFontDialog *dialog = new wxGenericFontDialog(this, data);
559 if (dialog->ShowModal() == wxID_OK)
560 {
561 wxFontData retData = dialog->GetFontData();
562 wxGetApp().m_canvasFont = retData.GetChosenFont();
563 wxGetApp().m_canvasTextColour = retData.GetColour();
564 myCanvas->Refresh();
565 }
566 dialog->Destroy();
567 }
568 #endif // USE_FONTDLG_GENERIC
569
570 #if wxUSE_LOG_DIALOG
571 void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event))
572 {
573 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
574 // being flushed -- test it
575 {
576 wxBusyCursor bc;
577 wxLogMessage(wxT("This is some message - everything is ok so far."));
578 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
579 wxLogWarning(wxT("And then something went wrong!"));
580
581 // and if ~wxBusyCursor doesn't do it, then call it manually
582 wxYield();
583 }
584
585 wxLogError(wxT("Intermediary error handler decided to abort."));
586 wxLogError(wxT("The top level caller detected an unrecoverable error."));
587
588 wxLog::FlushActive();
589
590 wxLogMessage(wxT("And this is the same dialog but with only one message."));
591 }
592 #endif // wxUSE_LOG_DIALOG
593
594 void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
595 {
596 wxMessageDialog dialog(NULL,
597 _T("This is a message box\nA long, long string to test out the message box properly"),
598 _T("Message box text"),
599 wxNO_DEFAULT | wxYES_NO | wxCANCEL | wxICON_INFORMATION);
600
601 if ( dialog.SetYesNoLabels(_T("Answer &Yes"),_T("Answer &No")) )
602 {
603 dialog.SetExtendedMessage(_T("This platform supports custom button labels"));
604 }
605 else
606 {
607 dialog.SetExtendedMessage(_T("Custom button labels are not supported."));
608 }
609
610 switch ( dialog.ShowModal() )
611 {
612 case wxID_YES:
613 wxLogStatus(wxT("You pressed \"Yes\""));
614 break;
615
616 case wxID_NO:
617 wxLogStatus(wxT("You pressed \"No\""));
618 break;
619
620 case wxID_CANCEL:
621 wxLogStatus(wxT("You pressed \"Cancel\""));
622 break;
623
624 default:
625 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
626 }
627 }
628
629 #if wxUSE_NUMBERDLG
630 void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) )
631 {
632 long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
633 _T("Even two rows of text."),
634 _T("Enter a number:"), _T("Numeric input test"),
635 50, 0, 100, this );
636
637 wxString msg;
638 int icon;
639 if ( res == -1 )
640 {
641 msg = _T("Invalid number entered or dialog cancelled.");
642 icon = wxICON_HAND;
643 }
644 else
645 {
646 msg.Printf(_T("You've entered %lu"), res );
647 icon = wxICON_INFORMATION;
648 }
649
650 wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this);
651 }
652 #endif // wxUSE_NUMBERDLG
653
654 #if wxUSE_TEXTDLG
655 void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
656 {
657 wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
658 _T("Password entry dialog"),
659 wxEmptyString,
660 this);
661 if ( !pwd.empty() )
662 {
663 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()),
664 _T("Got password"), wxOK | wxICON_INFORMATION, this);
665 }
666 }
667
668 void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
669 {
670 wxTextEntryDialog dialog(this,
671 _T("This is a small sample\n")
672 _T("A long, long string to test out the text entrybox"),
673 _T("Please enter a string"),
674 _T("Default value"),
675 wxOK | wxCANCEL);
676
677 if (dialog.ShowModal() == wxID_OK)
678 {
679 wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this);
680 }
681 }
682 #endif // wxUSE_TEXTDLG
683
684 #if wxUSE_CHOICEDLG
685 void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
686 {
687 const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
688
689 wxSingleChoiceDialog dialog(this,
690 _T("This is a small sample\n")
691 _T("A single-choice convenience dialog"),
692 _T("Please select a value"),
693 WXSIZEOF(choices), choices);
694
695 dialog.SetSelection(2);
696
697 if (dialog.ShowModal() == wxID_OK)
698 {
699 wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string"));
700 dialog2.ShowModal();
701 }
702 }
703
704 void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
705 {
706 const wxString choices[] =
707 {
708 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
709 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
710 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
711 };
712
713 wxArrayInt selections;
714 size_t count = wxGetMultipleChoices(selections,
715 _T("This is a small sample\n")
716 _T("A multi-choice convenience dialog"),
717 _T("Please select a value"),
718 WXSIZEOF(choices), choices,
719 this);
720 if ( count )
721 {
722 wxString msg;
723 msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
724 for ( size_t n = 0; n < count; n++ )
725 {
726 msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
727 (unsigned)n, (unsigned)selections[n],
728 choices[selections[n]].c_str());
729 }
730 wxLogMessage(msg);
731 }
732 //else: cancelled or nothing selected
733 }
734 #endif // wxUSE_CHOICEDLG
735
736 #if wxUSE_FILEDLG
737 void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
738 {
739 wxFileDialog dialog
740 (
741 this,
742 _T("Testing open file dialog"),
743 wxEmptyString,
744 wxEmptyString,
745 #ifdef __WXMOTIF__
746 _T("C++ files (*.cpp)|*.cpp")
747 #else
748 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
749 #endif
750 );
751
752 dialog.CentreOnParent();
753 dialog.SetDirectory(wxGetHomeDir());
754
755 if (dialog.ShowModal() == wxID_OK)
756 {
757 wxString info;
758 info.Printf(_T("Full file name: %s\n")
759 _T("Path: %s\n")
760 _T("Name: %s"),
761 dialog.GetPath().c_str(),
762 dialog.GetDirectory().c_str(),
763 dialog.GetFilename().c_str());
764 wxMessageDialog dialog2(this, info, _T("Selected file"));
765 dialog2.ShowModal();
766 }
767 }
768
769 // this shows how to take advantage of specifying a default extension in the
770 // call to wxFileSelector: it is remembered after each new call and the next
771 // one will use it by default
772 void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
773 {
774 static wxString s_extDef;
775 wxString path = wxFileSelector(
776 _T("Select the file to load"),
777 wxEmptyString, wxEmptyString,
778 s_extDef,
779 wxString::Format
780 (
781 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
782 wxFileSelectorDefaultWildcardStr,
783 wxFileSelectorDefaultWildcardStr
784 ),
785 wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW,
786 this
787 );
788
789 if ( !path )
790 return;
791
792 // it is just a sample, would use wxSplitPath in real program
793 s_extDef = path.AfterLast(_T('.'));
794
795 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
796 path, s_extDef);
797 }
798
799 void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
800 {
801 wxString wildcards =
802 #ifdef __WXMOTIF__
803 _T("C++ files (*.cpp)|*.cpp");
804 #else
805 wxString::Format
806 (
807 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
808 wxFileSelectorDefaultWildcardStr,
809 wxFileSelectorDefaultWildcardStr
810 );
811 #endif
812 wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
813 wxEmptyString, wxEmptyString, wildcards,
814 wxFD_OPEN|wxFD_MULTIPLE);
815
816 if (dialog.ShowModal() == wxID_OK)
817 {
818 wxArrayString paths, filenames;
819
820 dialog.GetPaths(paths);
821 dialog.GetFilenames(filenames);
822
823 wxString msg, s;
824 size_t count = paths.GetCount();
825 for ( size_t n = 0; n < count; n++ )
826 {
827 s.Printf(_T("File %d: %s (%s)\n"),
828 (int)n, paths[n].c_str(), filenames[n].c_str());
829
830 msg += s;
831 }
832 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
833 msg += s;
834
835 wxMessageDialog dialog2(this, msg, _T("Selected files"));
836 dialog2.ShowModal();
837 }
838 }
839
840 void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
841 {
842 wxFileDialog dialog(this,
843 _T("Testing save file dialog"),
844 wxEmptyString,
845 _T("myletter.doc"),
846 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
847 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
848
849 dialog.SetFilterIndex(1);
850
851 if (dialog.ShowModal() == wxID_OK)
852 {
853 wxLogMessage(_T("%s, filter %d"),
854 dialog.GetPath().c_str(), dialog.GetFilterIndex());
855 }
856 }
857 #endif // wxUSE_FILEDLG
858
859 #if USE_FILEDLG_GENERIC
860 void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) )
861 {
862 wxGenericFileDialog dialog
863 (
864 this,
865 _T("Testing open file dialog"),
866 wxEmptyString,
867 wxEmptyString,
868 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
869 );
870
871 dialog.SetDirectory(wxGetHomeDir());
872
873 if (dialog.ShowModal() == wxID_OK)
874 {
875 wxString info;
876 info.Printf(_T("Full file name: %s\n")
877 _T("Path: %s\n")
878 _T("Name: %s"),
879 dialog.GetPath().c_str(),
880 dialog.GetDirectory().c_str(),
881 dialog.GetFilename().c_str());
882 wxMessageDialog dialog2(this, info, _T("Selected file"));
883 dialog2.ShowModal();
884 }
885 }
886
887 void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) )
888 {
889 // On PocketPC you can disable OK-only dialogs policy using system option
890 int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
891 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
892
893 wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
894 wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"),
895 wxEmptyString, wxEmptyString, wildcards,
896 wxFD_MULTIPLE);
897
898 if (dialog.ShowModal() == wxID_OK)
899 {
900 wxArrayString paths, filenames;
901
902 dialog.GetPaths(paths);
903 dialog.GetFilenames(filenames);
904
905 wxString msg, s;
906 size_t count = paths.GetCount();
907 for ( size_t n = 0; n < count; n++ )
908 {
909 s.Printf(_T("File %d: %s (%s)\n"),
910 (int)n, paths[n].c_str(), filenames[n].c_str());
911
912 msg += s;
913 }
914 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
915 msg += s;
916
917 wxMessageDialog dialog2(this, msg, _T("Selected files"));
918 dialog2.ShowModal();
919 }
920
921 // restore system option
922 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons);
923 }
924
925 void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) )
926 {
927 wxGenericFileDialog dialog(this,
928 _T("Testing save file dialog"),
929 wxEmptyString,
930 _T("myletter.doc"),
931 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
932 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
933
934 dialog.SetFilterIndex(1);
935
936 if (dialog.ShowModal() == wxID_OK)
937 {
938 wxLogMessage(_T("%s, filter %d"),
939 dialog.GetPath().c_str(), dialog.GetFilterIndex());
940 }
941 }
942 #endif // USE_FILEDLG_GENERIC
943
944 #if wxUSE_DIRDLG
945 void MyFrame::DoDirChoose(int style)
946 {
947 // pass some initial dir to wxDirDialog
948 wxString dirHome;
949 wxGetHomeDir(&dirHome);
950
951 wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
952
953 if (dialog.ShowModal() == wxID_OK)
954 {
955 wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
956 }
957 }
958
959 void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
960 {
961 DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
962 }
963
964 void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
965 {
966 DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_DIR_MUST_EXIST);
967 }
968 #endif // wxUSE_DIRDLG
969
970 #if USE_DIRDLG_GENERIC
971 void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
972 {
973 // pass some initial dir to wxDirDialog
974 wxString dirHome;
975 wxGetHomeDir(&dirHome);
976
977 wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome);
978
979 if (dialog.ShowModal() == wxID_OK)
980 {
981 wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));
982 dialog2.ShowModal();
983 }
984 }
985 #endif // USE_DIRDLG_GENERIC
986
987 #if USE_MODAL_PRESENTATION
988 void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
989 {
990 MyModalDialog dlg(this);
991 dlg.ShowModal();
992 }
993
994 void MyFrame::ModelessDlg(wxCommandEvent& event)
995 {
996 bool show = GetMenuBar()->IsChecked(event.GetId());
997
998 if ( show )
999 {
1000 if ( !m_dialog )
1001 {
1002 m_dialog = new MyModelessDialog(this);
1003 }
1004
1005 m_dialog->Show(true);
1006 }
1007 else // hide
1008 {
1009 // If m_dialog is NULL, then possibly the system
1010 // didn't report the checked menu item status correctly.
1011 // It should be true just after the menu item was selected,
1012 // if there was no modeless dialog yet.
1013
1014 wxASSERT( m_dialog != NULL );
1015 if (m_dialog)
1016 m_dialog->Hide();
1017 }
1018 }
1019
1020 void MyFrame::DlgCenteredScreen(wxCommandEvent& WXUNUSED(event))
1021 {
1022 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on screen"),
1023 wxDefaultPosition, wxSize(200, 100));
1024 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
1025 dlg.CentreOnScreen();
1026 dlg.ShowModal();
1027 }
1028
1029 void MyFrame::DlgCenteredParent(wxCommandEvent& WXUNUSED(event))
1030 {
1031 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on parent"),
1032 wxDefaultPosition, wxSize(200, 100));
1033 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
1034 dlg.CentreOnParent();
1035 dlg.ShowModal();
1036 }
1037
1038 #endif // USE_MODAL_PRESENTATION
1039
1040 #if wxUSE_STARTUP_TIPS
1041 void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
1042 {
1043 static size_t s_index = (size_t)-1;
1044
1045 if ( s_index == (size_t)-1 )
1046 {
1047 srand(time(NULL));
1048
1049 // this is completely bogus, we don't know how many lines are there
1050 // in the file, but who cares, it's a demo only...
1051 s_index = rand() % 5;
1052 }
1053
1054 wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index);
1055
1056 bool showAtStartup = wxShowTip(this, tipProvider);
1057
1058 if ( showAtStartup )
1059 {
1060 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
1061 wxOK | wxICON_INFORMATION, this);
1062 }
1063
1064 s_index = tipProvider->GetCurrentTip();
1065 delete tipProvider;
1066 }
1067 #endif // wxUSE_STARTUP_TIPS
1068
1069 #if USE_SETTINGS_DIALOG
1070 void MyFrame::OnPropertySheet(wxCommandEvent& event)
1071 {
1072 SettingsDialog dialog(this, event.GetId());
1073 dialog.ShowModal();
1074 }
1075 #endif // USE_SETTINGS_DIALOG
1076
1077 void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event))
1078 {
1079 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1080
1081 wxSleep(3);
1082
1083 RequestUserAttention(wxUSER_ATTENTION_ERROR);
1084 }
1085
1086 void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent& WXUNUSED(event))
1087 {
1088 StdButtonSizerDialog dialog(this);
1089 dialog.ShowModal();
1090 }
1091
1092 void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
1093 {
1094 Close(true);
1095 }
1096
1097 #if wxUSE_PROGRESSDLG
1098
1099 void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
1100 {
1101 static const int max = 100;
1102
1103 wxProgressDialog dialog(_T("Progress dialog example"),
1104 _T("An informative message"),
1105 max, // range
1106 this, // parent
1107 wxPD_CAN_ABORT |
1108 wxPD_CAN_SKIP |
1109 wxPD_APP_MODAL |
1110 // wxPD_AUTO_HIDE | -- try this as well
1111 wxPD_ELAPSED_TIME |
1112 wxPD_ESTIMATED_TIME |
1113 wxPD_REMAINING_TIME
1114 | wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
1115 );
1116
1117 bool cont = true;
1118 for ( int i = 0; i <= max; i++ )
1119 {
1120 wxMilliSleep(200);
1121
1122 wxString msg;
1123
1124 // test both modes of wxProgressDialog behaviour: start in
1125 // indeterminate mode but switch to the determinate one later
1126 const bool determinate = i > max/2;
1127
1128 if ( i == max )
1129 {
1130 msg = _T("That's all, folks!");
1131 }
1132 else if ( !determinate )
1133 {
1134 msg = _T("Testing indeterminate mode");
1135 }
1136 else if ( determinate )
1137 {
1138 msg = _T("Now in standard determinate mode");
1139 }
1140
1141 // will be set to true if "Skip" button was pressed
1142 bool skip = false;
1143 if ( determinate )
1144 {
1145 cont = dialog.Update(i, msg, &skip);
1146 }
1147 else
1148 {
1149 cont = dialog.Pulse(msg, &skip);
1150 }
1151
1152 // each skip will move progress about quarter forward
1153 if ( skip )
1154 i += max/4;
1155
1156 if ( !cont )
1157 {
1158 if ( wxMessageBox(_T("Do you really want to cancel?"),
1159 _T("Progress dialog question"), // caption
1160 wxYES_NO | wxICON_QUESTION) == wxYES )
1161 break;
1162
1163 cont = true;
1164 dialog.Resume();
1165 }
1166 }
1167
1168 if ( !cont )
1169 {
1170 wxLogStatus(wxT("Progress dialog aborted!"));
1171 }
1172 else
1173 {
1174 wxLogStatus(wxT("Countdown from %d finished"), max);
1175 }
1176 }
1177
1178 #endif // wxUSE_PROGRESSDLG
1179
1180 #if wxUSE_ABOUTDLG
1181
1182 static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
1183 {
1184 info.SetName(_T("Dialogs Sample"));
1185 info.SetVersion(wxVERSION_NUM_DOT_STRING_T);
1186 info.SetDescription(_T("This sample shows different wxWidgets dialogs"));
1187 info.SetCopyright(_T("(C) 1998-2006 wxWidgets dev team"));
1188 info.AddDeveloper(_T("Vadim Zeitlin"));
1189 }
1190
1191 static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
1192 {
1193 InitAboutInfoMinimal(info);
1194
1195 info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
1196 }
1197
1198 static void InitAboutInfoAll(wxAboutDialogInfo& info)
1199 {
1200 InitAboutInfoMinimal(info);
1201
1202 // we can add a second developer
1203 info.AddDeveloper(_T("A.N. Other"));
1204
1205 // or we can add several persons at once like this
1206 static const wxChar *docwriters[] =
1207 {
1208 _T("First D. Writer"),
1209 _T("Second One"),
1210 };
1211
1212 info.SetDocWriters(wxArrayString(WXSIZEOF(docwriters), docwriters));
1213 info.SetLicence(wxString::FromAscii(
1214 " wxWindows Library Licence, Version 3.1\n"
1215 " ======================================\n"
1216 "\n"
1217 " Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
1218 "\n"
1219 " Everyone is permitted to copy and distribute verbatim copies\n"
1220 " of this licence document, but changing it is not allowed.\n"
1221 "\n"
1222 " WXWINDOWS LIBRARY LICENCE\n"
1223 " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
1224 "\n"
1225 " ...and so on and so forth...\n"
1226 ));
1227
1228 info.AddTranslator(_T("Wun Ngo Wen (Martian)"));
1229 }
1230
1231 void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
1232 {
1233 wxAboutDialogInfo info;
1234 InitAboutInfoMinimal(info);
1235
1236 wxAboutBox(info);
1237 }
1238
1239 void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
1240 {
1241 wxAboutDialogInfo info;
1242 InitAboutInfoWebsite(info);
1243
1244 wxAboutBox(info);
1245 }
1246
1247 void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
1248 {
1249 wxAboutDialogInfo info;
1250 InitAboutInfoAll(info);
1251
1252 wxAboutBox(info);
1253 }
1254
1255 // a trivial example of a custom dialog class
1256 class MyAboutDialog : public wxGenericAboutDialog
1257 {
1258 public:
1259 MyAboutDialog(const wxAboutDialogInfo& info)
1260 {
1261 Create(info);
1262 }
1263
1264 // add some custom controls
1265 virtual void DoAddCustomControls()
1266 {
1267 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1268 AddText(_T("Some custom text"));
1269 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1270 }
1271 };
1272
1273 void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event))
1274 {
1275 wxAboutDialogInfo info;
1276 InitAboutInfoAll(info);
1277
1278 MyAboutDialog dlg(info);
1279 dlg.ShowModal();
1280 }
1281
1282 #endif // wxUSE_ABOUTDLG
1283
1284 #if wxUSE_BUSYINFO
1285
1286 void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
1287 {
1288 wxWindowDisabler disableAll;
1289
1290 wxBusyInfo info(_T("Working, please wait..."), this);
1291
1292 for ( int i = 0; i < 18; i++ )
1293 {
1294 //wxUsleep(100);
1295 wxTheApp->Yield();
1296 }
1297
1298 wxSleep(2);
1299 //wxWakeUpIdle();
1300 }
1301
1302 #endif // wxUSE_BUSYINFO
1303
1304 #if wxUSE_FINDREPLDLG
1305
1306 void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
1307 {
1308 if ( m_dlgReplace )
1309 {
1310 delete m_dlgReplace;
1311 m_dlgReplace = NULL;
1312 }
1313 else
1314 {
1315 m_dlgReplace = new wxFindReplaceDialog
1316 (
1317 this,
1318 &m_findData,
1319 _T("Find and replace dialog"),
1320 wxFR_REPLACEDIALOG
1321 );
1322
1323 m_dlgReplace->Show(true);
1324 }
1325 }
1326
1327 void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
1328 {
1329 if ( m_dlgFind )
1330 {
1331 delete m_dlgFind;
1332 m_dlgFind = NULL;
1333 }
1334 else
1335 {
1336 m_dlgFind = new wxFindReplaceDialog
1337 (
1338 this,
1339 &m_findData,
1340 _T("Find dialog"),
1341 // just for testing
1342 wxFR_NOWHOLEWORD
1343 );
1344
1345 m_dlgFind->Show(true);
1346 }
1347 }
1348
1349 static wxString DecodeFindDialogEventFlags(int flags)
1350 {
1351 wxString str;
1352 str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ")
1353 << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T(""))
1354 << (flags & wxFR_MATCHCASE ? _T("") : _T("not "))
1355 << _T("case sensitive");
1356
1357 return str;
1358 }
1359
1360 void MyFrame::OnFindDialog(wxFindDialogEvent& event)
1361 {
1362 wxEventType type = event.GetEventType();
1363
1364 if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
1365 {
1366 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1367 type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
1368 event.GetFindString().c_str(),
1369 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1370 }
1371 else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
1372 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
1373 {
1374 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1375 type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""),
1376 event.GetFindString().c_str(),
1377 event.GetReplaceString().c_str(),
1378 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1379 }
1380 else if ( type == wxEVT_COMMAND_FIND_CLOSE )
1381 {
1382 wxFindReplaceDialog *dlg = event.GetDialog();
1383
1384 int idMenu;
1385 const wxChar *txt;
1386 if ( dlg == m_dlgFind )
1387 {
1388 txt = _T("Find");
1389 idMenu = DIALOGS_FIND;
1390 m_dlgFind = NULL;
1391 }
1392 else if ( dlg == m_dlgReplace )
1393 {
1394 txt = _T("Replace");
1395 idMenu = DIALOGS_REPLACE;
1396 m_dlgReplace = NULL;
1397 }
1398 else
1399 {
1400 txt = _T("Unknown");
1401 idMenu = wxID_ANY;
1402
1403 wxFAIL_MSG( _T("unexpected event") );
1404 }
1405
1406 wxLogMessage(wxT("%s dialog is being closed."), txt);
1407
1408 if ( idMenu != wxID_ANY )
1409 {
1410 GetMenuBar()->Check(idMenu, false);
1411 }
1412
1413 dlg->Destroy();
1414 }
1415 else
1416 {
1417 wxLogError(wxT("Unknown find dialog event!"));
1418 }
1419 }
1420
1421 #endif // wxUSE_FINDREPLDLG
1422
1423 // ----------------------------------------------------------------------------
1424 // MyCanvas
1425 // ----------------------------------------------------------------------------
1426
1427 void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
1428 {
1429 wxPaintDC dc(this);
1430 dc.SetFont(wxGetApp().m_canvasFont);
1431 dc.SetTextForeground(wxGetApp().m_canvasTextColour);
1432 dc.SetBackgroundMode(wxTRANSPARENT);
1433 dc.DrawText(
1434 _T("wxWidgets common dialogs")
1435 #if !defined(__SMARTPHONE__)
1436 _T(" test application")
1437 #endif
1438 , 10, 10);
1439 }
1440
1441 #if USE_MODAL_PRESENTATION
1442
1443 // ----------------------------------------------------------------------------
1444 // MyModelessDialog
1445 // ----------------------------------------------------------------------------
1446
1447 MyModelessDialog::MyModelessDialog(wxWindow *parent)
1448 : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog")))
1449 {
1450 wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
1451
1452 wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me"));
1453 wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled"));
1454 check->Disable();
1455
1456 sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5);
1457 sizerTop->Add(check, 1, wxEXPAND | wxALL, 5);
1458
1459 SetSizer(sizerTop);
1460
1461 sizerTop->SetSizeHints(this);
1462 sizerTop->Fit(this);
1463 }
1464
1465 void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event))
1466 {
1467 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1468 wxOK | wxICON_INFORMATION, this);
1469 }
1470
1471 void MyModelessDialog::OnClose(wxCloseEvent& event)
1472 {
1473 if ( event.CanVeto() )
1474 {
1475 wxMessageBox(_T("Use the menu item to close this dialog"),
1476 _T("Modeless dialog"),
1477 wxOK | wxICON_INFORMATION, this);
1478
1479 event.Veto();
1480 }
1481 }
1482
1483 // ----------------------------------------------------------------------------
1484 // MyModalDialog
1485 // ----------------------------------------------------------------------------
1486
1487 MyModalDialog::MyModalDialog(wxWindow *parent)
1488 : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog")))
1489 {
1490 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
1491
1492 m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog..."));
1493 m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog"));
1494 m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button"));
1495
1496 wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
1497 sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
1498 sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
1499 sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
1500 sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
1501
1502 SetSizer(sizerTop);
1503
1504 sizerTop->SetSizeHints(this);
1505 sizerTop->Fit(this);
1506
1507 m_btnModal->SetFocus();
1508 m_btnModal->SetDefault();
1509 }
1510
1511 void MyModalDialog::OnButton(wxCommandEvent& event)
1512 {
1513 if ( event.GetEventObject() == m_btnDelete )
1514 {
1515 delete m_btnModal;
1516 m_btnModal = NULL;
1517
1518 m_btnDelete->Disable();
1519 }
1520 else if ( event.GetEventObject() == m_btnModal )
1521 {
1522 #if wxUSE_TEXTDLG
1523 wxGetTextFromUser(_T("Dummy prompt"),
1524 _T("Modal dialog called from dialog"),
1525 wxEmptyString, this);
1526 #else
1527 wxMessageBox(_T("Modal dialog called from dialog"));
1528 #endif // wxUSE_TEXTDLG
1529 }
1530 else if ( event.GetEventObject() == m_btnModeless )
1531 {
1532 (new MyModelessDialog(this))->Show();
1533 }
1534 else
1535 {
1536 event.Skip();
1537 }
1538 }
1539
1540 #endif // USE_MODAL_PRESENTATION
1541
1542 // ----------------------------------------------------------------------------
1543 // StdButtonSizerDialog
1544 // ----------------------------------------------------------------------------
1545
1546 StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
1547 : wxDialog(parent, wxID_ANY, wxString(_T("StdButtonSizer dialog")),
1548 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
1549 m_buttonsSizer(NULL)
1550 {
1551 wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL);
1552
1553 wxBoxSizer *const sizer = new wxBoxSizer(wxHORIZONTAL);
1554 wxBoxSizer *const sizerInside1 = new wxBoxSizer(wxVERTICAL);
1555
1556 m_chkboxAffirmativeButton = new wxCheckBox(this, wxID_ANY, _("Enable Affirmative Button"));
1557
1558 wxStaticBoxSizer *const sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Affirmative Button"));
1559
1560 m_radiobtnOk = new wxRadioButton(this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1561 m_radiobtnYes = new wxRadioButton(this, wxID_ANY, _("Yes"));
1562
1563 wxBoxSizer *const sizerInside2 = new wxBoxSizer(wxVERTICAL);
1564
1565 m_chkboxDismissButton = new wxCheckBox(this, wxID_ANY, _("Enable Dismiss Button"));
1566
1567 wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Dismiss Button"));
1568
1569 m_radiobtnCancel = new wxRadioButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1570 m_radiobtnClose = new wxRadioButton(this, wxID_ANY, _("Close"));
1571
1572 wxBoxSizer *const sizer3 = new wxBoxSizer(wxHORIZONTAL);
1573
1574 m_chkboxNo = new wxCheckBox(this, wxID_ANY, _("No"));
1575 m_chkboxHelp = new wxCheckBox(this, wxID_ANY, _("Help"));
1576 m_chkboxApply = new wxCheckBox(this, wxID_ANY, _("Apply"));
1577
1578 m_chkboxNoDefault = new wxCheckBox(this, wxID_ANY, wxT("No Default"));
1579
1580 sizer1->Add(m_radiobtnOk, 0, wxALL, 5);
1581 sizer1->Add(m_radiobtnYes, 0, wxALL, 5);
1582
1583 sizer->Add(sizerInside1, 0, 0, 0);
1584 sizerInside1->Add(m_chkboxAffirmativeButton, 0, wxALL, 5);
1585 sizerInside1->Add(sizer1, 0, wxALL, 5);
1586 sizerInside1->SetItemMinSize(sizer1, sizer1->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1587
1588 sizer2->Add(m_radiobtnCancel, 0, wxALL, 5);
1589 sizer2->Add(m_radiobtnClose, 0, wxALL, 5);
1590
1591 sizer->Add(sizerInside2, 0, 0, 0);
1592 sizerInside2->Add(m_chkboxDismissButton, 0, wxALL, 5);
1593 sizerInside2->Add(sizer2, 0, wxALL, 5);
1594 sizerInside2->SetItemMinSize(sizer2, sizer2->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1595
1596 sizerTop->Add(sizer, 0, wxALL, 5);
1597
1598 sizer3->Add(m_chkboxNo, 0, wxALL, 5);
1599 sizer3->Add(m_chkboxHelp, 0, wxALL, 5);
1600 sizer3->Add(m_chkboxApply, 0, wxALL, 5);
1601
1602 sizerTop->Add(sizer3, 0, wxALL, 5);
1603
1604 sizerTop->Add(m_chkboxNoDefault, 0, wxLEFT|wxRIGHT, 10);
1605
1606 EnableDisableControls();
1607
1608 SetSizer(sizerTop);
1609
1610 sizerTop->SetSizeHints(this);
1611 wxCommandEvent ev;
1612 OnEvent(ev);
1613 }
1614
1615 void StdButtonSizerDialog::OnEvent(wxCommandEvent& WXUNUSED(event))
1616 {
1617 if (m_buttonsSizer)
1618 {
1619 m_buttonsSizer->DeleteWindows();
1620 GetSizer()->Remove(m_buttonsSizer);
1621 }
1622
1623 EnableDisableControls();
1624
1625 long flags = 0;
1626 unsigned long numButtons = 0;
1627
1628 if (m_chkboxAffirmativeButton->IsChecked())
1629 {
1630 if (m_radiobtnOk->GetValue())
1631 {
1632 flags |= wxOK;
1633 numButtons ++;
1634 }
1635 else if (m_radiobtnYes->GetValue())
1636 {
1637 flags |= wxYES;
1638 numButtons ++;
1639 }
1640 }
1641
1642 if (m_chkboxDismissButton->IsChecked())
1643 {
1644 if (m_radiobtnCancel->GetValue())
1645 {
1646 flags |= wxCANCEL;
1647 numButtons ++;
1648 }
1649
1650 else if (m_radiobtnClose->GetValue())
1651 {
1652 flags |= wxCLOSE;
1653 numButtons ++;
1654 }
1655
1656 }
1657
1658 if (m_chkboxApply->IsChecked())
1659 {
1660 flags |= wxAPPLY;
1661 numButtons ++;
1662 }
1663
1664 if (m_chkboxNo->IsChecked())
1665 {
1666 flags |= wxNO;
1667 numButtons ++;
1668 }
1669
1670 if (m_chkboxHelp->IsChecked())
1671 {
1672 flags |= wxHELP;
1673 numButtons ++;
1674 }
1675
1676 if (m_chkboxNoDefault->IsChecked())
1677 {
1678 flags |= wxNO_DEFAULT;
1679 }
1680
1681 m_buttonsSizer = CreateStdDialogButtonSizer(flags);
1682 GetSizer()->Add(m_buttonsSizer, 0, wxGROW|wxALL, 5);
1683
1684 Layout();
1685 GetSizer()->SetSizeHints(this);
1686 }
1687
1688 void StdButtonSizerDialog::EnableDisableControls()
1689 {
1690 const bool affButtonEnabled = m_chkboxAffirmativeButton->IsChecked();
1691
1692 m_radiobtnOk->Enable(affButtonEnabled);
1693 m_radiobtnYes->Enable(affButtonEnabled);
1694
1695 const bool dismissButtonEnabled = m_chkboxDismissButton->IsChecked();
1696
1697 m_radiobtnCancel->Enable(dismissButtonEnabled);
1698 m_radiobtnClose->Enable(dismissButtonEnabled);
1699 }
1700
1701 #if USE_SETTINGS_DIALOG
1702 // ----------------------------------------------------------------------------
1703 // SettingsDialog
1704 // ----------------------------------------------------------------------------
1705
1706 IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog)
1707
1708 BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog)
1709 END_EVENT_TABLE()
1710
1711 SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
1712 {
1713 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
1714
1715 int tabImage1 = -1;
1716 int tabImage2 = -1;
1717
1718 bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
1719 int resizeBorder = wxRESIZE_BORDER;
1720
1721 if (useToolBook)
1722 {
1723 resizeBorder = 0;
1724 tabImage1 = 0;
1725 tabImage2 = 1;
1726
1727 int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
1728 if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK)
1729 sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
1730 else
1731 sheetStyle |= wxPROPSHEET_TOOLBOOK;
1732
1733 SetSheetStyle(sheetStyle);
1734 SetSheetInnerBorder(0);
1735 SetSheetOuterBorder(0);
1736
1737 // create a dummy image list with a few icons
1738 const wxSize imageSize(32, 32);
1739
1740 m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
1741 m_imageList->
1742 Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
1743 m_imageList->
1744 Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
1745 m_imageList->
1746 Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
1747 m_imageList->
1748 Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
1749 }
1750 else
1751 m_imageList = NULL;
1752
1753 Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
1754 wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder)
1755 );
1756
1757 // If using a toolbook, also follow Mac style and don't create buttons
1758 if (!useToolBook)
1759 CreateButtons(wxOK | wxCANCEL |
1760 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)
1761 );
1762
1763 wxBookCtrlBase* notebook = GetBookCtrl();
1764 notebook->SetImageList(m_imageList);
1765
1766 wxPanel* generalSettings = CreateGeneralSettingsPage(notebook);
1767 wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook);
1768
1769 notebook->AddPage(generalSettings, _("General"), true, tabImage1);
1770 notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2);
1771
1772 LayoutDialog();
1773 }
1774
1775 SettingsDialog::~SettingsDialog()
1776 {
1777 delete m_imageList;
1778 }
1779
1780 wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent)
1781 {
1782 wxPanel* panel = new wxPanel(parent, wxID_ANY);
1783
1784 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
1785 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1786
1787 //// LOAD LAST FILE
1788
1789 wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL );
1790 wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize);
1791 itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1792 item0->Add(itemSizer3, 0, wxGROW|wxALL, 0);
1793
1794 //// AUTOSAVE
1795
1796 wxString autoSaveLabel = _("&Auto-save every");
1797 wxString minsLabel = _("mins");
1798
1799 wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL );
1800 wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize);
1801
1802 #if wxUSE_SPINCTRL
1803 wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString,
1804 wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1);
1805 #endif
1806
1807 itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1808 #if wxUSE_SPINCTRL
1809 itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1810 #endif
1811 itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1812 item0->Add(itemSizer12, 0, wxGROW|wxALL, 0);
1813
1814 //// TOOLTIPS
1815
1816 wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL );
1817 wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize);
1818 itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1819 item0->Add(itemSizer8, 0, wxGROW|wxALL, 0);
1820
1821 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
1822
1823 panel->SetSizer(topSizer);
1824 topSizer->Fit(panel);
1825
1826 return panel;
1827 }
1828
1829 wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent)
1830 {
1831 wxPanel* panel = new wxPanel(parent, wxID_ANY);
1832
1833 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
1834 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1835
1836 //// PROJECT OR GLOBAL
1837 wxString globalOrProjectChoices[2];
1838 globalOrProjectChoices[0] = _("&New projects");
1839 globalOrProjectChoices[1] = _("&This project");
1840
1841 wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"),
1842 wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices);
1843 item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5);
1844
1845 projectOrGlobal->SetSelection(0);
1846
1847 //// BACKGROUND STYLE
1848 wxArrayString backgroundStyleChoices;
1849 backgroundStyleChoices.Add(wxT("Colour"));
1850 backgroundStyleChoices.Add(wxT("Image"));
1851 wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:"));
1852
1853 wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL );
1854 item0->Add(styleSizer, 0, wxGROW|wxALL, 5);
1855
1856 wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL );
1857
1858 wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices);
1859
1860 itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1861 itemSizer2->Add(5, 5, 1, wxALL, 0);
1862 itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1863
1864 styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5);
1865
1866 #if wxUSE_SPINCTRL
1867 //// FONT SIZE SELECTION
1868
1869 wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:"));
1870 wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL );
1871
1872 wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition,
1873 wxSize(80, wxDefaultCoord));
1874 itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
1875
1876 item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5);
1877 #endif
1878
1879 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
1880 topSizer->AddSpacer(5);
1881
1882 panel->SetSizer(topSizer);
1883 topSizer->Fit(panel);
1884
1885 return panel;
1886 }
1887
1888 #endif // USE_SETTINGS_DIALOG