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/minifram.h"
31 #include "wx/sysopt.h"
32 #include "wx/notifmsg.h"
35 #include "wx/colordlg.h"
36 #endif // wxUSE_COLOURDLG
39 #include "wx/choicdlg.h"
40 #endif // wxUSE_CHOICEDLG
42 #if wxUSE_STARTUP_TIPS
43 #include "wx/tipdlg.h"
44 #endif // wxUSE_STARTUP_TIPS
47 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
48 #include "wx/datetime.h" // wxDateTime
51 #include "wx/progdlg.h"
52 #endif // wxUSE_PROGRESSDLG
55 #include "wx/aboutdlg.h"
57 // these headers are only needed for custom about dialog
58 #include "wx/statline.h"
59 #include "wx/generic/aboutdlgg.h"
60 #endif // wxUSE_ABOUTDLG
63 #include "wx/busyinfo.h"
64 #endif // wxUSE_BUSYINFO
67 #include "wx/numdlg.h"
68 #endif // wxUSE_NUMBERDLG
71 #include "wx/filedlg.h"
72 #endif // wxUSE_FILEDLG
75 #include "wx/dirdlg.h"
76 #endif // wxUSE_DIRDLG
79 #include "wx/fontdlg.h"
80 #endif // wxUSE_FONTDLG
83 #include "wx/fdrepdlg.h"
84 #endif // wxUSE_FINDREPLDLG
87 #include "wx/spinctrl.h"
90 #include "wx/propdlg.h"
94 #if USE_COLOURDLG_GENERIC
95 #include "wx/generic/colrdlgg.h"
96 #endif // USE_COLOURDLG_GENERIC
98 #if USE_DIRDLG_GENERIC
99 #include "wx/generic/dirdlgg.h"
100 #endif // USE_DIRDLG_GENERIC
102 #if USE_FILEDLG_GENERIC
103 #include "wx/generic/filedlgg.h"
104 #endif // USE_FILEDLG_GENERIC
106 #if USE_FONTDLG_GENERIC
107 #include "wx/generic/fontdlgg.h"
108 #endif // USE_FONTDLG_GENERIC
112 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
113 EVT_PAINT(MyCanvas::OnPaint
)
118 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
120 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
121 EVT_MENU(DIALOGS_MESSAGE_DIALOG
, MyFrame::MessageBoxDialog
)
122 EVT_MENU(DIALOGS_MESSAGE_BOX_WXINFO
, MyFrame::MessageBoxInfo
)
123 #endif // wxUSE_MSGDLG
125 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
126 EVT_MENU(DIALOGS_GET_COLOUR
, MyFrame::GetColour
)
127 #endif // wxUSE_COLOURDLG
130 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
131 #endif // wxUSE_FONTDLG
134 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
135 #endif // wxUSE_LOG_DIALOG
138 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
139 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
140 #endif // wxUSE_TEXTDLG
143 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
144 #endif // wxUSE_NUMBERDLG
147 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
148 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
149 #endif // wxUSE_CHOICEDLG
152 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
153 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
154 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
155 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
156 #endif // wxUSE_FILEDLG
158 #if USE_FILEDLG_GENERIC
159 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
160 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
161 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
162 #endif // USE_FILEDLG_GENERIC
165 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
166 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
167 #endif // wxUSE_DIRDLG
169 #if USE_MODAL_PRESENTATION
170 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
171 #endif // USE_MODAL_PRESENTATION
172 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
173 EVT_MENU(DIALOGS_CENTRE_SCREEN
, MyFrame::DlgCenteredScreen
)
174 EVT_MENU(DIALOGS_CENTRE_PARENT
, MyFrame::DlgCenteredParent
)
175 EVT_MENU(DIALOGS_MINIFRAME
, MyFrame::MiniFrame
)
176 EVT_MENU(DIALOGS_ONTOP
, MyFrame::DlgOnTop
)
178 #if wxUSE_STARTUP_TIPS
179 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
180 #endif // wxUSE_STARTUP_TIPS
182 #if USE_FONTDLG_GENERIC
183 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
184 #endif // USE_FONTDLG_GENERIC
186 #if USE_DIRDLG_GENERIC
187 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
188 #endif // wxMSW || wxMAC
190 #if USE_COLOURDLG_GENERIC
191 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
192 #endif // USE_COLOURDLG_GENERIC
194 #if wxUSE_PROGRESSDLG
195 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
196 #endif // wxUSE_PROGRESSDLG
199 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE
, MyFrame::ShowSimpleAboutDialog
)
200 EVT_MENU(DIALOGS_ABOUTDLG_FANCY
, MyFrame::ShowFancyAboutDialog
)
201 EVT_MENU(DIALOGS_ABOUTDLG_FULL
, MyFrame::ShowFullAboutDialog
)
202 EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM
, MyFrame::ShowCustomAboutDialog
)
203 #endif // wxUSE_ABOUTDLG
206 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
207 #endif // wxUSE_BUSYINFO
209 #if wxUSE_FINDREPLDLG
210 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
211 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
213 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
214 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
215 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
216 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
217 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
218 #endif // wxUSE_FINDREPLDLG
220 #if USE_SETTINGS_DIALOG
221 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
222 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheet
)
223 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, MyFrame::OnPropertySheet
)
224 #endif // USE_SETTINGS_DIALOG
226 EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
, MyFrame::OnStandardButtonsSizerDialog
)
227 EVT_MENU(DIALOGS_TEST_DEFAULT_ACTION
, MyFrame::OnTestDefaultActionDialog
)
229 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
230 #if wxUSE_NOTIFICATION_MESSAGE
231 EVT_MENU(DIALOGS_NOTIFY_AUTO
, MyFrame::OnNotifMsgAuto
)
232 EVT_MENU(DIALOGS_NOTIFY_SHOW
, MyFrame::OnNotifMsgShow
)
233 EVT_MENU(DIALOGS_NOTIFY_HIDE
, MyFrame::OnNotifMsgHide
)
234 #endif // wxUSE_NOTIFICATION_MESSAGE
236 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
239 #if USE_MODAL_PRESENTATION
241 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
242 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
245 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
246 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
247 EVT_CLOSE(MyModelessDialog::OnClose
)
250 #endif // USE_MODAL_PRESENTATION
252 BEGIN_EVENT_TABLE(StdButtonSizerDialog
, wxDialog
)
253 EVT_CHECKBOX(wxID_ANY
, StdButtonSizerDialog::OnEvent
)
254 EVT_RADIOBUTTON(wxID_ANY
, StdButtonSizerDialog::OnEvent
)
257 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
259 // `Main program' equivalent, creating windows and returning main app frame
262 if ( !wxApp::OnInit() )
266 wxInitAllImageHandlers();
269 m_canvasTextColour
= *wxBLACK
;
270 m_canvasFont
= *wxNORMAL_FONT
;
272 // Create the main frame window
273 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets dialogs example"));
276 wxMenu
*menuDlg
= new wxMenu
;
278 menuDlg
->Append(DIALOGS_MESSAGE_BOX
, _T("&Message box\tCtrl-M"));
279 menuDlg
->Append(DIALOGS_MESSAGE_DIALOG
, _T("Message dialog\tShift-Ctrl-M"));
282 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
284 wxMenu
*choices_menu
= new wxMenu
;
287 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, _T("&Choose bg colour"));
288 choices_menu
->Append(DIALOGS_GET_COLOUR
, _T("&Choose fg colour"));
289 #endif // wxUSE_COLOURDLG
292 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, _T("Choose &font"));
293 #endif // wxUSE_FONTDLG
296 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, _T("&Single choice\tCtrl-C"));
297 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, _T("M&ultiple choice\tCtrl-U"));
298 #endif // wxUSE_CHOICEDLG
300 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
301 choices_menu
->AppendSeparator();
302 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
304 #if USE_COLOURDLG_GENERIC
305 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, _T("&Choose colour (generic)"));
306 #endif // USE_COLOURDLG_GENERIC
308 #if USE_FONTDLG_GENERIC
309 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, _T("Choose &font (generic)"));
310 #endif // USE_FONTDLG_GENERIC
312 menuDlg
->Append(wxID_ANY
,_T("&Choices and selectors"),choices_menu
);
313 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
316 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
318 wxMenu
*entry_menu
= new wxMenu
;
321 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, _T("Text &entry\tCtrl-E"));
322 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, _T("&Password entry\tCtrl-P"));
323 #endif // wxUSE_TEXTDLG
326 entry_menu
->Append(DIALOGS_NUM_ENTRY
, _T("&Numeric entry\tCtrl-N"));
327 #endif // wxUSE_NUMBERDLG
329 menuDlg
->Append(wxID_ANY
,_T("&Entry dialogs"),entry_menu
);
331 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
336 wxMenu
*filedlg_menu
= new wxMenu
;
337 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, _T("&Open file\tCtrl-O"));
338 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, _T("&Second open file\tCtrl-2"));
339 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, _T("Open &files\tCtrl-Q"));
340 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, _T("Sa&ve file\tCtrl-S"));
342 #if USE_FILEDLG_GENERIC
343 filedlg_menu
->AppendSeparator();
344 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, _T("&Open file (generic)"));
345 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, _T("Open &files (generic)"));
346 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, _T("Sa&ve file (generic)"));
347 #endif // USE_FILEDLG_GENERIC
349 menuDlg
->Append(wxID_ANY
,_T("&File operations"),filedlg_menu
);
351 #endif // wxUSE_FILEDLG
354 wxMenu
*dir_menu
= new wxMenu
;
356 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, _T("&Choose a directory\tCtrl-D"));
357 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
358 menuDlg
->Append(wxID_ANY
,_T("&Directory operations"),dir_menu
);
360 #if USE_DIRDLG_GENERIC
361 dir_menu
->AppendSeparator();
362 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, _T("&Choose a directory (generic)"));
363 #endif // USE_DIRDLG_GENERIC
365 #endif // wxUSE_DIRDLG
368 #if wxUSE_STARTUP_TIPS || \
369 wxUSE_PROGRESSDLG || \
371 wxUSE_LOG_DIALOG || \
374 wxMenu
*info_menu
= new wxMenu
;
376 #if wxUSE_STARTUP_TIPS
377 info_menu
->Append(DIALOGS_TIP
, _T("&Tip of the day\tCtrl-T"));
378 #endif // wxUSE_STARTUP_TIPS
380 #if wxUSE_PROGRESSDLG
381 info_menu
->Append(DIALOGS_PROGRESS
, _T("Pro&gress dialog\tCtrl-G"));
382 #endif // wxUSE_PROGRESSDLG
385 info_menu
->Append(DIALOGS_BUSYINFO
, _T("&Busy info dialog\tCtrl-B"));
386 #endif // wxUSE_BUSYINFO
389 info_menu
->Append(DIALOGS_LOG_DIALOG
, _T("&Log dialog\tCtrl-L"));
390 #endif // wxUSE_LOG_DIALOG
393 info_menu
->Append(DIALOGS_MESSAGE_BOX_WXINFO
,
394 _T("&wxWidgets information\tCtrl-I"));
395 #endif // wxUSE_MSGDLG
397 menuDlg
->Append(wxID_ANY
,_T("&Informative dialogs"),info_menu
);
399 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
402 #if wxUSE_FINDREPLDLG
403 wxMenu
*find_menu
= new wxMenu
;
404 find_menu
->AppendCheckItem(DIALOGS_FIND
, _T("&Find dialog\tCtrl-F"));
405 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, _T("Find and &replace dialog\tShift-Ctrl-F"));
406 menuDlg
->Append(wxID_ANY
,_T("&Searching"),find_menu
);
407 #endif // wxUSE_FINDREPLDLG
409 wxMenu
*dialogs_menu
= new wxMenu
;
410 #if USE_MODAL_PRESENTATION
411 dialogs_menu
->Append(DIALOGS_MODAL
, _T("&Modal dialog\tCtrl-W"));
412 #endif // USE_MODAL_PRESENTATION
413 dialogs_menu
->AppendCheckItem(DIALOGS_MODELESS
, _T("Mode&less dialog\tCtrl-Z"));
414 dialogs_menu
->Append(DIALOGS_CENTRE_SCREEN
, _T("Centered on &screen\tShift-Ctrl-1"));
415 dialogs_menu
->Append(DIALOGS_CENTRE_PARENT
, _T("Centered on &parent\tShift-Ctrl-2"));
416 dialogs_menu
->Append(DIALOGS_MINIFRAME
, _T("&Mini frame"));
417 dialogs_menu
->Append(DIALOGS_ONTOP
, _T("Dialog staying on &top"));
418 menuDlg
->Append(wxID_ANY
, _T("&Generic dialogs"), dialogs_menu
);
420 #if USE_SETTINGS_DIALOG
421 wxMenu
*sheet_menu
= new wxMenu
;
422 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET
, _T("&Standard property sheet\tShift-Ctrl-P"));
423 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, _T("&Toolbook sheet\tShift-Ctrl-T"));
425 if (wxPlatformIs(wxPORT_MAC
))
426 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
429 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U"));
432 menuDlg
->Append(wxID_ANY
, _T("&Property sheets"), sheet_menu
);
433 #endif // USE_SETTINGS_DIALOG
435 wxMenu
*menuNotif
= new wxMenu
;
436 menuNotif
->Append(DIALOGS_REQUEST
, _T("&Request user attention\tCtrl-R"));
437 #if wxUSE_NOTIFICATION_MESSAGE
438 menuNotif
->Append(DIALOGS_NOTIFY_AUTO
, "&Automatically hidden notification");
439 menuNotif
->Append(DIALOGS_NOTIFY_SHOW
, "&Show manual notification");
440 menuNotif
->Append(DIALOGS_NOTIFY_HIDE
, "&Hide manual notification");
441 #endif // wxUSE_NOTIFICATION_MESSAGE
442 menuDlg
->AppendSubMenu(menuNotif
, "&User notifications");
444 menuDlg
->Append(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
, _T("&Standard Buttons Sizer Dialog"));
445 menuDlg
->Append(DIALOGS_TEST_DEFAULT_ACTION
, _T("&Test dialog default action"));
447 menuDlg
->AppendSeparator();
448 menuDlg
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"));
451 wxMenu
*menuHelp
= new wxMenu
;
452 menuHelp
->Append(DIALOGS_ABOUTDLG_SIMPLE
, _T("&About (simple)...\tF1"));
453 menuHelp
->Append(DIALOGS_ABOUTDLG_FANCY
, _T("About (&fancy)...\tShift-F1"));
454 menuHelp
->Append(DIALOGS_ABOUTDLG_FULL
, _T("About (f&ull)...\tCtrl-F1"));
455 menuHelp
->Append(DIALOGS_ABOUTDLG_CUSTOM
, _T("About (&custom)...\tCtrl-Shift-F1"));
456 #endif // wxUSE_ABOUTDLG
458 wxMenuBar
*menubar
= new wxMenuBar
;
459 menubar
->Append(menuDlg
, _T("&Dialogs"));
461 menubar
->Append(menuHelp
, _T("&Help"));
462 #endif // wxUSE_ABOUTDLG
464 frame
->SetMenuBar(menubar
);
466 myCanvas
= new MyCanvas(frame
);
467 myCanvas
->SetBackgroundColour(*wxWHITE
);
469 frame
->Centre(wxBOTH
);
479 // My frame constructor
480 MyFrame::MyFrame(wxWindow
*parent
,
481 const wxString
& title
)
482 : wxFrame(parent
, wxID_ANY
, title
)
486 #if USE_MODAL_PRESENTATION
487 m_dialog
= (MyModelessDialog
*)NULL
;
488 #endif // USE_MODAL_PRESENTATION
490 #if wxUSE_FINDREPLDLG
496 m_clrData
.SetChooseFull(true);
497 for (int i
= 0; i
< wxColourData::NUM_CUSTOM
; i
++)
499 unsigned char n
= i
*16;
500 m_clrData
.SetCustomColour(i
, wxColour(n
, n
, n
));
502 #endif // wxUSE_COLOURDLG
504 #if wxUSE_NOTIFICATION_MESSAGE
506 #endif // wxUSE_NOTIFICATION_MESSAGE
510 #endif // wxUSE_STATUSBAR
515 #if wxUSE_NOTIFICATION_MESSAGE
517 #endif // wxUSE_NOTIFICATION_MESSAGE
522 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
))
524 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
526 wxColourDialog
dialog(this, &m_clrData
);
527 dialog
.SetTitle(_("Please choose the background colour"));
528 if ( dialog
.ShowModal() == wxID_OK
)
530 m_clrData
= dialog
.GetColourData();
531 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
532 myCanvas
->ClearBackground();
537 void MyFrame::GetColour(wxCommandEvent
& WXUNUSED(event
))
539 wxColour clr
= wxGetColourFromUser
542 wxGetApp().m_canvasTextColour
,
543 "Please choose the foreground colour"
547 wxGetApp().m_canvasTextColour
= clr
;
550 //else: dialog cancelled by user
553 #endif // wxUSE_COLOURDLG
556 #if USE_COLOURDLG_GENERIC
557 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
559 m_clrData
.SetColour(myCanvas
->GetBackgroundColour());
561 //FIXME:TODO:This has no effect...
562 m_clrData
.SetChooseFull(true);
564 for (int i
= 0; i
< 16; i
++)
567 (unsigned char)(i
*16),
568 (unsigned char)(i
*16),
569 (unsigned char)(i
*16)
571 m_clrData
.SetCustomColour(i
, colour
);
574 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
575 if (dialog
->ShowModal() == wxID_OK
)
577 m_clrData
= dialog
->GetColourData();
578 myCanvas
->SetBackgroundColour(m_clrData
.GetColour());
579 myCanvas
->ClearBackground();
584 #endif // USE_COLOURDLG_GENERIC
587 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
590 data
.SetInitialFont(wxGetApp().m_canvasFont
);
591 data
.SetColour(wxGetApp().m_canvasTextColour
);
593 // you might also do this:
595 // wxFontDialog dialog;
596 // if ( !dialog.Create(this, data) { ... error ... }
598 wxFontDialog
dialog(this, data
);
600 if (dialog
.ShowModal() == wxID_OK
)
602 wxFontData retData
= dialog
.GetFontData();
603 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
604 wxGetApp().m_canvasTextColour
= retData
.GetColour();
607 //else: cancelled by the user, don't change the font
609 #endif // wxUSE_FONTDLG
611 #if USE_FONTDLG_GENERIC
612 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
615 data
.SetInitialFont(wxGetApp().m_canvasFont
);
616 data
.SetColour(wxGetApp().m_canvasTextColour
);
618 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, data
);
619 if (dialog
->ShowModal() == wxID_OK
)
621 wxFontData retData
= dialog
->GetFontData();
622 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
623 wxGetApp().m_canvasTextColour
= retData
.GetColour();
628 #endif // USE_FONTDLG_GENERIC
631 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
633 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
634 // being flushed -- test it
637 wxLogMessage(wxT("This is some message - everything is ok so far."));
638 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
639 wxLogWarning(wxT("And then something went wrong!"));
641 // and if ~wxBusyCursor doesn't do it, then call it manually
645 wxLogError(wxT("Intermediary error handler decided to abort."));
646 wxLogError(wxT("The top level caller detected an unrecoverable error."));
648 wxLog::FlushActive();
650 wxLogMessage(wxT("And this is the same dialog but with only one message."));
652 #endif // wxUSE_LOG_DIALOG
655 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
))
657 wxMessageDialog
dialog(this,
658 "This is a message box\n"
659 "A long, long string to test out the message box "
662 wxVSCROLL
| wxCENTER
|
663 wxNO_DEFAULT
| wxYES_NO
| wxCANCEL
|
667 if ( dialog
.SetYesNoCancelLabels
674 extmsg
= "This platform supports custom button labels,\n"
675 "so you should see the descriptive labels below.";
679 extmsg
= "Custom button labels are not supported on this platform,\n"
680 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
682 dialog
.SetExtendedMessage(extmsg
);
684 switch ( dialog
.ShowModal() )
687 wxLogStatus(wxT("You pressed \"Yes\""));
691 wxLogStatus(wxT("You pressed \"No\""));
695 wxLogStatus(wxT("You pressed \"Cancel\""));
699 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
703 void MyFrame::MessageBoxDialog(wxCommandEvent
& WXUNUSED(event
))
705 TestMessageBoxDialog
dlg(this);
709 void MyFrame::MessageBoxInfo(wxCommandEvent
& WXUNUSED(event
))
711 ::wxInfoMessageBox(this);
713 #endif // wxUSE_MSGDLG
716 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
))
718 long res
= wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n")
719 _T("Even two rows of text."),
720 _T("Enter a number:"), _T("Numeric input test"),
727 msg
= _T("Invalid number entered or dialog cancelled.");
732 msg
.Printf(_T("You've entered %lu"), res
);
733 icon
= wxICON_INFORMATION
;
736 wxMessageBox(msg
, _T("Numeric test result"), wxOK
| icon
, this);
738 #endif // wxUSE_NUMBERDLG
741 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
743 wxString pwd
= wxGetPasswordFromUser(_T("Enter password:"),
744 _T("Password entry dialog"),
749 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
750 _T("Got password"), wxOK
| wxICON_INFORMATION
, this);
754 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
756 wxTextEntryDialog
dialog(this,
757 _T("This is a small sample\n")
758 _T("A long, long string to test out the text entrybox"),
759 _T("Please enter a string"),
763 if (dialog
.ShowModal() == wxID_OK
)
765 wxMessageBox(dialog
.GetValue(), _T("Got string"), wxOK
| wxICON_INFORMATION
, this);
768 #endif // wxUSE_TEXTDLG
771 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
773 const wxString choices
[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
775 wxSingleChoiceDialog
dialog(this,
776 _T("This is a small sample\n")
777 _T("A single-choice convenience dialog"),
778 _T("Please select a value"),
779 WXSIZEOF(choices
), choices
);
781 dialog
.SetSelection(2);
783 if (dialog
.ShowModal() == wxID_OK
)
785 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), _T("Got string"));
790 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
792 const wxString choices
[] =
794 _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
795 _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
796 _T("Eleven"), _T("Twelve"), _T("Seventeen"),
799 wxArrayInt selections
;
800 size_t count
= wxGetMultipleChoices(selections
,
801 _T("This is a small sample\n")
802 _T("A multi-choice convenience dialog"),
803 _T("Please select a value"),
804 WXSIZEOF(choices
), choices
,
809 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
810 for ( size_t n
= 0; n
< count
; n
++ )
812 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
813 (unsigned)n
, (unsigned)selections
[n
],
814 choices
[selections
[n
]].c_str());
818 //else: cancelled or nothing selected
820 #endif // wxUSE_CHOICEDLG
824 // panel with custom controls for file dialog
825 class MyExtraPanel
: public wxPanel
828 MyExtraPanel(wxWindow
*parent
);
829 void OnCheckBox(wxCommandEvent
& event
) { m_btn
->Enable(event
.IsChecked()); }
830 wxString
GetInfo() const
832 return wxString::Format("checkbox value = %d", (int) m_cb
->GetValue());
839 MyExtraPanel::MyExtraPanel(wxWindow
*parent
)
842 m_btn
= new wxButton(this, -1, _T("Custom Button"));
843 m_btn
->Enable(false);
844 m_cb
= new wxCheckBox(this, -1, _T("Enable Custom Button"));
845 m_cb
->Connect(wxID_ANY
, wxEVT_COMMAND_CHECKBOX_CLICKED
,
846 wxCommandEventHandler(MyExtraPanel::OnCheckBox
), NULL
, this);
847 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
848 sizerTop
->Add(m_cb
, wxSizerFlags().Centre().Border());
849 sizerTop
->AddStretchSpacer();
850 sizerTop
->Add(m_btn
, wxSizerFlags().Right().Border());
851 SetSizerAndFit(sizerTop
);
854 // a static method can be used instead of a function with most of compilers
855 static wxWindow
* createMyExtraPanel(wxWindow
*parent
)
857 return new MyExtraPanel(parent
);
860 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
865 _T("Testing open file dialog"),
869 _T("C++ files (*.cpp)|*.cpp")
871 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
875 dialog
.SetExtraControlCreator(&createMyExtraPanel
);
876 dialog
.CentreOnParent();
877 dialog
.SetDirectory(wxGetHomeDir());
879 if (dialog
.ShowModal() == wxID_OK
)
882 MyExtraPanel
*extra_panel
883 = static_cast<MyExtraPanel
*>(dialog
.GetExtraControl());
884 info
.Printf(_T("Full file name: %s\n")
887 _T("Custom window: %s"),
888 dialog
.GetPath().c_str(),
889 dialog
.GetDirectory().c_str(),
890 dialog
.GetFilename().c_str(),
891 extra_panel
->GetInfo().c_str());
892 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
897 // this shows how to take advantage of specifying a default extension in the
898 // call to wxFileSelector: it is remembered after each new call and the next
899 // one will use it by default
900 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
902 static wxString s_extDef
;
903 wxString path
= wxFileSelector(
904 _T("Select the file to load"),
905 wxEmptyString
, wxEmptyString
,
909 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
910 wxFileSelectorDefaultWildcardStr
,
911 wxFileSelectorDefaultWildcardStr
913 wxFD_OPEN
|wxFD_CHANGE_DIR
|wxFD_PREVIEW
,
920 // it is just a sample, would use wxSplitPath in real program
921 s_extDef
= path
.AfterLast(_T('.'));
923 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
927 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
931 _T("C++ files (*.cpp)|*.cpp");
935 _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
936 wxFileSelectorDefaultWildcardStr
,
937 wxFileSelectorDefaultWildcardStr
940 wxFileDialog
dialog(this, _T("Testing open multiple file dialog"),
941 wxEmptyString
, wxEmptyString
, wildcards
,
942 wxFD_OPEN
|wxFD_MULTIPLE
);
944 if (dialog
.ShowModal() == wxID_OK
)
946 wxArrayString paths
, filenames
;
948 dialog
.GetPaths(paths
);
949 dialog
.GetFilenames(filenames
);
952 size_t count
= paths
.GetCount();
953 for ( size_t n
= 0; n
< count
; n
++ )
955 s
.Printf(_T("File %d: %s (%s)\n"),
956 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
960 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
963 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
968 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
970 wxFileDialog
dialog(this,
971 _T("Testing save file dialog"),
974 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
975 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
977 dialog
.SetFilterIndex(1);
979 if (dialog
.ShowModal() == wxID_OK
)
981 wxLogMessage(_T("%s, filter %d"),
982 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
985 #endif // wxUSE_FILEDLG
987 #if USE_FILEDLG_GENERIC
988 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
990 wxGenericFileDialog dialog
993 _T("Testing open file dialog"),
996 _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
999 dialog
.SetExtraControlCreator(&createMyExtraPanel
);
1000 dialog
.SetDirectory(wxGetHomeDir());
1002 if (dialog
.ShowModal() == wxID_OK
)
1005 info
.Printf(_T("Full file name: %s\n")
1008 dialog
.GetPath().c_str(),
1009 dialog
.GetDirectory().c_str(),
1010 dialog
.GetFilename().c_str());
1011 wxMessageDialog
dialog2(this, info
, _T("Selected file"));
1012 dialog2
.ShowModal();
1016 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
1018 // On PocketPC you can disable OK-only dialogs policy using system option
1019 int buttons
= wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
1020 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
1022 wxString wildcards
= _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
1023 wxGenericFileDialog
dialog(this, _T("Testing open multiple file dialog"),
1024 wxEmptyString
, wxEmptyString
, wildcards
,
1027 if (dialog
.ShowModal() == wxID_OK
)
1029 wxArrayString paths
, filenames
;
1031 dialog
.GetPaths(paths
);
1032 dialog
.GetFilenames(filenames
);
1035 size_t count
= paths
.GetCount();
1036 for ( size_t n
= 0; n
< count
; n
++ )
1038 s
.Printf(_T("File %d: %s (%s)\n"),
1039 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
1043 s
.Printf(_T("Filter index: %d"), dialog
.GetFilterIndex());
1046 wxMessageDialog
dialog2(this, msg
, _T("Selected files"));
1047 dialog2
.ShowModal();
1050 // restore system option
1051 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons
);
1054 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
1056 wxGenericFileDialog
dialog(this,
1057 _T("Testing save file dialog"),
1060 _T("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
1061 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1063 dialog
.SetFilterIndex(1);
1065 if (dialog
.ShowModal() == wxID_OK
)
1067 wxLogMessage(_T("%s, filter %d"),
1068 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
1071 #endif // USE_FILEDLG_GENERIC
1074 void MyFrame::DoDirChoose(int style
)
1076 // pass some initial dir to wxDirDialog
1078 wxGetHomeDir(&dirHome
);
1080 wxDirDialog
dialog(this, _T("Testing directory picker"), dirHome
, style
);
1082 if (dialog
.ShowModal() == wxID_OK
)
1084 wxLogMessage(_T("Selected path: %s"), dialog
.GetPath().c_str());
1088 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
1090 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_DIR_MUST_EXIST
);
1093 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
1095 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_DIR_MUST_EXIST
);
1097 #endif // wxUSE_DIRDLG
1099 #if USE_DIRDLG_GENERIC
1100 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
1102 // pass some initial dir to wxDirDialog
1104 wxGetHomeDir(&dirHome
);
1106 wxGenericDirDialog
dialog(this, _T("Testing generic directory picker"), dirHome
);
1108 if (dialog
.ShowModal() == wxID_OK
)
1110 wxMessageDialog
dialog2(this, dialog
.GetPath(), _T("Selected path"));
1111 dialog2
.ShowModal();
1114 #endif // USE_DIRDLG_GENERIC
1116 #if USE_MODAL_PRESENTATION
1117 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
1119 MyModalDialog
dlg(this);
1122 #endif // USE_MODAL_PRESENTATION
1124 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
1126 bool show
= GetMenuBar()->IsChecked(event
.GetId());
1132 m_dialog
= new MyModelessDialog(this);
1135 m_dialog
->Show(true);
1139 // If m_dialog is NULL, then possibly the system
1140 // didn't report the checked menu item status correctly.
1141 // It should be true just after the menu item was selected,
1142 // if there was no modeless dialog yet.
1144 wxASSERT( m_dialog
!= NULL
);
1150 void MyFrame::DlgCenteredScreen(wxCommandEvent
& WXUNUSED(event
))
1152 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on screen"),
1153 wxDefaultPosition
, wxSize(200, 100));
1154 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
1155 dlg
.CentreOnScreen();
1159 void MyFrame::DlgCenteredParent(wxCommandEvent
& WXUNUSED(event
))
1161 wxDialog
dlg(this, wxID_ANY
, _T("Dialog centered on parent"),
1162 wxDefaultPosition
, wxSize(200, 100));
1163 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
1164 dlg
.CentreOnParent();
1168 void MyFrame::MiniFrame(wxCommandEvent
& WXUNUSED(event
))
1170 wxFrame
*frame
= new wxMiniFrame(this, wxID_ANY
, _T("Mini frame"),
1171 wxDefaultPosition
, wxSize(300, 100),
1172 wxCAPTION
| wxCLOSE_BOX
);
1173 new wxStaticText(frame
,
1175 _T("Mini frames have slightly different appearance"),
1177 new wxStaticText(frame
,
1179 _T("from the normal frames but that's the only difference."),
1182 frame
->CentreOnParent();
1186 void MyFrame::DlgOnTop(wxCommandEvent
& WXUNUSED(event
))
1188 wxDialog
dlg(this, wxID_ANY
, _T("Dialog staying on top of other windows"),
1189 wxDefaultPosition
, wxSize(300, 100),
1190 wxDEFAULT_DIALOG_STYLE
| wxSTAY_ON_TOP
);
1191 (new wxButton(&dlg
, wxID_OK
, _T("Close")))->Centre();
1195 #if wxUSE_STARTUP_TIPS
1196 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
1198 static size_t s_index
= (size_t)-1;
1200 if ( s_index
== (size_t)-1 )
1204 // this is completely bogus, we don't know how many lines are there
1205 // in the file, but who cares, it's a demo only...
1206 s_index
= rand() % 5;
1209 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(_T("tips.txt"), s_index
);
1211 bool showAtStartup
= wxShowTip(this, tipProvider
);
1213 if ( showAtStartup
)
1215 wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"),
1216 wxOK
| wxICON_INFORMATION
, this);
1219 s_index
= tipProvider
->GetCurrentTip();
1222 #endif // wxUSE_STARTUP_TIPS
1224 #if USE_SETTINGS_DIALOG
1225 void MyFrame::OnPropertySheet(wxCommandEvent
& event
)
1227 SettingsDialog
dialog(this, event
.GetId());
1230 #endif // USE_SETTINGS_DIALOG
1232 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
1234 wxLogStatus(_T("Sleeping for 3 seconds to allow you to switch to another window"));
1238 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
1241 #if wxUSE_NOTIFICATION_MESSAGE
1243 void MyFrame::OnNotifMsgAuto(wxCommandEvent
& WXUNUSED(event
))
1245 if ( !wxNotificationMessage
1247 "Automatic Notification",
1248 "Nothing important has happened\n"
1249 "this notification will disappear soon."
1252 wxLogStatus("Failed to show notification message");
1256 void MyFrame::OnNotifMsgShow(wxCommandEvent
& WXUNUSED(event
))
1260 m_notifMsg
= new wxNotificationMessage
1262 "wxWidgets Manual Notification",
1263 "You can hide this notification from the menu",
1268 if ( !m_notifMsg
->Show(wxNotificationMessage::Timeout_Never
) )
1270 wxLogStatus("Failed to show manual notification message");
1274 void MyFrame::OnNotifMsgHide(wxCommandEvent
& WXUNUSED(event
))
1278 if ( !m_notifMsg
->Close() )
1279 wxLogStatus("Failed to hide manual notification message");
1283 #endif // wxUSE_NOTIFICATION_MESSAGE
1285 void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent
& WXUNUSED(event
))
1287 StdButtonSizerDialog
dialog(this);
1291 // TestDefaultAction
1293 #define ID_CATCH_LISTBOX_DCLICK 100
1294 #define ID_LISTBOX 101
1296 BEGIN_EVENT_TABLE(TestDefaultActionDialog
, wxDialog
)
1297 EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK
, TestDefaultActionDialog::OnCatchListBoxDClick
)
1298 EVT_LISTBOX_DCLICK(ID_LISTBOX
, TestDefaultActionDialog::OnListBoxDClick
)
1301 TestDefaultActionDialog::TestDefaultActionDialog( wxWindow
*parent
) :
1302 wxDialog( parent
, -1, "Test default action" )
1304 m_catchListBoxDClick
= false;
1306 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
1308 wxFlexGridSizer
*grid_sizer
= new wxFlexGridSizer( 2, 5, 5 );
1310 wxListBox
*listbox
= new wxListBox( this, ID_LISTBOX
);
1311 listbox
->Append( "String 1" );
1312 listbox
->Append( "String 2" );
1313 listbox
->Append( "String 3" );
1314 listbox
->Append( "String 4" );
1315 grid_sizer
->Add( listbox
);
1317 grid_sizer
->Add( new wxCheckBox( this, ID_CATCH_LISTBOX_DCLICK
, "Catch DoubleClick from wxListBox" ), 0, wxALIGN_CENTRE_VERTICAL
);
1319 grid_sizer
->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxSize(80,-1), 0 ), 0, wxALIGN_CENTRE_VERTICAL
);
1320 grid_sizer
->Add( new wxStaticText( this, -1, "wxTextCtrl without wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL
);
1322 grid_sizer
->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxSize(80,-1), wxTE_PROCESS_ENTER
), 0, wxALIGN_CENTRE_VERTICAL
);
1323 grid_sizer
->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL
);
1325 main_sizer
->Add( grid_sizer
, 0, wxALL
, 10 );
1327 wxSizer
*button_sizer
= CreateSeparatedButtonSizer( wxOK
|wxCANCEL
);
1329 main_sizer
->Add( button_sizer
, 0, wxALL
|wxGROW
, 5 );
1331 SetSizerAndFit( main_sizer
);
1334 void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent
& event
)
1336 event
.Skip( !m_catchListBoxDClick
);
1339 void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent
& WXUNUSED(event
))
1341 m_catchListBoxDClick
= !m_catchListBoxDClick
;
1344 void MyFrame::OnTestDefaultActionDialog(wxCommandEvent
& WXUNUSED(event
))
1346 TestDefaultActionDialog
dialog( this );
1350 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1355 #if wxUSE_PROGRESSDLG
1357 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1359 static const int max
= 100;
1361 wxProgressDialog
dialog(_T("Progress dialog example"),
1362 _T("An informative message"),
1368 // wxPD_AUTO_HIDE | -- try this as well
1370 wxPD_ESTIMATED_TIME
|
1372 | wxPD_SMOOTH
// - makes indeterminate mode bar on WinXP very small
1376 for ( int i
= 0; i
<= max
; i
++ )
1382 // test both modes of wxProgressDialog behaviour: start in
1383 // indeterminate mode but switch to the determinate one later
1384 const bool determinate
= i
> max
/2;
1388 msg
= _T("That's all, folks!");
1390 else if ( !determinate
)
1392 msg
= _T("Testing indeterminate mode");
1394 else if ( determinate
)
1396 msg
= _T("Now in standard determinate mode");
1399 // will be set to true if "Skip" button was pressed
1403 cont
= dialog
.Update(i
, msg
, &skip
);
1407 cont
= dialog
.Pulse(msg
, &skip
);
1410 // each skip will move progress about quarter forward
1416 if ( wxMessageBox(_T("Do you really want to cancel?"),
1417 _T("Progress dialog question"), // caption
1418 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1428 wxLogStatus(wxT("Progress dialog aborted!"));
1432 wxLogStatus(wxT("Countdown from %d finished"), max
);
1436 #endif // wxUSE_PROGRESSDLG
1440 static void InitAboutInfoMinimal(wxAboutDialogInfo
& info
)
1442 info
.SetName(_T("Dialogs Sample"));
1443 info
.SetVersion(wxVERSION_NUM_DOT_STRING_T
);
1444 info
.SetDescription(_T("This sample shows different wxWidgets dialogs"));
1445 info
.SetCopyright(_T("(C) 1998-2006 wxWidgets dev team"));
1446 info
.AddDeveloper(_T("Vadim Zeitlin"));
1449 static void InitAboutInfoWebsite(wxAboutDialogInfo
& info
)
1451 InitAboutInfoMinimal(info
);
1453 info
.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
1456 static void InitAboutInfoAll(wxAboutDialogInfo
& info
)
1458 InitAboutInfoWebsite(info
);
1460 // we can add a second developer
1461 info
.AddDeveloper(_T("A.N. Other"));
1463 // or we can add several persons at once like this
1464 static const wxChar
*docwriters
[] =
1466 _T("First D. Writer"),
1470 info
.SetDocWriters(wxArrayString(WXSIZEOF(docwriters
), docwriters
));
1471 info
.SetLicence(wxString::FromAscii(
1472 " wxWindows Library Licence, Version 3.1\n"
1473 " ======================================\n"
1475 " Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
1477 " Everyone is permitted to copy and distribute verbatim copies\n"
1478 " of this licence document, but changing it is not allowed.\n"
1480 " WXWINDOWS LIBRARY LICENCE\n"
1481 " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
1483 " ...and so on and so forth...\n"
1486 info
.AddTranslator(_T("Wun Ngo Wen (Martian)"));
1489 void MyFrame::ShowSimpleAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1491 wxAboutDialogInfo info
;
1492 InitAboutInfoMinimal(info
);
1497 void MyFrame::ShowFancyAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1499 wxAboutDialogInfo info
;
1500 InitAboutInfoWebsite(info
);
1505 void MyFrame::ShowFullAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1507 wxAboutDialogInfo info
;
1508 InitAboutInfoAll(info
);
1513 // a trivial example of a custom dialog class
1514 class MyAboutDialog
: public wxGenericAboutDialog
1517 MyAboutDialog(const wxAboutDialogInfo
& info
)
1522 // add some custom controls
1523 virtual void DoAddCustomControls()
1525 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1526 AddText(_T("Some custom text"));
1527 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1531 void MyFrame::ShowCustomAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1533 wxAboutDialogInfo info
;
1534 InitAboutInfoAll(info
);
1536 MyAboutDialog
dlg(info
);
1540 #endif // wxUSE_ABOUTDLG
1544 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1546 wxWindowDisabler disableAll
;
1548 wxBusyInfo
info(_T("Working, please wait..."), this);
1550 for ( int i
= 0; i
< 18; i
++ )
1560 #endif // wxUSE_BUSYINFO
1562 #if wxUSE_FINDREPLDLG
1564 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1568 delete m_dlgReplace
;
1569 m_dlgReplace
= NULL
;
1573 m_dlgReplace
= new wxFindReplaceDialog
1577 _T("Find and replace dialog"),
1581 m_dlgReplace
->Show(true);
1585 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1594 m_dlgFind
= new wxFindReplaceDialog
1603 m_dlgFind
->Show(true);
1607 static wxString
DecodeFindDialogEventFlags(int flags
)
1610 str
<< (flags
& wxFR_DOWN
? _T("down") : _T("up")) << _T(", ")
1611 << (flags
& wxFR_WHOLEWORD
? _T("whole words only, ") : _T(""))
1612 << (flags
& wxFR_MATCHCASE
? _T("") : _T("not "))
1613 << _T("case sensitive");
1618 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
1620 wxEventType type
= event
.GetEventType();
1622 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
1624 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
1625 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
1626 event
.GetFindString().c_str(),
1627 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1629 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
1630 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
1632 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
1633 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? _T("all ") : wxT(""),
1634 event
.GetFindString().c_str(),
1635 event
.GetReplaceString().c_str(),
1636 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
1638 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
1640 wxFindReplaceDialog
*dlg
= event
.GetDialog();
1644 if ( dlg
== m_dlgFind
)
1647 idMenu
= DIALOGS_FIND
;
1650 else if ( dlg
== m_dlgReplace
)
1652 txt
= _T("Replace");
1653 idMenu
= DIALOGS_REPLACE
;
1654 m_dlgReplace
= NULL
;
1658 txt
= _T("Unknown");
1661 wxFAIL_MSG( _T("unexpected event") );
1664 wxLogMessage(wxT("%s dialog is being closed."), txt
);
1666 if ( idMenu
!= wxID_ANY
)
1668 GetMenuBar()->Check(idMenu
, false);
1675 wxLogError(wxT("Unknown find dialog event!"));
1679 #endif // wxUSE_FINDREPLDLG
1681 // ----------------------------------------------------------------------------
1683 // ----------------------------------------------------------------------------
1685 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
1688 dc
.SetFont(wxGetApp().m_canvasFont
);
1689 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
1690 dc
.SetBackgroundMode(wxTRANSPARENT
);
1692 _T("wxWidgets common dialogs")
1693 #if !defined(__SMARTPHONE__)
1694 _T(" test application")
1699 #if USE_MODAL_PRESENTATION
1701 // ----------------------------------------------------------------------------
1703 // ----------------------------------------------------------------------------
1705 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
1706 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modeless dialog")))
1708 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
1710 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, _T("Press me"));
1711 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, _T("Should be disabled"));
1714 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
1715 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
1717 SetSizerAndFit(sizerTop
);
1720 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
1722 wxMessageBox(_T("Button pressed in modeless dialog"), _T("Info"),
1723 wxOK
| wxICON_INFORMATION
, this);
1726 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
1728 if ( event
.CanVeto() )
1730 wxMessageBox(_T("Use the menu item to close this dialog"),
1731 _T("Modeless dialog"),
1732 wxOK
| wxICON_INFORMATION
, this);
1738 // ----------------------------------------------------------------------------
1740 // ----------------------------------------------------------------------------
1742 MyModalDialog::MyModalDialog(wxWindow
*parent
)
1743 : wxDialog(parent
, wxID_ANY
, wxString(_T("Modal dialog")))
1745 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1747 m_btnModal
= new wxButton(this, wxID_ANY
, _T("&Modal dialog..."));
1748 m_btnModeless
= new wxButton(this, wxID_ANY
, _T("Mode&less dialog"));
1749 m_btnDelete
= new wxButton(this, wxID_ANY
, _T("&Delete button"));
1751 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _T("&Close"));
1752 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
1753 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
1754 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
1755 sizerTop
->Add(btnOk
, 0, wxALIGN_CENTER
| wxALL
, 5);
1757 SetSizerAndFit(sizerTop
);
1759 m_btnModal
->SetFocus();
1760 m_btnModal
->SetDefault();
1763 void MyModalDialog::OnButton(wxCommandEvent
& event
)
1765 if ( event
.GetEventObject() == m_btnDelete
)
1770 m_btnDelete
->Disable();
1772 else if ( event
.GetEventObject() == m_btnModal
)
1775 wxGetTextFromUser(_T("Dummy prompt"),
1776 _T("Modal dialog called from dialog"),
1777 wxEmptyString
, this);
1779 wxMessageBox(_T("Modal dialog called from dialog"));
1780 #endif // wxUSE_TEXTDLG
1782 else if ( event
.GetEventObject() == m_btnModeless
)
1784 (new MyModelessDialog(this))->Show();
1792 #endif // USE_MODAL_PRESENTATION
1794 // ----------------------------------------------------------------------------
1795 // StdButtonSizerDialog
1796 // ----------------------------------------------------------------------------
1798 StdButtonSizerDialog::StdButtonSizerDialog(wxWindow
*parent
)
1799 : wxDialog(parent
, wxID_ANY
, wxString(_T("StdButtonSizer dialog")),
1800 wxDefaultPosition
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
),
1801 m_buttonsSizer(NULL
)
1803 wxBoxSizer
*const sizerTop
= new wxBoxSizer(wxVERTICAL
);
1805 wxBoxSizer
*const sizer
= new wxBoxSizer(wxHORIZONTAL
);
1806 wxBoxSizer
*const sizerInside1
= new wxBoxSizer(wxVERTICAL
);
1808 m_chkboxAffirmativeButton
= new wxCheckBox(this, wxID_ANY
, _("Enable Affirmative Button"));
1810 wxStaticBoxSizer
*const sizer1
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Affirmative Button"));
1812 m_radiobtnOk
= new wxRadioButton(this, wxID_ANY
, _("Ok"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
1813 m_radiobtnYes
= new wxRadioButton(this, wxID_ANY
, _("Yes"));
1815 wxBoxSizer
*const sizerInside2
= new wxBoxSizer(wxVERTICAL
);
1817 m_chkboxDismissButton
= new wxCheckBox(this, wxID_ANY
, _("Enable Dismiss Button"));
1819 wxStaticBoxSizer
*const sizer2
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Dismiss Button"));
1821 m_radiobtnCancel
= new wxRadioButton(this, wxID_ANY
, _("Cancel"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
1822 m_radiobtnClose
= new wxRadioButton(this, wxID_ANY
, _("Close"));
1824 wxBoxSizer
*const sizer3
= new wxBoxSizer(wxHORIZONTAL
);
1826 m_chkboxNo
= new wxCheckBox(this, wxID_ANY
, _("No"));
1827 m_chkboxHelp
= new wxCheckBox(this, wxID_ANY
, _("Help"));
1828 m_chkboxApply
= new wxCheckBox(this, wxID_ANY
, _("Apply"));
1830 m_chkboxNoDefault
= new wxCheckBox(this, wxID_ANY
, wxT("No Default"));
1832 sizer1
->Add(m_radiobtnOk
, 0, wxALL
, 5);
1833 sizer1
->Add(m_radiobtnYes
, 0, wxALL
, 5);
1835 sizer
->Add(sizerInside1
, 0, 0, 0);
1836 sizerInside1
->Add(m_chkboxAffirmativeButton
, 0, wxALL
, 5);
1837 sizerInside1
->Add(sizer1
, 0, wxALL
, 5);
1838 sizerInside1
->SetItemMinSize(sizer1
, sizer1
->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1840 sizer2
->Add(m_radiobtnCancel
, 0, wxALL
, 5);
1841 sizer2
->Add(m_radiobtnClose
, 0, wxALL
, 5);
1843 sizer
->Add(sizerInside2
, 0, 0, 0);
1844 sizerInside2
->Add(m_chkboxDismissButton
, 0, wxALL
, 5);
1845 sizerInside2
->Add(sizer2
, 0, wxALL
, 5);
1846 sizerInside2
->SetItemMinSize(sizer2
, sizer2
->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
1848 sizerTop
->Add(sizer
, 0, wxALL
, 5);
1850 sizer3
->Add(m_chkboxNo
, 0, wxALL
, 5);
1851 sizer3
->Add(m_chkboxHelp
, 0, wxALL
, 5);
1852 sizer3
->Add(m_chkboxApply
, 0, wxALL
, 5);
1854 sizerTop
->Add(sizer3
, 0, wxALL
, 5);
1856 sizerTop
->Add(m_chkboxNoDefault
, 0, wxLEFT
|wxRIGHT
, 10);
1858 EnableDisableControls();
1860 SetSizerAndFit(sizerTop
);
1866 void StdButtonSizerDialog::OnEvent(wxCommandEvent
& WXUNUSED(event
))
1870 m_buttonsSizer
->DeleteWindows();
1871 GetSizer()->Remove(m_buttonsSizer
);
1874 EnableDisableControls();
1877 unsigned long numButtons
= 0;
1879 if (m_chkboxAffirmativeButton
->IsChecked())
1881 if (m_radiobtnOk
->GetValue())
1886 else if (m_radiobtnYes
->GetValue())
1893 if (m_chkboxDismissButton
->IsChecked())
1895 if (m_radiobtnCancel
->GetValue())
1901 else if (m_radiobtnClose
->GetValue())
1909 if (m_chkboxApply
->IsChecked())
1915 if (m_chkboxNo
->IsChecked())
1921 if (m_chkboxHelp
->IsChecked())
1927 if (m_chkboxNoDefault
->IsChecked())
1929 flags
|= wxNO_DEFAULT
;
1932 m_buttonsSizer
= CreateStdDialogButtonSizer(flags
);
1933 GetSizer()->Add(m_buttonsSizer
, 0, wxGROW
|wxALL
, 5);
1936 GetSizer()->SetSizeHints(this);
1939 void StdButtonSizerDialog::EnableDisableControls()
1941 const bool affButtonEnabled
= m_chkboxAffirmativeButton
->IsChecked();
1943 m_radiobtnOk
->Enable(affButtonEnabled
);
1944 m_radiobtnYes
->Enable(affButtonEnabled
);
1946 const bool dismissButtonEnabled
= m_chkboxDismissButton
->IsChecked();
1948 m_radiobtnCancel
->Enable(dismissButtonEnabled
);
1949 m_radiobtnClose
->Enable(dismissButtonEnabled
);
1952 #if USE_SETTINGS_DIALOG
1953 // ----------------------------------------------------------------------------
1955 // ----------------------------------------------------------------------------
1957 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
1959 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
1962 SettingsDialog::SettingsDialog(wxWindow
* win
, int dialogType
)
1964 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
1969 bool useToolBook
= (dialogType
== DIALOGS_PROPERTY_SHEET_TOOLBOOK
|| dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
);
1970 int resizeBorder
= wxRESIZE_BORDER
;
1978 int sheetStyle
= wxPROPSHEET_SHRINKTOFIT
;
1979 if (dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
)
1980 sheetStyle
|= wxPROPSHEET_BUTTONTOOLBOOK
;
1982 sheetStyle
|= wxPROPSHEET_TOOLBOOK
;
1984 SetSheetStyle(sheetStyle
);
1985 SetSheetInnerBorder(0);
1986 SetSheetOuterBorder(0);
1988 // create a dummy image list with a few icons
1989 const wxSize
imageSize(32, 32);
1991 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
1993 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
1995 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
1997 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
1999 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
2004 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
2005 wxDEFAULT_DIALOG_STYLE
| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, resizeBorder
)
2008 // If using a toolbook, also follow Mac style and don't create buttons
2010 CreateButtons(wxOK
| wxCANCEL
|
2011 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, wxHELP
)
2014 wxBookCtrlBase
* notebook
= GetBookCtrl();
2015 notebook
->SetImageList(m_imageList
);
2017 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
2018 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
2020 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
2021 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
2026 SettingsDialog::~SettingsDialog()
2031 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
2033 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
2035 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
2036 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
2040 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
2041 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
2042 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2043 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
2047 wxString autoSaveLabel
= _("&Auto-save every");
2048 wxString minsLabel
= _("mins");
2050 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
2051 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
2054 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
2055 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
2058 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2060 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2062 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2063 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
2067 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
2068 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
2069 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2070 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
2072 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
2074 panel
->SetSizerAndFit(topSizer
);
2079 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
2081 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
2083 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
2084 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
2086 //// PROJECT OR GLOBAL
2087 wxString globalOrProjectChoices
[2];
2088 globalOrProjectChoices
[0] = _("&New projects");
2089 globalOrProjectChoices
[1] = _("&This project");
2091 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
2092 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
2093 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
2095 projectOrGlobal
->SetSelection(0);
2097 //// BACKGROUND STYLE
2098 wxArrayString backgroundStyleChoices
;
2099 backgroundStyleChoices
.Add(wxT("Colour"));
2100 backgroundStyleChoices
.Add(wxT("Image"));
2101 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
2103 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
2104 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
2106 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
2108 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
2110 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2111 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
2112 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2114 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
2117 //// FONT SIZE SELECTION
2119 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
2120 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
2122 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
2123 wxSize(80, wxDefaultCoord
));
2124 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
2126 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
2129 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
2130 topSizer
->AddSpacer(5);
2132 panel
->SetSizerAndFit(topSizer
);
2137 // ----------------------------------------------------------------------------
2138 // TestMessageBoxDialog
2139 // ----------------------------------------------------------------------------
2142 const TestMessageBoxDialog::BtnInfo
TestMessageBoxDialog::ms_btnInfo
[] =
2147 { wxCANCEL
, "&Cancel" },
2150 BEGIN_EVENT_TABLE(TestMessageBoxDialog
, wxDialog
)
2151 EVT_BUTTON(wxID_APPLY
, TestMessageBoxDialog::OnApply
)
2152 EVT_BUTTON(wxID_CLOSE
, TestMessageBoxDialog::OnClose
)
2155 TestMessageBoxDialog::TestMessageBoxDialog(wxWindow
*parent
)
2156 : wxDialog(parent
, wxID_ANY
, "Message Box Test Dialog",
2157 wxDefaultPosition
, wxDefaultSize
,
2158 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
2160 wxSizer
* const sizerTop
= new wxBoxSizer(wxVERTICAL
);
2162 // this sizer allows to configure the messages shown in the message box
2164 sizerMsgs
= new wxStaticBoxSizer(wxVERTICAL
, this, "&Messages");
2165 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Main message:"));
2166 m_textMsg
= new wxTextCtrl(this, wxID_ANY
, "Hello from a box!",
2167 wxDefaultPosition
, wxDefaultSize
,
2169 sizerMsgs
->Add(m_textMsg
, wxSizerFlags(1).Expand().Border(wxBOTTOM
));
2171 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Extended message:"));
2172 m_textExtMsg
= new wxTextCtrl(this, wxID_ANY
, "",
2173 wxDefaultPosition
, wxDefaultSize
,
2175 sizerMsgs
->Add(m_textExtMsg
, wxSizerFlags(1).Expand());
2177 sizerTop
->Add(sizerMsgs
, wxSizerFlags(1).Expand().Border());
2180 // this one is for configuring the buttons
2181 wxFlexGridSizer
* const sizerBtns
= new wxFlexGridSizer(2, 5, 5);
2182 sizerBtns
->AddGrowableCol(1);
2184 sizerBtns
->Add(new wxStaticText(this, wxID_ANY
, "Button(s)"));
2185 sizerBtns
->Add(new wxStaticText(this, wxID_ANY
, "Custom label"));
2187 for ( int n
= 0; n
< Btn_Max
; n
++ )
2189 m_buttons
[n
] = new wxCheckBox(this, wxID_ANY
, ms_btnInfo
[n
].name
);
2190 sizerBtns
->Add(m_buttons
[n
], wxSizerFlags().Centre().Left());
2192 m_labels
[n
] = new wxTextCtrl(this, wxID_ANY
);
2193 sizerBtns
->Add(m_labels
[n
], wxSizerFlags(1).Centre().Expand());
2195 m_labels
[n
]->Connect(wxEVT_UPDATE_UI
,
2196 wxUpdateUIEventHandler(
2197 TestMessageBoxDialog::OnUpdateLabelUI
),
2203 sizerBtnsBox
= new wxStaticBoxSizer(wxVERTICAL
, this, "&Buttons");
2204 sizerBtnsBox
->Add(sizerBtns
, wxSizerFlags(1).Expand());
2205 sizerTop
->Add(sizerBtnsBox
, wxSizerFlags().Expand().Border());
2209 const wxString icons
[] = {
2210 "&Information", "&Question", "&Warning", "&Error"
2213 m_icons
= new wxRadioBox(this, wxID_ANY
, "&Icon:",
2214 wxDefaultPosition
, wxDefaultSize
,
2215 WXSIZEOF(icons
), icons
);
2216 sizerTop
->Add(m_icons
, wxSizerFlags().Expand().Border());
2219 // miscellaneous other stuff
2221 sizerFlags
= new wxStaticBoxSizer(wxHORIZONTAL
, this, "&Other flags");
2223 m_chkNoDefault
= new wxCheckBox(this, wxID_ANY
, "Make \"No\" &default");
2224 m_chkNoDefault
->Connect(wxEVT_UPDATE_UI
,
2225 wxUpdateUIEventHandler(
2226 TestMessageBoxDialog::OnUpdateNoDefaultUI
),
2229 sizerFlags
->Add(m_chkNoDefault
, wxSizerFlags(1).Border());
2231 m_chkCentre
= new wxCheckBox(this, wxID_ANY
, "Centre on &parent");
2232 sizerFlags
->Add(m_chkCentre
, wxSizerFlags(1).Border());
2234 sizerTop
->Add(sizerFlags
, wxSizerFlags().Expand().Border());
2236 // finally buttons to show the resulting message box and close this dialog
2237 sizerTop
->Add(CreateStdDialogButtonSizer(wxAPPLY
| wxCLOSE
),
2238 wxSizerFlags().Right().Border());
2240 SetSizerAndFit(sizerTop
);
2242 m_buttons
[Btn_Ok
]->SetValue(true);
2245 void TestMessageBoxDialog::OnUpdateLabelUI(wxUpdateUIEvent
& event
)
2247 for ( int n
= 0; n
< Btn_Max
; n
++ )
2249 if ( event
.GetEventObject() == m_labels
[n
] )
2251 event
.Enable( m_buttons
[n
]->IsChecked() );
2256 wxFAIL_MSG( "called for unknown label" );
2259 void TestMessageBoxDialog::OnUpdateNoDefaultUI(wxUpdateUIEvent
& event
)
2261 event
.Enable( m_buttons
[Btn_No
]->IsChecked() );
2264 void TestMessageBoxDialog::OnApply(wxCommandEvent
& WXUNUSED(event
))
2268 for ( int n
= 0; n
< Btn_Max
; n
++ )
2270 if ( m_buttons
[n
]->IsChecked() )
2271 style
|= ms_btnInfo
[n
].flag
;
2274 switch ( m_icons
->GetSelection() )
2276 case 0: style
|= wxICON_INFORMATION
; break;
2277 case 1: style
|= wxICON_QUESTION
; break;
2278 case 2: style
|= wxICON_WARNING
; break;
2279 case 3: style
|= wxICON_ERROR
; break;
2282 if ( m_chkCentre
->IsChecked() )
2285 if ( m_chkNoDefault
->IsEnabled() && m_chkNoDefault
->IsChecked() )
2286 style
|= wxNO_DEFAULT
;
2289 wxMessageDialog
dlg(this, m_textMsg
->GetValue(), "Test Message Box",
2291 if ( !m_textExtMsg
->IsEmpty() )
2292 dlg
.SetExtendedMessage(m_textExtMsg
->GetValue());
2294 if ( style
& wxYES_NO
)
2296 if ( style
& wxCANCEL
)
2298 dlg
.SetYesNoCancelLabels(m_labels
[Btn_Yes
]->GetValue(),
2299 m_labels
[Btn_No
]->GetValue(),
2300 m_labels
[Btn_Cancel
]->GetValue());
2304 dlg
.SetYesNoLabels(m_labels
[Btn_Yes
]->GetValue(),
2305 m_labels
[Btn_No
]->GetValue());
2310 if ( style
& wxCANCEL
)
2312 dlg
.SetOKCancelLabels(m_labels
[Btn_Ok
]->GetValue(),
2313 m_labels
[Btn_Cancel
]->GetValue());
2317 dlg
.SetOKLabel(m_labels
[Btn_Ok
]->GetValue());
2324 void TestMessageBoxDialog::OnClose(wxCommandEvent
& WXUNUSED(event
))
2326 EndModal(wxID_CANCEL
);
2329 #endif // USE_SETTINGS_DIALOG