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::OnPropertySheetToolBook
)
202 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
204 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
207 #if USE_MODAL_PRESENTATION
209 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
210 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
213 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
214 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
215 EVT_CLOSE(MyModelessDialog::OnClose
)
218 #endif // USE_MODAL_PRESENTATION
220 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
222 // `Main program' equivalent, creating windows and returning main app frame
226 wxInitAllImageHandlers();
229 m_canvasTextColour
= wxColour(_T("BLACK"));
230 m_canvasFont
= *wxNORMAL_FONT
;
232 // Create the main frame window
233 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets dialogs example"));
236 wxMenu
*file_menu
= new wxMenu
;
238 file_menu
->Append(DIALOGS_MESSAGE_BOX
, _T("&Message box\tCtrl-M"));
241 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
243 wxMenu
*choices_menu
= new wxMenu
;
246 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, _T("&Choose colour"));
247 #endif // wxUSE_COLOURDLG
250 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, _T("Choose &font"));
251 #endif // wxUSE_FONTDLG
254 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, _T("&Single choice\tCtrl-C"));
255 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, _T("M&ultiple choice\tCtrl-U"));
256 #endif // wxUSE_CHOICEDLG
258 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
259 choices_menu
->AppendSeparator();
260 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
262 #if USE_COLOURDLG_GENERIC
263 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, _T("&Choose colour (generic)"));
264 #endif // USE_COLOURDLG_GENERIC
266 #if USE_FONTDLG_GENERIC
267 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, _T("Choose &font (generic)"));
268 #endif // USE_FONTDLG_GENERIC
270 file_menu
->Append(wxID_ANY
,_T("&Choices and selectors"),choices_menu
);
271 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
274 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
276 wxMenu
*entry_menu
= new wxMenu
;
279 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, _T("Text &entry\tCtrl-E"));
280 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, _T("&Password entry\tCtrl-P"));
281 #endif // wxUSE_TEXTDLG
284 entry_menu
->Append(DIALOGS_NUM_ENTRY
, _T("&Numeric entry\tCtrl-N"));
285 #endif // wxUSE_NUMBERDLG
287 file_menu
->Append(wxID_ANY
,_T("&Entry dialogs"),entry_menu
);
289 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
294 wxMenu
*filedlg_menu
= new wxMenu
;
295 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, _T("&Open file\tCtrl-O"));
296 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, _T("&Second open file\tCtrl-2"));
297 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, _T("Open &files\tCtrl-Q"));
298 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, _T("Sa&ve file\tCtrl-S"));
300 #if USE_FILEDLG_GENERIC
301 filedlg_menu
->AppendSeparator();
302 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, _T("&Open file (generic)"));
303 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, _T("Open &files (generic)"));
304 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, _T("Sa&ve file (generic)"));
305 #endif // USE_FILEDLG_GENERIC
307 file_menu
->Append(wxID_ANY
,_T("&File operations"),filedlg_menu
);
309 #endif // wxUSE_FILEDLG
312 wxMenu
*dir_menu
= new wxMenu
;
314 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, _T("&Choose a directory\tCtrl-D"));
315 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
316 file_menu
->Append(wxID_ANY
,_T("&Directory operations"),dir_menu
);
318 #if USE_DIRDLG_GENERIC
319 dir_menu
->AppendSeparator();
320 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, _T("&Choose a directory (generic)"));
321 #endif // USE_DIRDLG_GENERIC
323 #endif // wxUSE_DIRDLG
326 #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
328 wxMenu
*info_menu
= new wxMenu
;
330 #if wxUSE_STARTUP_TIPS
331 info_menu
->Append(DIALOGS_TIP
, _T("&Tip of the day\tCtrl-T"));
332 #endif // wxUSE_STARTUP_TIPS
334 #if wxUSE_PROGRESSDLG
335 info_menu
->Append(DIALOGS_PROGRESS
, _T("Pro&gress dialog\tCtrl-G"));
336 #endif // wxUSE_PROGRESSDLG
339 info_menu
->Append(DIALOGS_BUSYINFO
, _T("&Busy info dialog\tCtrl-B"));
340 #endif // wxUSE_BUSYINFO
343 info_menu
->Append(DIALOGS_LOG_DIALOG
, _T("&Log dialog\tCtrl-L"));
344 #endif // wxUSE_LOG_DIALOG
346 file_menu
->Append(wxID_ANY
,_T("&Informative dialogs"),info_menu
);
348 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
351 #if wxUSE_FINDREPLDLG
352 wxMenu
*find_menu
= new wxMenu
;
353 find_menu
->AppendCheckItem(DIALOGS_FIND
, _T("&Find dialog\tCtrl-F"));
354 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, _T("Find and &replace dialog\tShift-Ctrl-F"));
355 file_menu
->Append(wxID_ANY
,_T("&Searching"),find_menu
);
356 #endif // wxUSE_FINDREPLDLG
358 #if USE_MODAL_PRESENTATION
359 wxMenu
*dialogs_menu
= new wxMenu
;
360 dialogs_menu
->Append(DIALOGS_MODAL
, _T("&Modal dialog\tCtrl-W"));
361 dialogs_menu
->AppendCheckItem(DIALOGS_MODELESS
, _T("Mode&less dialog\tCtrl-Z"));
362 dialogs_menu
->AppendCheckItem(DIALOGS_CENTRE_SCREEN
, _T("Centered on &screen\tShift-Ctrl-1"));
363 dialogs_menu
->AppendCheckItem(DIALOGS_CENTRE_PARENT
, _T("Centered on &parent\tShift-Ctrl-2"));
364 file_menu
->Append(wxID_ANY
, _T("&Generic dialogs"), dialogs_menu
);
365 #endif // USE_MODAL_PRESENTATION
367 #if USE_SETTINGS_DIALOG
368 wxMenu
*sheet_menu
= new wxMenu
;
369 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET
, _T("&Standard property sheet\tShift-Ctrl-P"));
370 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, _T("&Toolbook sheet\tShift-Ctrl-T"));
371 file_menu
->Append(wxID_ANY
, _T("&Property sheets"), sheet_menu
);
372 #endif // USE_SETTINGS_DIALOG
374 file_menu
->Append(DIALOGS_REQUEST
, _T("&Request user attention\tCtrl-R"));
376 file_menu
->AppendSeparator();
377 file_menu
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"));
379 wxMenuBar
*menu_bar
= new wxMenuBar
;
380 menu_bar
->Append(file_menu
, _T("&File"));
381 frame
->SetMenuBar(menu_bar
);
383 myCanvas
= new MyCanvas(frame
);
384 myCanvas
->SetBackgroundColour(*wxWHITE
);
386 frame
->Centre(wxBOTH
);
396 // My frame constructor
397 MyFrame::MyFrame(wxWindow
*parent
,
398 const wxString
& title
)
399 : wxFrame(parent
, wxID_ANY
, title
)
403 #if USE_MODAL_PRESENTATION
404 m_dialog
= (MyModelessDialog
*)NULL
;
405 #endif // USE_MODAL_PRESENTATION
407 #if wxUSE_FINDREPLDLG
413 m_clrData
.SetChooseFull(true);
414 for (int i
= 0; i
< 16; i
++)
416 m_clrData
.SetCustomColour(
419 (unsigned char)(i
*16),
420 (unsigned char)(i
*16),
421 (unsigned char)(i
*16)
425 #endif // wxUSE_COLOURDLG
429 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
431 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
433 wxColourDialog
dialog(this, &m_clrData
);
434 dialog
.SetTitle(_T("Choose the background colour"));
435 if (dialog
.ShowModal() == wxID_OK
)
437 m_clrData
= dialog
.GetColourData();
438 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
439 myCanvas
->ClearBackground();
443 #endif // wxUSE_COLOURDLG
445 #if USE_COLOURDLG_GENERIC
446 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
448 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
450 //FIXME:TODO:This has no effect...
451 m_clrData
.SetChooseFull(true);
453 for (int i
= 0; i
< 16; i
++)
456 (unsigned char)(i
*16),
457 (unsigned char)(i
*16),
458 (unsigned char)(i
*16)
460 m_clrData
.SetCustomColour(i
, colour
);
463 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
464 if (dialog
->ShowModal() == wxID_OK
)
466 m_clrData
= dialog
->GetColourData();
467 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
468 myCanvas
->ClearBackground();
473 #endif // USE_COLOURDLG_GENERIC
476 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
479 data
.SetInitialFont(wxGetApp().m_canvasFont
);
480 data
.SetColour(wxGetApp().m_canvasTextColour
);
482 // you might also do this:
484 // wxFontDialog dialog;
485 // if ( !dialog.Create(this, data) { ... error ... }
487 wxFontDialog
dialog(this, data
);
489 if (dialog
.ShowModal() == wxID_OK
)
491 wxFontData retData
= dialog
.GetFontData();
492 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
493 wxGetApp().m_canvasTextColour
= retData
.GetColour();
496 //else: cancelled by the user, don't change the font
498 #endif // wxUSE_FONTDLG
500 #if USE_FONTDLG_GENERIC
501 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
504 data
.SetInitialFont(wxGetApp().m_canvasFont
);
505 data
.SetColour(wxGetApp().m_canvasTextColour
);
507 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, &data
);
508 if (dialog
->ShowModal() == wxID_OK
)
510 wxFontData retData
= dialog
->GetFontData();
511 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
512 wxGetApp().m_canvasTextColour
= retData
.GetColour();
517 #endif // USE_FONTDLG_GENERIC
520 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
522 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
523 // being flushed -- test it
526 wxLogMessage(wxT("This is some message - everything is ok so far."));
527 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
528 wxLogWarning(wxT("And then something went wrong!"));
530 // and if ~wxBusyCursor doesn't do it, then call it manually
534 wxLogError(wxT("Intermediary error handler decided to abort."));
535 wxLogError(wxT("The top level caller detected an unrecoverable error."));
537 wxLog::FlushActive();
539 wxLogMessage(wxT("And this is the same dialog but with only one message."));
541 #endif // wxUSE_LOG_DIALOG
543 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
545 wxMessageDialog
dialog( NULL
, _T("This is a message box\nA long, long string to test out the message box properly"),
546 _T("Message box text"), wxNO_DEFAULT
|wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
548 switch ( dialog
.ShowModal() )
551 wxLogStatus(wxT("You pressed \"Yes\""));
555 wxLogStatus(wxT("You pressed \"No\""));
559 wxLogStatus(wxT("You pressed \"Cancel\""));
563 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
568 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
570 long res
= wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
571 _T("Even two rows of text."),
572 _T("Enter a number:"), _T("Numeric input test"),
579 msg
= _T("Invalid number entered or dialog cancelled.");
584 msg
.Printf(_T("You've entered %lu"), res
);
585 icon
= wxICON_INFORMATION
;
588 wxMessageBox(msg
, _T("Numeric test result"), wxOK
| icon
, this);
590 #endif // wxUSE_NUMBERDLG
593 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
595 wxString pwd
= wxGetPasswordFromUser(_T("Enter password:"),
596 _T("Password entry dialog"),
601 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
602 _T("Got password"), wxOK
| wxICON_INFORMATION
, this);
606 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
608 wxTextEntryDialog
dialog(this,
609 _T("This is a small sample\n")
610 _T("A long, long string to test out the text entrybox"),
611 _T("Please enter a string"),
615 if (dialog
.ShowModal() == wxID_OK
)
617 wxMessageBox(dialog
.GetValue(), _T("Got string"), wxOK
| wxICON_INFORMATION
, this);
620 #endif // wxUSE_TEXTDLG
623 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
625 const wxString choices
[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
627 wxSingleChoiceDialog
dialog(this,
628 _T("This is a small sample\n")
629 _T("A single-choice convenience dialog"),
630 _T("Please select a value"),
631 WXSIZEOF(choices
), choices
);
633 dialog
.SetSelection(2);
635 if (dialog
.ShowModal() == wxID_OK
)
637 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), _T("Got string"));
642 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
644 const wxString choices
[] =
646 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
647 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
648 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
651 wxArrayInt selections
;
652 size_t count
= wxGetMultipleChoices(selections
,
653 _T("This is a small sample\n")
654 _T("A multi-choice convenience dialog"),
655 _T("Please select a value"),
656 WXSIZEOF(choices
), choices
,
661 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
662 for ( size_t n
= 0; n
< count
; n
++ )
664 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
665 (unsigned)n
, (unsigned)selections
[n
],
666 choices
[selections
[n
]].c_str());
670 //else: cancelled or nothing selected
672 #endif // wxUSE_CHOICEDLG
675 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
680 _T("Testing open file dialog"),
684 _T("C++ files (*.cpp)|*.cpp")
686 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
690 dialog
.SetDirectory(wxGetHomeDir());
691 dialog
.CentreOnParent();
693 if (dialog
.ShowModal() == wxID_OK
)
696 info
.Printf(_T("Full file name: %s\n")
699 dialog
.GetPath().c_str(),
700 dialog
.GetDirectory().c_str(),
701 dialog
.GetFilename().c_str());
702 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
707 // this shows how to take advantage of specifying a default extension in the
708 // call to wxFileSelector: it is remembered after each new call and the next
709 // one will use it by default
710 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
712 static wxString s_extDef
;
713 wxString path
= wxFileSelector(
714 _T("Select the file to load"),
715 wxEmptyString
, wxEmptyString
,
719 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
720 wxFileSelectorDefaultWildcardStr
,
721 wxFileSelectorDefaultWildcardStr
730 // it is just a sample, would use wxSplitPath in real program
731 s_extDef
= path
.AfterLast(_T('.'));
733 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
734 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
737 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
741 _T("C++ files (*.cpp)|*.cpp");
745 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
746 wxFileSelectorDefaultWildcardStr
,
747 wxFileSelectorDefaultWildcardStr
750 wxFileDialog
dialog(this, _T("Testing open multiple file dialog"),
751 wxEmptyString
, wxEmptyString
, wildcards
,
754 if (dialog
.ShowModal() == wxID_OK
)
756 wxArrayString paths
, filenames
;
758 dialog
.GetPaths(paths
);
759 dialog
.GetFilenames(filenames
);
762 size_t count
= paths
.GetCount();
763 for ( size_t n
= 0; n
< count
; n
++ )
765 s
.Printf(_T("File %d: %s (%s)\n"),
766 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
770 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
773 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
778 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
780 wxFileDialog
dialog(this,
781 _T("Testing save file dialog"),
784 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
785 wxSAVE
|wxOVERWRITE_PROMPT
);
787 dialog
.SetFilterIndex(1);
789 if (dialog
.ShowModal() == wxID_OK
)
791 wxLogMessage(_T("%s, filter %d"),
792 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
795 #endif // wxUSE_FILEDLG
797 #if USE_FILEDLG_GENERIC
798 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
800 wxGenericFileDialog dialog
803 _T("Testing open file dialog"),
806 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
809 dialog
.SetDirectory(wxGetHomeDir());
811 if (dialog
.ShowModal() == wxID_OK
)
814 info
.Printf(_T("Full file name: %s\n")
817 dialog
.GetPath().c_str(),
818 dialog
.GetDirectory().c_str(),
819 dialog
.GetFilename().c_str());
820 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
825 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
827 // On PocketPC you can disable OK-only dialogs policy using system option
828 int buttons
= wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
829 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
831 wxString wildcards
= _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
832 wxGenericFileDialog
dialog(this, _T("Testing open multiple file dialog"),
833 wxEmptyString
, wxEmptyString
, wildcards
,
836 if (dialog
.ShowModal() == wxID_OK
)
838 wxArrayString paths
, filenames
;
840 dialog
.GetPaths(paths
);
841 dialog
.GetFilenames(filenames
);
844 size_t count
= paths
.GetCount();
845 for ( size_t n
= 0; n
< count
; n
++ )
847 s
.Printf(_T("File %d: %s (%s)\n"),
848 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
852 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
855 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
859 // restore system option
860 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons
);
863 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
865 wxGenericFileDialog
dialog(this,
866 _T("Testing save file dialog"),
869 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
870 wxSAVE
|wxOVERWRITE_PROMPT
);
872 dialog
.SetFilterIndex(1);
874 if (dialog
.ShowModal() == wxID_OK
)
876 wxLogMessage(_T("%s, filter %d"),
877 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
880 #endif // USE_FILEDLG_GENERIC
883 void MyFrame::DoDirChoose(int style
)
885 // pass some initial dir to wxDirDialog
887 wxGetHomeDir(&dirHome
);
889 wxDirDialog
dialog(this, _T("Testing directory picker"), dirHome
, style
);
891 if (dialog
.ShowModal() == wxID_OK
)
893 wxLogMessage(_T("Selected path: %s"), dialog
.GetPath().c_str());
897 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
899 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_NEW_DIR_BUTTON
);
902 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
904 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_NEW_DIR_BUTTON
);
906 #endif // wxUSE_DIRDLG
908 #if USE_DIRDLG_GENERIC
909 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
911 // pass some initial dir to wxDirDialog
913 wxGetHomeDir(&dirHome
);
915 wxGenericDirDialog
dialog(this, _T("Testing generic directory picker"), dirHome
);
917 if (dialog
.ShowModal() == wxID_OK
)
919 wxMessageDialog
dialog2(this, dialog
.GetPath(), _T("Selected path"));
923 #endif // USE_DIRDLG_GENERIC
925 #if USE_MODAL_PRESENTATION
926 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
928 MyModalDialog
dlg(this);
932 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
934 bool show
= GetMenuBar()->IsChecked(event
.GetId());
940 m_dialog
= new MyModelessDialog(this);
943 m_dialog
->Show(true);
947 // If m_dialog is NULL, then possibly the system
948 // didn't report the checked menu item status correctly.
949 // It should be true just after the menu item was selected,
950 // if there was no modeless dialog yet.
952 wxASSERT( m_dialog
!= NULL
);
958 void MyFrame::DlgCenteredScreen(wxCommandEvent
& WXUNUSED(event
))
960 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on screen"),
961 wxDefaultPosition
, wxSize(200, 100));
962 new wxButton(&dlg
, wxID_OK
, _T("Close"), wxPoint(10, 10));
963 dlg
.CentreOnScreen();
967 void MyFrame::DlgCenteredParent(wxCommandEvent
& WXUNUSED(event
))
969 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on parent"),
970 wxDefaultPosition
, wxSize(200, 100));
971 new wxButton(&dlg
, wxID_OK
, _T("Close"), wxPoint(10, 10));
972 dlg
.CentreOnParent();
976 #endif // USE_MODAL_PRESENTATION
978 #if wxUSE_STARTUP_TIPS
979 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
981 static size_t s_index
= (size_t)-1;
983 if ( s_index
== (size_t)-1 )
987 // this is completely bogus, we don't know how many lines are there
988 // in the file, but who cares, it's a demo only...
989 s_index
= rand() % 5;
992 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(_T("tips.txt"), s_index
);
994 bool showAtStartup
= wxShowTip(this, tipProvider
);
998 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
999 wxOK
| wxICON_INFORMATION
, this);
1002 s_index
= tipProvider
->GetCurrentTip();
1005 #endif // wxUSE_STARTUP_TIPS
1007 #if USE_SETTINGS_DIALOG
1008 void MyFrame::OnPropertySheet(wxCommandEvent
& WXUNUSED(event
))
1010 SettingsDialog
dialog(this);
1014 void MyFrame::OnPropertySheetToolBook(wxCommandEvent
& WXUNUSED(event
))
1016 SettingsDialog
dialog(this, true);
1019 #endif // USE_SETTINGS_DIALOG
1021 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
1023 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1027 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
1030 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1035 #if wxUSE_PROGRESSDLG
1037 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1039 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1040 // check the performance
1041 int countrandomnumbers
= 0, count
= 0;
1042 wxTimeSpan
tsTest(0,0,0,250);
1043 wxDateTime DT2
, DT1
= wxDateTime::UNow();
1048 ++countrandomnumbers
;
1049 if ( countrandomnumbers
== 1000 )
1052 countrandomnumbers
= 0;
1054 DT2
= wxDateTime::UNow();
1055 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1056 if ( ts
.IsLongerThan( tsTest
) )
1062 const int max
= 40 * count
;
1064 static const int max
= 10;
1065 #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG
1067 wxProgressDialog
dialog(_T("Progress dialog example"),
1068 _T("An informative message"),
1074 // wxPD_AUTO_HIDE | -- try this as well
1076 wxPD_ESTIMATED_TIME
|
1077 wxPD_REMAINING_TIME
|
1082 // each skip will move progress about quarter forward
1083 for ( int i
= 0; i
<= max
; i
= wxMin(i
+(skip
?int(max
/4):1), max
+1), skip
= false )
1085 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1086 // do (almost) the same operations as we did for the performance test
1088 for ( int j
= 0; j
< 1000; j
++ )
1093 DT2
= wxDateTime::UNow();
1094 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1095 if ( ts
.IsLongerThan( tsTest
) )
1109 msg
= _T("That's all, folks!");
1111 else if ( i
> max
/ 2 )
1113 msg
= _T("Only a half left (very long message)!");
1116 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1117 if ( (i
% (max
/100)) == 0 ) // // only 100 updates, this makes it much faster
1119 cont
= dialog
.Update(i
, msg
, &skip
);
1122 cont
= dialog
.Update(i
, msg
, &skip
);
1127 if ( wxMessageBox(_T("Do you really want to cancel?"),
1128 _T("Progress dialog question"), // caption
1129 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1139 wxLogStatus(wxT("Progress dialog aborted!"));
1143 wxLogStatus(wxT("Countdown from %d finished"), max
);
1147 #endif // wxUSE_PROGRESSDLG
1151 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1153 wxWindowDisabler disableAll
;
1155 wxBusyInfo
info(_T("Working, please wait..."), this);
1157 for ( int i
= 0; i
< 18; i
++ )
1167 #endif // wxUSE_BUSYINFO
1169 #if wxUSE_FINDREPLDLG
1171 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1175 delete m_dlgReplace
;
1176 m_dlgReplace
= NULL
;
1180 m_dlgReplace
= new wxFindReplaceDialog
1184 _T("Find and replace dialog"),
1188 m_dlgReplace
->Show(true);
1192 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1201 m_dlgFind
= new wxFindReplaceDialog
1210 m_dlgFind
->Show(true);
1214 static wxString
DecodeFindDialogEventFlags(int flags
)
1217 str
<< (flags
& wxFR_DOWN
? _T("down") : _T("up")) << _T(", ")
1218 << (flags
& wxFR_WHOLEWORD
? _T("whole words only, ") : _T(""))
1219 << (flags
& wxFR_MATCHCASE
? _T("") : _T("not "))
1220 << _T("case sensitive");
1225 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
1227 wxEventType type
= event
.GetEventType();
1229 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
1231 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1232 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
1233 event
.GetFindString().c_str(),
1234 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1236 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
1237 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
1239 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1240 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? _T("all ") : wxT(""),
1241 event
.GetFindString().c_str(),
1242 event
.GetReplaceString().c_str(),
1243 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1245 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
1247 wxFindReplaceDialog
*dlg
= event
.GetDialog();
1251 if ( dlg
== m_dlgFind
)
1254 idMenu
= DIALOGS_FIND
;
1257 else if ( dlg
== m_dlgReplace
)
1259 txt
= _T("Replace");
1260 idMenu
= DIALOGS_REPLACE
;
1261 m_dlgReplace
= NULL
;
1265 txt
= _T("Unknown");
1268 wxFAIL_MSG( _T("unexpected event") );
1271 wxLogMessage(wxT("%s dialog is being closed."), txt
);
1273 if ( idMenu
!= wxID_ANY
)
1275 GetMenuBar()->Check(idMenu
, false);
1282 wxLogError(wxT("Unknown find dialog event!"));
1286 #endif // wxUSE_FINDREPLDLG
1288 // ----------------------------------------------------------------------------
1290 // ----------------------------------------------------------------------------
1292 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
1295 dc
.SetFont(wxGetApp().m_canvasFont
);
1296 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
1297 dc
.SetBackgroundMode(wxTRANSPARENT
);
1299 _T("wxWidgets common dialogs")
1300 #if !defined(__SMARTPHONE__)
1301 _T(" test application")
1306 #if USE_MODAL_PRESENTATION
1308 // ----------------------------------------------------------------------------
1310 // ----------------------------------------------------------------------------
1312 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
1313 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modeless dialog")))
1315 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
1317 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, _T("Press me"));
1318 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, _T("Should be disabled"));
1321 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
1322 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
1326 sizerTop
->SetSizeHints(this);
1327 sizerTop
->Fit(this);
1330 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
1332 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1333 wxOK
| wxICON_INFORMATION
, this);
1336 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
1338 if ( event
.CanVeto() )
1340 wxMessageBox(_T("Use the menu item to close this dialog"),
1341 _T("Modeless dialog"),
1342 wxOK
| wxICON_INFORMATION
, this);
1348 // ----------------------------------------------------------------------------
1350 // ----------------------------------------------------------------------------
1352 MyModalDialog::MyModalDialog(wxWindow
*parent
)
1353 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modal dialog")))
1355 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1357 m_btnModal
= new wxButton(this, wxID_ANY
, _T("&Modal dialog..."));
1358 m_btnModeless
= new wxButton(this, wxID_ANY
, _T("Mode&less dialog"));
1359 m_btnDelete
= new wxButton(this, wxID_ANY
, _T("&Delete button"));
1361 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _T("&Close"));
1362 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
1363 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
1364 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
1365 sizerTop
->Add(btnOk
, 0, wxALIGN_CENTER
| wxALL
, 5);
1369 sizerTop
->SetSizeHints(this);
1370 sizerTop
->Fit(this);
1372 m_btnModal
->SetFocus();
1373 m_btnModal
->SetDefault();
1376 void MyModalDialog::OnButton(wxCommandEvent
& event
)
1378 if ( event
.GetEventObject() == m_btnDelete
)
1383 m_btnDelete
->Disable();
1385 else if ( event
.GetEventObject() == m_btnModal
)
1388 wxGetTextFromUser(_T("Dummy prompt"),
1389 _T("Modal dialog called from dialog"),
1390 wxEmptyString
, this);
1392 wxMessageBox(_T("Modal dialog called from dialog"));
1393 #endif // wxUSE_TEXTDLG
1395 else if ( event
.GetEventObject() == m_btnModeless
)
1397 (new MyModelessDialog(this))->Show();
1405 #endif // USE_MODAL_PRESENTATION
1407 #if USE_SETTINGS_DIALOG
1408 // ----------------------------------------------------------------------------
1410 // ----------------------------------------------------------------------------
1412 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
1414 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
1417 SettingsDialog::SettingsDialog(wxWindow
* win
, bool useToolBook
)
1419 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
1428 SetSheetStyle(wxPROPSHEET_TOOLBOOK
|wxPROPSHEET_SHRINKTOFIT
);
1430 // create a dummy image list with a few icons
1431 const wxSize
imageSize(32, 32);
1433 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
1435 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
1437 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
1439 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
1441 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
1446 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
1447 wxDEFAULT_DIALOG_STYLE
1453 // If using a toolbook, also follow Mac style and don't create buttons
1455 CreateButtons(wxOK
|wxCANCEL
1456 #ifndef __POCKETPC__
1461 wxBookCtrlBase
* notebook
= GetBookCtrl();
1462 notebook
->SetImageList(m_imageList
);
1464 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
1465 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
1467 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
1468 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
1473 SettingsDialog::~SettingsDialog()
1478 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
1480 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1482 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1483 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1487 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
1488 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
1489 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1490 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
1494 wxString autoSaveLabel
= _("&Auto-save every");
1495 wxString minsLabel
= _("mins");
1497 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
1498 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
1501 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
1502 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
1505 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1507 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1509 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1510 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
1514 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
1515 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
1516 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1517 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
1519 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1521 panel
->SetSizer(topSizer
);
1522 topSizer
->Fit(panel
);
1527 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
1529 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1531 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1532 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1534 //// PROJECT OR GLOBAL
1535 wxString globalOrProjectChoices
[2];
1536 globalOrProjectChoices
[0] = _("&New projects");
1537 globalOrProjectChoices
[1] = _("&This project");
1539 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
1540 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
1541 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
1543 projectOrGlobal
->SetSelection(0);
1545 //// BACKGROUND STYLE
1546 wxArrayString backgroundStyleChoices
;
1547 backgroundStyleChoices
.Add(wxT("Colour"));
1548 backgroundStyleChoices
.Add(wxT("Image"));
1549 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
1551 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
1552 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
1554 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
1556 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
1558 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1559 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
1560 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1562 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
1565 //// FONT SIZE SELECTION
1567 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
1568 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
1570 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
1571 wxSize(80, wxDefaultCoord
));
1572 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
1574 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
1577 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1578 topSizer
->AddSpacer(5);
1580 panel
->SetSizer(topSizer
);
1581 topSizer
->Fit(panel
);
1586 #endif // USE_SETTINGS_DIALOG