1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart
5 // Modified by: ABX (2004) - adjustements for conditional building + new menu
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "../sample.xpm"
25 #include "wx/datetime.h"
27 #include "wx/bookctrl.h"
28 #include "wx/artprov.h"
29 #include "wx/imaglist.h"
30 #include "wx/sysopt.h"
33 #include "wx/colordlg.h"
34 #endif // wxUSE_COLOURDLG
37 #include "wx/choicdlg.h"
38 #endif // wxUSE_CHOICEDLG
40 #if wxUSE_STARTUP_TIPS
41 #include "wx/tipdlg.h"
42 #endif // wxUSE_STARTUP_TIPS
45 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
46 #include "wx/datetime.h" // wxDateTime
49 #include "wx/progdlg.h"
50 #endif // wxUSE_PROGRESSDLG
53 #include "wx/aboutdlg.h"
54 #endif // wxUSE_ABOUTDLG
57 #include "wx/busyinfo.h"
58 #endif // wxUSE_BUSYINFO
61 #include "wx/numdlg.h"
62 #endif // wxUSE_NUMBERDLG
65 #include "wx/filedlg.h"
66 #endif // wxUSE_FILEDLG
69 #include "wx/dirdlg.h"
70 #endif // wxUSE_DIRDLG
73 #include "wx/fontdlg.h"
74 #endif // wxUSE_FONTDLG
77 #include "wx/fdrepdlg.h"
78 #endif // wxUSE_FINDREPLDLG
81 #include "wx/spinctrl.h"
84 #include "wx/propdlg.h"
88 #if USE_COLOURDLG_GENERIC
89 #include "wx/generic/colrdlgg.h"
90 #endif // USE_COLOURDLG_GENERIC
92 #if USE_DIRDLG_GENERIC
93 #include "wx/generic/dirdlgg.h"
94 #endif // USE_DIRDLG_GENERIC
96 #if USE_FILEDLG_GENERIC
97 #include "wx/generic/filedlgg.h"
98 #endif // USE_FILEDLG_GENERIC
100 #if USE_FONTDLG_GENERIC
101 #include "wx/generic/fontdlgg.h"
102 #endif // USE_FONTDLG_GENERIC
106 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
107 EVT_PAINT(MyCanvas::OnPaint
)
112 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
113 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
116 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
117 #endif // wxUSE_COLOURDLG
120 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
121 #endif // wxUSE_FONTDLG
124 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
125 #endif // wxUSE_LOG_DIALOG
128 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
129 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
130 #endif // wxUSE_TEXTDLG
133 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
134 #endif // wxUSE_NUMBERDLG
137 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
138 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
139 #endif // wxUSE_CHOICEDLG
142 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
143 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
144 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
145 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
146 #endif // wxUSE_FILEDLG
148 #if USE_FILEDLG_GENERIC
149 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
150 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
151 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
152 #endif // USE_FILEDLG_GENERIC
155 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
156 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
157 #endif // wxUSE_DIRDLG
159 #if USE_MODAL_PRESENTATION
160 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
161 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
162 EVT_MENU(DIALOGS_CENTRE_SCREEN
, MyFrame::DlgCenteredScreen
)
163 EVT_MENU(DIALOGS_CENTRE_PARENT
, MyFrame::DlgCenteredParent
)
166 #if wxUSE_STARTUP_TIPS
167 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
168 #endif // wxUSE_STARTUP_TIPS
170 #if USE_FONTDLG_GENERIC
171 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
172 #endif // USE_FONTDLG_GENERIC
174 #if USE_DIRDLG_GENERIC
175 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
176 #endif // wxMSW || wxMAC
178 #if USE_COLOURDLG_GENERIC
179 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
180 #endif // USE_COLOURDLG_GENERIC
182 #if wxUSE_PROGRESSDLG
183 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
184 #endif // wxUSE_PROGRESSDLG
187 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE
, MyFrame::ShowSimpleAboutDialog
)
188 EVT_MENU(DIALOGS_ABOUTDLG_FANCY
, MyFrame::ShowFancyAboutDialog
)
189 #endif // wxUSE_ABOUTDLG
192 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
193 #endif // wxUSE_BUSYINFO
195 #if wxUSE_FINDREPLDLG
196 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
197 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
199 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
200 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
201 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
202 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
203 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
204 #endif // wxUSE_FINDREPLDLG
206 #if USE_SETTINGS_DIALOG
207 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
208 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheet
)
209 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, MyFrame::OnPropertySheet
)
212 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
214 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
217 #if USE_MODAL_PRESENTATION
219 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
220 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
223 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
224 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
225 EVT_CLOSE(MyModelessDialog::OnClose
)
228 #endif // USE_MODAL_PRESENTATION
230 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
232 // `Main program' equivalent, creating windows and returning main app frame
236 wxInitAllImageHandlers();
239 m_canvasTextColour
= *wxBLACK
;
240 m_canvasFont
= *wxNORMAL_FONT
;
242 // Create the main frame window
243 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets dialogs example"));
246 wxMenu
*menuDlg
= new wxMenu
;
248 menuDlg
->Append(DIALOGS_MESSAGE_BOX
, _T("&Message box\tCtrl-M"));
251 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
253 wxMenu
*choices_menu
= new wxMenu
;
256 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, _T("&Choose colour"));
257 #endif // wxUSE_COLOURDLG
260 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, _T("Choose &font"));
261 #endif // wxUSE_FONTDLG
264 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, _T("&Single choice\tCtrl-C"));
265 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, _T("M&ultiple choice\tCtrl-U"));
266 #endif // wxUSE_CHOICEDLG
268 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
269 choices_menu
->AppendSeparator();
270 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
272 #if USE_COLOURDLG_GENERIC
273 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, _T("&Choose colour (generic)"));
274 #endif // USE_COLOURDLG_GENERIC
276 #if USE_FONTDLG_GENERIC
277 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, _T("Choose &font (generic)"));
278 #endif // USE_FONTDLG_GENERIC
280 menuDlg
->Append(wxID_ANY
,_T("&Choices and selectors"),choices_menu
);
281 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
284 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
286 wxMenu
*entry_menu
= new wxMenu
;
289 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, _T("Text &entry\tCtrl-E"));
290 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, _T("&Password entry\tCtrl-P"));
291 #endif // wxUSE_TEXTDLG
294 entry_menu
->Append(DIALOGS_NUM_ENTRY
, _T("&Numeric entry\tCtrl-N"));
295 #endif // wxUSE_NUMBERDLG
297 menuDlg
->Append(wxID_ANY
,_T("&Entry dialogs"),entry_menu
);
299 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
304 wxMenu
*filedlg_menu
= new wxMenu
;
305 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, _T("&Open file\tCtrl-O"));
306 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, _T("&Second open file\tCtrl-2"));
307 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, _T("Open &files\tCtrl-Q"));
308 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, _T("Sa&ve file\tCtrl-S"));
310 #if USE_FILEDLG_GENERIC
311 filedlg_menu
->AppendSeparator();
312 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, _T("&Open file (generic)"));
313 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, _T("Open &files (generic)"));
314 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, _T("Sa&ve file (generic)"));
315 #endif // USE_FILEDLG_GENERIC
317 menuDlg
->Append(wxID_ANY
,_T("&File operations"),filedlg_menu
);
319 #endif // wxUSE_FILEDLG
322 wxMenu
*dir_menu
= new wxMenu
;
324 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, _T("&Choose a directory\tCtrl-D"));
325 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
326 menuDlg
->Append(wxID_ANY
,_T("&Directory operations"),dir_menu
);
328 #if USE_DIRDLG_GENERIC
329 dir_menu
->AppendSeparator();
330 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, _T("&Choose a directory (generic)"));
331 #endif // USE_DIRDLG_GENERIC
333 #endif // wxUSE_DIRDLG
336 #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
338 wxMenu
*info_menu
= new wxMenu
;
340 #if wxUSE_STARTUP_TIPS
341 info_menu
->Append(DIALOGS_TIP
, _T("&Tip of the day\tCtrl-T"));
342 #endif // wxUSE_STARTUP_TIPS
344 #if wxUSE_PROGRESSDLG
345 info_menu
->Append(DIALOGS_PROGRESS
, _T("Pro&gress dialog\tCtrl-G"));
346 #endif // wxUSE_PROGRESSDLG
349 info_menu
->Append(DIALOGS_BUSYINFO
, _T("&Busy info dialog\tCtrl-B"));
350 #endif // wxUSE_BUSYINFO
353 info_menu
->Append(DIALOGS_LOG_DIALOG
, _T("&Log dialog\tCtrl-L"));
354 #endif // wxUSE_LOG_DIALOG
356 menuDlg
->Append(wxID_ANY
,_T("&Informative dialogs"),info_menu
);
358 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
361 #if wxUSE_FINDREPLDLG
362 wxMenu
*find_menu
= new wxMenu
;
363 find_menu
->AppendCheckItem(DIALOGS_FIND
, _T("&Find dialog\tCtrl-F"));
364 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, _T("Find and &replace dialog\tShift-Ctrl-F"));
365 menuDlg
->Append(wxID_ANY
,_T("&Searching"),find_menu
);
366 #endif // wxUSE_FINDREPLDLG
368 #if USE_MODAL_PRESENTATION
369 wxMenu
*dialogs_menu
= new wxMenu
;
370 dialogs_menu
->Append(DIALOGS_MODAL
, _T("&Modal dialog\tCtrl-W"));
371 dialogs_menu
->AppendCheckItem(DIALOGS_MODELESS
, _T("Mode&less dialog\tCtrl-Z"));
372 dialogs_menu
->Append(DIALOGS_CENTRE_SCREEN
, _T("Centered on &screen\tShift-Ctrl-1"));
373 dialogs_menu
->Append(DIALOGS_CENTRE_PARENT
, _T("Centered on &parent\tShift-Ctrl-2"));
374 menuDlg
->Append(wxID_ANY
, _T("&Generic dialogs"), dialogs_menu
);
375 #endif // USE_MODAL_PRESENTATION
377 #if USE_SETTINGS_DIALOG
378 wxMenu
*sheet_menu
= new wxMenu
;
379 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET
, _T("&Standard property sheet\tShift-Ctrl-P"));
380 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, _T("&Toolbook sheet\tShift-Ctrl-T"));
382 if (wxPlatformIs(wxPORT_MAC
))
383 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
386 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
389 menuDlg
->Append(wxID_ANY
, _T("&Property sheets"), sheet_menu
);
390 #endif // USE_SETTINGS_DIALOG
392 menuDlg
->Append(DIALOGS_REQUEST
, _T("&Request user attention\tCtrl-R"));
394 menuDlg
->AppendSeparator();
395 menuDlg
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"));
398 wxMenu
*menuHelp
= new wxMenu
;
399 menuHelp
->Append(DIALOGS_ABOUTDLG_SIMPLE
, _T("&About (simple)..."));
400 menuHelp
->Append(DIALOGS_ABOUTDLG_FANCY
, _T("About (&fancy)..."));
401 #endif // wxUSE_ABOUTDLG
403 wxMenuBar
*menubar
= new wxMenuBar
;
404 menubar
->Append(menuDlg
, _T("&Dialogs"));
406 menubar
->Append(menuHelp
, _T("&Help"));
407 #endif // wxUSE_ABOUTDLG
409 frame
->SetMenuBar(menubar
);
411 myCanvas
= new MyCanvas(frame
);
412 myCanvas
->SetBackgroundColour(*wxWHITE
);
414 frame
->Centre(wxBOTH
);
424 // My frame constructor
425 MyFrame::MyFrame(wxWindow
*parent
,
426 const wxString
& title
)
427 : wxFrame(parent
, wxID_ANY
, title
)
431 #if USE_MODAL_PRESENTATION
432 m_dialog
= (MyModelessDialog
*)NULL
;
433 #endif // USE_MODAL_PRESENTATION
435 #if wxUSE_FINDREPLDLG
441 m_clrData
.SetChooseFull(true);
442 for (int i
= 0; i
< 16; i
++)
444 m_clrData
.SetCustomColour(
447 (unsigned char)(i
*16),
448 (unsigned char)(i
*16),
449 (unsigned char)(i
*16)
453 #endif // wxUSE_COLOURDLG
457 #endif // wxUSE_STATUSBAR
461 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
463 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
465 wxColourDialog
dialog(this, &m_clrData
);
466 dialog
.SetTitle(_T("Choose the background colour"));
467 if (dialog
.ShowModal() == wxID_OK
)
469 m_clrData
= dialog
.GetColourData();
470 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
471 myCanvas
->ClearBackground();
475 #endif // wxUSE_COLOURDLG
477 #if USE_COLOURDLG_GENERIC
478 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
480 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
482 //FIXME:TODO:This has no effect...
483 m_clrData
.SetChooseFull(true);
485 for (int i
= 0; i
< 16; i
++)
488 (unsigned char)(i
*16),
489 (unsigned char)(i
*16),
490 (unsigned char)(i
*16)
492 m_clrData
.SetCustomColour(i
, colour
);
495 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
496 if (dialog
->ShowModal() == wxID_OK
)
498 m_clrData
= dialog
->GetColourData();
499 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
500 myCanvas
->ClearBackground();
505 #endif // USE_COLOURDLG_GENERIC
508 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
511 data
.SetInitialFont(wxGetApp().m_canvasFont
);
512 data
.SetColour(wxGetApp().m_canvasTextColour
);
514 // you might also do this:
516 // wxFontDialog dialog;
517 // if ( !dialog.Create(this, data) { ... error ... }
519 wxFontDialog
dialog(this, data
);
521 if (dialog
.ShowModal() == wxID_OK
)
523 wxFontData retData
= dialog
.GetFontData();
524 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
525 wxGetApp().m_canvasTextColour
= retData
.GetColour();
528 //else: cancelled by the user, don't change the font
530 #endif // wxUSE_FONTDLG
532 #if USE_FONTDLG_GENERIC
533 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
536 data
.SetInitialFont(wxGetApp().m_canvasFont
);
537 data
.SetColour(wxGetApp().m_canvasTextColour
);
539 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, data
);
540 if (dialog
->ShowModal() == wxID_OK
)
542 wxFontData retData
= dialog
->GetFontData();
543 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
544 wxGetApp().m_canvasTextColour
= retData
.GetColour();
549 #endif // USE_FONTDLG_GENERIC
552 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
554 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
555 // being flushed -- test it
558 wxLogMessage(wxT("This is some message - everything is ok so far."));
559 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
560 wxLogWarning(wxT("And then something went wrong!"));
562 // and if ~wxBusyCursor doesn't do it, then call it manually
566 wxLogError(wxT("Intermediary error handler decided to abort."));
567 wxLogError(wxT("The top level caller detected an unrecoverable error."));
569 wxLog::FlushActive();
571 wxLogMessage(wxT("And this is the same dialog but with only one message."));
573 #endif // wxUSE_LOG_DIALOG
575 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
577 wxMessageDialog
dialog( NULL
, _T("This is a message box\nA long, long string to test out the message box properly"),
578 _T("Message box text"), wxNO_DEFAULT
|wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
580 switch ( dialog
.ShowModal() )
583 wxLogStatus(wxT("You pressed \"Yes\""));
587 wxLogStatus(wxT("You pressed \"No\""));
591 wxLogStatus(wxT("You pressed \"Cancel\""));
595 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
600 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
602 long res
= wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
603 _T("Even two rows of text."),
604 _T("Enter a number:"), _T("Numeric input test"),
611 msg
= _T("Invalid number entered or dialog cancelled.");
616 msg
.Printf(_T("You've entered %lu"), res
);
617 icon
= wxICON_INFORMATION
;
620 wxMessageBox(msg
, _T("Numeric test result"), wxOK
| icon
, this);
622 #endif // wxUSE_NUMBERDLG
625 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
627 wxString pwd
= wxGetPasswordFromUser(_T("Enter password:"),
628 _T("Password entry dialog"),
633 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
634 _T("Got password"), wxOK
| wxICON_INFORMATION
, this);
638 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
640 wxTextEntryDialog
dialog(this,
641 _T("This is a small sample\n")
642 _T("A long, long string to test out the text entrybox"),
643 _T("Please enter a string"),
647 if (dialog
.ShowModal() == wxID_OK
)
649 wxMessageBox(dialog
.GetValue(), _T("Got string"), wxOK
| wxICON_INFORMATION
, this);
652 #endif // wxUSE_TEXTDLG
655 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
657 const wxString choices
[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
659 wxSingleChoiceDialog
dialog(this,
660 _T("This is a small sample\n")
661 _T("A single-choice convenience dialog"),
662 _T("Please select a value"),
663 WXSIZEOF(choices
), choices
);
665 dialog
.SetSelection(2);
667 if (dialog
.ShowModal() == wxID_OK
)
669 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), _T("Got string"));
674 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
676 const wxString choices
[] =
678 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
679 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
680 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
683 wxArrayInt selections
;
684 size_t count
= wxGetMultipleChoices(selections
,
685 _T("This is a small sample\n")
686 _T("A multi-choice convenience dialog"),
687 _T("Please select a value"),
688 WXSIZEOF(choices
), choices
,
693 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
694 for ( size_t n
= 0; n
< count
; n
++ )
696 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
697 (unsigned)n
, (unsigned)selections
[n
],
698 choices
[selections
[n
]].c_str());
702 //else: cancelled or nothing selected
704 #endif // wxUSE_CHOICEDLG
707 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
712 _T("Testing open file dialog"),
716 _T("C++ files (*.cpp)|*.cpp")
718 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
722 dialog
.CentreOnParent();
723 dialog
.SetDirectory(wxGetHomeDir());
725 if (dialog
.ShowModal() == wxID_OK
)
728 info
.Printf(_T("Full file name: %s\n")
731 dialog
.GetPath().c_str(),
732 dialog
.GetDirectory().c_str(),
733 dialog
.GetFilename().c_str());
734 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
739 // this shows how to take advantage of specifying a default extension in the
740 // call to wxFileSelector: it is remembered after each new call and the next
741 // one will use it by default
742 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
744 static wxString s_extDef
;
745 wxString path
= wxFileSelector(
746 _T("Select the file to load"),
747 wxEmptyString
, wxEmptyString
,
751 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
752 wxFileSelectorDefaultWildcardStr
,
753 wxFileSelectorDefaultWildcardStr
755 wxFD_OPEN
|wxFD_CHANGE_DIR
|wxFD_PREVIEW
,
762 // it is just a sample, would use wxSplitPath in real program
763 s_extDef
= path
.AfterLast(_T('.'));
765 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
766 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
769 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
773 _T("C++ files (*.cpp)|*.cpp");
777 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
778 wxFileSelectorDefaultWildcardStr
,
779 wxFileSelectorDefaultWildcardStr
782 wxFileDialog
dialog(this, _T("Testing open multiple file dialog"),
783 wxEmptyString
, wxEmptyString
, wildcards
,
784 wxFD_OPEN
|wxFD_MULTIPLE
);
786 if (dialog
.ShowModal() == wxID_OK
)
788 wxArrayString paths
, filenames
;
790 dialog
.GetPaths(paths
);
791 dialog
.GetFilenames(filenames
);
794 size_t count
= paths
.GetCount();
795 for ( size_t n
= 0; n
< count
; n
++ )
797 s
.Printf(_T("File %d: %s (%s)\n"),
798 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
802 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
805 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
810 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
812 wxFileDialog
dialog(this,
813 _T("Testing save file dialog"),
816 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
817 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
819 dialog
.SetFilterIndex(1);
821 if (dialog
.ShowModal() == wxID_OK
)
823 wxLogMessage(_T("%s, filter %d"),
824 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
827 #endif // wxUSE_FILEDLG
829 #if USE_FILEDLG_GENERIC
830 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
832 wxGenericFileDialog dialog
835 _T("Testing open file dialog"),
838 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
841 dialog
.SetDirectory(wxGetHomeDir());
843 if (dialog
.ShowModal() == wxID_OK
)
846 info
.Printf(_T("Full file name: %s\n")
849 dialog
.GetPath().c_str(),
850 dialog
.GetDirectory().c_str(),
851 dialog
.GetFilename().c_str());
852 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
857 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
859 // On PocketPC you can disable OK-only dialogs policy using system option
860 int buttons
= wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
861 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
863 wxString wildcards
= _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
864 wxGenericFileDialog
dialog(this, _T("Testing open multiple file dialog"),
865 wxEmptyString
, wxEmptyString
, wildcards
,
868 if (dialog
.ShowModal() == wxID_OK
)
870 wxArrayString paths
, filenames
;
872 dialog
.GetPaths(paths
);
873 dialog
.GetFilenames(filenames
);
876 size_t count
= paths
.GetCount();
877 for ( size_t n
= 0; n
< count
; n
++ )
879 s
.Printf(_T("File %d: %s (%s)\n"),
880 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
884 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
887 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
891 // restore system option
892 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons
);
895 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
897 wxGenericFileDialog
dialog(this,
898 _T("Testing save file dialog"),
901 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
902 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
904 dialog
.SetFilterIndex(1);
906 if (dialog
.ShowModal() == wxID_OK
)
908 wxLogMessage(_T("%s, filter %d"),
909 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
912 #endif // USE_FILEDLG_GENERIC
915 void MyFrame::DoDirChoose(int style
)
917 // pass some initial dir to wxDirDialog
919 wxGetHomeDir(&dirHome
);
921 wxDirDialog
dialog(this, _T("Testing directory picker"), dirHome
, style
);
923 if (dialog
.ShowModal() == wxID_OK
)
925 wxLogMessage(_T("Selected path: %s"), dialog
.GetPath().c_str());
929 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
931 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_DIR_MUST_EXIST
);
934 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
936 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_DIR_MUST_EXIST
);
938 #endif // wxUSE_DIRDLG
940 #if USE_DIRDLG_GENERIC
941 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
943 // pass some initial dir to wxDirDialog
945 wxGetHomeDir(&dirHome
);
947 wxGenericDirDialog
dialog(this, _T("Testing generic directory picker"), dirHome
);
949 if (dialog
.ShowModal() == wxID_OK
)
951 wxMessageDialog
dialog2(this, dialog
.GetPath(), _T("Selected path"));
955 #endif // USE_DIRDLG_GENERIC
957 #if USE_MODAL_PRESENTATION
958 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
960 MyModalDialog
dlg(this);
964 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
966 bool show
= GetMenuBar()->IsChecked(event
.GetId());
972 m_dialog
= new MyModelessDialog(this);
975 m_dialog
->Show(true);
979 // If m_dialog is NULL, then possibly the system
980 // didn't report the checked menu item status correctly.
981 // It should be true just after the menu item was selected,
982 // if there was no modeless dialog yet.
984 wxASSERT( m_dialog
!= NULL
);
990 void MyFrame::DlgCenteredScreen(wxCommandEvent
& WXUNUSED(event
))
992 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on screen"),
993 wxDefaultPosition
, wxSize(200, 100));
994 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
995 dlg
.CentreOnScreen();
999 void MyFrame::DlgCenteredParent(wxCommandEvent
& WXUNUSED(event
))
1001 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on parent"),
1002 wxDefaultPosition
, wxSize(200, 100));
1003 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
1004 dlg
.CentreOnParent();
1008 #endif // USE_MODAL_PRESENTATION
1010 #if wxUSE_STARTUP_TIPS
1011 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
1013 static size_t s_index
= (size_t)-1;
1015 if ( s_index
== (size_t)-1 )
1019 // this is completely bogus, we don't know how many lines are there
1020 // in the file, but who cares, it's a demo only...
1021 s_index
= rand() % 5;
1024 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(_T("tips.txt"), s_index
);
1026 bool showAtStartup
= wxShowTip(this, tipProvider
);
1028 if ( showAtStartup
)
1030 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
1031 wxOK
| wxICON_INFORMATION
, this);
1034 s_index
= tipProvider
->GetCurrentTip();
1037 #endif // wxUSE_STARTUP_TIPS
1039 #if USE_SETTINGS_DIALOG
1040 void MyFrame::OnPropertySheet(wxCommandEvent
& event
)
1042 SettingsDialog
dialog(this, event
.GetId());
1045 #endif // USE_SETTINGS_DIALOG
1047 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
1049 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1053 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
1056 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1061 #if wxUSE_PROGRESSDLG
1063 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1065 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1066 // check the performance
1067 int countrandomnumbers
= 0, count
= 0;
1068 wxTimeSpan
tsTest(0,0,0,250);
1069 wxDateTime DT2
, DT1
= wxDateTime::UNow();
1074 ++countrandomnumbers
;
1075 if ( countrandomnumbers
== 1000 )
1078 countrandomnumbers
= 0;
1080 DT2
= wxDateTime::UNow();
1081 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1082 if ( ts
.IsLongerThan( tsTest
) )
1088 const int max
= 40 * count
;
1090 static const int max
= 10;
1091 #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG
1093 wxProgressDialog
dialog(_T("Progress dialog example"),
1094 _T("An informative message"),
1100 // wxPD_AUTO_HIDE | -- try this as well
1102 wxPD_ESTIMATED_TIME
|
1103 wxPD_REMAINING_TIME
|
1108 // each skip will move progress about quarter forward
1109 for ( int i
= 0; i
<= max
; i
= wxMin(i
+(skip
?int(max
/4):1), max
+1), skip
= false )
1111 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1112 // do (almost) the same operations as we did for the performance test
1114 for ( int j
= 0; j
< 1000; j
++ )
1119 DT2
= wxDateTime::UNow();
1120 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1121 if ( ts
.IsLongerThan( tsTest
) )
1135 msg
= _T("That's all, folks!");
1137 else if ( i
> max
/ 2 )
1139 msg
= _T("Only a half left (very long message)!");
1142 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1143 if ( (i
% (max
/100)) == 0 ) // // only 100 updates, this makes it much faster
1145 cont
= dialog
.Update(i
, msg
, &skip
);
1148 cont
= dialog
.Update(i
, msg
, &skip
);
1153 if ( wxMessageBox(_T("Do you really want to cancel?"),
1154 _T("Progress dialog question"), // caption
1155 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1165 wxLogStatus(wxT("Progress dialog aborted!"));
1169 wxLogStatus(wxT("Countdown from %d finished"), max
);
1173 #endif // wxUSE_PROGRESSDLG
1177 static void CommonAboutInfoInit(wxAboutDialogInfo
& info
)
1179 info
.SetName(_T("Dialogs Sample"));
1180 info
.SetVersion(wxVERSION_NUM_DOT_STRING_T
);
1181 info
.SetDescription(_T("This sample shows different wxWidgets dialogs"));
1182 info
.SetCopyright(_T("© 1998-2006 wxWidgets dev team"));
1185 void MyFrame::ShowSimpleAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1187 wxAboutDialogInfo info
;
1188 CommonAboutInfoInit(info
);
1193 void MyFrame::ShowFancyAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1195 wxAboutDialogInfo info
;
1196 CommonAboutInfoInit(info
);
1197 info
.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
1202 #endif // wxUSE_ABOUTDLG
1206 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1208 wxWindowDisabler disableAll
;
1210 wxBusyInfo
info(_T("Working, please wait..."), this);
1212 for ( int i
= 0; i
< 18; i
++ )
1222 #endif // wxUSE_BUSYINFO
1224 #if wxUSE_FINDREPLDLG
1226 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1230 delete m_dlgReplace
;
1231 m_dlgReplace
= NULL
;
1235 m_dlgReplace
= new wxFindReplaceDialog
1239 _T("Find and replace dialog"),
1243 m_dlgReplace
->Show(true);
1247 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1256 m_dlgFind
= new wxFindReplaceDialog
1265 m_dlgFind
->Show(true);
1269 static wxString
DecodeFindDialogEventFlags(int flags
)
1272 str
<< (flags
& wxFR_DOWN
? _T("down") : _T("up")) << _T(", ")
1273 << (flags
& wxFR_WHOLEWORD
? _T("whole words only, ") : _T(""))
1274 << (flags
& wxFR_MATCHCASE
? _T("") : _T("not "))
1275 << _T("case sensitive");
1280 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
1282 wxEventType type
= event
.GetEventType();
1284 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
1286 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1287 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
1288 event
.GetFindString().c_str(),
1289 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1291 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
1292 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
1294 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1295 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? _T("all ") : wxT(""),
1296 event
.GetFindString().c_str(),
1297 event
.GetReplaceString().c_str(),
1298 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1300 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
1302 wxFindReplaceDialog
*dlg
= event
.GetDialog();
1306 if ( dlg
== m_dlgFind
)
1309 idMenu
= DIALOGS_FIND
;
1312 else if ( dlg
== m_dlgReplace
)
1314 txt
= _T("Replace");
1315 idMenu
= DIALOGS_REPLACE
;
1316 m_dlgReplace
= NULL
;
1320 txt
= _T("Unknown");
1323 wxFAIL_MSG( _T("unexpected event") );
1326 wxLogMessage(wxT("%s dialog is being closed."), txt
);
1328 if ( idMenu
!= wxID_ANY
)
1330 GetMenuBar()->Check(idMenu
, false);
1337 wxLogError(wxT("Unknown find dialog event!"));
1341 #endif // wxUSE_FINDREPLDLG
1343 // ----------------------------------------------------------------------------
1345 // ----------------------------------------------------------------------------
1347 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
1350 dc
.SetFont(wxGetApp().m_canvasFont
);
1351 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
1352 dc
.SetBackgroundMode(wxTRANSPARENT
);
1354 _T("wxWidgets common dialogs")
1355 #if !defined(__SMARTPHONE__)
1356 _T(" test application")
1361 #if USE_MODAL_PRESENTATION
1363 // ----------------------------------------------------------------------------
1365 // ----------------------------------------------------------------------------
1367 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
1368 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modeless dialog")))
1370 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
1372 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, _T("Press me"));
1373 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, _T("Should be disabled"));
1376 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
1377 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
1381 sizerTop
->SetSizeHints(this);
1382 sizerTop
->Fit(this);
1385 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
1387 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1388 wxOK
| wxICON_INFORMATION
, this);
1391 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
1393 if ( event
.CanVeto() )
1395 wxMessageBox(_T("Use the menu item to close this dialog"),
1396 _T("Modeless dialog"),
1397 wxOK
| wxICON_INFORMATION
, this);
1403 // ----------------------------------------------------------------------------
1405 // ----------------------------------------------------------------------------
1407 MyModalDialog::MyModalDialog(wxWindow
*parent
)
1408 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modal dialog")))
1410 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1412 m_btnModal
= new wxButton(this, wxID_ANY
, _T("&Modal dialog..."));
1413 m_btnModeless
= new wxButton(this, wxID_ANY
, _T("Mode&less dialog"));
1414 m_btnDelete
= new wxButton(this, wxID_ANY
, _T("&Delete button"));
1416 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _T("&Close"));
1417 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
1418 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
1419 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
1420 sizerTop
->Add(btnOk
, 0, wxALIGN_CENTER
| wxALL
, 5);
1424 sizerTop
->SetSizeHints(this);
1425 sizerTop
->Fit(this);
1427 m_btnModal
->SetFocus();
1428 m_btnModal
->SetDefault();
1431 void MyModalDialog::OnButton(wxCommandEvent
& event
)
1433 if ( event
.GetEventObject() == m_btnDelete
)
1438 m_btnDelete
->Disable();
1440 else if ( event
.GetEventObject() == m_btnModal
)
1443 wxGetTextFromUser(_T("Dummy prompt"),
1444 _T("Modal dialog called from dialog"),
1445 wxEmptyString
, this);
1447 wxMessageBox(_T("Modal dialog called from dialog"));
1448 #endif // wxUSE_TEXTDLG
1450 else if ( event
.GetEventObject() == m_btnModeless
)
1452 (new MyModelessDialog(this))->Show();
1460 #endif // USE_MODAL_PRESENTATION
1462 #if USE_SETTINGS_DIALOG
1463 // ----------------------------------------------------------------------------
1465 // ----------------------------------------------------------------------------
1467 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
1469 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
1472 SettingsDialog::SettingsDialog(wxWindow
* win
, int dialogType
)
1474 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
1479 bool useToolBook
= (dialogType
== DIALOGS_PROPERTY_SHEET_TOOLBOOK
|| dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
);
1480 int resizeBorder
= wxRESIZE_BORDER
;
1488 int sheetStyle
= wxPROPSHEET_SHRINKTOFIT
;
1489 if (dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
)
1490 sheetStyle
|= wxPROPSHEET_BUTTONTOOLBOOK
;
1492 sheetStyle
|= wxPROPSHEET_TOOLBOOK
;
1494 SetSheetStyle(sheetStyle
);
1495 SetSheetInnerBorder(0);
1496 SetSheetOuterBorder(0);
1498 // create a dummy image list with a few icons
1499 const wxSize
imageSize(32, 32);
1501 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
1503 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
1505 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
1507 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
1509 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
1514 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
1515 wxDEFAULT_DIALOG_STYLE
| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, resizeBorder
)
1518 // If using a toolbook, also follow Mac style and don't create buttons
1520 CreateButtons(wxOK
| wxCANCEL
|
1521 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, wxHELP
)
1524 wxBookCtrlBase
* notebook
= GetBookCtrl();
1525 notebook
->SetImageList(m_imageList
);
1527 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
1528 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
1530 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
1531 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
1536 SettingsDialog::~SettingsDialog()
1541 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
1543 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1545 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1546 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1550 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
1551 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
1552 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1553 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
1557 wxString autoSaveLabel
= _("&Auto-save every");
1558 wxString minsLabel
= _("mins");
1560 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
1561 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
1564 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
1565 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
1568 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1570 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1572 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1573 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
1577 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
1578 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
1579 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1580 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
1582 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1584 panel
->SetSizer(topSizer
);
1585 topSizer
->Fit(panel
);
1590 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
1592 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1594 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1595 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1597 //// PROJECT OR GLOBAL
1598 wxString globalOrProjectChoices
[2];
1599 globalOrProjectChoices
[0] = _("&New projects");
1600 globalOrProjectChoices
[1] = _("&This project");
1602 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
1603 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
1604 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
1606 projectOrGlobal
->SetSelection(0);
1608 //// BACKGROUND STYLE
1609 wxArrayString backgroundStyleChoices
;
1610 backgroundStyleChoices
.Add(wxT("Colour"));
1611 backgroundStyleChoices
.Add(wxT("Image"));
1612 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
1614 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
1615 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
1617 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
1619 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
1621 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1622 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
1623 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1625 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
1628 //// FONT SIZE SELECTION
1630 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
1631 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
1633 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
1634 wxSize(80, wxDefaultCoord
));
1635 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
1637 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
1640 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1641 topSizer
->AddSpacer(5);
1643 panel
->SetSizer(topSizer
);
1644 topSizer
->Fit(panel
);
1649 #endif // USE_SETTINGS_DIALOG