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"
32 #include "wx/colordlg.h"
33 #endif // wxUSE_COLOURDLG
36 #include "wx/choicdlg.h"
37 #endif // wxUSE_CHOICEDLG
39 #if wxUSE_STARTUP_TIPS
40 #include "wx/tipdlg.h"
41 #endif // wxUSE_STARTUP_TIPS
44 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
45 #include "wx/datetime.h" // wxDateTime
48 #include "wx/progdlg.h"
49 #endif // wxUSE_PROGRESSDLG
52 #include "wx/busyinfo.h"
53 #endif // wxUSE_BUSYINFO
56 #include "wx/numdlg.h"
57 #endif // wxUSE_NUMBERDLG
60 #include "wx/filedlg.h"
61 #endif // wxUSE_FILEDLG
64 #include "wx/dirdlg.h"
65 #endif // wxUSE_DIRDLG
68 #include "wx/fontdlg.h"
69 #endif // wxUSE_FONTDLG
72 #include "wx/fdrepdlg.h"
73 #endif // wxUSE_FINDREPLDLG
76 #include "wx/spinctrl.h"
79 #include "wx/propdlg.h"
83 #if USE_COLOURDLG_GENERIC
84 #include "wx/generic/colrdlgg.h"
85 #endif // USE_COLOURDLG_GENERIC
87 #if USE_DIRDLG_GENERIC
88 #include "wx/generic/dirdlgg.h"
89 #endif // USE_DIRDLG_GENERIC
91 #if USE_FILEDLG_GENERIC
92 #include "wx/generic/filedlgg.h"
93 #endif // USE_FILEDLG_GENERIC
95 #if USE_FONTDLG_GENERIC
96 #include "wx/generic/fontdlgg.h"
97 #endif // USE_FONTDLG_GENERIC
101 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
102 EVT_PAINT(MyCanvas::OnPaint
)
107 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
108 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
111 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
112 #endif // wxUSE_COLOURDLG
115 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
116 #endif // wxUSE_FONTDLG
119 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
120 #endif // wxUSE_LOG_DIALOG
123 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
124 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
125 #endif // wxUSE_TEXTDLG
128 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
129 #endif // wxUSE_NUMBERDLG
132 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
133 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
134 #endif // wxUSE_CHOICEDLG
137 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
138 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
139 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
140 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
141 #endif // wxUSE_FILEDLG
143 #if USE_FILEDLG_GENERIC
144 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
145 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
146 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
147 #endif // USE_FILEDLG_GENERIC
150 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
151 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
152 #endif // wxUSE_DIRDLG
154 #if USE_MODAL_PRESENTATION
155 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
156 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
159 #if wxUSE_STARTUP_TIPS
160 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
161 #endif // wxUSE_STARTUP_TIPS
163 #if USE_FONTDLG_GENERIC
164 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
165 #endif // USE_FONTDLG_GENERIC
167 #if USE_DIRDLG_GENERIC
168 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
169 #endif // wxMSW || wxMAC
171 #if USE_COLOURDLG_GENERIC
172 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
173 #endif // USE_COLOURDLG_GENERIC
175 #if wxUSE_PROGRESSDLG
176 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
177 #endif // wxUSE_PROGRESSDLG
180 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
181 #endif // wxUSE_BUSYINFO
183 #if wxUSE_FINDREPLDLG
184 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
185 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
187 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
188 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
189 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
190 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
191 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
192 #endif // wxUSE_FINDREPLDLG
194 #if USE_SETTINGS_DIALOG
195 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
196 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheetToolBook
)
199 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
201 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
204 #if USE_MODAL_PRESENTATION
206 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
207 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
210 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
211 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
212 EVT_CLOSE(MyModelessDialog::OnClose
)
215 #endif // USE_MODAL_PRESENTATION
217 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
219 // `Main program' equivalent, creating windows and returning main app frame
223 wxInitAllImageHandlers();
226 m_canvasTextColour
= wxColour(_T("BLACK"));
227 m_canvasFont
= *wxNORMAL_FONT
;
229 // Create the main frame window
230 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets dialogs example"));
233 wxMenu
*file_menu
= new wxMenu
;
235 file_menu
->Append(DIALOGS_MESSAGE_BOX
, _T("&Message box\tCtrl-M"));
238 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
240 wxMenu
*choices_menu
= new wxMenu
;
243 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, _T("&Choose colour"));
244 #endif // wxUSE_COLOURDLG
247 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, _T("Choose &font"));
248 #endif // wxUSE_FONTDLG
251 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, _T("&Single choice\tCtrl-C"));
252 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, _T("M&ultiple choice\tCtrl-U"));
253 #endif // wxUSE_CHOICEDLG
255 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
256 choices_menu
->AppendSeparator();
257 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
259 #if USE_COLOURDLG_GENERIC
260 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, _T("&Choose colour (generic)"));
261 #endif // USE_COLOURDLG_GENERIC
263 #if USE_FONTDLG_GENERIC
264 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, _T("Choose &font (generic)"));
265 #endif // USE_FONTDLG_GENERIC
267 file_menu
->Append(wxID_ANY
,_T("&Choices and selectors"),choices_menu
);
268 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
271 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
273 wxMenu
*entry_menu
= new wxMenu
;
276 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, _T("Text &entry\tCtrl-E"));
277 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, _T("&Password entry\tCtrl-P"));
278 #endif // wxUSE_TEXTDLG
281 entry_menu
->Append(DIALOGS_NUM_ENTRY
, _T("&Numeric entry\tCtrl-N"));
282 #endif // wxUSE_NUMBERDLG
284 file_menu
->Append(wxID_ANY
,_T("&Entry dialogs"),entry_menu
);
286 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
291 wxMenu
*filedlg_menu
= new wxMenu
;
292 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, _T("&Open file\tCtrl-O"));
293 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, _T("&Second open file\tCtrl-2"));
294 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, _T("Open &files\tCtrl-Q"));
295 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, _T("Sa&ve file\tCtrl-S"));
297 #if USE_FILEDLG_GENERIC
298 filedlg_menu
->AppendSeparator();
299 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, _T("&Open file (generic)"));
300 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, _T("Open &files (generic)"));
301 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, _T("Sa&ve file (generic)"));
302 #endif // USE_FILEDLG_GENERIC
304 file_menu
->Append(wxID_ANY
,_T("&File operations"),filedlg_menu
);
306 #endif // wxUSE_FILEDLG
309 wxMenu
*dir_menu
= new wxMenu
;
311 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, _T("&Choose a directory\tCtrl-D"));
312 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
313 file_menu
->Append(wxID_ANY
,_T("&Directory operations"),dir_menu
);
315 #if USE_DIRDLG_GENERIC
316 dir_menu
->AppendSeparator();
317 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, _T("&Choose a directory (generic)"));
318 #endif // USE_DIRDLG_GENERIC
320 #endif // wxUSE_DIRDLG
323 #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
325 wxMenu
*info_menu
= new wxMenu
;
327 #if wxUSE_STARTUP_TIPS
328 info_menu
->Append(DIALOGS_TIP
, _T("&Tip of the day\tCtrl-T"));
329 #endif // wxUSE_STARTUP_TIPS
331 #if wxUSE_PROGRESSDLG
332 info_menu
->Append(DIALOGS_PROGRESS
, _T("Pro&gress dialog\tCtrl-G"));
333 #endif // wxUSE_PROGRESSDLG
336 info_menu
->Append(DIALOGS_BUSYINFO
, _T("&Busy info dialog\tCtrl-B"));
337 #endif // wxUSE_BUSYINFO
340 info_menu
->Append(DIALOGS_LOG_DIALOG
, _T("&Log dialog\tCtrl-L"));
341 #endif // wxUSE_LOG_DIALOG
343 file_menu
->Append(wxID_ANY
,_T("&Informative dialogs"),info_menu
);
345 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
348 #if wxUSE_FINDREPLDLG
349 wxMenu
*find_menu
= new wxMenu
;
350 find_menu
->AppendCheckItem(DIALOGS_FIND
, _T("&Find dialog\tCtrl-F"));
351 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, _T("Find and &replace dialog\tShift-Ctrl-F"));
352 file_menu
->Append(wxID_ANY
,_T("&Searching"),find_menu
);
353 #endif // wxUSE_FINDREPLDLG
355 #if USE_MODAL_PRESENTATION
356 wxMenu
*modal_menu
= new wxMenu
;
357 modal_menu
->Append(DIALOGS_MODAL
, _T("Mo&dal dialog\tCtrl-W"));
358 modal_menu
->AppendCheckItem(DIALOGS_MODELESS
, _T("Modeless &dialog\tCtrl-Z"));
359 file_menu
->Append(wxID_ANY
,_T("&Modal/Modeless"),modal_menu
);
360 #endif // USE_MODAL_PRESENTATION
362 #if USE_SETTINGS_DIALOG
363 file_menu
->Append(DIALOGS_PROPERTY_SHEET
, _T("&Property Sheet Dialog\tCtrl-P"));
364 file_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, _T("Property Sheet Dialog using &ToolBook"));
367 file_menu
->Append(DIALOGS_REQUEST
, _T("&Request user attention\tCtrl-R"));
369 file_menu
->AppendSeparator();
370 file_menu
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"));
372 wxMenuBar
*menu_bar
= new wxMenuBar
;
373 menu_bar
->Append(file_menu
, _T("&File"));
374 frame
->SetMenuBar(menu_bar
);
376 myCanvas
= new MyCanvas(frame
);
377 myCanvas
->SetBackgroundColour(*wxWHITE
);
379 frame
->Centre(wxBOTH
);
389 // My frame constructor
390 MyFrame::MyFrame(wxWindow
*parent
,
391 const wxString
& title
)
392 : wxFrame(parent
, wxID_ANY
, title
)
396 #if USE_MODAL_PRESENTATION
397 m_dialog
= (MyModelessDialog
*)NULL
;
398 #endif // USE_MODAL_PRESENTATION
400 #if wxUSE_FINDREPLDLG
406 m_clrData
.SetChooseFull(true);
407 for (int i
= 0; i
< 16; i
++)
409 m_clrData
.SetCustomColour(
412 (unsigned char)(i
*16),
413 (unsigned char)(i
*16),
414 (unsigned char)(i
*16)
418 #endif // wxUSE_COLOURDLG
422 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
424 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
426 wxColourDialog
dialog(this, &m_clrData
);
427 dialog
.SetTitle(_T("Choose the background colour"));
428 if (dialog
.ShowModal() == wxID_OK
)
430 m_clrData
= dialog
.GetColourData();
431 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
432 myCanvas
->ClearBackground();
436 #endif // wxUSE_COLOURDLG
438 #if USE_COLOURDLG_GENERIC
439 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
441 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
443 //FIXME:TODO:This has no effect...
444 m_clrData
.SetChooseFull(true);
446 for (int i
= 0; i
< 16; i
++)
449 (unsigned char)(i
*16),
450 (unsigned char)(i
*16),
451 (unsigned char)(i
*16)
453 m_clrData
.SetCustomColour(i
, colour
);
456 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
457 if (dialog
->ShowModal() == wxID_OK
)
459 m_clrData
= dialog
->GetColourData();
460 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
461 myCanvas
->ClearBackground();
466 #endif // USE_COLOURDLG_GENERIC
469 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
472 data
.SetInitialFont(wxGetApp().m_canvasFont
);
473 data
.SetColour(wxGetApp().m_canvasTextColour
);
475 // you might also do this:
477 // wxFontDialog dialog;
478 // if ( !dialog.Create(this, data) { ... error ... }
480 wxFontDialog
dialog(this, data
);
482 if (dialog
.ShowModal() == wxID_OK
)
484 wxFontData retData
= dialog
.GetFontData();
485 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
486 wxGetApp().m_canvasTextColour
= retData
.GetColour();
489 //else: cancelled by the user, don't change the font
491 #endif // wxUSE_FONTDLG
493 #if USE_FONTDLG_GENERIC
494 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
497 data
.SetInitialFont(wxGetApp().m_canvasFont
);
498 data
.SetColour(wxGetApp().m_canvasTextColour
);
500 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, &data
);
501 if (dialog
->ShowModal() == wxID_OK
)
503 wxFontData retData
= dialog
->GetFontData();
504 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
505 wxGetApp().m_canvasTextColour
= retData
.GetColour();
510 #endif // USE_FONTDLG_GENERIC
513 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
515 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
516 // being flushed -- test it
519 wxLogMessage(wxT("This is some message - everything is ok so far."));
520 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
521 wxLogWarning(wxT("And then something went wrong!"));
523 // and if ~wxBusyCursor doesn't do it, then call it manually
527 wxLogError(wxT("Intermediary error handler decided to abort."));
528 wxLogError(wxT("The top level caller detected an unrecoverable error."));
530 wxLog::FlushActive();
532 wxLogMessage(wxT("And this is the same dialog but with only one message."));
534 #endif // wxUSE_LOG_DIALOG
536 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
538 wxMessageDialog
dialog( NULL
, _T("This is a message box\nA long, long string to test out the message box properly"),
539 _T("Message box text"), wxNO_DEFAULT
|wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
541 switch ( dialog
.ShowModal() )
544 wxLogStatus(wxT("You pressed \"Yes\""));
548 wxLogStatus(wxT("You pressed \"No\""));
552 wxLogStatus(wxT("You pressed \"Cancel\""));
556 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
561 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
563 long res
= wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
564 _T("Even two rows of text."),
565 _T("Enter a number:"), _T("Numeric input test"),
572 msg
= _T("Invalid number entered or dialog cancelled.");
577 msg
.Printf(_T("You've entered %lu"), res
);
578 icon
= wxICON_INFORMATION
;
581 wxMessageBox(msg
, _T("Numeric test result"), wxOK
| icon
, this);
583 #endif // wxUSE_NUMBERDLG
586 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
588 wxString pwd
= wxGetPasswordFromUser(_T("Enter password:"),
589 _T("Password entry dialog"),
594 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
595 _T("Got password"), wxOK
| wxICON_INFORMATION
, this);
599 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
601 wxTextEntryDialog
dialog(this,
602 _T("This is a small sample\n")
603 _T("A long, long string to test out the text entrybox"),
604 _T("Please enter a string"),
608 if (dialog
.ShowModal() == wxID_OK
)
610 wxMessageBox(dialog
.GetValue(), _T("Got string"), wxOK
| wxICON_INFORMATION
, this);
613 #endif // wxUSE_TEXTDLG
616 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
618 const wxString choices
[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
620 wxSingleChoiceDialog
dialog(this,
621 _T("This is a small sample\n")
622 _T("A single-choice convenience dialog"),
623 _T("Please select a value"),
624 WXSIZEOF(choices
), choices
);
626 dialog
.SetSelection(2);
628 if (dialog
.ShowModal() == wxID_OK
)
630 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), _T("Got string"));
635 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
637 const wxString choices
[] =
639 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
640 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
641 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
644 wxArrayInt selections
;
645 size_t count
= wxGetMultipleChoices(selections
,
646 _T("This is a small sample\n")
647 _T("A multi-choice convenience dialog"),
648 _T("Please select a value"),
649 WXSIZEOF(choices
), choices
,
654 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
655 for ( size_t n
= 0; n
< count
; n
++ )
657 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
658 (unsigned)n
, (unsigned)selections
[n
],
659 choices
[selections
[n
]].c_str());
663 //else: cancelled or nothing selected
665 #endif // wxUSE_CHOICEDLG
668 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
673 _T("Testing open file dialog"),
677 _T("C++ files (*.cpp)|*.cpp")
679 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
683 dialog
.SetDirectory(wxGetHomeDir());
684 dialog
.CentreOnParent();
686 if (dialog
.ShowModal() == wxID_OK
)
689 info
.Printf(_T("Full file name: %s\n")
692 dialog
.GetPath().c_str(),
693 dialog
.GetDirectory().c_str(),
694 dialog
.GetFilename().c_str());
695 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
700 // this shows how to take advantage of specifying a default extension in the
701 // call to wxFileSelector: it is remembered after each new call and the next
702 // one will use it by default
703 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
705 static wxString s_extDef
;
706 wxString path
= wxFileSelector(
707 _T("Select the file to load"),
708 wxEmptyString
, wxEmptyString
,
712 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
713 wxFileSelectorDefaultWildcardStr
,
714 wxFileSelectorDefaultWildcardStr
723 // it is just a sample, would use wxSplitPath in real program
724 s_extDef
= path
.AfterLast(_T('.'));
726 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
727 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
730 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
734 _T("C++ files (*.cpp)|*.cpp");
738 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
739 wxFileSelectorDefaultWildcardStr
,
740 wxFileSelectorDefaultWildcardStr
743 wxFileDialog
dialog(this, _T("Testing open multiple file dialog"),
744 wxEmptyString
, wxEmptyString
, wildcards
,
747 if (dialog
.ShowModal() == wxID_OK
)
749 wxArrayString paths
, filenames
;
751 dialog
.GetPaths(paths
);
752 dialog
.GetFilenames(filenames
);
755 size_t count
= paths
.GetCount();
756 for ( size_t n
= 0; n
< count
; n
++ )
758 s
.Printf(_T("File %d: %s (%s)\n"),
759 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
763 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
766 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
771 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
773 wxFileDialog
dialog(this,
774 _T("Testing save file dialog"),
777 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
778 wxSAVE
|wxOVERWRITE_PROMPT
);
780 dialog
.SetFilterIndex(1);
782 if (dialog
.ShowModal() == wxID_OK
)
784 wxLogMessage(_T("%s, filter %d"),
785 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
788 #endif // wxUSE_FILEDLG
790 #if USE_FILEDLG_GENERIC
791 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
793 wxGenericFileDialog dialog
796 _T("Testing open file dialog"),
799 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
802 dialog
.SetDirectory(wxGetHomeDir());
804 if (dialog
.ShowModal() == wxID_OK
)
807 info
.Printf(_T("Full file name: %s\n")
810 dialog
.GetPath().c_str(),
811 dialog
.GetDirectory().c_str(),
812 dialog
.GetFilename().c_str());
813 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
818 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
820 wxString wildcards
= _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
821 wxGenericFileDialog
dialog(this, _T("Testing open multiple file dialog"),
822 wxEmptyString
, wxEmptyString
, wildcards
,
825 if (dialog
.ShowModal() == wxID_OK
)
827 wxArrayString paths
, filenames
;
829 dialog
.GetPaths(paths
);
830 dialog
.GetFilenames(filenames
);
833 size_t count
= paths
.GetCount();
834 for ( size_t n
= 0; n
< count
; n
++ )
836 s
.Printf(_T("File %d: %s (%s)\n"),
837 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
841 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
844 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
849 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
851 wxGenericFileDialog
dialog(this,
852 _T("Testing save file dialog"),
855 _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
856 wxSAVE
|wxOVERWRITE_PROMPT
);
858 dialog
.SetFilterIndex(1);
860 if (dialog
.ShowModal() == wxID_OK
)
862 wxLogMessage(_T("%s, filter %d"),
863 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
866 #endif // USE_FILEDLG_GENERIC
869 void MyFrame::DoDirChoose(int style
)
871 // pass some initial dir to wxDirDialog
873 wxGetHomeDir(&dirHome
);
875 wxDirDialog
dialog(this, _T("Testing directory picker"), dirHome
, style
);
877 if (dialog
.ShowModal() == wxID_OK
)
879 wxLogMessage(_T("Selected path: %s"), dialog
.GetPath().c_str());
883 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
885 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_NEW_DIR_BUTTON
);
888 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
890 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_NEW_DIR_BUTTON
);
892 #endif // wxUSE_DIRDLG
894 #if USE_DIRDLG_GENERIC
895 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
897 // pass some initial dir to wxDirDialog
899 wxGetHomeDir(&dirHome
);
901 wxGenericDirDialog
dialog(this, _T("Testing generic directory picker"), dirHome
);
903 if (dialog
.ShowModal() == wxID_OK
)
905 wxMessageDialog
dialog2(this, dialog
.GetPath(), _T("Selected path"));
909 #endif // USE_DIRDLG_GENERIC
911 #if USE_MODAL_PRESENTATION
912 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
914 MyModalDialog
dlg(this);
918 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
920 bool show
= GetMenuBar()->IsChecked(event
.GetId());
926 m_dialog
= new MyModelessDialog(this);
929 m_dialog
->Show(true);
933 // If m_dialog is NULL, then possibly the system
934 // didn't report the checked menu item status correctly.
935 // It should be true just after the menu item was selected,
936 // if there was no modeless dialog yet.
938 wxASSERT( m_dialog
!= NULL
);
943 #endif // USE_MODAL_PRESENTATION
945 #if wxUSE_STARTUP_TIPS
946 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
948 static size_t s_index
= (size_t)-1;
950 if ( s_index
== (size_t)-1 )
954 // this is completely bogus, we don't know how many lines are there
955 // in the file, but who cares, it's a demo only...
956 s_index
= rand() % 5;
959 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(_T("tips.txt"), s_index
);
961 bool showAtStartup
= wxShowTip(this, tipProvider
);
965 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
966 wxOK
| wxICON_INFORMATION
, this);
969 s_index
= tipProvider
->GetCurrentTip();
972 #endif // wxUSE_STARTUP_TIPS
974 #if USE_SETTINGS_DIALOG
975 void MyFrame::OnPropertySheet(wxCommandEvent
& WXUNUSED(event
))
977 SettingsDialog
dialog(this);
981 void MyFrame::OnPropertySheetToolBook(wxCommandEvent
& WXUNUSED(event
))
983 SettingsDialog
dialog(this, true);
986 #endif // USE_SETTINGS_DIALOG
988 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
990 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
994 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
997 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1002 #if wxUSE_PROGRESSDLG
1004 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1006 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1007 // check the performance
1008 int countrandomnumbers
= 0, count
= 0;
1009 wxTimeSpan
tsTest(0,0,0,250);
1010 wxDateTime DT2
, DT1
= wxDateTime::UNow();
1015 ++countrandomnumbers
;
1016 if ( countrandomnumbers
== 1000 )
1019 countrandomnumbers
= 0;
1021 DT2
= wxDateTime::UNow();
1022 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1023 if ( ts
.IsLongerThan( tsTest
) )
1029 const int max
= 40 * count
;
1031 static const int max
= 10;
1032 #endif // wxUSE_STOPWATCH && wxUSE_LONGLONG
1034 wxProgressDialog
dialog(_T("Progress dialog example"),
1035 _T("An informative message"),
1041 // wxPD_AUTO_HIDE | -- try this as well
1043 wxPD_ESTIMATED_TIME
|
1044 wxPD_REMAINING_TIME
|
1049 // each skip will move progress about quarter forward
1050 for ( int i
= 0; i
<= max
; i
= wxMin(i
+(skip
?int(max
/4):1), max
+1), skip
= false )
1052 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1053 // do (almost) the same operations as we did for the performance test
1055 for ( int j
= 0; j
< 1000; j
++ )
1060 DT2
= wxDateTime::UNow();
1061 wxTimeSpan ts
= DT2
.Subtract( DT1
);
1062 if ( ts
.IsLongerThan( tsTest
) )
1076 msg
= _T("That's all, folks!");
1078 else if ( i
> max
/ 2 )
1080 msg
= _T("Only a half left (very long message)!");
1083 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
1084 if ( (i
% (max
/100)) == 0 ) // // only 100 updates, this makes it much faster
1086 cont
= dialog
.Update(i
, msg
, &skip
);
1089 cont
= dialog
.Update(i
, msg
, &skip
);
1094 if ( wxMessageBox(_T("Do you really want to cancel?"),
1095 _T("Progress dialog question"), // caption
1096 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1106 wxLogStatus(wxT("Progress dialog aborted!"));
1110 wxLogStatus(wxT("Countdown from %d finished"), max
);
1114 #endif // wxUSE_PROGRESSDLG
1118 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1120 wxWindowDisabler disableAll
;
1122 wxBusyInfo
info(_T("Working, please wait..."), this);
1124 for ( int i
= 0; i
< 18; i
++ )
1134 #endif // wxUSE_BUSYINFO
1136 #if wxUSE_FINDREPLDLG
1138 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1142 delete m_dlgReplace
;
1143 m_dlgReplace
= NULL
;
1147 m_dlgReplace
= new wxFindReplaceDialog
1151 _T("Find and replace dialog"),
1155 m_dlgReplace
->Show(true);
1159 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1168 m_dlgFind
= new wxFindReplaceDialog
1177 m_dlgFind
->Show(true);
1181 static wxString
DecodeFindDialogEventFlags(int flags
)
1184 str
<< (flags
& wxFR_DOWN
? _T("down") : _T("up")) << _T(", ")
1185 << (flags
& wxFR_WHOLEWORD
? _T("whole words only, ") : _T(""))
1186 << (flags
& wxFR_MATCHCASE
? _T("") : _T("not "))
1187 << _T("case sensitive");
1192 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
1194 wxEventType type
= event
.GetEventType();
1196 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
1198 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1199 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
1200 event
.GetFindString().c_str(),
1201 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1203 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
1204 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
1206 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1207 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? _T("all ") : wxT(""),
1208 event
.GetFindString().c_str(),
1209 event
.GetReplaceString().c_str(),
1210 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1212 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
1214 wxFindReplaceDialog
*dlg
= event
.GetDialog();
1218 if ( dlg
== m_dlgFind
)
1221 idMenu
= DIALOGS_FIND
;
1224 else if ( dlg
== m_dlgReplace
)
1226 txt
= _T("Replace");
1227 idMenu
= DIALOGS_REPLACE
;
1228 m_dlgReplace
= NULL
;
1232 txt
= _T("Unknown");
1235 wxFAIL_MSG( _T("unexpected event") );
1238 wxLogMessage(wxT("%s dialog is being closed."), txt
);
1240 if ( idMenu
!= wxID_ANY
)
1242 GetMenuBar()->Check(idMenu
, false);
1249 wxLogError(wxT("Unknown find dialog event!"));
1253 #endif // wxUSE_FINDREPLDLG
1255 // ----------------------------------------------------------------------------
1257 // ----------------------------------------------------------------------------
1259 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
1262 dc
.SetFont(wxGetApp().m_canvasFont
);
1263 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
1264 dc
.SetBackgroundMode(wxTRANSPARENT
);
1266 _T("wxWidgets common dialogs")
1267 #if !defined(__SMARTPHONE__)
1268 _T(" test application")
1273 #if USE_MODAL_PRESENTATION
1275 // ----------------------------------------------------------------------------
1277 // ----------------------------------------------------------------------------
1279 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
1280 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modeless dialog")))
1282 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
1284 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, _T("Press me"));
1285 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, _T("Should be disabled"));
1288 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
1289 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
1293 sizerTop
->SetSizeHints(this);
1294 sizerTop
->Fit(this);
1297 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
1299 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1300 wxOK
| wxICON_INFORMATION
, this);
1303 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
1305 if ( event
.CanVeto() )
1307 wxMessageBox(_T("Use the menu item to close this dialog"),
1308 _T("Modeless dialog"),
1309 wxOK
| wxICON_INFORMATION
, this);
1315 // ----------------------------------------------------------------------------
1317 // ----------------------------------------------------------------------------
1319 MyModalDialog::MyModalDialog(wxWindow
*parent
)
1320 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modal dialog")))
1322 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1324 m_btnModal
= new wxButton(this, wxID_ANY
, _T("&Modal dialog..."));
1325 m_btnModeless
= new wxButton(this, wxID_ANY
, _T("Mode&less dialog"));
1326 m_btnDelete
= new wxButton(this, wxID_ANY
, _T("&Delete button"));
1328 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _T("&Close"));
1329 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
1330 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
1331 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
1332 sizerTop
->Add(btnOk
, 0, wxALIGN_CENTER
| wxALL
, 5);
1336 sizerTop
->SetSizeHints(this);
1337 sizerTop
->Fit(this);
1339 m_btnModal
->SetFocus();
1340 m_btnModal
->SetDefault();
1343 void MyModalDialog::OnButton(wxCommandEvent
& event
)
1345 if ( event
.GetEventObject() == m_btnDelete
)
1350 m_btnDelete
->Disable();
1352 else if ( event
.GetEventObject() == m_btnModal
)
1355 wxGetTextFromUser(_T("Dummy prompt"),
1356 _T("Modal dialog called from dialog"),
1357 wxEmptyString
, this);
1359 wxMessageBox(_T("Modal dialog called from dialog"));
1360 #endif // wxUSE_TEXTDLG
1362 else if ( event
.GetEventObject() == m_btnModeless
)
1364 (new MyModelessDialog(this))->Show();
1372 #endif // USE_MODAL_PRESENTATION
1374 #if USE_SETTINGS_DIALOG
1375 // ----------------------------------------------------------------------------
1377 // ----------------------------------------------------------------------------
1379 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
1381 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
1384 SettingsDialog::SettingsDialog(wxWindow
* win
, bool useToolBook
)
1386 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
1395 SetSheetStyle(wxPROPSHEET_TOOLBOOK
|wxPROPSHEET_SHRINKTOFIT
);
1397 // create a dummy image list with a few icons
1398 const wxSize
imageSize(32, 32);
1400 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
1402 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
1404 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
1406 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
1408 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
1413 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
1414 wxDEFAULT_DIALOG_STYLE
1420 // If using a toolbook, also follow Mac style and don't create buttons
1422 CreateButtons(wxOK
|wxCANCEL
1423 #ifndef __POCKETPC__
1428 wxBookCtrlBase
* notebook
= GetBookCtrl();
1429 notebook
->SetImageList(m_imageList
);
1431 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
1432 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
1434 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
1435 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
1440 SettingsDialog::~SettingsDialog()
1445 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
1447 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1449 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1450 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1454 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
1455 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
1456 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1457 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
1461 wxString autoSaveLabel
= _("&Auto-save every");
1462 wxString minsLabel
= _("mins");
1464 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
1465 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
1468 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
1469 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
1472 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1474 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1476 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1477 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
1481 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
1482 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
1483 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1484 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
1486 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1488 panel
->SetSizer(topSizer
);
1489 topSizer
->Fit(panel
);
1494 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
1496 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
1498 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
1499 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
1501 //// PROJECT OR GLOBAL
1502 wxString globalOrProjectChoices
[2];
1503 globalOrProjectChoices
[0] = _("&New projects");
1504 globalOrProjectChoices
[1] = _("&This project");
1506 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
1507 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
1508 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
1510 projectOrGlobal
->SetSelection(0);
1512 //// BACKGROUND STYLE
1513 wxArrayString backgroundStyleChoices
;
1514 backgroundStyleChoices
.Add(wxT("Colour"));
1515 backgroundStyleChoices
.Add(wxT("Image"));
1516 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
1518 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
1519 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
1521 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
1523 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
1525 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1526 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
1527 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
1529 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
1532 //// FONT SIZE SELECTION
1534 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
1535 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
1537 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
1538 wxSize(80, wxDefaultCoord
));
1539 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
1541 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
1544 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
1545 topSizer
->AddSpacer(5);
1547 panel
->SetSizer(topSizer
);
1548 topSizer
->Fit(panel
);
1553 #endif // USE_SETTINGS_DIALOG