]> git.saurik.com Git - wxWidgets.git/blob - samples/dialogs/dialogs.cpp
fix DLL export declaration (adv, not core)
[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, _T("This is a message box\nA long, long string to test out the message box properly"),
597 _T("Message box text"), wxNO_DEFAULT|wxYES_NO|wxCANCEL|wxICON_INFORMATION);
598
599 switch ( dialog.ShowModal() )
600 {
601 case wxID_YES:
602 wxLogStatus(wxT("You pressed \"Yes\""));
603 break;
604
605 case wxID_NO:
606 wxLogStatus(wxT("You pressed \"No\""));
607 break;
608
609 case wxID_CANCEL:
610 wxLogStatus(wxT("You pressed \"Cancel\""));
611 break;
612
613 default:
614 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
615 }
616 }
617
618 #if wxUSE_NUMBERDLG
619 void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) )
620 {
621 long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
622 _T("Even two rows of text."),
623 _T("Enter a number:"), _T("Numeric input test"),
624 50, 0, 100, this );
625
626 wxString msg;
627 int icon;
628 if ( res == -1 )
629 {
630 msg = _T("Invalid number entered or dialog cancelled.");
631 icon = wxICON_HAND;
632 }
633 else
634 {
635 msg.Printf(_T("You've entered %lu"), res );
636 icon = wxICON_INFORMATION;
637 }
638
639 wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this);
640 }
641 #endif // wxUSE_NUMBERDLG
642
643 #if wxUSE_TEXTDLG
644 void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
645 {
646 wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
647 _T("Password entry dialog"),
648 wxEmptyString,
649 this);
650 if ( !pwd.empty() )
651 {
652 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()),
653 _T("Got password"), wxOK | wxICON_INFORMATION, this);
654 }
655 }
656
657 void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
658 {
659 wxTextEntryDialog dialog(this,
660 _T("This is a small sample\n")
661 _T("A long, long string to test out the text entrybox"),
662 _T("Please enter a string"),
663 _T("Default value"),
664 wxOK | wxCANCEL);
665
666 if (dialog.ShowModal() == wxID_OK)
667 {
668 wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this);
669 }
670 }
671 #endif // wxUSE_TEXTDLG
672
673 #if wxUSE_CHOICEDLG
674 void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
675 {
676 const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
677
678 wxSingleChoiceDialog dialog(this,
679 _T("This is a small sample\n")
680 _T("A single-choice convenience dialog"),
681 _T("Please select a value"),
682 WXSIZEOF(choices), choices);
683
684 dialog.SetSelection(2);
685
686 if (dialog.ShowModal() == wxID_OK)
687 {
688 wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string"));
689 dialog2.ShowModal();
690 }
691 }
692
693 void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
694 {
695 const wxString choices[] =
696 {
697 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
698 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
699 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
700 };
701
702 wxArrayInt selections;
703 size_t count = wxGetMultipleChoices(selections,
704 _T("This is a small sample\n")
705 _T("A multi-choice convenience dialog"),
706 _T("Please select a value"),
707 WXSIZEOF(choices), choices,
708 this);
709 if ( count )
710 {
711 wxString msg;
712 msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
713 for ( size_t n = 0; n < count; n++ )
714 {
715 msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
716 (unsigned)n, (unsigned)selections[n],
717 choices[selections[n]].c_str());
718 }
719 wxLogMessage(msg);
720 }
721 //else: cancelled or nothing selected
722 }
723 #endif // wxUSE_CHOICEDLG
724
725 #if wxUSE_FILEDLG
726 void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
727 {
728 wxFileDialog dialog
729 (
730 this,
731 _T("Testing open file dialog"),
732 wxEmptyString,
733 wxEmptyString,
734 #ifdef __WXMOTIF__
735 _T("C++ files (*.cpp)|*.cpp")
736 #else
737 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
738 #endif
739 );
740
741 dialog.CentreOnParent();
742 dialog.SetDirectory(wxGetHomeDir());
743
744 if (dialog.ShowModal() == wxID_OK)
745 {
746 wxString info;
747 info.Printf(_T("Full file name: %s\n")
748 _T("Path: %s\n")
749 _T("Name: %s"),
750 dialog.GetPath().c_str(),
751 dialog.GetDirectory().c_str(),
752 dialog.GetFilename().c_str());
753 wxMessageDialog dialog2(this, info, _T("Selected file"));
754 dialog2.ShowModal();
755 }
756 }
757
758 // this shows how to take advantage of specifying a default extension in the
759 // call to wxFileSelector: it is remembered after each new call and the next
760 // one will use it by default
761 void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
762 {
763 static wxString s_extDef;
764 wxString path = wxFileSelector(
765 _T("Select the file to load"),
766 wxEmptyString, wxEmptyString,
767 s_extDef,
768 wxString::Format
769 (
770 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
771 wxFileSelectorDefaultWildcardStr,
772 wxFileSelectorDefaultWildcardStr
773 ),
774 wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW,
775 this
776 );
777
778 if ( !path )
779 return;
780
781 // it is just a sample, would use wxSplitPath in real program
782 s_extDef = path.AfterLast(_T('.'));
783
784 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
785 (const wxChar*) path, (const wxChar*) s_extDef);
786 }
787
788 void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
789 {
790 wxString wildcards =
791 #ifdef __WXMOTIF__
792 _T("C++ files (*.cpp)|*.cpp");
793 #else
794 wxString::Format
795 (
796 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
797 wxFileSelectorDefaultWildcardStr,
798 wxFileSelectorDefaultWildcardStr
799 );
800 #endif
801 wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
802 wxEmptyString, wxEmptyString, wildcards,
803 wxFD_OPEN|wxFD_MULTIPLE);
804
805 if (dialog.ShowModal() == wxID_OK)
806 {
807 wxArrayString paths, filenames;
808
809 dialog.GetPaths(paths);
810 dialog.GetFilenames(filenames);
811
812 wxString msg, s;
813 size_t count = paths.GetCount();
814 for ( size_t n = 0; n < count; n++ )
815 {
816 s.Printf(_T("File %d: %s (%s)\n"),
817 (int)n, paths[n].c_str(), filenames[n].c_str());
818
819 msg += s;
820 }
821 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
822 msg += s;
823
824 wxMessageDialog dialog2(this, msg, _T("Selected files"));
825 dialog2.ShowModal();
826 }
827 }
828
829 void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
830 {
831 wxFileDialog dialog(this,
832 _T("Testing save file dialog"),
833 wxEmptyString,
834 _T("myletter.doc"),
835 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
836 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
837
838 dialog.SetFilterIndex(1);
839
840 if (dialog.ShowModal() == wxID_OK)
841 {
842 wxLogMessage(_T("%s, filter %d"),
843 dialog.GetPath().c_str(), dialog.GetFilterIndex());
844 }
845 }
846 #endif // wxUSE_FILEDLG
847
848 #if USE_FILEDLG_GENERIC
849 void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) )
850 {
851 wxGenericFileDialog dialog
852 (
853 this,
854 _T("Testing open file dialog"),
855 wxEmptyString,
856 wxEmptyString,
857 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
858 );
859
860 dialog.SetDirectory(wxGetHomeDir());
861
862 if (dialog.ShowModal() == wxID_OK)
863 {
864 wxString info;
865 info.Printf(_T("Full file name: %s\n")
866 _T("Path: %s\n")
867 _T("Name: %s"),
868 dialog.GetPath().c_str(),
869 dialog.GetDirectory().c_str(),
870 dialog.GetFilename().c_str());
871 wxMessageDialog dialog2(this, info, _T("Selected file"));
872 dialog2.ShowModal();
873 }
874 }
875
876 void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) )
877 {
878 // On PocketPC you can disable OK-only dialogs policy using system option
879 int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
880 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
881
882 wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
883 wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"),
884 wxEmptyString, wxEmptyString, wildcards,
885 wxFD_MULTIPLE);
886
887 if (dialog.ShowModal() == wxID_OK)
888 {
889 wxArrayString paths, filenames;
890
891 dialog.GetPaths(paths);
892 dialog.GetFilenames(filenames);
893
894 wxString msg, s;
895 size_t count = paths.GetCount();
896 for ( size_t n = 0; n < count; n++ )
897 {
898 s.Printf(_T("File %d: %s (%s)\n"),
899 (int)n, paths[n].c_str(), filenames[n].c_str());
900
901 msg += s;
902 }
903 s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
904 msg += s;
905
906 wxMessageDialog dialog2(this, msg, _T("Selected files"));
907 dialog2.ShowModal();
908 }
909
910 // restore system option
911 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons);
912 }
913
914 void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) )
915 {
916 wxGenericFileDialog dialog(this,
917 _T("Testing save file dialog"),
918 wxEmptyString,
919 _T("myletter.doc"),
920 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
921 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
922
923 dialog.SetFilterIndex(1);
924
925 if (dialog.ShowModal() == wxID_OK)
926 {
927 wxLogMessage(_T("%s, filter %d"),
928 dialog.GetPath().c_str(), dialog.GetFilterIndex());
929 }
930 }
931 #endif // USE_FILEDLG_GENERIC
932
933 #if wxUSE_DIRDLG
934 void MyFrame::DoDirChoose(int style)
935 {
936 // pass some initial dir to wxDirDialog
937 wxString dirHome;
938 wxGetHomeDir(&dirHome);
939
940 wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
941
942 if (dialog.ShowModal() == wxID_OK)
943 {
944 wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
945 }
946 }
947
948 void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
949 {
950 DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
951 }
952
953 void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
954 {
955 DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_DIR_MUST_EXIST);
956 }
957 #endif // wxUSE_DIRDLG
958
959 #if USE_DIRDLG_GENERIC
960 void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
961 {
962 // pass some initial dir to wxDirDialog
963 wxString dirHome;
964 wxGetHomeDir(&dirHome);
965
966 wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome);
967
968 if (dialog.ShowModal() == wxID_OK)
969 {
970 wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));
971 dialog2.ShowModal();
972 }
973 }
974 #endif // USE_DIRDLG_GENERIC
975
976 #if USE_MODAL_PRESENTATION
977 void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
978 {
979 MyModalDialog dlg(this);
980 dlg.ShowModal();
981 }
982
983 void MyFrame::ModelessDlg(wxCommandEvent& event)
984 {
985 bool show = GetMenuBar()->IsChecked(event.GetId());
986
987 if ( show )
988 {
989 if ( !m_dialog )
990 {
991 m_dialog = new MyModelessDialog(this);
992 }
993
994 m_dialog->Show(true);
995 }
996 else // hide
997 {
998 // If m_dialog is NULL, then possibly the system
999 // didn't report the checked menu item status correctly.
1000 // It should be true just after the menu item was selected,
1001 // if there was no modeless dialog yet.
1002
1003 wxASSERT( m_dialog != NULL );
1004 if (m_dialog)
1005 m_dialog->Hide();
1006 }
1007 }
1008
1009 void MyFrame::DlgCenteredScreen(wxCommandEvent& WXUNUSED(event))
1010 {
1011 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on screen"),
1012 wxDefaultPosition, wxSize(200, 100));
1013 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
1014 dlg.CentreOnScreen();
1015 dlg.ShowModal();
1016 }
1017
1018 void MyFrame::DlgCenteredParent(wxCommandEvent& WXUNUSED(event))
1019 {
1020 wxDialog dlg(this, wxID_ANY, _T("Dialog centered on parent"),
1021 wxDefaultPosition, wxSize(200, 100));
1022 (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
1023 dlg.CentreOnParent();
1024 dlg.ShowModal();
1025 }
1026
1027 #endif // USE_MODAL_PRESENTATION
1028
1029 #if wxUSE_STARTUP_TIPS
1030 void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
1031 {
1032 static size_t s_index = (size_t)-1;
1033
1034 if ( s_index == (size_t)-1 )
1035 {
1036 srand(time(NULL));
1037
1038 // this is completely bogus, we don't know how many lines are there
1039 // in the file, but who cares, it's a demo only...
1040 s_index = rand() % 5;
1041 }
1042
1043 wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index);
1044
1045 bool showAtStartup = wxShowTip(this, tipProvider);
1046
1047 if ( showAtStartup )
1048 {
1049 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
1050 wxOK | wxICON_INFORMATION, this);
1051 }
1052
1053 s_index = tipProvider->GetCurrentTip();
1054 delete tipProvider;
1055 }
1056 #endif // wxUSE_STARTUP_TIPS
1057
1058 #if USE_SETTINGS_DIALOG
1059 void MyFrame::OnPropertySheet(wxCommandEvent& event)
1060 {
1061 SettingsDialog dialog(this, event.GetId());
1062 dialog.ShowModal();
1063 }
1064 #endif // USE_SETTINGS_DIALOG
1065
1066 void MyFrame::OnRequestUserAttention(wxCommandEvent& WXUNUSED(event))
1067 {
1068 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1069
1070 wxSleep(3);
1071
1072 RequestUserAttention(wxUSER_ATTENTION_ERROR);
1073 }
1074
1075 void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent& WXUNUSED(event))
1076 {
1077 StdButtonSizerDialog dialog(this);
1078 dialog.ShowModal();
1079 }
1080
1081 void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
1082 {
1083 Close(true);
1084 }
1085
1086 #if wxUSE_PROGRESSDLG
1087
1088 void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
1089 {
1090 static const int max = 100;
1091
1092 wxProgressDialog dialog(_T("Progress dialog example"),
1093 _T("An informative message"),
1094 max, // range
1095 this, // parent
1096 wxPD_CAN_ABORT |
1097 wxPD_CAN_SKIP |
1098 wxPD_APP_MODAL |
1099 // wxPD_AUTO_HIDE | -- try this as well
1100 wxPD_ELAPSED_TIME |
1101 wxPD_ESTIMATED_TIME |
1102 wxPD_REMAINING_TIME
1103 | wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
1104 );
1105
1106 bool cont = true;
1107 for ( int i = 0; i <= max; i++ )
1108 {
1109 wxMilliSleep(200);
1110
1111 wxString msg;
1112
1113 // test both modes of wxProgressDialog behaviour: start in
1114 // indeterminate mode but switch to the determinate one later
1115 const bool determinate = i > max/2;
1116
1117 if ( i == max )
1118 {
1119 msg = _T("That's all, folks!");
1120 }
1121 else if ( !determinate )
1122 {
1123 msg = _T("Testing indeterminate mode");
1124 }
1125 else if ( determinate )
1126 {
1127 msg = _T("Now in standard determinate mode");
1128 }
1129
1130 // will be set to true if "Skip" button was pressed
1131 bool skip = false;
1132 if ( determinate )
1133 {
1134 cont = dialog.Update(i, msg, &skip);
1135 }
1136 else
1137 {
1138 cont = dialog.Pulse(msg, &skip);
1139 }
1140
1141 // each skip will move progress about quarter forward
1142 if ( skip )
1143 i += max/4;
1144
1145 if ( !cont )
1146 {
1147 if ( wxMessageBox(_T("Do you really want to cancel?"),
1148 _T("Progress dialog question"), // caption
1149 wxYES_NO | wxICON_QUESTION) == wxYES )
1150 break;
1151
1152 cont = true;
1153 dialog.Resume();
1154 }
1155 }
1156
1157 if ( !cont )
1158 {
1159 wxLogStatus(wxT("Progress dialog aborted!"));
1160 }
1161 else
1162 {
1163 wxLogStatus(wxT("Countdown from %d finished"), max);
1164 }
1165 }
1166
1167 #endif // wxUSE_PROGRESSDLG
1168
1169 #if wxUSE_ABOUTDLG
1170
1171 static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
1172 {
1173 info.SetName(_T("Dialogs Sample"));
1174 info.SetVersion(wxVERSION_NUM_DOT_STRING_T);
1175 info.SetDescription(_T("This sample shows different wxWidgets dialogs"));
1176 info.SetCopyright(_T("(C) 1998-2006 wxWidgets dev team"));
1177 info.AddDeveloper(_T("Vadim Zeitlin"));
1178 }
1179
1180 static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
1181 {
1182 InitAboutInfoMinimal(info);
1183
1184 info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
1185 }
1186
1187 static void InitAboutInfoAll(wxAboutDialogInfo& info)
1188 {
1189 InitAboutInfoMinimal(info);
1190
1191 // we can add a second developer
1192 info.AddDeveloper(_T("A.N. Other"));
1193
1194 // or we can add several persons at once like this
1195 static const wxChar *docwriters[] =
1196 {
1197 _T("First D. Writer"),
1198 _T("Second One"),
1199 };
1200
1201 info.SetDocWriters(wxArrayString(WXSIZEOF(docwriters), docwriters));
1202 info.SetLicence(wxString::FromAscii(
1203 " wxWindows Library Licence, Version 3.1\n"
1204 " ======================================\n"
1205 "\n"
1206 " Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
1207 "\n"
1208 " Everyone is permitted to copy and distribute verbatim copies\n"
1209 " of this licence document, but changing it is not allowed.\n"
1210 "\n"
1211 " WXWINDOWS LIBRARY LICENCE\n"
1212 " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
1213 "\n"
1214 " ...and so on and so forth...\n"
1215 ));
1216
1217 info.AddTranslator(_T("Wun Ngo Wen (Martian)"));
1218 }
1219
1220 void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
1221 {
1222 wxAboutDialogInfo info;
1223 InitAboutInfoMinimal(info);
1224
1225 wxAboutBox(info);
1226 }
1227
1228 void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
1229 {
1230 wxAboutDialogInfo info;
1231 InitAboutInfoWebsite(info);
1232
1233 wxAboutBox(info);
1234 }
1235
1236 void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
1237 {
1238 wxAboutDialogInfo info;
1239 InitAboutInfoAll(info);
1240
1241 wxAboutBox(info);
1242 }
1243
1244 // a trivial example of a custom dialog class
1245 class MyAboutDialog : public wxGenericAboutDialog
1246 {
1247 public:
1248 MyAboutDialog(const wxAboutDialogInfo& info)
1249 {
1250 Create(info);
1251 }
1252
1253 // add some custom controls
1254 virtual void DoAddCustomControls()
1255 {
1256 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1257 AddText(_T("Some custom text"));
1258 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1259 }
1260 };
1261
1262 void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event))
1263 {
1264 wxAboutDialogInfo info;
1265 InitAboutInfoAll(info);
1266
1267 MyAboutDialog dlg(info);
1268 dlg.ShowModal();
1269 }
1270
1271 #endif // wxUSE_ABOUTDLG
1272
1273 #if wxUSE_BUSYINFO
1274
1275 void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
1276 {
1277 wxWindowDisabler disableAll;
1278
1279 wxBusyInfo info(_T("Working, please wait..."), this);
1280
1281 for ( int i = 0; i < 18; i++ )
1282 {
1283 //wxUsleep(100);
1284 wxTheApp->Yield();
1285 }
1286
1287 wxSleep(2);
1288 //wxWakeUpIdle();
1289 }
1290
1291 #endif // wxUSE_BUSYINFO
1292
1293 #if wxUSE_FINDREPLDLG
1294
1295 void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
1296 {
1297 if ( m_dlgReplace )
1298 {
1299 delete m_dlgReplace;
1300 m_dlgReplace = NULL;
1301 }
1302 else
1303 {
1304 m_dlgReplace = new wxFindReplaceDialog
1305 (
1306 this,
1307 &m_findData,
1308 _T("Find and replace dialog"),
1309 wxFR_REPLACEDIALOG
1310 );
1311
1312 m_dlgReplace->Show(true);
1313 }
1314 }
1315
1316 void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
1317 {
1318 if ( m_dlgFind )
1319 {
1320 delete m_dlgFind;
1321 m_dlgFind = NULL;
1322 }
1323 else
1324 {
1325 m_dlgFind = new wxFindReplaceDialog
1326 (
1327 this,
1328 &m_findData,
1329 _T("Find dialog"),
1330 // just for testing
1331 wxFR_NOWHOLEWORD
1332 );
1333
1334 m_dlgFind->Show(true);
1335 }
1336 }
1337
1338 static wxString DecodeFindDialogEventFlags(int flags)
1339 {
1340 wxString str;
1341 str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ")
1342 << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T(""))
1343 << (flags & wxFR_MATCHCASE ? _T("") : _T("not "))
1344 << _T("case sensitive");
1345
1346 return str;
1347 }
1348
1349 void MyFrame::OnFindDialog(wxFindDialogEvent& event)
1350 {
1351 wxEventType type = event.GetEventType();
1352
1353 if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
1354 {
1355 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1356 type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
1357 event.GetFindString().c_str(),
1358 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1359 }
1360 else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
1361 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
1362 {
1363 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1364 type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""),
1365 event.GetFindString().c_str(),
1366 event.GetReplaceString().c_str(),
1367 DecodeFindDialogEventFlags(event.GetFlags()).c_str());
1368 }
1369 else if ( type == wxEVT_COMMAND_FIND_CLOSE )
1370 {
1371 wxFindReplaceDialog *dlg = event.GetDialog();
1372
1373 int idMenu;
1374 const wxChar *txt;
1375 if ( dlg == m_dlgFind )
1376 {
1377 txt = _T("Find");
1378 idMenu = DIALOGS_FIND;
1379 m_dlgFind = NULL;
1380 }
1381 else if ( dlg == m_dlgReplace )
1382 {
1383 txt = _T("Replace");
1384 idMenu = DIALOGS_REPLACE;
1385 m_dlgReplace = NULL;
1386 }
1387 else
1388 {
1389 txt = _T("Unknown");
1390 idMenu = wxID_ANY;
1391
1392 wxFAIL_MSG( _T("unexpected event") );
1393 }
1394
1395 wxLogMessage(wxT("%s dialog is being closed."), txt);
1396
1397 if ( idMenu != wxID_ANY )
1398 {
1399 GetMenuBar()->Check(idMenu, false);
1400 }
1401
1402 dlg->Destroy();
1403 }
1404 else
1405 {
1406 wxLogError(wxT("Unknown find dialog event!"));
1407 }
1408 }
1409
1410 #endif // wxUSE_FINDREPLDLG
1411
1412 // ----------------------------------------------------------------------------
1413 // MyCanvas
1414 // ----------------------------------------------------------------------------
1415
1416 void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
1417 {
1418 wxPaintDC dc(this);
1419 dc.SetFont(wxGetApp().m_canvasFont);
1420 dc.SetTextForeground(wxGetApp().m_canvasTextColour);
1421 dc.SetBackgroundMode(wxTRANSPARENT);
1422 dc.DrawText(
1423 _T("wxWidgets common dialogs")
1424 #if !defined(__SMARTPHONE__)
1425 _T(" test application")
1426 #endif
1427 , 10, 10);
1428 }
1429
1430 #if USE_MODAL_PRESENTATION
1431
1432 // ----------------------------------------------------------------------------
1433 // MyModelessDialog
1434 // ----------------------------------------------------------------------------
1435
1436 MyModelessDialog::MyModelessDialog(wxWindow *parent)
1437 : wxDialog(parent, wxID_ANY, wxString(_T("Modeless dialog")))
1438 {
1439 wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
1440
1441 wxButton *btn = new wxButton(this, DIALOGS_MODELESS_BTN, _T("Press me"));
1442 wxCheckBox *check = new wxCheckBox(this, wxID_ANY, _T("Should be disabled"));
1443 check->Disable();
1444
1445 sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5);
1446 sizerTop->Add(check, 1, wxEXPAND | wxALL, 5);
1447
1448 SetSizer(sizerTop);
1449
1450 sizerTop->SetSizeHints(this);
1451 sizerTop->Fit(this);
1452 }
1453
1454 void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event))
1455 {
1456 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1457 wxOK | wxICON_INFORMATION, this);
1458 }
1459
1460 void MyModelessDialog::OnClose(wxCloseEvent& event)
1461 {
1462 if ( event.CanVeto() )
1463 {
1464 wxMessageBox(_T("Use the menu item to close this dialog"),
1465 _T("Modeless dialog"),
1466 wxOK | wxICON_INFORMATION, this);
1467
1468 event.Veto();
1469 }
1470 }
1471
1472 // ----------------------------------------------------------------------------
1473 // MyModalDialog
1474 // ----------------------------------------------------------------------------
1475
1476 MyModalDialog::MyModalDialog(wxWindow *parent)
1477 : wxDialog(parent, wxID_ANY, wxString(_T("Modal dialog")))
1478 {
1479 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
1480
1481 m_btnModal = new wxButton(this, wxID_ANY, _T("&Modal dialog..."));
1482 m_btnModeless = new wxButton(this, wxID_ANY, _T("Mode&less dialog"));
1483 m_btnDelete = new wxButton(this, wxID_ANY, _T("&Delete button"));
1484
1485 wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
1486 sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
1487 sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
1488 sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
1489 sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
1490
1491 SetSizer(sizerTop);
1492
1493 sizerTop->SetSizeHints(this);
1494 sizerTop->Fit(this);
1495
1496 m_btnModal->SetFocus();
1497 m_btnModal->SetDefault();
1498 }
1499
1500 void MyModalDialog::OnButton(wxCommandEvent& event)
1501 {
1502 if ( event.GetEventObject() == m_btnDelete )
1503 {
1504 delete m_btnModal;
1505 m_btnModal = NULL;
1506
1507 m_btnDelete->Disable();
1508 }
1509 else if ( event.GetEventObject() == m_btnModal )
1510 {
1511 #if wxUSE_TEXTDLG
1512 wxGetTextFromUser(_T("Dummy prompt"),
1513 _T("Modal dialog called from dialog"),
1514 wxEmptyString, this);
1515 #else
1516 wxMessageBox(_T("Modal dialog called from dialog"));
1517 #endif // wxUSE_TEXTDLG
1518 }
1519 else if ( event.GetEventObject() == m_btnModeless )
1520 {
1521 (new MyModelessDialog(this))->Show();
1522 }
1523 else
1524 {
1525 event.Skip();
1526 }
1527 }
1528
1529 #endif // USE_MODAL_PRESENTATION
1530
1531 // ----------------------------------------------------------------------------
1532 // StdButtonSizerDialog
1533 // ----------------------------------------------------------------------------
1534
1535 StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
1536 : wxDialog(parent, wxID_ANY, wxString(_T("StdButtonSizer dialog")),
1537 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
1538 m_buttonsSizer(NULL)
1539 {
1540 wxBoxSizer *const sizerTop = new wxBoxSizer(wxVERTICAL);
1541
1542 wxBoxSizer *const sizer = new wxBoxSizer(wxHORIZONTAL);
1543 wxBoxSizer *const sizerInside1 = new wxBoxSizer(wxVERTICAL);
1544
1545 m_chkboxAffirmativeButton = new wxCheckBox(this, wxID_ANY, _("Enable Affirmative Button"));
1546
1547 wxStaticBoxSizer *const sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Affirmative Button"));
1548
1549 m_radiobtnOk = new wxRadioButton(this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1550 m_radiobtnYes = new wxRadioButton(this, wxID_ANY, _("Yes"));
1551
1552 wxBoxSizer *const sizerInside2 = new wxBoxSizer(wxVERTICAL);
1553
1554 m_chkboxDismissButton = new wxCheckBox(this, wxID_ANY, _("Enable Dismiss Button"));
1555
1556 wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Dismiss Button"));
1557
1558 m_radiobtnCancel = new wxRadioButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
1559 m_radiobtnClose = new wxRadioButton(this, wxID_ANY, _("Close"));
1560
1561 wxBoxSizer *const sizer3 = new wxBoxSizer(wxHORIZONTAL);
1562
1563 m_chkboxNo = new wxCheckBox(this, wxID_ANY, _("No"));
1564 m_chkboxHelp = new wxCheckBox(this, wxID_ANY, _("Help"));
1565 m_chkboxApply = new wxCheckBox(this, wxID_ANY, _("Apply"));
1566
1567 m_chkboxNoDefault = new wxCheckBox(this, wxID_ANY, wxT("No Default"));
1568
1569 sizer1->Add(m_radiobtnOk, 0, wxALL, 5);
1570 sizer1->Add(m_radiobtnYes, 0, wxALL, 5);
1571
1572 sizer->Add(sizerInside1, 0, 0, 0);
1573 sizerInside1->Add(m_chkboxAffirmativeButton, 0, wxALL, 5);
1574 sizerInside1->Add(sizer1, 0, wxALL, 5);
1575 sizerInside1->SetItemMinSize(sizer1, sizer1->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1576
1577 sizer2->Add(m_radiobtnCancel, 0, wxALL, 5);
1578 sizer2->Add(m_radiobtnClose, 0, wxALL, 5);
1579
1580 sizer->Add(sizerInside2, 0, 0, 0);
1581 sizerInside2->Add(m_chkboxDismissButton, 0, wxALL, 5);
1582 sizerInside2->Add(sizer2, 0, wxALL, 5);
1583 sizerInside2->SetItemMinSize(sizer2, sizer2->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1584
1585 sizerTop->Add(sizer, 0, wxALL, 5);
1586
1587 sizer3->Add(m_chkboxNo, 0, wxALL, 5);
1588 sizer3->Add(m_chkboxHelp, 0, wxALL, 5);
1589 sizer3->Add(m_chkboxApply, 0, wxALL, 5);
1590
1591 sizerTop->Add(sizer3, 0, wxALL, 5);
1592
1593 sizerTop->Add(m_chkboxNoDefault, 0, wxLEFT|wxRIGHT, 10);
1594
1595 EnableDisableControls();
1596
1597 SetSizer(sizerTop);
1598
1599 sizerTop->SetSizeHints(this);
1600 wxCommandEvent ev;
1601 OnEvent(ev);
1602 }
1603
1604 void StdButtonSizerDialog::OnEvent(wxCommandEvent& WXUNUSED(event))
1605 {
1606 if (m_buttonsSizer)
1607 {
1608 m_buttonsSizer->DeleteWindows();
1609 GetSizer()->Remove(m_buttonsSizer);
1610 }
1611
1612 EnableDisableControls();
1613
1614 long flags = 0;
1615 unsigned long numButtons = 0;
1616
1617 if (m_chkboxAffirmativeButton->IsChecked())
1618 {
1619 if (m_radiobtnOk->GetValue())
1620 {
1621 flags |= wxOK;
1622 numButtons ++;
1623 }
1624 else if (m_radiobtnYes->GetValue())
1625 {
1626 flags |= wxYES;
1627 numButtons ++;
1628 }
1629 }
1630
1631 if (m_chkboxDismissButton->IsChecked())
1632 {
1633 if (m_radiobtnCancel->GetValue())
1634 {
1635 flags |= wxCANCEL;
1636 numButtons ++;
1637 }
1638
1639 else if (m_radiobtnClose->GetValue())
1640 {
1641 flags |= wxCLOSE;
1642 numButtons ++;
1643 }
1644
1645 }
1646
1647 if (m_chkboxApply->IsChecked())
1648 {
1649 flags |= wxAPPLY;
1650 numButtons ++;
1651 }
1652
1653 if (m_chkboxNo->IsChecked())
1654 {
1655 flags |= wxNO;
1656 numButtons ++;
1657 }
1658
1659 if (m_chkboxHelp->IsChecked())
1660 {
1661 flags |= wxHELP;
1662 numButtons ++;
1663 }
1664
1665 if (m_chkboxNoDefault->IsChecked())
1666 {
1667 flags |= wxNO_DEFAULT;
1668 }
1669
1670 m_buttonsSizer = CreateStdDialogButtonSizer(flags);
1671 GetSizer()->Add(m_buttonsSizer, 0, wxGROW|wxALL, 5);
1672
1673 Layout();
1674 GetSizer()->SetSizeHints(this);
1675 }
1676
1677 void StdButtonSizerDialog::EnableDisableControls()
1678 {
1679 const bool affButtonEnabled = m_chkboxAffirmativeButton->IsChecked();
1680
1681 m_radiobtnOk->Enable(affButtonEnabled);
1682 m_radiobtnYes->Enable(affButtonEnabled);
1683
1684 const bool dismissButtonEnabled = m_chkboxDismissButton->IsChecked();
1685
1686 m_radiobtnCancel->Enable(dismissButtonEnabled);
1687 m_radiobtnClose->Enable(dismissButtonEnabled);
1688 }
1689
1690 #if USE_SETTINGS_DIALOG
1691 // ----------------------------------------------------------------------------
1692 // SettingsDialog
1693 // ----------------------------------------------------------------------------
1694
1695 IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog)
1696
1697 BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog)
1698 END_EVENT_TABLE()
1699
1700 SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
1701 {
1702 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
1703
1704 int tabImage1 = -1;
1705 int tabImage2 = -1;
1706
1707 bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
1708 int resizeBorder = wxRESIZE_BORDER;
1709
1710 if (useToolBook)
1711 {
1712 resizeBorder = 0;
1713 tabImage1 = 0;
1714 tabImage2 = 1;
1715
1716 int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
1717 if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK)
1718 sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
1719 else
1720 sheetStyle |= wxPROPSHEET_TOOLBOOK;
1721
1722 SetSheetStyle(sheetStyle);
1723 SetSheetInnerBorder(0);
1724 SetSheetOuterBorder(0);
1725
1726 // create a dummy image list with a few icons
1727 const wxSize imageSize(32, 32);
1728
1729 m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
1730 m_imageList->
1731 Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
1732 m_imageList->
1733 Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
1734 m_imageList->
1735 Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
1736 m_imageList->
1737 Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
1738 }
1739 else
1740 m_imageList = NULL;
1741
1742 Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
1743 wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder)
1744 );
1745
1746 // If using a toolbook, also follow Mac style and don't create buttons
1747 if (!useToolBook)
1748 CreateButtons(wxOK | wxCANCEL |
1749 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP)
1750 );
1751
1752 wxBookCtrlBase* notebook = GetBookCtrl();
1753 notebook->SetImageList(m_imageList);
1754
1755 wxPanel* generalSettings = CreateGeneralSettingsPage(notebook);
1756 wxPanel* aestheticSettings = CreateAestheticSettingsPage(notebook);
1757
1758 notebook->AddPage(generalSettings, _("General"), true, tabImage1);
1759 notebook->AddPage(aestheticSettings, _("Aesthetics"), false, tabImage2);
1760
1761 LayoutDialog();
1762 }
1763
1764 SettingsDialog::~SettingsDialog()
1765 {
1766 delete m_imageList;
1767 }
1768
1769 wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent)
1770 {
1771 wxPanel* panel = new wxPanel(parent, wxID_ANY);
1772
1773 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
1774 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1775
1776 //// LOAD LAST FILE
1777
1778 wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL );
1779 wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize);
1780 itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1781 item0->Add(itemSizer3, 0, wxGROW|wxALL, 0);
1782
1783 //// AUTOSAVE
1784
1785 wxString autoSaveLabel = _("&Auto-save every");
1786 wxString minsLabel = _("mins");
1787
1788 wxBoxSizer* itemSizer12 = new wxBoxSizer( wxHORIZONTAL );
1789 wxCheckBox* checkBox12 = new wxCheckBox(panel, ID_AUTO_SAVE, autoSaveLabel, wxDefaultPosition, wxDefaultSize);
1790
1791 #if wxUSE_SPINCTRL
1792 wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString,
1793 wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1);
1794 #endif
1795
1796 itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1797 #if wxUSE_SPINCTRL
1798 itemSizer12->Add(spinCtrl12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1799 #endif
1800 itemSizer12->Add(new wxStaticText(panel, wxID_STATIC, minsLabel), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1801 item0->Add(itemSizer12, 0, wxGROW|wxALL, 0);
1802
1803 //// TOOLTIPS
1804
1805 wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL );
1806 wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize);
1807 itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1808 item0->Add(itemSizer8, 0, wxGROW|wxALL, 0);
1809
1810 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
1811
1812 panel->SetSizer(topSizer);
1813 topSizer->Fit(panel);
1814
1815 return panel;
1816 }
1817
1818 wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent)
1819 {
1820 wxPanel* panel = new wxPanel(parent, wxID_ANY);
1821
1822 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
1823 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1824
1825 //// PROJECT OR GLOBAL
1826 wxString globalOrProjectChoices[2];
1827 globalOrProjectChoices[0] = _("&New projects");
1828 globalOrProjectChoices[1] = _("&This project");
1829
1830 wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"),
1831 wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices);
1832 item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5);
1833
1834 projectOrGlobal->SetSelection(0);
1835
1836 //// BACKGROUND STYLE
1837 wxArrayString backgroundStyleChoices;
1838 backgroundStyleChoices.Add(wxT("Colour"));
1839 backgroundStyleChoices.Add(wxT("Image"));
1840 wxStaticBox* staticBox3 = new wxStaticBox(panel, wxID_ANY, _("Background style:"));
1841
1842 wxBoxSizer* styleSizer = new wxStaticBoxSizer( staticBox3, wxVERTICAL );
1843 item0->Add(styleSizer, 0, wxGROW|wxALL, 5);
1844
1845 wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL );
1846
1847 wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices);
1848
1849 itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1850 itemSizer2->Add(5, 5, 1, wxALL, 0);
1851 itemSizer2->Add(choice2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
1852
1853 styleSizer->Add(itemSizer2, 0, wxGROW|wxALL, 5);
1854
1855 #if wxUSE_SPINCTRL
1856 //// FONT SIZE SELECTION
1857
1858 wxStaticBox* staticBox1 = new wxStaticBox(panel, wxID_ANY, _("Tile font size:"));
1859 wxBoxSizer* itemSizer5 = new wxStaticBoxSizer( staticBox1, wxHORIZONTAL );
1860
1861 wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition,
1862 wxSize(80, wxDefaultCoord));
1863 itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
1864
1865 item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5);
1866 #endif
1867
1868 topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
1869 topSizer->AddSpacer(5);
1870
1871 panel->SetSizer(topSizer);
1872 topSizer->Fit(panel);
1873
1874 return panel;
1875 }
1876
1877 #endif // USE_SETTINGS_DIALOG