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"
31 #include "wx/colordlg.h"
32 #endif // wxUSE_COLOURDLG
35 #include "wx/choicdlg.h"
36 #endif // wxUSE_CHOICEDLG
38 #if wxUSE_STARTUP_TIPS
39 #include "wx/tipdlg.h"
40 #endif // wxUSE_STARTUP_TIPS
43 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
44 #include "wx/datetime.h" // wxDateTime
47 #include "wx/progdlg.h"
48 #endif // wxUSE_PROGRESSDLG
51 #include "wx/busyinfo.h"
52 #endif // wxUSE_BUSYINFO
55 #include "wx/numdlg.h"
56 #endif // wxUSE_NUMBERDLG
59 #include "wx/filedlg.h"
60 #endif // wxUSE_FILEDLG
63 #include "wx/dirdlg.h"
64 #endif // wxUSE_DIRDLG
67 #include "wx/fontdlg.h"
68 #endif // wxUSE_FONTDLG
71 #include "wx/fdrepdlg.h"
72 #endif // wxUSE_FINDREPLDLG
75 #include "wx/spinctrl.h"
78 #include "wx/propdlg.h"
82 #if USE_COLOURDLG_GENERIC
83 #include "wx/generic/colrdlgg.h"
84 #endif // USE_COLOURDLG_GENERIC
86 #if USE_DIRDLG_GENERIC
87 #include "wx/generic/dirdlgg.h"
88 #endif // USE_DIRDLG_GENERIC
90 #if USE_FILEDLG_GENERIC
91 #include "wx/generic/filedlgg.h"
92 #endif // USE_FILEDLG_GENERIC
94 #if USE_FONTDLG_GENERIC
95 #include "wx/generic/fontdlgg.h"
96 #endif // USE_FONTDLG_GENERIC
100 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
101 EVT_PAINT(MyCanvas::OnPaint
)
106 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
107 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
110 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
111 #endif // wxUSE_COLOURDLG
114 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
115 #endif // wxUSE_FONTDLG
118 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
119 #endif // wxUSE_LOG_DIALOG
122 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
123 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
124 #endif // wxUSE_TEXTDLG
127 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
128 #endif // wxUSE_NUMBERDLG
131 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
132 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
133 #endif // wxUSE_CHOICEDLG
136 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
137 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
138 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
139 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
140 #endif // wxUSE_FILEDLG
142 #if USE_FILEDLG_GENERIC
143 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
144 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
145 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
146 #endif // USE_FILEDLG_GENERIC
149 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
150 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
151 #endif // wxUSE_DIRDLG
153 #if USE_MODAL_PRESENTATION
154 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
155 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
158 #if wxUSE_STARTUP_TIPS
159 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
160 #endif // wxUSE_STARTUP_TIPS
162 #if USE_FONTDLG_GENERIC
163 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
164 #endif // USE_FONTDLG_GENERIC
166 #if USE_DIRDLG_GENERIC
167 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
168 #endif // wxMSW || wxMAC
170 #if USE_COLOURDLG_GENERIC
171 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
172 #endif // USE_COLOURDLG_GENERIC
174 #if wxUSE_PROGRESSDLG
175 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
176 #endif // wxUSE_PROGRESSDLG
179 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
180 #endif // wxUSE_BUSYINFO
182 #if wxUSE_FINDREPLDLG
183 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
184 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
186 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
187 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
188 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
189 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
190 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
191 #endif // wxUSE_FINDREPLDLG
193 #if USE_SETTINGS_DIALOG
194 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
195 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheetToolBook
)
198 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
200 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
203 #if USE_MODAL_PRESENTATION
205 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
206 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
209 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
210 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
211 EVT_CLOSE(MyModelessDialog::OnClose
)
214 #endif // USE_MODAL_PRESENTATION
216 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
218 // `Main program' equivalent, creating windows and returning main app frame
222 wxInitAllImageHandlers();
225 m_canvasTextColour
= wxColour(_T("BLACK"));
226 m_canvasFont
= *wxNORMAL_FONT
;
228 // Create the main frame window
229 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets dialogs example"));
232 wxMenu
*file_menu
= new wxMenu
;
234 file_menu
->Append(DIALOGS_MESSAGE_BOX
, _T("&Message box\tCtrl-M"));
237 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
239 wxMenu
*choices_menu
= new wxMenu
;
242 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, _T("&Choose colour"));
243 #endif // wxUSE_COLOURDLG
246 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, _T("Choose &font"));
247 #endif // wxUSE_FONTDLG
250 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, _T("&Single choice\tCtrl-C"));
251 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, _T("M&ultiple choice\tCtrl-U"));
252 #endif // wxUSE_CHOICEDLG
254 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
255 choices_menu
->AppendSeparator();
256 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
258 #if USE_COLOURDLG_GENERIC
259 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, _T("&Choose colour (generic)"));
260 #endif // USE_COLOURDLG_GENERIC
262 #if USE_FONTDLG_GENERIC
263 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, _T("Choose &font (generic)"));
264 #endif // USE_FONTDLG_GENERIC
266 file_menu
->Append(wxID_ANY
,_T("&Choices and selectors"),choices_menu
);
267 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
270 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
272 wxMenu
*entry_menu
= new wxMenu
;
275 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, _T("Text &entry\tCtrl-E"));
276 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, _T("&Password entry\tCtrl-P"));
277 #endif // wxUSE_TEXTDLG
280 entry_menu
->Append(DIALOGS_NUM_ENTRY
, _T("&Numeric entry\tCtrl-N"));
281 #endif // wxUSE_NUMBERDLG
283 file_menu
->Append(wxID_ANY
,_T("&Entry dialogs"),entry_menu
);
285 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
290 wxMenu
*filedlg_menu
= new wxMenu
;
291 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, _T("&Open file\tCtrl-O"));
292 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, _T("&Second open file\tCtrl-2"));
293 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, _T("Open &files\tCtrl-Q"));
294 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, _T("Sa&ve file\tCtrl-S"));
296 #if USE_FILEDLG_GENERIC
297 filedlg_menu
->AppendSeparator();
298 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, _T("&Open file (generic)"));
299 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, _T("Open &files (generic)"));
300 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, _T("Sa&ve file (generic)"));
301 #endif // USE_FILEDLG_GENERIC
303 file_menu
->Append(wxID_ANY
,_T("&File operations"),filedlg_menu
);
305 #endif // wxUSE_FILEDLG
308 wxMenu
*dir_menu
= new wxMenu
;
310 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, _T("&Choose a directory\tCtrl-D"));
311 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
312 file_menu
->Append(wxID_ANY
,_T("&Directory operations"),dir_menu
);
314 #if USE_DIRDLG_GENERIC
315 dir_menu
->AppendSeparator();
316 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, _T("&Choose a directory (generic)"));
317 #endif // USE_DIRDLG_GENERIC
319 #endif // wxUSE_DIRDLG
322 #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
324 wxMenu
*info_menu
= new wxMenu
;
326 #if wxUSE_STARTUP_TIPS
327 info_menu
->Append(DIALOGS_TIP
, _T("&Tip of the day\tCtrl-T"));
328 #endif // wxUSE_STARTUP_TIPS
330 #if wxUSE_PROGRESSDLG
331 info_menu
->Append(DIALOGS_PROGRESS
, _T("Pro&gress dialog\tCtrl-G"));
332 #endif // wxUSE_PROGRESSDLG
335 info_menu
->Append(DIALOGS_BUSYINFO
, _T("&Busy info dialog\tCtrl-B"));
336 #endif // wxUSE_BUSYINFO
339 info_menu
->Append(DIALOGS_LOG_DIALOG
, _T("&Log dialog\tCtrl-L"));
340 #endif // wxUSE_LOG_DIALOG
342 file_menu
->Append(wxID_ANY
,_T("&Informative dialogs"),info_menu
);
344 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
347 #if wxUSE_FINDREPLDLG
348 wxMenu
*find_menu
= new wxMenu
;
349 find_menu
->AppendCheckItem(DIALOGS_FIND
, _T("&Find dialog\tCtrl-F"));
350 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, _T("Find and &replace dialog\tShift-Ctrl-F"));
351 file_menu
->Append(wxID_ANY
,_T("&Searching"),find_menu
);
352 #endif // wxUSE_FINDREPLDLG
354 #if USE_MODAL_PRESENTATION
355 wxMenu
*modal_menu
= new wxMenu
;
356 modal_menu
->Append(DIALOGS_MODAL
, _T("Mo&dal dialog\tCtrl-W"));
357 modal_menu
->AppendCheckItem(DIALOGS_MODELESS
, _T("Modeless &dialog\tCtrl-Z"));
358 file_menu
->Append(wxID_ANY
,_T("&Modal/Modeless"),modal_menu
);
359 #endif // USE_MODAL_PRESENTATION
361 #if USE_SETTINGS_DIALOG
362 file_menu
->Append(DIALOGS_PROPERTY_SHEET
, _T("&Property Sheet Dialog\tCtrl-P"));
363 file_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, _T("Property Sheet Dialog using &ToolBook"));
366 file_menu
->Append(DIALOGS_REQUEST
, _T("&Request user attention\tCtrl-R"));
368 file_menu
->AppendSeparator();
369 file_menu
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"));
371 wxMenuBar
*menu_bar
= new wxMenuBar
;
372 menu_bar
->Append(file_menu
, _T("&File"));
373 frame
->SetMenuBar(menu_bar
);
375 myCanvas
= new MyCanvas(frame
);
376 myCanvas
->SetBackgroundColour(*wxWHITE
);
378 frame
->Centre(wxBOTH
);
388 // My frame constructor
389 MyFrame::MyFrame(wxWindow
*parent
,
390 const wxString
& title
)
391 : wxFrame(parent
, wxID_ANY
, title
)
395 #if USE_MODAL_PRESENTATION
396 m_dialog
= (MyModelessDialog
*)NULL
;
397 #endif // USE_MODAL_PRESENTATION
399 #if wxUSE_FINDREPLDLG
405 m_clrData
.SetChooseFull(true);
406 for (int i
= 0; i
< 16; i
++)
408 m_clrData
.SetCustomColour(
411 (unsigned char)(i
*16),
412 (unsigned char)(i
*16),
413 (unsigned char)(i
*16)
417 #endif // wxUSE_COLOURDLG
421 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
423 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
425 wxColourDialog
dialog(this, &m_clrData
);
426 dialog
.SetTitle(_T("Choose the background colour"));
427 if (dialog
.ShowModal() == wxID_OK
)
429 m_clrData
= dialog
.GetColourData();
430 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
431 myCanvas
->ClearBackground();
435 #endif // wxUSE_COLOURDLG
437 #if USE_COLOURDLG_GENERIC
438 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
440 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
442 //FIXME:TODO:This has no effect...
443 m_clrData
.SetChooseFull(true);
445 for (int i
= 0; i
< 16; i
++)
448 (unsigned char)(i
*16),
449 (unsigned char)(i
*16),
450 (unsigned char)(i
*16)
452 m_clrData
.SetCustomColour(i
, colour
);
455 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
456 if (dialog
->ShowModal() == wxID_OK
)
458 m_clrData
= dialog
->GetColourData();
459 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
460 myCanvas
->ClearBackground();
465 #endif // USE_COLOURDLG_GENERIC
468 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
471 data
.SetInitialFont(wxGetApp().m_canvasFont
);
472 data
.SetColour(wxGetApp().m_canvasTextColour
);
474 // you might also do this:
476 // wxFontDialog dialog;
477 // if ( !dialog.Create(this, data) { ... error ... }
479 wxFontDialog
dialog(this, data
);
481 if (dialog
.ShowModal() == wxID_OK
)
483 wxFontData retData
= dialog
.GetFontData();
484 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
485 wxGetApp().m_canvasTextColour
= retData
.GetColour();
488 //else: cancelled by the user, don't change the font
490 #endif // wxUSE_FONTDLG
492 #if USE_FONTDLG_GENERIC
493 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
496 data
.SetInitialFont(wxGetApp().m_canvasFont
);
497 data
.SetColour(wxGetApp().m_canvasTextColour
);
499 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, &data
);
500 if (dialog
->ShowModal() == wxID_OK
)
502 wxFontData retData
= dialog
->GetFontData();
503 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
504 wxGetApp().m_canvasTextColour
= retData
.GetColour();
509 #endif // USE_FONTDLG_GENERIC
512 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
514 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
515 // being flushed -- test it
518 wxLogMessage(wxT("This is some message - everything is ok so far."));
519 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
520 wxLogWarning(wxT("And then something went wrong!"));
522 // and if ~wxBusyCursor doesn't do it, then call it manually
526 wxLogError(wxT("Intermediary error handler decided to abort."));
527 wxLogError(wxT("The top level caller detected an unrecoverable error."));
529 wxLog::FlushActive();
531 wxLogMessage(wxT("And this is the same dialog but with only one message."));
533 #endif // wxUSE_LOG_DIALOG
535 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
537 wxMessageDialog
dialog( NULL
, _T("This is a message box\nA long, long string to test out the message box properly"),
538 _T("Message box text"), wxNO_DEFAULT
|wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
540 switch ( dialog
.ShowModal() )
543 wxLogStatus(wxT("You pressed \"Yes\""));
547 wxLogStatus(wxT("You pressed \"No\""));
551 wxLogStatus(wxT("You pressed \"Cancel\""));
555 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
560 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
562 long res
= wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
563 _T("Even two rows of text."),
564 _T("Enter a number:"), _T("Numeric input test"),
571 msg
= _T("Invalid number entered or dialog cancelled.");
576 msg
.Printf(_T("You've entered %lu"), res
);
577 icon
= wxICON_INFORMATION
;
580 wxMessageBox(msg
, _T("Numeric test result"), wxOK
| icon
, this);
582 #endif // wxUSE_NUMBERDLG
585 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
587 wxString pwd
= wxGetPasswordFromUser(_T("Enter password:"),
588 _T("Password entry dialog"),
593 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
594 _T("Got password"), wxOK
| wxICON_INFORMATION
, this);
598 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
600 wxTextEntryDialog
dialog(this,
601 _T("This is a small sample\n")
602 _T("A long, long string to test out the text entrybox"),
603 _T("Please enter a string"),
607 if (dialog
.ShowModal() == wxID_OK
)
609 wxMessageBox(dialog
.GetValue(), _T("Got string"), wxOK
| wxICON_INFORMATION
, this);
612 #endif // wxUSE_TEXTDLG
615 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
617 const wxString choices
[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
619 wxSingleChoiceDialog
dialog(this,
620 _T("This is a small sample\n")
621 _T("A single-choice convenience dialog"),
622 _T("Please select a value"),
623 WXSIZEOF(choices
), choices
);
625 dialog
.SetSelection(2);
627 if (dialog
.ShowModal() == wxID_OK
)
629 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), _T("Got string"));
634 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
636 const wxString choices
[] =
638 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
639 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
640 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
643 wxArrayInt selections
;
644 size_t count
= wxGetMultipleChoices(selections
,
645 _T("This is a small sample\n")
646 _T("A multi-choice convenience dialog"),
647 _T("Please select a value"),
648 WXSIZEOF(choices
), choices
,
653 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
654 for ( size_t n
= 0; n
< count
; n
++ )
656 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
657 (unsigned)n
, (unsigned)selections
[n
],
658 choices
[selections
[n
]].c_str());
662 //else: cancelled or nothing selected
664 #endif // wxUSE_CHOICEDLG
667 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
672 _T("Testing open file dialog"),
676 _T("C++ files (*.cpp)|*.cpp")
678 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
682 dialog
.SetDirectory(wxGetHomeDir());
683 dialog
.CentreOnParent();
685 if (dialog
.ShowModal() == wxID_OK
)
688 info
.Printf(_T("Full file name: %s\n")
691 dialog
.GetPath().c_str(),
692 dialog
.GetDirectory().c_str(),
693 dialog
.GetFilename().c_str());
694 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
699 // this shows how to take advantage of specifying a default extension in the
700 // call to wxFileSelector: it is remembered after each new call and the next
701 // one will use it by default
702 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
704 static wxString s_extDef
;
705 wxString path
= wxFileSelector(
706 _T("Select the file to load"),
707 wxEmptyString
, wxEmptyString
,
711 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
712 wxFileSelectorDefaultWildcardStr
,
713 wxFileSelectorDefaultWildcardStr
722 // it is just a sample, would use wxSplitPath in real program
723 s_extDef
= path
.AfterLast(_T('.'));
725 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
726 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
729 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
733 _T("C++ files (*.cpp)|*.cpp");
737 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
738 wxFileSelectorDefaultWildcardStr
,
739 wxFileSelectorDefaultWildcardStr
742 wxFileDialog
dialog(this, _T("Testing open multiple file dialog"),
743 wxEmptyString
, wxEmptyString
, wildcards
,
746 if (dialog
.ShowModal() == wxID_OK
)
748 wxArrayString paths
, filenames
;
750 dialog
.GetPaths(paths
);
751 dialog
.GetFilenames(filenames
);
754 size_t count
= paths
.GetCount();
755 for ( size_t n
= 0; n
< count
; n
++ )
757 s
.Printf(_T("File %d: %s (%s)\n"),
758 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
762 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
765 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
770 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
772 wxFileDialog
dialog(this,
773 _T("Testing save file dialog"),
776 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
777 wxSAVE
|wxOVERWRITE_PROMPT
);
779 dialog
.SetFilterIndex(1);
781 if (dialog
.ShowModal() == wxID_OK
)
783 wxLogMessage(_T("%s, filter %d"),
784 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
787 #endif // wxUSE_FILEDLG
789 #if USE_FILEDLG_GENERIC
790 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
792 wxGenericFileDialog dialog
795 _T("Testing open file dialog"),
798 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
801 dialog
.SetDirectory(wxGetHomeDir());
803 if (dialog
.ShowModal() == wxID_OK
)
806 info
.Printf(_T("Full file name: %s\n")
809 dialog
.GetPath().c_str(),
810 dialog
.GetDirectory().c_str(),
811 dialog
.GetFilename().c_str());
812 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
817 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
819 wxString wildcards
= _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
820 wxGenericFileDialog
dialog(this, _T("Testing open multiple file dialog"),
821 wxEmptyString
, wxEmptyString
, wildcards
,
824 if (dialog
.ShowModal() == wxID_OK
)
826 wxArrayString paths
, filenames
;
828 dialog
.GetPaths(paths
);
829 dialog
.GetFilenames(filenames
);
832 size_t count
= paths
.GetCount();
833 for ( size_t n
= 0; n
< count
; n
++ )
835 s
.Printf(_T("File %d: %s (%s)\n"),
836 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
840 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
843 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
848 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
850 wxGenericFileDialog
dialog(this,
851 _T("Testing save file dialog"),
854 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
855 wxSAVE
|wxOVERWRITE_PROMPT
);
857 dialog
.SetFilterIndex(1);
859 if (dialog
.ShowModal() == wxID_OK
)
861 wxLogMessage(_T("%s, filter %d"),
862 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
865 #endif // USE_FILEDLG_GENERIC
868 void MyFrame::DoDirChoose(int style
)
870 // pass some initial dir to wxDirDialog
872 wxGetHomeDir(&dirHome
);
874 wxDirDialog
dialog(this, _T("Testing directory picker"), dirHome
, style
);
876 if (dialog
.ShowModal() == wxID_OK
)
878 wxLogMessage(_T("Selected path: %s"), dialog
.GetPath().c_str());
882 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
884 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_NEW_DIR_BUTTON
);
887 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
889 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_NEW_DIR_BUTTON
);
891 #endif // wxUSE_DIRDLG
893 #if USE_DIRDLG_GENERIC
894 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
896 // pass some initial dir to wxDirDialog
898 wxGetHomeDir(&dirHome
);
900 wxGenericDirDialog
dialog(this, _T("Testing generic directory picker"), dirHome
);
902 if (dialog
.ShowModal() == wxID_OK
)
904 wxMessageDialog
dialog2(this, dialog
.GetPath(), _T("Selected path"));
908 #endif // USE_DIRDLG_GENERIC
910 #if USE_MODAL_PRESENTATION
911 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
913 MyModalDialog
dlg(this);
917 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
919 bool show
= GetMenuBar()->IsChecked(event
.GetId());
925 m_dialog
= new MyModelessDialog(this);
928 m_dialog
->Show(true);
932 // If m_dialog is NULL, then possibly the system
933 // didn't report the checked menu item status correctly.
934 // It should be true just after the menu item was selected,
935 // if there was no modeless dialog yet.
937 wxASSERT( m_dialog
!= NULL
);
942 #endif // USE_MODAL_PRESENTATION
944 #if wxUSE_STARTUP_TIPS
945 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
947 static size_t s_index
= (size_t)-1;
949 if ( s_index
== (size_t)-1 )
953 // this is completely bogus, we don't know how many lines are there
954 // in the file, but who cares, it's a demo only...
955 s_index
= rand() % 5;
958 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(_T("tips.txt"), s_index
);
960 bool showAtStartup
= wxShowTip(this, tipProvider
);
964 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
965 wxOK
| wxICON_INFORMATION
, this);
968 s_index
= tipProvider
->GetCurrentTip();
971 #endif // wxUSE_STARTUP_TIPS
973 #if USE_SETTINGS_DIALOG
974 void MyFrame::OnPropertySheet(wxCommandEvent
& WXUNUSED(event
))
976 SettingsDialog
dialog(this);
980 void MyFrame::OnPropertySheetToolBook(wxCommandEvent
& WXUNUSED(event
))
982 SettingsDialog
dialog(this, true);
985 #endif // USE_SETTINGS_DIALOG
987 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
989 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
993 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
996 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1001 #if wxUSE_PROGRESSDLG
1003 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1005 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1006 // check the performance
1007 int countrandomnumbers
= 0, count
= 0;
1008 wxTimeSpan
tsTest(0,0,0,250);
1009 wxDateTime DT2
, DT1
= wxDateTime::UNow();
1014 ++countrandomnumbers
;
1015 if ( countrandomnumbers
== 1000 )
1018 countrandomnumbers
= 0;
1020 DT2
= wxDateTime::UNow();
1021 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1022 if ( ts
.IsLongerThan( tsTest
) )
1028 const int max
= 40 * count
;
1030 static const int max
= 10;
1031 #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG
1033 wxProgressDialog
dialog(_T("Progress dialog example"),
1034 _T("An informative message"),
1040 // wxPD_AUTO_HIDE | -- try this as well
1042 wxPD_ESTIMATED_TIME
|
1043 wxPD_REMAINING_TIME
|
1048 // each skip will move progress about quarter forward
1049 for ( int i
= 0; i
<= max
; i
= wxMin(i
+(skip
?int(max
/4):1), max
+1), skip
= false )
1051 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1052 // do (almost) the same operations as we did for the performance test
1054 for ( int j
= 0; j
< 1000; j
++ )
1059 DT2
= wxDateTime::UNow();
1060 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1061 if ( ts
.IsLongerThan( tsTest
) )
1075 msg
= _T("That's all, folks!");
1077 else if ( i
> max
/ 2 )
1079 msg
= _T("Only a half left (very long message)!");
1082 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1083 if ( (i
% (max
/100)) == 0 ) // // only 100 updates, this makes it much faster
1085 cont
= dialog
.Update(i
, msg
, &skip
);
1088 cont
= dialog
.Update(i
, msg
, &skip
);
1093 if ( wxMessageBox(_T("Do you really want to cancel?"),
1094 _T("Progress dialog question"), // caption
1095 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1105 wxLogStatus(wxT("Progress dialog aborted!"));
1109 wxLogStatus(wxT("Countdown from %d finished"), max
);
1113 #endif // wxUSE_PROGRESSDLG
1117 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1119 wxWindowDisabler disableAll
;
1121 wxBusyInfo
info(_T("Working, please wait..."), this);
1123 for ( int i
= 0; i
< 18; i
++ )
1133 #endif // wxUSE_BUSYINFO
1135 #if wxUSE_FINDREPLDLG
1137 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1141 delete m_dlgReplace
;
1142 m_dlgReplace
= NULL
;
1146 m_dlgReplace
= new wxFindReplaceDialog
1150 _T("Find and replace dialog"),
1154 m_dlgReplace
->Show(true);
1158 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1167 m_dlgFind
= new wxFindReplaceDialog
1176 m_dlgFind
->Show(true);
1180 static wxString
DecodeFindDialogEventFlags(int flags
)
1183 str
<< (flags
& wxFR_DOWN
? _T("down") : _T("up")) << _T(", ")
1184 << (flags
& wxFR_WHOLEWORD
? _T("whole words only, ") : _T(""))
1185 << (flags
& wxFR_MATCHCASE
? _T("") : _T("not "))
1186 << _T("case sensitive");
1191 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
1193 wxEventType type
= event
.GetEventType();
1195 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
1197 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1198 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
1199 event
.GetFindString().c_str(),
1200 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1202 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
1203 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
1205 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1206 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? _T("all ") : wxT(""),
1207 event
.GetFindString().c_str(),
1208 event
.GetReplaceString().c_str(),
1209 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1211 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
1213 wxFindReplaceDialog
*dlg
= event
.GetDialog();
1217 if ( dlg
== m_dlgFind
)
1220 idMenu
= DIALOGS_FIND
;
1223 else if ( dlg
== m_dlgReplace
)
1225 txt
= _T("Replace");
1226 idMenu
= DIALOGS_REPLACE
;
1227 m_dlgReplace
= NULL
;
1231 txt
= _T("Unknown");
1234 wxFAIL_MSG( _T("unexpected event") );
1237 wxLogMessage(wxT("%s dialog is being closed."), txt
);
1239 if ( idMenu
!= wxID_ANY
)
1241 GetMenuBar()->Check(idMenu
, false);
1248 wxLogError(wxT("Unknown find dialog event!"));
1252 #endif // wxUSE_FINDREPLDLG
1254 // ----------------------------------------------------------------------------
1256 // ----------------------------------------------------------------------------
1258 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
1261 dc
.SetFont(wxGetApp().m_canvasFont
);
1262 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
1263 dc
.SetBackgroundMode(wxTRANSPARENT
);
1265 _T("wxWidgets common dialogs")
1266 #if !defined(__SMARTPHONE__)
1267 _T(" test application")
1272 #if USE_MODAL_PRESENTATION
1274 // ----------------------------------------------------------------------------
1276 // ----------------------------------------------------------------------------
1278 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
1279 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modeless dialog")))
1281 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
1283 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, _T("Press me"));
1284 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, _T("Should be disabled"));
1287 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
1288 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
1292 sizerTop
->SetSizeHints(this);
1293 sizerTop
->Fit(this);
1296 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
1298 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1299 wxOK
| wxICON_INFORMATION
, this);
1302 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
1304 if ( event
.CanVeto() )
1306 wxMessageBox(_T("Use the menu item to close this dialog"),
1307 _T("Modeless dialog"),
1308 wxOK
| wxICON_INFORMATION
, this);
1314 // ----------------------------------------------------------------------------
1316 // ----------------------------------------------------------------------------
1318 MyModalDialog::MyModalDialog(wxWindow
*parent
)
1319 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modal dialog")))
1321 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1323 m_btnModal
= new wxButton(this, wxID_ANY
, _T("&Modal dialog..."));
1324 m_btnModeless
= new wxButton(this, wxID_ANY
, _T("Mode&less dialog"));
1325 m_btnDelete
= new wxButton(this, wxID_ANY
, _T("&Delete button"));
1327 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _T("&Close"));
1328 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
1329 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
1330 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
1331 sizerTop
->Add(btnOk
, 0, wxALIGN_CENTER
| wxALL
, 5);
1335 sizerTop
->SetSizeHints(this);
1336 sizerTop
->Fit(this);
1338 m_btnModal
->SetFocus();
1339 m_btnModal
->SetDefault();
1342 void MyModalDialog::OnButton(wxCommandEvent
& event
)
1344 if ( event
.GetEventObject() == m_btnDelete
)
1349 m_btnDelete
->Disable();
1351 else if ( event
.GetEventObject() == m_btnModal
)
1354 wxGetTextFromUser(_T("Dummy prompt"),
1355 _T("Modal dialog called from dialog"),
1356 wxEmptyString
, this);
1358 wxMessageBox(_T("Modal dialog called from dialog"));
1359 #endif // wxUSE_TEXTDLG
1361 else if ( event
.GetEventObject() == m_btnModeless
)
1363 (new MyModelessDialog(this))->Show();
1371 #endif // USE_MODAL_PRESENTATION
1373 #if USE_SETTINGS_DIALOG
1374 // ----------------------------------------------------------------------------
1376 // ----------------------------------------------------------------------------
1378 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
1380 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
1383 SettingsDialog::SettingsDialog(wxWindow
* win
, bool useToolBook
)
1385 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
1394 SetSheetStyle(wxPROPSHEET_TOOLBOOK
|wxPROPSHEET_SHRINKTOFIT
);
1396 // create a dummy image list with a few icons
1397 const wxSize
imageSize(32, 32);
1399 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
1401 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
1403 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
1405 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
1407 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
1412 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
1413 wxDEFAULT_DIALOG_STYLE
1419 // If using a toolbook, also follow Mac style and don't create buttons
1421 CreateButtons(wxOK
|wxCANCEL
1422 #ifndef __POCKETPC__
1427 wxBookCtrlBase
* notebook
= GetBookCtrl();
1428 notebook
->SetImageList(m_imageList
);
1430 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
1431 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
1433 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
1434 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
1439 SettingsDialog::~SettingsDialog()
1444 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
1446 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1448 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1449 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1453 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
1454 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
1455 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1456 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
1460 wxString autoSaveLabel
= _("&Auto-save every");
1461 wxString minsLabel
= _("mins");
1463 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
1464 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
1467 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
1468 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
1471 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1473 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1475 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1476 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
1480 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
1481 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
1482 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1483 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
1485 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1487 panel
->SetSizer(topSizer
);
1488 topSizer
->Fit(panel
);
1493 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
1495 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1497 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1498 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1500 //// PROJECT OR GLOBAL
1501 wxString globalOrProjectChoices
[2];
1502 globalOrProjectChoices
[0] = _("&New projects");
1503 globalOrProjectChoices
[1] = _("&This project");
1505 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
1506 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
1507 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
1509 projectOrGlobal
->SetSelection(0);
1511 //// BACKGROUND STYLE
1512 wxArrayString backgroundStyleChoices
;
1513 backgroundStyleChoices
.Add(wxT("Colour"));
1514 backgroundStyleChoices
.Add(wxT("Image"));
1515 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
1517 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
1518 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
1520 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
1522 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
1524 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1525 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
1526 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1528 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
1531 //// FONT SIZE SELECTION
1533 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
1534 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
1536 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
1537 wxSize(80, wxDefaultCoord
));
1538 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
1540 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
1543 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1544 topSizer
->AddSpacer(5);
1546 panel
->SetSizer(topSizer
);
1547 topSizer
->Fit(panel
);
1552 #endif // USE_SETTINGS_DIALOG