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/busyinfo.h"
54 #endif // wxUSE_BUSYINFO
57 #include "wx/numdlg.h"
58 #endif // wxUSE_NUMBERDLG
61 #include "wx/filedlg.h"
62 #endif // wxUSE_FILEDLG
65 #include "wx/dirdlg.h"
66 #endif // wxUSE_DIRDLG
69 #include "wx/fontdlg.h"
70 #endif // wxUSE_FONTDLG
73 #include "wx/fdrepdlg.h"
74 #endif // wxUSE_FINDREPLDLG
77 #include "wx/spinctrl.h"
80 #include "wx/propdlg.h"
84 #if USE_COLOURDLG_GENERIC
85 #include "wx/generic/colrdlgg.h"
86 #endif // USE_COLOURDLG_GENERIC
88 #if USE_DIRDLG_GENERIC
89 #include "wx/generic/dirdlgg.h"
90 #endif // USE_DIRDLG_GENERIC
92 #if USE_FILEDLG_GENERIC
93 #include "wx/generic/filedlgg.h"
94 #endif // USE_FILEDLG_GENERIC
96 #if USE_FONTDLG_GENERIC
97 #include "wx/generic/fontdlgg.h"
98 #endif // USE_FONTDLG_GENERIC
102 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
103 EVT_PAINT(MyCanvas::OnPaint
)
108 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
109 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
112 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
113 #endif // wxUSE_COLOURDLG
116 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
117 #endif // wxUSE_FONTDLG
120 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
121 #endif // wxUSE_LOG_DIALOG
124 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
125 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
126 #endif // wxUSE_TEXTDLG
129 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
130 #endif // wxUSE_NUMBERDLG
133 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
134 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
135 #endif // wxUSE_CHOICEDLG
138 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
139 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
140 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
141 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
142 #endif // wxUSE_FILEDLG
144 #if USE_FILEDLG_GENERIC
145 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
146 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
147 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
148 #endif // USE_FILEDLG_GENERIC
151 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
152 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
153 #endif // wxUSE_DIRDLG
155 #if USE_MODAL_PRESENTATION
156 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
157 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
158 EVT_MENU(DIALOGS_CENTRE_SCREEN
, MyFrame::DlgCenteredScreen
)
159 EVT_MENU(DIALOGS_CENTRE_PARENT
, MyFrame::DlgCenteredParent
)
162 #if wxUSE_STARTUP_TIPS
163 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
164 #endif // wxUSE_STARTUP_TIPS
166 #if USE_FONTDLG_GENERIC
167 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
168 #endif // USE_FONTDLG_GENERIC
170 #if USE_DIRDLG_GENERIC
171 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
172 #endif // wxMSW || wxMAC
174 #if USE_COLOURDLG_GENERIC
175 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
176 #endif // USE_COLOURDLG_GENERIC
178 #if wxUSE_PROGRESSDLG
179 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
180 #endif // wxUSE_PROGRESSDLG
183 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
184 #endif // wxUSE_BUSYINFO
186 #if wxUSE_FINDREPLDLG
187 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
188 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
190 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
191 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
192 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
193 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
194 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
195 #endif // wxUSE_FINDREPLDLG
197 #if USE_SETTINGS_DIALOG
198 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
199 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheet
)
200 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, MyFrame::OnPropertySheet
)
203 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
205 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
208 #if USE_MODAL_PRESENTATION
210 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
211 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
214 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
215 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
216 EVT_CLOSE(MyModelessDialog::OnClose
)
219 #endif // USE_MODAL_PRESENTATION
221 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
223 // `Main program' equivalent, creating windows and returning main app frame
227 wxInitAllImageHandlers();
230 m_canvasTextColour
= wxColour(_T("BLACK"));
231 m_canvasFont
= *wxNORMAL_FONT
;
233 // Create the main frame window
234 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets dialogs example"));
237 wxMenu
*file_menu
= new wxMenu
;
239 file_menu
->Append(DIALOGS_MESSAGE_BOX
, _T("&Message box\tCtrl-M"));
242 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
244 wxMenu
*choices_menu
= new wxMenu
;
247 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, _T("&Choose colour"));
248 #endif // wxUSE_COLOURDLG
251 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, _T("Choose &font"));
252 #endif // wxUSE_FONTDLG
255 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, _T("&Single choice\tCtrl-C"));
256 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, _T("M&ultiple choice\tCtrl-U"));
257 #endif // wxUSE_CHOICEDLG
259 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
260 choices_menu
->AppendSeparator();
261 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
263 #if USE_COLOURDLG_GENERIC
264 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, _T("&Choose colour (generic)"));
265 #endif // USE_COLOURDLG_GENERIC
267 #if USE_FONTDLG_GENERIC
268 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, _T("Choose &font (generic)"));
269 #endif // USE_FONTDLG_GENERIC
271 file_menu
->Append(wxID_ANY
,_T("&Choices and selectors"),choices_menu
);
272 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
275 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
277 wxMenu
*entry_menu
= new wxMenu
;
280 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, _T("Text &entry\tCtrl-E"));
281 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, _T("&Password entry\tCtrl-P"));
282 #endif // wxUSE_TEXTDLG
285 entry_menu
->Append(DIALOGS_NUM_ENTRY
, _T("&Numeric entry\tCtrl-N"));
286 #endif // wxUSE_NUMBERDLG
288 file_menu
->Append(wxID_ANY
,_T("&Entry dialogs"),entry_menu
);
290 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
295 wxMenu
*filedlg_menu
= new wxMenu
;
296 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, _T("&Open file\tCtrl-O"));
297 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, _T("&Second open file\tCtrl-2"));
298 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, _T("Open &files\tCtrl-Q"));
299 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, _T("Sa&ve file\tCtrl-S"));
301 #if USE_FILEDLG_GENERIC
302 filedlg_menu
->AppendSeparator();
303 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, _T("&Open file (generic)"));
304 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, _T("Open &files (generic)"));
305 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, _T("Sa&ve file (generic)"));
306 #endif // USE_FILEDLG_GENERIC
308 file_menu
->Append(wxID_ANY
,_T("&File operations"),filedlg_menu
);
310 #endif // wxUSE_FILEDLG
313 wxMenu
*dir_menu
= new wxMenu
;
315 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, _T("&Choose a directory\tCtrl-D"));
316 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
317 file_menu
->Append(wxID_ANY
,_T("&Directory operations"),dir_menu
);
319 #if USE_DIRDLG_GENERIC
320 dir_menu
->AppendSeparator();
321 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, _T("&Choose a directory (generic)"));
322 #endif // USE_DIRDLG_GENERIC
324 #endif // wxUSE_DIRDLG
327 #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
329 wxMenu
*info_menu
= new wxMenu
;
331 #if wxUSE_STARTUP_TIPS
332 info_menu
->Append(DIALOGS_TIP
, _T("&Tip of the day\tCtrl-T"));
333 #endif // wxUSE_STARTUP_TIPS
335 #if wxUSE_PROGRESSDLG
336 info_menu
->Append(DIALOGS_PROGRESS
, _T("Pro&gress dialog\tCtrl-G"));
337 #endif // wxUSE_PROGRESSDLG
340 info_menu
->Append(DIALOGS_BUSYINFO
, _T("&Busy info dialog\tCtrl-B"));
341 #endif // wxUSE_BUSYINFO
344 info_menu
->Append(DIALOGS_LOG_DIALOG
, _T("&Log dialog\tCtrl-L"));
345 #endif // wxUSE_LOG_DIALOG
347 file_menu
->Append(wxID_ANY
,_T("&Informative dialogs"),info_menu
);
349 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
352 #if wxUSE_FINDREPLDLG
353 wxMenu
*find_menu
= new wxMenu
;
354 find_menu
->AppendCheckItem(DIALOGS_FIND
, _T("&Find dialog\tCtrl-F"));
355 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, _T("Find and &replace dialog\tShift-Ctrl-F"));
356 file_menu
->Append(wxID_ANY
,_T("&Searching"),find_menu
);
357 #endif // wxUSE_FINDREPLDLG
359 #if USE_MODAL_PRESENTATION
360 wxMenu
*dialogs_menu
= new wxMenu
;
361 dialogs_menu
->Append(DIALOGS_MODAL
, _T("&Modal dialog\tCtrl-W"));
362 dialogs_menu
->AppendCheckItem(DIALOGS_MODELESS
, _T("Mode&less dialog\tCtrl-Z"));
363 dialogs_menu
->AppendCheckItem(DIALOGS_CENTRE_SCREEN
, _T("Centered on &screen\tShift-Ctrl-1"));
364 dialogs_menu
->AppendCheckItem(DIALOGS_CENTRE_PARENT
, _T("Centered on &parent\tShift-Ctrl-2"));
365 file_menu
->Append(wxID_ANY
, _T("&Generic dialogs"), dialogs_menu
);
366 #endif // USE_MODAL_PRESENTATION
368 #if USE_SETTINGS_DIALOG
369 wxMenu
*sheet_menu
= new wxMenu
;
370 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET
, _T("&Standard property sheet\tShift-Ctrl-P"));
371 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, _T("&Toolbook sheet\tShift-Ctrl-T"));
373 if (wxPlatformIs(wxMac
))
374 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
377 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
380 file_menu
->Append(wxID_ANY
, _T("&Property sheets"), sheet_menu
);
381 #endif // USE_SETTINGS_DIALOG
383 file_menu
->Append(DIALOGS_REQUEST
, _T("&Request user attention\tCtrl-R"));
385 file_menu
->AppendSeparator();
386 file_menu
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"));
388 wxMenuBar
*menu_bar
= new wxMenuBar
;
389 menu_bar
->Append(file_menu
, _T("&File"));
390 frame
->SetMenuBar(menu_bar
);
392 myCanvas
= new MyCanvas(frame
);
393 myCanvas
->SetBackgroundColour(*wxWHITE
);
395 frame
->Centre(wxBOTH
);
405 // My frame constructor
406 MyFrame::MyFrame(wxWindow
*parent
,
407 const wxString
& title
)
408 : wxFrame(parent
, wxID_ANY
, title
)
412 #if USE_MODAL_PRESENTATION
413 m_dialog
= (MyModelessDialog
*)NULL
;
414 #endif // USE_MODAL_PRESENTATION
416 #if wxUSE_FINDREPLDLG
422 m_clrData
.SetChooseFull(true);
423 for (int i
= 0; i
< 16; i
++)
425 m_clrData
.SetCustomColour(
428 (unsigned char)(i
*16),
429 (unsigned char)(i
*16),
430 (unsigned char)(i
*16)
434 #endif // wxUSE_COLOURDLG
438 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
440 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
442 wxColourDialog
dialog(this, &m_clrData
);
443 dialog
.SetTitle(_T("Choose the background colour"));
444 if (dialog
.ShowModal() == wxID_OK
)
446 m_clrData
= dialog
.GetColourData();
447 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
448 myCanvas
->ClearBackground();
452 #endif // wxUSE_COLOURDLG
454 #if USE_COLOURDLG_GENERIC
455 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
457 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
459 //FIXME:TODO:This has no effect...
460 m_clrData
.SetChooseFull(true);
462 for (int i
= 0; i
< 16; i
++)
465 (unsigned char)(i
*16),
466 (unsigned char)(i
*16),
467 (unsigned char)(i
*16)
469 m_clrData
.SetCustomColour(i
, colour
);
472 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
473 if (dialog
->ShowModal() == wxID_OK
)
475 m_clrData
= dialog
->GetColourData();
476 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
477 myCanvas
->ClearBackground();
482 #endif // USE_COLOURDLG_GENERIC
485 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
488 data
.SetInitialFont(wxGetApp().m_canvasFont
);
489 data
.SetColour(wxGetApp().m_canvasTextColour
);
491 // you might also do this:
493 // wxFontDialog dialog;
494 // if ( !dialog.Create(this, data) { ... error ... }
496 wxFontDialog
dialog(this, data
);
498 if (dialog
.ShowModal() == wxID_OK
)
500 wxFontData retData
= dialog
.GetFontData();
501 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
502 wxGetApp().m_canvasTextColour
= retData
.GetColour();
505 //else: cancelled by the user, don't change the font
507 #endif // wxUSE_FONTDLG
509 #if USE_FONTDLG_GENERIC
510 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
513 data
.SetInitialFont(wxGetApp().m_canvasFont
);
514 data
.SetColour(wxGetApp().m_canvasTextColour
);
516 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, data
);
517 if (dialog
->ShowModal() == wxID_OK
)
519 wxFontData retData
= dialog
->GetFontData();
520 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
521 wxGetApp().m_canvasTextColour
= retData
.GetColour();
526 #endif // USE_FONTDLG_GENERIC
529 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
531 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
532 // being flushed -- test it
535 wxLogMessage(wxT("This is some message - everything is ok so far."));
536 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
537 wxLogWarning(wxT("And then something went wrong!"));
539 // and if ~wxBusyCursor doesn't do it, then call it manually
543 wxLogError(wxT("Intermediary error handler decided to abort."));
544 wxLogError(wxT("The top level caller detected an unrecoverable error."));
546 wxLog::FlushActive();
548 wxLogMessage(wxT("And this is the same dialog but with only one message."));
550 #endif // wxUSE_LOG_DIALOG
552 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
554 wxMessageDialog
dialog( NULL
, _T("This is a message box\nA long, long string to test out the message box properly"),
555 _T("Message box text"), wxNO_DEFAULT
|wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
557 switch ( dialog
.ShowModal() )
560 wxLogStatus(wxT("You pressed \"Yes\""));
564 wxLogStatus(wxT("You pressed \"No\""));
568 wxLogStatus(wxT("You pressed \"Cancel\""));
572 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
577 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
579 long res
= wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
580 _T("Even two rows of text."),
581 _T("Enter a number:"), _T("Numeric input test"),
588 msg
= _T("Invalid number entered or dialog cancelled.");
593 msg
.Printf(_T("You've entered %lu"), res
);
594 icon
= wxICON_INFORMATION
;
597 wxMessageBox(msg
, _T("Numeric test result"), wxOK
| icon
, this);
599 #endif // wxUSE_NUMBERDLG
602 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
604 wxString pwd
= wxGetPasswordFromUser(_T("Enter password:"),
605 _T("Password entry dialog"),
610 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
611 _T("Got password"), wxOK
| wxICON_INFORMATION
, this);
615 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
617 wxTextEntryDialog
dialog(this,
618 _T("This is a small sample\n")
619 _T("A long, long string to test out the text entrybox"),
620 _T("Please enter a string"),
624 if (dialog
.ShowModal() == wxID_OK
)
626 wxMessageBox(dialog
.GetValue(), _T("Got string"), wxOK
| wxICON_INFORMATION
, this);
629 #endif // wxUSE_TEXTDLG
632 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
634 const wxString choices
[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
636 wxSingleChoiceDialog
dialog(this,
637 _T("This is a small sample\n")
638 _T("A single-choice convenience dialog"),
639 _T("Please select a value"),
640 WXSIZEOF(choices
), choices
);
642 dialog
.SetSelection(2);
644 if (dialog
.ShowModal() == wxID_OK
)
646 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), _T("Got string"));
651 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
653 const wxString choices
[] =
655 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
656 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
657 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
660 wxArrayInt selections
;
661 size_t count
= wxGetMultipleChoices(selections
,
662 _T("This is a small sample\n")
663 _T("A multi-choice convenience dialog"),
664 _T("Please select a value"),
665 WXSIZEOF(choices
), choices
,
670 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
671 for ( size_t n
= 0; n
< count
; n
++ )
673 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
674 (unsigned)n
, (unsigned)selections
[n
],
675 choices
[selections
[n
]].c_str());
679 //else: cancelled or nothing selected
681 #endif // wxUSE_CHOICEDLG
684 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
689 _T("Testing open file dialog"),
693 _T("C++ files (*.cpp)|*.cpp")
695 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
699 dialog
.CentreOnParent();
700 dialog
.SetDirectory(wxGetHomeDir());
702 if (dialog
.ShowModal() == wxID_OK
)
705 info
.Printf(_T("Full file name: %s\n")
708 dialog
.GetPath().c_str(),
709 dialog
.GetDirectory().c_str(),
710 dialog
.GetFilename().c_str());
711 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
716 // this shows how to take advantage of specifying a default extension in the
717 // call to wxFileSelector: it is remembered after each new call and the next
718 // one will use it by default
719 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
721 static wxString s_extDef
;
722 wxString path
= wxFileSelector(
723 _T("Select the file to load"),
724 wxEmptyString
, wxEmptyString
,
728 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
729 wxFileSelectorDefaultWildcardStr
,
730 wxFileSelectorDefaultWildcardStr
739 // it is just a sample, would use wxSplitPath in real program
740 s_extDef
= path
.AfterLast(_T('.'));
742 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
743 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
746 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
750 _T("C++ files (*.cpp)|*.cpp");
754 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
755 wxFileSelectorDefaultWildcardStr
,
756 wxFileSelectorDefaultWildcardStr
759 wxFileDialog
dialog(this, _T("Testing open multiple file dialog"),
760 wxEmptyString
, wxEmptyString
, wildcards
,
763 if (dialog
.ShowModal() == wxID_OK
)
765 wxArrayString paths
, filenames
;
767 dialog
.GetPaths(paths
);
768 dialog
.GetFilenames(filenames
);
771 size_t count
= paths
.GetCount();
772 for ( size_t n
= 0; n
< count
; n
++ )
774 s
.Printf(_T("File %d: %s (%s)\n"),
775 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
779 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
782 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
787 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
789 wxFileDialog
dialog(this,
790 _T("Testing save file dialog"),
793 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
794 wxSAVE
|wxOVERWRITE_PROMPT
);
796 dialog
.SetFilterIndex(1);
798 if (dialog
.ShowModal() == wxID_OK
)
800 wxLogMessage(_T("%s, filter %d"),
801 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
804 #endif // wxUSE_FILEDLG
806 #if USE_FILEDLG_GENERIC
807 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
809 wxGenericFileDialog dialog
812 _T("Testing open file dialog"),
815 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
818 dialog
.SetDirectory(wxGetHomeDir());
820 if (dialog
.ShowModal() == wxID_OK
)
823 info
.Printf(_T("Full file name: %s\n")
826 dialog
.GetPath().c_str(),
827 dialog
.GetDirectory().c_str(),
828 dialog
.GetFilename().c_str());
829 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
834 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
836 // On PocketPC you can disable OK-only dialogs policy using system option
837 int buttons
= wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
838 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
840 wxString wildcards
= _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
841 wxGenericFileDialog
dialog(this, _T("Testing open multiple file dialog"),
842 wxEmptyString
, wxEmptyString
, wildcards
,
845 if (dialog
.ShowModal() == wxID_OK
)
847 wxArrayString paths
, filenames
;
849 dialog
.GetPaths(paths
);
850 dialog
.GetFilenames(filenames
);
853 size_t count
= paths
.GetCount();
854 for ( size_t n
= 0; n
< count
; n
++ )
856 s
.Printf(_T("File %d: %s (%s)\n"),
857 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
861 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
864 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
868 // restore system option
869 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons
);
872 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
874 wxGenericFileDialog
dialog(this,
875 _T("Testing save file dialog"),
878 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
879 wxSAVE
|wxOVERWRITE_PROMPT
);
881 dialog
.SetFilterIndex(1);
883 if (dialog
.ShowModal() == wxID_OK
)
885 wxLogMessage(_T("%s, filter %d"),
886 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
889 #endif // USE_FILEDLG_GENERIC
892 void MyFrame::DoDirChoose(int style
)
894 // pass some initial dir to wxDirDialog
896 wxGetHomeDir(&dirHome
);
898 wxDirDialog
dialog(this, _T("Testing directory picker"), dirHome
, style
);
900 if (dialog
.ShowModal() == wxID_OK
)
902 wxLogMessage(_T("Selected path: %s"), dialog
.GetPath().c_str());
906 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
908 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_NEW_DIR_BUTTON
);
911 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
913 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_NEW_DIR_BUTTON
);
915 #endif // wxUSE_DIRDLG
917 #if USE_DIRDLG_GENERIC
918 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
920 // pass some initial dir to wxDirDialog
922 wxGetHomeDir(&dirHome
);
924 wxGenericDirDialog
dialog(this, _T("Testing generic directory picker"), dirHome
);
926 if (dialog
.ShowModal() == wxID_OK
)
928 wxMessageDialog
dialog2(this, dialog
.GetPath(), _T("Selected path"));
932 #endif // USE_DIRDLG_GENERIC
934 #if USE_MODAL_PRESENTATION
935 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
937 MyModalDialog
dlg(this);
941 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
943 bool show
= GetMenuBar()->IsChecked(event
.GetId());
949 m_dialog
= new MyModelessDialog(this);
952 m_dialog
->Show(true);
956 // If m_dialog is NULL, then possibly the system
957 // didn't report the checked menu item status correctly.
958 // It should be true just after the menu item was selected,
959 // if there was no modeless dialog yet.
961 wxASSERT( m_dialog
!= NULL
);
967 void MyFrame::DlgCenteredScreen(wxCommandEvent
& WXUNUSED(event
))
969 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on screen"),
970 wxDefaultPosition
, wxSize(200, 100));
971 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
972 dlg
.CentreOnScreen();
976 void MyFrame::DlgCenteredParent(wxCommandEvent
& WXUNUSED(event
))
978 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on parent"),
979 wxDefaultPosition
, wxSize(200, 100));
980 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
981 dlg
.CentreOnParent();
985 #endif // USE_MODAL_PRESENTATION
987 #if wxUSE_STARTUP_TIPS
988 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
990 static size_t s_index
= (size_t)-1;
992 if ( s_index
== (size_t)-1 )
996 // this is completely bogus, we don't know how many lines are there
997 // in the file, but who cares, it's a demo only...
998 s_index
= rand() % 5;
1001 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(_T("tips.txt"), s_index
);
1003 bool showAtStartup
= wxShowTip(this, tipProvider
);
1005 if ( showAtStartup
)
1007 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
1008 wxOK
| wxICON_INFORMATION
, this);
1011 s_index
= tipProvider
->GetCurrentTip();
1014 #endif // wxUSE_STARTUP_TIPS
1016 #if USE_SETTINGS_DIALOG
1017 void MyFrame::OnPropertySheet(wxCommandEvent
& event
)
1019 SettingsDialog
dialog(this, event
.GetId());
1022 #endif // USE_SETTINGS_DIALOG
1024 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
1026 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1030 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
1033 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1038 #if wxUSE_PROGRESSDLG
1040 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1042 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1043 // check the performance
1044 int countrandomnumbers
= 0, count
= 0;
1045 wxTimeSpan
tsTest(0,0,0,250);
1046 wxDateTime DT2
, DT1
= wxDateTime::UNow();
1051 ++countrandomnumbers
;
1052 if ( countrandomnumbers
== 1000 )
1055 countrandomnumbers
= 0;
1057 DT2
= wxDateTime::UNow();
1058 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1059 if ( ts
.IsLongerThan( tsTest
) )
1065 const int max
= 40 * count
;
1067 static const int max
= 10;
1068 #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG
1070 wxProgressDialog
dialog(_T("Progress dialog example"),
1071 _T("An informative message"),
1077 // wxPD_AUTO_HIDE | -- try this as well
1079 wxPD_ESTIMATED_TIME
|
1080 wxPD_REMAINING_TIME
|
1085 // each skip will move progress about quarter forward
1086 for ( int i
= 0; i
<= max
; i
= wxMin(i
+(skip
?int(max
/4):1), max
+1), skip
= false )
1088 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1089 // do (almost) the same operations as we did for the performance test
1091 for ( int j
= 0; j
< 1000; j
++ )
1096 DT2
= wxDateTime::UNow();
1097 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1098 if ( ts
.IsLongerThan( tsTest
) )
1112 msg
= _T("That's all, folks!");
1114 else if ( i
> max
/ 2 )
1116 msg
= _T("Only a half left (very long message)!");
1119 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1120 if ( (i
% (max
/100)) == 0 ) // // only 100 updates, this makes it much faster
1122 cont
= dialog
.Update(i
, msg
, &skip
);
1125 cont
= dialog
.Update(i
, msg
, &skip
);
1130 if ( wxMessageBox(_T("Do you really want to cancel?"),
1131 _T("Progress dialog question"), // caption
1132 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1142 wxLogStatus(wxT("Progress dialog aborted!"));
1146 wxLogStatus(wxT("Countdown from %d finished"), max
);
1150 #endif // wxUSE_PROGRESSDLG
1154 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1156 wxWindowDisabler disableAll
;
1158 wxBusyInfo
info(_T("Working, please wait..."), this);
1160 for ( int i
= 0; i
< 18; i
++ )
1170 #endif // wxUSE_BUSYINFO
1172 #if wxUSE_FINDREPLDLG
1174 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1178 delete m_dlgReplace
;
1179 m_dlgReplace
= NULL
;
1183 m_dlgReplace
= new wxFindReplaceDialog
1187 _T("Find and replace dialog"),
1191 m_dlgReplace
->Show(true);
1195 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1204 m_dlgFind
= new wxFindReplaceDialog
1213 m_dlgFind
->Show(true);
1217 static wxString
DecodeFindDialogEventFlags(int flags
)
1220 str
<< (flags
& wxFR_DOWN
? _T("down") : _T("up")) << _T(", ")
1221 << (flags
& wxFR_WHOLEWORD
? _T("whole words only, ") : _T(""))
1222 << (flags
& wxFR_MATCHCASE
? _T("") : _T("not "))
1223 << _T("case sensitive");
1228 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
1230 wxEventType type
= event
.GetEventType();
1232 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
1234 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1235 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
1236 event
.GetFindString().c_str(),
1237 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1239 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
1240 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
1242 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1243 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? _T("all ") : wxT(""),
1244 event
.GetFindString().c_str(),
1245 event
.GetReplaceString().c_str(),
1246 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1248 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
1250 wxFindReplaceDialog
*dlg
= event
.GetDialog();
1254 if ( dlg
== m_dlgFind
)
1257 idMenu
= DIALOGS_FIND
;
1260 else if ( dlg
== m_dlgReplace
)
1262 txt
= _T("Replace");
1263 idMenu
= DIALOGS_REPLACE
;
1264 m_dlgReplace
= NULL
;
1268 txt
= _T("Unknown");
1271 wxFAIL_MSG( _T("unexpected event") );
1274 wxLogMessage(wxT("%s dialog is being closed."), txt
);
1276 if ( idMenu
!= wxID_ANY
)
1278 GetMenuBar()->Check(idMenu
, false);
1285 wxLogError(wxT("Unknown find dialog event!"));
1289 #endif // wxUSE_FINDREPLDLG
1291 // ----------------------------------------------------------------------------
1293 // ----------------------------------------------------------------------------
1295 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
1298 dc
.SetFont(wxGetApp().m_canvasFont
);
1299 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
1300 dc
.SetBackgroundMode(wxTRANSPARENT
);
1302 _T("wxWidgets common dialogs")
1303 #if !defined(__SMARTPHONE__)
1304 _T(" test application")
1309 #if USE_MODAL_PRESENTATION
1311 // ----------------------------------------------------------------------------
1313 // ----------------------------------------------------------------------------
1315 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
1316 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modeless dialog")))
1318 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
1320 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, _T("Press me"));
1321 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, _T("Should be disabled"));
1324 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
1325 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
1329 sizerTop
->SetSizeHints(this);
1330 sizerTop
->Fit(this);
1333 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
1335 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1336 wxOK
| wxICON_INFORMATION
, this);
1339 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
1341 if ( event
.CanVeto() )
1343 wxMessageBox(_T("Use the menu item to close this dialog"),
1344 _T("Modeless dialog"),
1345 wxOK
| wxICON_INFORMATION
, this);
1351 // ----------------------------------------------------------------------------
1353 // ----------------------------------------------------------------------------
1355 MyModalDialog::MyModalDialog(wxWindow
*parent
)
1356 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modal dialog")))
1358 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1360 m_btnModal
= new wxButton(this, wxID_ANY
, _T("&Modal dialog..."));
1361 m_btnModeless
= new wxButton(this, wxID_ANY
, _T("Mode&less dialog"));
1362 m_btnDelete
= new wxButton(this, wxID_ANY
, _T("&Delete button"));
1364 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _T("&Close"));
1365 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
1366 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
1367 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
1368 sizerTop
->Add(btnOk
, 0, wxALIGN_CENTER
| wxALL
, 5);
1372 sizerTop
->SetSizeHints(this);
1373 sizerTop
->Fit(this);
1375 m_btnModal
->SetFocus();
1376 m_btnModal
->SetDefault();
1379 void MyModalDialog::OnButton(wxCommandEvent
& event
)
1381 if ( event
.GetEventObject() == m_btnDelete
)
1386 m_btnDelete
->Disable();
1388 else if ( event
.GetEventObject() == m_btnModal
)
1391 wxGetTextFromUser(_T("Dummy prompt"),
1392 _T("Modal dialog called from dialog"),
1393 wxEmptyString
, this);
1395 wxMessageBox(_T("Modal dialog called from dialog"));
1396 #endif // wxUSE_TEXTDLG
1398 else if ( event
.GetEventObject() == m_btnModeless
)
1400 (new MyModelessDialog(this))->Show();
1408 #endif // USE_MODAL_PRESENTATION
1410 #if USE_SETTINGS_DIALOG
1411 // ----------------------------------------------------------------------------
1413 // ----------------------------------------------------------------------------
1415 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
1417 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
1420 SettingsDialog::SettingsDialog(wxWindow
* win
, int dialogType
)
1422 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
1427 bool useToolBook
= (dialogType
== DIALOGS_PROPERTY_SHEET_TOOLBOOK
|| dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
);
1428 int resizeBorder
= wxRESIZE_BORDER
;
1436 int sheetStyle
= wxPROPSHEET_SHRINKTOFIT
;
1437 if (dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
)
1438 sheetStyle
|= wxPROPSHEET_BUTTONTOOLBOOK
;
1440 sheetStyle
|= wxPROPSHEET_TOOLBOOK
;
1442 SetSheetStyle(sheetStyle
);
1443 SetSheetInnerBorder(0);
1444 SetSheetOuterBorder(0);
1446 // create a dummy image list with a few icons
1447 const wxSize
imageSize(32, 32);
1449 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
1451 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
1453 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
1455 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
1457 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
1462 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
1463 wxDEFAULT_DIALOG_STYLE
| (int)wxPlatform::IfNot(wxWinCE
, resizeBorder
)
1471 // If using a toolbook, also follow Mac style and don't create buttons
1473 CreateButtons(wxOK
|wxCANCEL
| (int)wxPlatform::IfNot(wxWinPocketPC
, wxHELP
)
1475 #ifndef __POCKETPC__
1481 wxBookCtrlBase
* notebook
= GetBookCtrl();
1482 notebook
->SetImageList(m_imageList
);
1484 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
1485 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
1487 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
1488 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
1493 SettingsDialog::~SettingsDialog()
1498 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
1500 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1502 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1503 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1507 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
1508 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
1509 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1510 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
1514 wxString autoSaveLabel
= _("&Auto-save every");
1515 wxString minsLabel
= _("mins");
1517 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
1518 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
1521 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
1522 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
1525 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1527 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1529 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1530 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
1534 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
1535 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
1536 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1537 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
1539 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1541 panel
->SetSizer(topSizer
);
1542 topSizer
->Fit(panel
);
1547 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
1549 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1551 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1552 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1554 //// PROJECT OR GLOBAL
1555 wxString globalOrProjectChoices
[2];
1556 globalOrProjectChoices
[0] = _("&New projects");
1557 globalOrProjectChoices
[1] = _("&This project");
1559 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
1560 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
1561 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
1563 projectOrGlobal
->SetSelection(0);
1565 //// BACKGROUND STYLE
1566 wxArrayString backgroundStyleChoices
;
1567 backgroundStyleChoices
.Add(wxT("Colour"));
1568 backgroundStyleChoices
.Add(wxT("Image"));
1569 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
1571 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
1572 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
1574 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
1576 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
1578 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1579 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
1580 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1582 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
1585 //// FONT SIZE SELECTION
1587 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
1588 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
1590 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
1591 wxSize(80, wxDefaultCoord
));
1592 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
1594 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
1597 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1598 topSizer
->AddSpacer(5);
1600 panel
->SetSizer(topSizer
);
1601 topSizer
->Fit(panel
);
1606 #endif // USE_SETTINGS_DIALOG