1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart, Vadim Zeitlin, ABX
7 // Copyright: (c) Julian Smart
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx/wx.h".
14 #include "wx/wxprec.h"
24 #include "../sample.xpm"
26 #include "wx/apptrait.h"
27 #include "wx/datetime.h"
29 #include "wx/bookctrl.h"
30 #include "wx/artprov.h"
31 #include "wx/imaglist.h"
32 #include "wx/minifram.h"
33 #include "wx/sysopt.h"
34 #include "wx/notifmsg.h"
37 #include "wx/colordlg.h"
38 #endif // wxUSE_COLOURDLG
41 #include "wx/choicdlg.h"
42 #endif // wxUSE_CHOICEDLG
44 #include "wx/rearrangectrl.h"
46 #if wxUSE_STARTUP_TIPS
47 #include "wx/tipdlg.h"
48 #endif // wxUSE_STARTUP_TIPS
51 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
52 #include "wx/datetime.h" // wxDateTime
55 #include "wx/progdlg.h"
56 #endif // wxUSE_PROGRESSDLG
59 #include "wx/aboutdlg.h"
61 // these headers are only needed for custom about dialog
62 #include "wx/statline.h"
63 #include "wx/generic/aboutdlgg.h"
64 #endif // wxUSE_ABOUTDLG
67 #include "wx/busyinfo.h"
68 #endif // wxUSE_BUSYINFO
71 #include "wx/numdlg.h"
72 #endif // wxUSE_NUMBERDLG
75 #include "wx/filedlg.h"
76 #endif // wxUSE_FILEDLG
79 #include "wx/dirdlg.h"
80 #endif // wxUSE_DIRDLG
83 #include "wx/fontdlg.h"
84 #endif // wxUSE_FONTDLG
87 #include "wx/fdrepdlg.h"
88 #endif // wxUSE_FINDREPLDLG
91 #include "wx/infobar.h"
92 #endif // wxUSE_INFOBAR
94 #include "wx/spinctrl.h"
95 #include "wx/propdlg.h"
99 #if USE_COLOURDLG_GENERIC
100 #include "wx/generic/colrdlgg.h"
101 #endif // USE_COLOURDLG_GENERIC
103 #if USE_DIRDLG_GENERIC
104 #include "wx/generic/dirdlgg.h"
105 #endif // USE_DIRDLG_GENERIC
107 #if USE_FILEDLG_GENERIC
108 #include "wx/generic/filedlgg.h"
109 #endif // USE_FILEDLG_GENERIC
111 #if USE_FONTDLG_GENERIC
112 #include "wx/generic/fontdlgg.h"
113 #endif // USE_FONTDLG_GENERIC
117 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
118 EVT_PAINT(MyCanvas::OnPaint
)
123 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
125 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
126 EVT_MENU(DIALOGS_MESSAGE_BOX_WINDOW_MODAL
, MyFrame::MessageBoxWindowModal
)
127 EVT_MENU(DIALOGS_MESSAGE_DIALOG
, MyFrame::MessageBoxDialog
)
128 EVT_MENU(DIALOGS_MESSAGE_BOX_WXINFO
, MyFrame::MessageBoxInfo
)
129 #endif // wxUSE_MSGDLG
131 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
132 EVT_MENU(DIALOGS_GET_COLOUR
, MyFrame::GetColour
)
133 #endif // wxUSE_COLOURDLG
136 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
137 #endif // wxUSE_FONTDLG
140 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
141 #endif // wxUSE_LOG_DIALOG
143 EVT_MENU(DIALOGS_INFOBAR_SIMPLE
, MyFrame::InfoBarSimple
)
144 EVT_MENU(DIALOGS_INFOBAR_ADVANCED
, MyFrame::InfoBarAdvanced
)
145 #endif // wxUSE_INFOBAR
148 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
149 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
150 #endif // wxUSE_TEXTDLG
153 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
154 #endif // wxUSE_NUMBERDLG
157 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
158 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
159 #endif // wxUSE_CHOICEDLG
161 #if wxUSE_REARRANGECTRL
162 EVT_MENU(DIALOGS_REARRANGE
, MyFrame::Rearrange
)
163 #endif // wxUSE_REARRANGECTRL
166 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
167 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
168 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
169 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
170 #endif // wxUSE_FILEDLG
172 #if USE_FILEDLG_GENERIC
173 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
174 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
175 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
176 #endif // USE_FILEDLG_GENERIC
179 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
180 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
181 #endif // wxUSE_DIRDLG
183 #if USE_MODAL_PRESENTATION
184 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
185 #endif // USE_MODAL_PRESENTATION
186 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
187 EVT_MENU(DIALOGS_CENTRE_SCREEN
, MyFrame::DlgCenteredScreen
)
188 EVT_MENU(DIALOGS_CENTRE_PARENT
, MyFrame::DlgCenteredParent
)
190 EVT_MENU(DIALOGS_MINIFRAME
, MyFrame::MiniFrame
)
191 #endif // wxUSE_MINIFRAME
192 EVT_MENU(DIALOGS_ONTOP
, MyFrame::DlgOnTop
)
194 #if wxUSE_STARTUP_TIPS
195 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
196 #endif // wxUSE_STARTUP_TIPS
198 #if USE_FONTDLG_GENERIC
199 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
200 #endif // USE_FONTDLG_GENERIC
202 #if USE_DIRDLG_GENERIC
203 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
204 #endif // wxMSW || wxMAC
206 #if USE_COLOURDLG_GENERIC
207 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
208 #endif // USE_COLOURDLG_GENERIC
210 #if wxUSE_PROGRESSDLG
211 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
212 #endif // wxUSE_PROGRESSDLG
215 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE
, MyFrame::ShowSimpleAboutDialog
)
216 EVT_MENU(DIALOGS_ABOUTDLG_FANCY
, MyFrame::ShowFancyAboutDialog
)
217 EVT_MENU(DIALOGS_ABOUTDLG_FULL
, MyFrame::ShowFullAboutDialog
)
218 EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM
, MyFrame::ShowCustomAboutDialog
)
219 #endif // wxUSE_ABOUTDLG
222 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
223 #endif // wxUSE_BUSYINFO
225 #if wxUSE_FINDREPLDLG
226 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
227 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
229 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
230 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
231 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
232 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
233 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
234 #endif // wxUSE_FINDREPLDLG
236 #if USE_SETTINGS_DIALOG
237 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
238 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheet
)
239 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, MyFrame::OnPropertySheet
)
240 #endif // USE_SETTINGS_DIALOG
242 EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
, MyFrame::OnStandardButtonsSizerDialog
)
243 EVT_MENU(DIALOGS_TEST_DEFAULT_ACTION
, MyFrame::OnTestDefaultActionDialog
)
245 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
246 #if wxUSE_NOTIFICATION_MESSAGE
247 EVT_MENU(DIALOGS_NOTIFY_AUTO
, MyFrame::OnNotifMsgAuto
)
248 EVT_MENU(DIALOGS_NOTIFY_SHOW
, MyFrame::OnNotifMsgShow
)
249 EVT_MENU(DIALOGS_NOTIFY_HIDE
, MyFrame::OnNotifMsgHide
)
250 #endif // wxUSE_NOTIFICATION_MESSAGE
252 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
255 #if USE_MODAL_PRESENTATION
257 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
258 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
261 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
262 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
263 EVT_CLOSE(MyModelessDialog::OnClose
)
266 #endif // USE_MODAL_PRESENTATION
268 BEGIN_EVENT_TABLE(StdButtonSizerDialog
, wxDialog
)
269 EVT_CHECKBOX(wxID_ANY
, StdButtonSizerDialog::OnEvent
)
270 EVT_RADIOBUTTON(wxID_ANY
, StdButtonSizerDialog::OnEvent
)
273 // `Main program' equivalent, creating windows and returning main app frame
276 if ( !wxApp::OnInit() )
280 wxInitAllImageHandlers();
283 // Create the main frame window
284 MyFrame
*frame
= new MyFrame(wxT("wxWidgets dialogs example"));
287 wxMenu
*menuDlg
= new wxMenu
;
289 menuDlg
->Append(DIALOGS_MESSAGE_BOX
, wxT("&Message box\tCtrl-M"));
290 menuDlg
->Append(DIALOGS_MESSAGE_BOX_WINDOW_MODAL
, wxT("Window-Modal Message box "));
291 menuDlg
->Append(DIALOGS_MESSAGE_DIALOG
, wxT("Message dialog\tShift-Ctrl-M"));
294 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
296 wxMenu
*choices_menu
= new wxMenu
;
299 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, wxT("&Choose bg colour"));
300 choices_menu
->Append(DIALOGS_GET_COLOUR
, wxT("&Choose fg colour"));
301 #endif // wxUSE_COLOURDLG
304 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, wxT("Choose &font"));
305 #endif // wxUSE_FONTDLG
308 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, wxT("&Single choice\tCtrl-C"));
309 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, wxT("M&ultiple choice\tCtrl-U"));
310 #endif // wxUSE_CHOICEDLG
312 #if wxUSE_REARRANGECTRL
313 choices_menu
->Append(DIALOGS_REARRANGE
, wxT("&Rearrange dialog\tCtrl-R"));
314 #endif // wxUSE_REARRANGECTRL
316 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
317 choices_menu
->AppendSeparator();
318 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
320 #if USE_COLOURDLG_GENERIC
321 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, wxT("&Choose colour (generic)"));
322 #endif // USE_COLOURDLG_GENERIC
324 #if USE_FONTDLG_GENERIC
325 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, wxT("Choose &font (generic)"));
326 #endif // USE_FONTDLG_GENERIC
328 menuDlg
->Append(wxID_ANY
,wxT("&Choices and selectors"),choices_menu
);
329 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
332 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
334 wxMenu
*entry_menu
= new wxMenu
;
337 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, wxT("Text &entry\tCtrl-E"));
338 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, wxT("&Password entry\tCtrl-P"));
339 #endif // wxUSE_TEXTDLG
342 entry_menu
->Append(DIALOGS_NUM_ENTRY
, wxT("&Numeric entry\tCtrl-N"));
343 #endif // wxUSE_NUMBERDLG
345 menuDlg
->Append(wxID_ANY
,wxT("&Entry dialogs"),entry_menu
);
347 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
352 wxMenu
*filedlg_menu
= new wxMenu
;
353 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, wxT("&Open file\tCtrl-O"));
354 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, wxT("&Second open file\tCtrl-2"));
355 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, wxT("Open &files\tCtrl-Q"));
356 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, wxT("Sa&ve file\tCtrl-S"));
358 #if USE_FILEDLG_GENERIC
359 filedlg_menu
->AppendSeparator();
360 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, wxT("&Open file (generic)"));
361 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, wxT("Open &files (generic)"));
362 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, wxT("Sa&ve file (generic)"));
363 #endif // USE_FILEDLG_GENERIC
365 menuDlg
->Append(wxID_ANY
,wxT("&File operations"),filedlg_menu
);
367 #endif // wxUSE_FILEDLG
370 wxMenu
*dir_menu
= new wxMenu
;
372 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, wxT("&Choose a directory\tCtrl-D"));
373 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, wxT("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
374 menuDlg
->Append(wxID_ANY
,wxT("&Directory operations"),dir_menu
);
376 #if USE_DIRDLG_GENERIC
377 dir_menu
->AppendSeparator();
378 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, wxT("&Choose a directory (generic)"));
379 #endif // USE_DIRDLG_GENERIC
381 #endif // wxUSE_DIRDLG
384 #if wxUSE_STARTUP_TIPS || \
385 wxUSE_PROGRESSDLG || \
387 wxUSE_LOG_DIALOG || \
390 wxMenu
*info_menu
= new wxMenu
;
392 #if wxUSE_STARTUP_TIPS
393 info_menu
->Append(DIALOGS_TIP
, wxT("&Tip of the day\tCtrl-T"));
394 #endif // wxUSE_STARTUP_TIPS
396 #if wxUSE_PROGRESSDLG
397 info_menu
->Append(DIALOGS_PROGRESS
, wxT("Pro&gress dialog\tCtrl-G"));
398 #endif // wxUSE_PROGRESSDLG
401 info_menu
->Append(DIALOGS_BUSYINFO
, wxT("&Busy info dialog\tCtrl-B"));
402 #endif // wxUSE_BUSYINFO
405 info_menu
->Append(DIALOGS_LOG_DIALOG
, wxT("&Log dialog\tCtrl-L"));
406 #endif // wxUSE_LOG_DIALOG
409 info_menu
->Append(DIALOGS_INFOBAR_SIMPLE
, "Simple &info bar\tCtrl-I");
410 info_menu
->Append(DIALOGS_INFOBAR_ADVANCED
, "&Advanced info bar\tShift-Ctrl-I");
411 #endif // wxUSE_INFOBAR
414 info_menu
->Append(DIALOGS_MESSAGE_BOX_WXINFO
,
415 wxT("&wxWidgets information\tCtrl-W"));
416 #endif // wxUSE_MSGDLG
418 menuDlg
->Append(wxID_ANY
,wxT("&Informative dialogs"),info_menu
);
420 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
423 #if wxUSE_FINDREPLDLG
424 wxMenu
*find_menu
= new wxMenu
;
425 find_menu
->AppendCheckItem(DIALOGS_FIND
, wxT("&Find dialog\tCtrl-F"));
426 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, wxT("Find and &replace dialog\tShift-Ctrl-F"));
427 menuDlg
->Append(wxID_ANY
,wxT("&Searching"),find_menu
);
428 #endif // wxUSE_FINDREPLDLG
430 wxMenu
*dialogs_menu
= new wxMenu
;
431 #if USE_MODAL_PRESENTATION
432 dialogs_menu
->Append(DIALOGS_MODAL
, wxT("&Modal dialog\tShift-Ctrl-W"));
433 #endif // USE_MODAL_PRESENTATION
434 dialogs_menu
->AppendCheckItem(DIALOGS_MODELESS
, wxT("Mode&less dialog\tShift-Ctrl-Z"));
435 dialogs_menu
->Append(DIALOGS_CENTRE_SCREEN
, wxT("Centered on &screen\tShift-Ctrl-1"));
436 dialogs_menu
->Append(DIALOGS_CENTRE_PARENT
, wxT("Centered on &parent\tShift-Ctrl-2"));
438 dialogs_menu
->Append(DIALOGS_MINIFRAME
, wxT("&Mini frame"));
439 #endif // wxUSE_MINIFRAME
440 dialogs_menu
->Append(DIALOGS_ONTOP
, wxT("Dialog staying on &top"));
441 menuDlg
->Append(wxID_ANY
, wxT("&Generic dialogs"), dialogs_menu
);
443 #if USE_SETTINGS_DIALOG
444 wxMenu
*sheet_menu
= new wxMenu
;
445 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET
, wxT("&Standard property sheet\tShift-Ctrl-P"));
446 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, wxT("&Toolbook sheet\tShift-Ctrl-T"));
448 if (wxPlatformIs(wxPORT_MAC
))
449 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, wxT("Button &Toolbook sheet\tShift-Ctrl-U"));
452 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, wxT("Button &Toolbook sheet\tShift-Ctrl-U"));
455 menuDlg
->Append(wxID_ANY
, wxT("&Property sheets"), sheet_menu
);
456 #endif // USE_SETTINGS_DIALOG
458 wxMenu
*menuNotif
= new wxMenu
;
459 menuNotif
->Append(DIALOGS_REQUEST
, wxT("&Request user attention\tCtrl-Shift-R"));
460 #if wxUSE_NOTIFICATION_MESSAGE
461 menuNotif
->Append(DIALOGS_NOTIFY_AUTO
, "&Automatically hidden notification");
462 menuNotif
->Append(DIALOGS_NOTIFY_SHOW
, "&Show manual notification");
463 menuNotif
->Append(DIALOGS_NOTIFY_HIDE
, "&Hide manual notification");
464 #endif // wxUSE_NOTIFICATION_MESSAGE
465 menuDlg
->AppendSubMenu(menuNotif
, "&User notifications");
467 menuDlg
->Append(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
, wxT("&Standard Buttons Sizer Dialog"));
468 menuDlg
->Append(DIALOGS_TEST_DEFAULT_ACTION
, wxT("&Test dialog default action"));
470 menuDlg
->AppendSeparator();
471 menuDlg
->Append(wxID_EXIT
, wxT("E&xit\tAlt-X"));
474 wxMenu
*menuHelp
= new wxMenu
;
475 menuHelp
->Append(DIALOGS_ABOUTDLG_SIMPLE
, wxT("&About (simple)...\tF1"));
476 menuHelp
->Append(DIALOGS_ABOUTDLG_FANCY
, wxT("About (&fancy)...\tShift-F1"));
477 menuHelp
->Append(DIALOGS_ABOUTDLG_FULL
, wxT("About (f&ull)...\tCtrl-F1"));
478 menuHelp
->Append(DIALOGS_ABOUTDLG_CUSTOM
, wxT("About (&custom)...\tCtrl-Shift-F1"));
479 #endif // wxUSE_ABOUTDLG
481 wxMenuBar
*menubar
= new wxMenuBar
;
482 menubar
->Append(menuDlg
, wxT("&Dialogs"));
484 menubar
->Append(menuHelp
, wxT("&Help"));
485 #endif // wxUSE_ABOUTDLG
487 frame
->SetMenuBar(menubar
);
489 frame
->Centre(wxBOTH
);
495 // My frame constructor
496 MyFrame::MyFrame(const wxString
& title
)
497 : wxFrame(NULL
, wxID_ANY
, title
)
501 #if USE_MODAL_PRESENTATION
502 m_dialog
= (MyModelessDialog
*)NULL
;
503 #endif // USE_MODAL_PRESENTATION
505 #if wxUSE_FINDREPLDLG
511 m_clrData
.SetChooseFull(true);
512 for (int i
= 0; i
< wxColourData::NUM_CUSTOM
; i
++)
514 unsigned char n
= i
*16;
515 m_clrData
.SetCustomColour(i
, wxColour(n
, n
, n
));
517 #endif // wxUSE_COLOURDLG
519 #if wxUSE_NOTIFICATION_MESSAGE
521 #endif // wxUSE_NOTIFICATION_MESSAGE
525 #endif // wxUSE_STATUSBAR
527 m_canvas
= new MyCanvas(this);
530 // an info bar can be created very simply and used without any extra effort
531 m_infoBarSimple
= new wxInfoBar(this);
533 // or it can also be customized by
534 m_infoBarAdvanced
= new wxInfoBar(this);
536 // ... adding extra buttons (but more than two will usually be too many)
537 m_infoBarAdvanced
->AddButton(wxID_UNDO
);
538 m_infoBarAdvanced
->AddButton(wxID_REDO
);
540 m_infoBarAdvanced
->Connect(wxID_REDO
, wxEVT_COMMAND_BUTTON_CLICKED
,
541 wxCommandEventHandler(MyFrame::OnInfoBarRedo
),
545 // adding and removing a button immediately doesn't make sense here, of
546 // course, it's done just to show that it is possible
547 m_infoBarAdvanced
->AddButton(wxID_EXIT
);
548 m_infoBarAdvanced
->RemoveButton(wxID_EXIT
);
550 // ... changing the colours and/or fonts
551 m_infoBarAdvanced
->SetOwnBackgroundColour(0xc8ffff);
552 m_infoBarAdvanced
->SetFont(GetFont().Bold().Larger());
554 // ... and changing the effect (only does anything under MSW currently)
555 m_infoBarAdvanced
->SetShowHideEffects(wxSHOW_EFFECT_EXPAND
,
556 wxSHOW_EFFECT_EXPAND
);
557 m_infoBarAdvanced
->SetEffectDuration(1500);
560 // to use the info bars we need to use sizer for the window layout
561 wxBoxSizer
* const sizer
= new wxBoxSizer(wxVERTICAL
);
562 sizer
->Add(m_infoBarSimple
, wxSizerFlags().Expand());
563 sizer
->Add(m_canvas
, wxSizerFlags(1).Expand());
564 sizer
->Add(m_infoBarAdvanced
, wxSizerFlags().Expand());
567 // final touch: under MSW the info bars are shown progressively and parts
568 // of the parent window can be seen during the process, so use the same
569 // background colour for our background as for the canvas window which
570 // covers our entire client area to avoid jarring colour jumps
571 SetOwnBackgroundColour(m_canvas
->GetBackgroundColour());
572 #endif // wxUSE_INFOBAR
577 #if wxUSE_NOTIFICATION_MESSAGE
579 #endif // wxUSE_NOTIFICATION_MESSAGE
584 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
))
586 m_clrData
.SetColour(m_canvas
->GetBackgroundColour());
588 wxColourDialog
dialog(this, &m_clrData
);
589 dialog
.SetTitle(_("Please choose the background colour"));
590 if ( dialog
.ShowModal() == wxID_OK
)
592 m_clrData
= dialog
.GetColourData();
593 m_canvas
->SetBackgroundColour(m_clrData
.GetColour());
594 m_canvas
->ClearBackground();
599 void MyFrame::GetColour(wxCommandEvent
& WXUNUSED(event
))
601 wxColour clr
= wxGetColourFromUser
604 m_canvas
->GetForegroundColour(),
605 "Please choose the foreground colour"
609 m_canvas
->SetForegroundColour(clr
);
612 //else: dialog cancelled by user
615 #endif // wxUSE_COLOURDLG
618 #if USE_COLOURDLG_GENERIC
619 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
621 m_clrData
.SetColour(m_canvas
->GetBackgroundColour());
623 //FIXME:TODO:This has no effect...
624 m_clrData
.SetChooseFull(true);
626 for (int i
= 0; i
< 16; i
++)
629 (unsigned char)(i
*16),
630 (unsigned char)(i
*16),
631 (unsigned char)(i
*16)
633 m_clrData
.SetCustomColour(i
, colour
);
636 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
637 if (dialog
->ShowModal() == wxID_OK
)
639 m_clrData
= dialog
->GetColourData();
640 m_canvas
->SetBackgroundColour(m_clrData
.GetColour());
641 m_canvas
->ClearBackground();
646 #endif // USE_COLOURDLG_GENERIC
649 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
652 data
.SetInitialFont(m_canvas
->GetFont());
653 data
.SetColour(m_canvas
->GetForegroundColour());
655 // you might also do this:
657 // wxFontDialog dialog;
658 // if ( !dialog.Create(this, data) { ... error ... }
660 wxFontDialog
dialog(this, data
);
662 if (dialog
.ShowModal() == wxID_OK
)
664 wxFontData retData
= dialog
.GetFontData();
665 m_canvas
->SetFont(retData
.GetChosenFont());
666 m_canvas
->SetForegroundColour(retData
.GetColour());
669 //else: cancelled by the user, don't change the font
671 #endif // wxUSE_FONTDLG
673 #if USE_FONTDLG_GENERIC
674 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
677 data
.SetInitialFont(m_canvas
->GetFont());
678 data
.SetColour(m_canvas
->GetForegroundColour());
680 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, data
);
681 if (dialog
->ShowModal() == wxID_OK
)
683 wxFontData retData
= dialog
->GetFontData();
684 m_canvas
->SetFont(retData
.GetChosenFont());
685 m_canvas
->SetForegroundColour(retData
.GetColour());
690 #endif // USE_FONTDLG_GENERIC
693 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
695 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
696 // being flushed -- test it
699 wxLogMessage(wxT("This is some message - everything is ok so far."));
700 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
701 wxLogWarning(wxT("And then something went wrong!"));
703 // and if ~wxBusyCursor doesn't do it, then call it manually
707 wxLogError(wxT("Intermediary error handler decided to abort."));
708 wxLogError(wxT("The top level caller detected an unrecoverable error."));
710 wxLog::FlushActive();
712 wxLogMessage(wxT("And this is the same dialog but with only one message."));
714 #endif // wxUSE_LOG_DIALOG
718 void MyFrame::InfoBarSimple(wxCommandEvent
& WXUNUSED(event
))
720 static int s_count
= 0;
721 m_infoBarSimple
->ShowMessage
723 wxString::Format("Message #%d in the info bar.", ++s_count
)
727 void MyFrame::InfoBarAdvanced(wxCommandEvent
& WXUNUSED(event
))
729 m_infoBarAdvanced
->ShowMessage("Sorry, it didn't work out.", wxICON_WARNING
);
732 void MyFrame::OnInfoBarRedo(wxCommandEvent
& WXUNUSED(event
))
734 m_infoBarAdvanced
->ShowMessage("Still no, sorry again.", wxICON_ERROR
);
737 #endif // wxUSE_INFOBAR
741 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
))
743 wxMessageDialog
dialog(this,
744 "This is a message box\n"
745 "This is a long, long string to test out if the message box "
746 "is laid out properly.",
749 wxNO_DEFAULT
| wxYES_NO
| wxCANCEL
|
753 if ( dialog
.SetYesNoCancelLabels
760 extmsg
= "This platform supports custom button labels,\n"
761 "so you should see the descriptive labels below.";
765 extmsg
= "Custom button labels are not supported on this platform,\n"
766 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
768 dialog
.SetExtendedMessage(extmsg
);
770 switch ( dialog
.ShowModal() )
773 wxLogStatus(wxT("You pressed \"Yes\""));
777 wxLogStatus(wxT("You pressed \"No\""));
781 wxLogStatus(wxT("You pressed \"Cancel\""));
785 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
789 void MyFrame::MessageBoxWindowModal(wxCommandEvent
& WXUNUSED(event
))
791 wxMessageDialog
* dialog
= new wxMessageDialog(this,
792 "This is a message box\n"
793 "This is a long, long string to test out if the message box "
794 "is laid out properly.",
797 wxNO_DEFAULT
| wxYES_NO
| wxCANCEL
|
801 if ( dialog
->SetYesNoCancelLabels
808 extmsg
= "This platform supports custom button labels,\n"
809 "so you should see the descriptive labels below.";
813 extmsg
= "Custom button labels are not supported on this platform,\n"
814 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
816 dialog
->SetExtendedMessage(extmsg
);
817 dialog
->Connect( wxEVT_WINDOW_MODAL_DIALOG_CLOSED
, wxWindowModalDialogEventHandler(MyFrame::MessageBoxWindowModalClosed
), NULL
, this );
818 dialog
->ShowWindowModal();
821 void MyFrame::MessageBoxWindowModalClosed(wxWindowModalDialogEvent
& event
)
823 wxDialog
* dialog
= event
.GetDialog();
824 switch ( dialog
->GetReturnCode() )
827 wxLogStatus(wxT("You pressed \"Yes\""));
831 wxLogStatus(wxT("You pressed \"No\""));
835 wxLogStatus(wxT("You pressed \"Cancel\""));
839 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
844 void MyFrame::MessageBoxDialog(wxCommandEvent
& WXUNUSED(event
))
846 TestMessageBoxDialog
dlg(this);
850 void MyFrame::MessageBoxInfo(wxCommandEvent
& WXUNUSED(event
))
852 ::wxInfoMessageBox(this);
854 #endif // wxUSE_MSGDLG
857 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
))
859 long res
= wxGetNumberFromUser( wxT("This is some text, actually a lot of text.\n")
860 wxT("Even two rows of text."),
861 wxT("Enter a number:"), wxT("Numeric input test"),
868 msg
= wxT("Invalid number entered or dialog cancelled.");
873 msg
.Printf(wxT("You've entered %lu"), res
);
874 icon
= wxICON_INFORMATION
;
877 wxMessageBox(msg
, wxT("Numeric test result"), wxOK
| icon
, this);
879 #endif // wxUSE_NUMBERDLG
882 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
884 wxString pwd
= wxGetPasswordFromUser(wxT("Enter password:"),
885 wxT("Password entry dialog"),
890 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
891 wxT("Got password"), wxOK
| wxICON_INFORMATION
, this);
895 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
897 wxTextEntryDialog
dialog(this,
898 wxT("This is a small sample\n")
899 wxT("A long, long string to test out the text entrybox"),
900 wxT("Please enter a string"),
901 wxT("Default value"),
904 if (dialog
.ShowModal() == wxID_OK
)
906 wxMessageBox(dialog
.GetValue(), wxT("Got string"), wxOK
| wxICON_INFORMATION
, this);
909 #endif // wxUSE_TEXTDLG
912 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
914 const wxString choices
[] = { wxT("One"), wxT("Two"), wxT("Three"), wxT("Four"), wxT("Five") } ;
916 wxSingleChoiceDialog
dialog(this,
917 wxT("This is a small sample\n")
918 wxT("A single-choice convenience dialog"),
919 wxT("Please select a value"),
920 WXSIZEOF(choices
), choices
);
922 dialog
.SetSelection(2);
924 if (dialog
.ShowModal() == wxID_OK
)
926 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), wxT("Got string"));
931 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
933 const wxString choices
[] =
935 wxT("One"), wxT("Two"), wxT("Three"), wxT("Four"), wxT("Five"),
936 wxT("Six"), wxT("Seven"), wxT("Eight"), wxT("Nine"), wxT("Ten"),
937 wxT("Eleven"), wxT("Twelve"), wxT("Seventeen"),
940 wxArrayInt selections
;
941 const int count
= wxGetSelectedChoices(selections
,
942 wxT("This is a small sample\n")
943 wxT("A multi-choice convenience dialog"),
944 wxT("Please select a value"),
945 WXSIZEOF(choices
), choices
,
952 msg
= wxT("You did not select any items");
956 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
957 for ( int n
= 0; n
< count
; n
++ )
959 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
960 (unsigned)n
, (unsigned)selections
[n
],
961 choices
[selections
[n
]].c_str());
968 #endif // wxUSE_CHOICEDLG
970 #if wxUSE_REARRANGECTRL
971 // custom rearrange dialog: it adds the possibility to rename an item to the
972 // base class functionality
973 class MyRearrangeDialog
: public wxRearrangeDialog
976 MyRearrangeDialog(wxWindow
*parent
,
978 wxArrayString
& labels
,
979 wxArrayString
& labelsOrig
)
983 "Configure the columns shown:",
984 "wxRearrangeDialog example",
990 m_labelsOrig(labelsOrig
)
994 wxPanel
* const panel
= new wxPanel(this);
995 wxSizer
* const sizer
= new wxBoxSizer(wxHORIZONTAL
);
997 m_labelOrig
= new wxStaticText(panel
, wxID_ANY
, "");
998 sizer
->Add(m_labelOrig
, wxSizerFlags().Centre().Border(wxRIGHT
));
1000 m_text
= new wxTextCtrl(panel
, wxID_ANY
, "",
1001 wxDefaultPosition
, wxDefaultSize
,
1002 wxTE_PROCESS_ENTER
);
1003 sizer
->Add(m_text
, wxSizerFlags().Centre().Border(wxRIGHT
));
1005 sizer
->Add(new wxButton(panel
, wxID_APPLY
, "&Rename"),
1006 wxSizerFlags().Centre());
1008 panel
->SetSizer(sizer
);
1010 // call this first to ensure that the controls have a reasonable best
1011 // size before they're added
1012 DoUpdateExtraControls(GetList()->GetSelection());
1014 AddExtraControls(panel
);
1017 // another customization not directly supported by the dialog: add a
1019 wxWindow
* const btnOk
= FindWindow(wxID_OK
);
1020 wxCHECK_RET( btnOk
, "no Ok button?" );
1022 wxSizer
* const sizerBtns
= btnOk
->GetContainingSizer();
1023 wxCHECK_RET( sizerBtns
, "no buttons sizer?" );
1025 sizerBtns
->Add(new wxButton(this, wxID_RESET
, "&Reset all"),
1026 wxSizerFlags().Border(wxLEFT
));
1029 // call this instead of ShowModal() to update order and labels array in
1030 // case the dialog was not cancelled
1033 switch ( ShowModal() )
1039 m_order
= GetOrder();
1043 // order already reset
1051 void OnSelChange(wxCommandEvent
& event
)
1053 DoUpdateExtraControls(event
.GetInt());
1056 void OnUpdateUIRename(wxUpdateUIEvent
& event
)
1058 event
.Enable( CanRename() );
1061 void OnRename(wxCommandEvent
& WXUNUSED(event
))
1066 m_labels
[m_sel
] = m_text
->GetValue();
1067 GetList()->SetString(m_sel
, m_labels
[m_sel
]);
1070 void OnReset(wxCommandEvent
& WXUNUSED(event
))
1072 // in a real program we should probably ask if the user really wants to
1073 // do this but here we just go ahead and reset all columns labels and
1074 // their order without confirmation
1075 const unsigned count
= m_order
.size();
1076 for ( unsigned n
= 0; n
< count
; n
++ )
1079 m_labels
[n
] = m_labelsOrig
[n
];
1082 EndModal(wxID_RESET
);
1085 bool CanRename() const
1087 // only allow renaming if the user modified the currently selected item
1088 // text (which presupposes that we do have a current item)
1089 return m_sel
!= wxNOT_FOUND
&& m_text
->GetValue() != m_labels
[m_sel
];
1092 void DoUpdateExtraControls(int sel
)
1096 if ( m_sel
== wxNOT_FOUND
)
1098 m_labelOrig
->SetLabel("<no selection>");
1102 else // have valid item
1104 m_labelOrig
->SetLabelText(m_labelsOrig
[m_sel
]);
1106 m_text
->SetValue(m_labels
[m_sel
]);
1110 wxArrayInt
& m_order
;
1111 wxArrayString
& m_labels
,
1115 wxStaticText
*m_labelOrig
;
1118 DECLARE_EVENT_TABLE()
1119 wxDECLARE_NO_COPY_CLASS(MyRearrangeDialog
);
1122 BEGIN_EVENT_TABLE(MyRearrangeDialog
, wxRearrangeDialog
)
1123 EVT_LISTBOX(wxID_ANY
, MyRearrangeDialog::OnSelChange
)
1125 EVT_UPDATE_UI(wxID_APPLY
, MyRearrangeDialog::OnUpdateUIRename
)
1127 EVT_TEXT_ENTER(wxID_ANY
, MyRearrangeDialog::OnRename
)
1128 EVT_BUTTON(wxID_APPLY
, MyRearrangeDialog::OnRename
)
1129 EVT_BUTTON(wxID_RESET
, MyRearrangeDialog::OnReset
)
1132 void MyFrame::Rearrange(wxCommandEvent
& WXUNUSED(event
))
1134 // the arrays are static so that we preserve the items order between calls
1136 static wxArrayInt s_order
;
1137 static wxArrayString s_labels
,
1140 // initialize them on the first call
1141 if ( s_labelsOrig
.empty() )
1143 static const struct ItemInfo
1146 const char *labelOrig
;
1150 { "File name", "Name", 0 },
1151 { "File type", "Ext", 1 },
1152 { "Size", "Size", 2 },
1153 { "Creation time", "Ctime", ~3 }, // negated so hidden
1154 { "Last accessed", "Atime", ~4 },
1155 { "Last modified", "Mtime", 5 },
1158 s_order
.reserve(WXSIZEOF(items
));
1159 s_labels
.reserve(WXSIZEOF(items
));
1160 s_labelsOrig
.reserve(WXSIZEOF(items
));
1161 for ( unsigned n
= 0; n
< WXSIZEOF(items
); n
++ )
1163 const ItemInfo
& item
= items
[n
];
1164 s_order
.push_back(item
.order
);
1165 s_labels
.push_back(item
.label
);
1166 s_labelsOrig
.push_back(item
.labelOrig
);
1170 MyRearrangeDialog
dlg(this, s_order
, s_labels
, s_labelsOrig
);
1171 if ( !dlg
.Rearrange() )
1175 for ( unsigned n
= 0; n
< s_order
.size(); n
++ )
1177 columns
+= wxString::Format("\n %u: ", n
);
1178 int idx
= s_order
[n
];
1181 columns
+= "[hidden] ";
1185 columns
+= s_labels
[idx
];
1186 if ( s_labels
[idx
] != s_labelsOrig
[idx
] )
1188 columns
+= wxString::Format(" (original label: \"%s\")",
1193 wxLogMessage("The columns order now is:%s", columns
);
1195 #endif // wxUSE_REARRANGECTRL
1199 // panel with custom controls for file dialog
1200 class MyExtraPanel
: public wxPanel
1203 MyExtraPanel(wxWindow
*parent
);
1204 void OnCheckBox(wxCommandEvent
& event
) { m_btn
->Enable(event
.IsChecked()); }
1205 wxString
GetInfo() const
1207 return wxString::Format("checkbox value = %d", (int) m_cb
->GetValue());
1214 MyExtraPanel::MyExtraPanel(wxWindow
*parent
)
1217 m_btn
= new wxButton(this, -1, wxT("Custom Button"));
1218 m_btn
->Enable(false);
1219 m_cb
= new wxCheckBox(this, -1, wxT("Enable Custom Button"));
1220 m_cb
->Connect(wxID_ANY
, wxEVT_COMMAND_CHECKBOX_CLICKED
,
1221 wxCommandEventHandler(MyExtraPanel::OnCheckBox
), NULL
, this);
1222 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1223 sizerTop
->Add(m_cb
, wxSizerFlags().Centre().Border());
1224 sizerTop
->AddStretchSpacer();
1225 sizerTop
->Add(m_btn
, wxSizerFlags().Right().Border());
1226 SetSizerAndFit(sizerTop
);
1229 // a static method can be used instead of a function with most of compilers
1230 static wxWindow
* createMyExtraPanel(wxWindow
*parent
)
1232 return new MyExtraPanel(parent
);
1235 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
1240 wxT("Testing open file dialog"),
1244 wxT("C++ files (*.cpp)|*.cpp")
1246 wxT("C++ files (*.cpp;*.h)|*.cpp;*.h")
1250 dialog
.SetExtraControlCreator(&createMyExtraPanel
);
1251 dialog
.CentreOnParent();
1252 dialog
.SetDirectory(wxGetHomeDir());
1254 if (dialog
.ShowModal() == wxID_OK
)
1257 wxWindow
* const extra
= dialog
.GetExtraControl();
1258 info
.Printf(wxT("Full file name: %s\n")
1261 wxT("Custom window: %s"),
1262 dialog
.GetPath().c_str(),
1263 dialog
.GetDirectory().c_str(),
1264 dialog
.GetFilename().c_str(),
1265 extra
? static_cast<MyExtraPanel
*>(extra
)->GetInfo()
1266 : wxString("None"));
1267 wxMessageDialog
dialog2(this, info
, wxT("Selected file"));
1268 dialog2
.ShowModal();
1272 // this shows how to take advantage of specifying a default extension in the
1273 // call to wxFileSelector: it is remembered after each new call and the next
1274 // one will use it by default
1275 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
1277 static wxString s_extDef
;
1278 wxString path
= wxFileSelector(
1279 wxT("Select the file to load"),
1280 wxEmptyString
, wxEmptyString
,
1284 wxT("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
1285 wxFileSelectorDefaultWildcardStr
,
1286 wxFileSelectorDefaultWildcardStr
1288 wxFD_OPEN
|wxFD_CHANGE_DIR
|wxFD_PREVIEW
,
1295 // it is just a sample, would use wxSplitPath in real program
1296 s_extDef
= path
.AfterLast(wxT('.'));
1298 wxLogMessage(wxT("You selected the file '%s', remembered extension '%s'"),
1302 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
1304 wxString wildcards
=
1306 wxT("C++ files (*.cpp)|*.cpp");
1310 wxT("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
1311 wxFileSelectorDefaultWildcardStr
,
1312 wxFileSelectorDefaultWildcardStr
1315 wxFileDialog
dialog(this, wxT("Testing open multiple file dialog"),
1316 wxEmptyString
, wxEmptyString
, wildcards
,
1317 wxFD_OPEN
|wxFD_MULTIPLE
);
1319 if (dialog
.ShowModal() == wxID_OK
)
1321 wxArrayString paths
, filenames
;
1323 dialog
.GetPaths(paths
);
1324 dialog
.GetFilenames(filenames
);
1327 size_t count
= paths
.GetCount();
1328 for ( size_t n
= 0; n
< count
; n
++ )
1330 s
.Printf(wxT("File %d: %s (%s)\n"),
1331 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
1335 s
.Printf(wxT("Filter index: %d"), dialog
.GetFilterIndex());
1338 wxMessageDialog
dialog2(this, msg
, wxT("Selected files"));
1339 dialog2
.ShowModal();
1343 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
1345 wxFileDialog
dialog(this,
1346 wxT("Testing save file dialog"),
1348 wxT("myletter.doc"),
1349 wxT("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
1350 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1352 dialog
.SetFilterIndex(1);
1354 if (dialog
.ShowModal() == wxID_OK
)
1356 wxLogMessage(wxT("%s, filter %d"),
1357 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
1360 #endif // wxUSE_FILEDLG
1362 #if USE_FILEDLG_GENERIC
1363 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
1365 wxGenericFileDialog dialog
1368 wxT("Testing open file dialog"),
1371 wxT("C++ files (*.cpp;*.h)|*.cpp;*.h")
1374 dialog
.SetExtraControlCreator(&createMyExtraPanel
);
1375 dialog
.SetDirectory(wxGetHomeDir());
1377 if (dialog
.ShowModal() == wxID_OK
)
1380 info
.Printf(wxT("Full file name: %s\n")
1383 dialog
.GetPath().c_str(),
1384 dialog
.GetDirectory().c_str(),
1385 dialog
.GetFilename().c_str());
1386 wxMessageDialog
dialog2(this, info
, wxT("Selected file"));
1387 dialog2
.ShowModal();
1391 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
1393 // On PocketPC you can disable OK-only dialogs policy using system option
1394 int buttons
= wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
1395 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
1397 wxString wildcards
= wxT("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
1398 wxGenericFileDialog
dialog(this, wxT("Testing open multiple file dialog"),
1399 wxEmptyString
, wxEmptyString
, wildcards
,
1402 if (dialog
.ShowModal() == wxID_OK
)
1404 wxArrayString paths
, filenames
;
1406 dialog
.GetPaths(paths
);
1407 dialog
.GetFilenames(filenames
);
1410 size_t count
= paths
.GetCount();
1411 for ( size_t n
= 0; n
< count
; n
++ )
1413 s
.Printf(wxT("File %d: %s (%s)\n"),
1414 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
1418 s
.Printf(wxT("Filter index: %d"), dialog
.GetFilterIndex());
1421 wxMessageDialog
dialog2(this, msg
, wxT("Selected files"));
1422 dialog2
.ShowModal();
1425 // restore system option
1426 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons
);
1429 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
1431 wxGenericFileDialog
dialog(this,
1432 wxT("Testing save file dialog"),
1434 wxT("myletter.doc"),
1435 wxT("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
1436 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1438 dialog
.SetFilterIndex(1);
1440 if (dialog
.ShowModal() == wxID_OK
)
1442 wxLogMessage(wxT("%s, filter %d"),
1443 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
1446 #endif // USE_FILEDLG_GENERIC
1449 void MyFrame::DoDirChoose(int style
)
1451 // pass some initial dir to wxDirDialog
1453 wxGetHomeDir(&dirHome
);
1455 wxDirDialog
dialog(this, wxT("Testing directory picker"), dirHome
, style
);
1457 if (dialog
.ShowModal() == wxID_OK
)
1459 wxLogMessage(wxT("Selected path: %s"), dialog
.GetPath().c_str());
1463 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
1465 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_DIR_MUST_EXIST
);
1468 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
1470 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_DIR_MUST_EXIST
);
1472 #endif // wxUSE_DIRDLG
1474 #if USE_DIRDLG_GENERIC
1475 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
1477 // pass some initial dir to wxDirDialog
1479 wxGetHomeDir(&dirHome
);
1481 wxGenericDirDialog
dialog(this, wxT("Testing generic directory picker"), dirHome
);
1483 if (dialog
.ShowModal() == wxID_OK
)
1485 wxMessageDialog
dialog2(this, dialog
.GetPath(), wxT("Selected path"));
1486 dialog2
.ShowModal();
1489 #endif // USE_DIRDLG_GENERIC
1491 #if USE_MODAL_PRESENTATION
1492 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
1494 MyModalDialog
dlg(this);
1497 #endif // USE_MODAL_PRESENTATION
1499 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
1501 bool show
= GetMenuBar()->IsChecked(event
.GetId());
1507 m_dialog
= new MyModelessDialog(this);
1510 m_dialog
->Show(true);
1514 // If m_dialog is NULL, then possibly the system
1515 // didn't report the checked menu item status correctly.
1516 // It should be true just after the menu item was selected,
1517 // if there was no modeless dialog yet.
1519 wxASSERT( m_dialog
!= NULL
);
1525 void MyFrame::DlgCenteredScreen(wxCommandEvent
& WXUNUSED(event
))
1527 wxDialog
dlg(this, wxID_ANY
, wxT("Dialog centered on screen"),
1528 wxDefaultPosition
, wxSize(200, 100));
1529 (new wxButton(&dlg
, wxID_OK
, wxT("Close")))->Centre();
1530 dlg
.CentreOnScreen();
1534 void MyFrame::DlgCenteredParent(wxCommandEvent
& WXUNUSED(event
))
1536 wxDialog
dlg(this, wxID_ANY
, wxT("Dialog centered on parent"),
1537 wxDefaultPosition
, wxSize(200, 100));
1538 (new wxButton(&dlg
, wxID_OK
, wxT("Close")))->Centre();
1539 dlg
.CentreOnParent();
1544 void MyFrame::MiniFrame(wxCommandEvent
& WXUNUSED(event
))
1546 wxFrame
*frame
= new wxMiniFrame(this, wxID_ANY
, wxT("Mini frame"),
1547 wxDefaultPosition
, wxSize(300, 100),
1548 wxCAPTION
| wxCLOSE_BOX
);
1549 new wxStaticText(frame
,
1551 wxT("Mini frames have slightly different appearance"),
1553 new wxStaticText(frame
,
1555 wxT("from the normal frames but that's the only difference."),
1558 frame
->CentreOnParent();
1561 #endif // wxUSE_MINIFRAME
1563 void MyFrame::DlgOnTop(wxCommandEvent
& WXUNUSED(event
))
1565 wxDialog
dlg(this, wxID_ANY
, wxT("Dialog staying on top of other windows"),
1566 wxDefaultPosition
, wxSize(300, 100),
1567 wxDEFAULT_DIALOG_STYLE
| wxSTAY_ON_TOP
);
1568 (new wxButton(&dlg
, wxID_OK
, wxT("Close")))->Centre();
1572 #if wxUSE_STARTUP_TIPS
1573 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
1575 static size_t s_index
= (size_t)-1;
1577 if ( s_index
== (size_t)-1 )
1581 // this is completely bogus, we don't know how many lines are there
1582 // in the file, but who cares, it's a demo only...
1583 s_index
= rand() % 5;
1586 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(wxT("tips.txt"), s_index
);
1588 bool showAtStartup
= wxShowTip(this, tipProvider
);
1590 if ( showAtStartup
)
1592 wxMessageBox(wxT("Will show tips on startup"), wxT("Tips dialog"),
1593 wxOK
| wxICON_INFORMATION
, this);
1596 s_index
= tipProvider
->GetCurrentTip();
1599 #endif // wxUSE_STARTUP_TIPS
1601 #if USE_SETTINGS_DIALOG
1602 void MyFrame::OnPropertySheet(wxCommandEvent
& event
)
1604 SettingsDialog
dialog(this, event
.GetId());
1607 #endif // USE_SETTINGS_DIALOG
1609 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
1611 wxLogStatus(wxT("Sleeping for 3 seconds to allow you to switch to another window"));
1615 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
1618 #if wxUSE_NOTIFICATION_MESSAGE
1620 void MyFrame::OnNotifMsgAuto(wxCommandEvent
& WXUNUSED(event
))
1622 if ( !wxNotificationMessage
1624 "Automatic Notification",
1625 "Nothing important has happened\n"
1626 "this notification will disappear soon."
1629 wxLogStatus("Failed to show notification message");
1633 void MyFrame::OnNotifMsgShow(wxCommandEvent
& WXUNUSED(event
))
1637 m_notifMsg
= new wxNotificationMessage
1639 "wxWidgets Manual Notification",
1640 "You can hide this notification from the menu",
1645 if ( !m_notifMsg
->Show(wxNotificationMessage::Timeout_Never
) )
1647 wxLogStatus("Failed to show manual notification message");
1651 void MyFrame::OnNotifMsgHide(wxCommandEvent
& WXUNUSED(event
))
1653 if ( m_notifMsg
&& !m_notifMsg
->Close() )
1655 wxLogStatus("Failed to hide manual notification message");
1659 #endif // wxUSE_NOTIFICATION_MESSAGE
1661 void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent
& WXUNUSED(event
))
1663 StdButtonSizerDialog
dialog(this);
1667 // TestDefaultAction
1669 #define ID_CATCH_LISTBOX_DCLICK 100
1670 #define ID_LISTBOX 101
1672 BEGIN_EVENT_TABLE(TestDefaultActionDialog
, wxDialog
)
1673 EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK
, TestDefaultActionDialog::OnCatchListBoxDClick
)
1674 EVT_LISTBOX_DCLICK(ID_LISTBOX
, TestDefaultActionDialog::OnListBoxDClick
)
1677 TestDefaultActionDialog::TestDefaultActionDialog( wxWindow
*parent
) :
1678 wxDialog( parent
, -1, "Test default action" )
1680 m_catchListBoxDClick
= false;
1682 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
1684 wxFlexGridSizer
*grid_sizer
= new wxFlexGridSizer( 2, 5, 5 );
1687 wxListBox
*listbox
= new wxListBox( this, ID_LISTBOX
);
1688 listbox
->Append( "String 1" );
1689 listbox
->Append( "String 2" );
1690 listbox
->Append( "String 3" );
1691 listbox
->Append( "String 4" );
1692 grid_sizer
->Add( listbox
);
1693 #endif // wxUSE_LISTBOX
1695 grid_sizer
->Add( new wxCheckBox( this, ID_CATCH_LISTBOX_DCLICK
, "Catch DoubleClick from wxListBox" ), 0, wxALIGN_CENTRE_VERTICAL
);
1697 grid_sizer
->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxSize(80,-1), 0 ), 0, wxALIGN_CENTRE_VERTICAL
);
1698 grid_sizer
->Add( new wxStaticText( this, -1, "wxTextCtrl without wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL
);
1700 grid_sizer
->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxSize(80,-1), wxTE_PROCESS_ENTER
), 0, wxALIGN_CENTRE_VERTICAL
);
1701 grid_sizer
->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL
);
1703 main_sizer
->Add( grid_sizer
, 0, wxALL
, 10 );
1705 wxSizer
*button_sizer
= CreateSeparatedButtonSizer( wxOK
|wxCANCEL
);
1707 main_sizer
->Add( button_sizer
, 0, wxALL
|wxGROW
, 5 );
1709 SetSizerAndFit( main_sizer
);
1712 void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent
& event
)
1714 event
.Skip( !m_catchListBoxDClick
);
1717 void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent
& WXUNUSED(event
))
1719 m_catchListBoxDClick
= !m_catchListBoxDClick
;
1722 void MyFrame::OnTestDefaultActionDialog(wxCommandEvent
& WXUNUSED(event
))
1724 TestDefaultActionDialog
dialog( this );
1728 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
1733 #if wxUSE_PROGRESSDLG
1735 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1737 static const int max
= 100;
1739 wxProgressDialog
dialog(wxT("Progress dialog example"),
1740 wxT("An informative message"),
1746 // wxPD_AUTO_HIDE | -- try this as well
1748 wxPD_ESTIMATED_TIME
|
1750 | wxPD_SMOOTH
// - makes indeterminate mode bar on WinXP very small
1754 for ( int i
= 0; i
<= max
; i
++ )
1760 // test both modes of wxProgressDialog behaviour: start in
1761 // indeterminate mode but switch to the determinate one later
1762 const bool determinate
= i
> max
/2;
1766 msg
= wxT("That's all, folks!");
1768 else if ( !determinate
)
1770 msg
= wxT("Testing indeterminate mode");
1772 else if ( determinate
)
1774 msg
= wxT("Now in standard determinate mode");
1777 // will be set to true if "Skip" button was pressed
1781 cont
= dialog
.Update(i
, msg
, &skip
);
1785 cont
= dialog
.Pulse(msg
, &skip
);
1788 // each skip will move progress about quarter forward
1794 if ( wxMessageBox(wxT("Do you really want to cancel?"),
1795 wxT("Progress dialog question"), // caption
1796 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
1806 wxLogStatus(wxT("Progress dialog aborted!"));
1810 wxLogStatus(wxT("Countdown from %d finished"), max
);
1814 #endif // wxUSE_PROGRESSDLG
1818 static void InitAboutInfoMinimal(wxAboutDialogInfo
& info
)
1820 info
.SetName(wxT("Dialogs Sample"));
1821 info
.SetVersion(wxVERSION_NUM_DOT_STRING
,
1825 wxMINOR_VERSION
% 2 ? "Development" : "Stable",
1826 wxVERSION_NUM_DOT_STRING
1828 info
.SetDescription(wxT("This sample shows different wxWidgets dialogs"));
1829 info
.SetCopyright(wxT("(C) 1998-2006 wxWidgets dev team"));
1830 info
.AddDeveloper(wxT("Vadim Zeitlin"));
1833 static void InitAboutInfoWebsite(wxAboutDialogInfo
& info
)
1835 InitAboutInfoMinimal(info
);
1837 info
.SetWebSite(wxT("http://www.wxwidgets.org/"), wxT("wxWidgets web site"));
1840 static void InitAboutInfoAll(wxAboutDialogInfo
& info
)
1842 InitAboutInfoWebsite(info
);
1844 // we can add a second developer
1845 info
.AddDeveloper(wxT("A.N. Other"));
1847 // or we can add several persons at once like this
1848 static const wxChar
*docwriters
[] =
1850 wxT("First D. Writer"),
1854 info
.SetDocWriters(wxArrayString(WXSIZEOF(docwriters
), docwriters
));
1855 info
.SetLicence(wxString::FromAscii(
1856 " wxWindows Library Licence, Version 3.1\n"
1857 " ======================================\n"
1859 " Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
1861 " Everyone is permitted to copy and distribute verbatim copies\n"
1862 " of this licence document, but changing it is not allowed.\n"
1864 " WXWINDOWS LIBRARY LICENCE\n"
1865 " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
1867 " ...and so on and so forth...\n"
1870 info
.AddTranslator(wxT("Wun Ngo Wen (Martian)"));
1873 void MyFrame::ShowSimpleAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1875 wxAboutDialogInfo info
;
1876 InitAboutInfoMinimal(info
);
1878 wxAboutBox(info
, this);
1881 void MyFrame::ShowFancyAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1883 wxAboutDialogInfo info
;
1884 InitAboutInfoWebsite(info
);
1886 wxAboutBox(info
, this);
1889 void MyFrame::ShowFullAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1891 wxAboutDialogInfo info
;
1892 InitAboutInfoAll(info
);
1894 wxAboutBox(info
, this);
1897 // a trivial example of a custom dialog class
1898 class MyAboutDialog
: public wxGenericAboutDialog
1901 MyAboutDialog(const wxAboutDialogInfo
& info
, wxWindow
* parent
)
1903 Create(info
, parent
);
1906 // add some custom controls
1907 virtual void DoAddCustomControls()
1909 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1910 AddText(wxT("Some custom text"));
1911 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
1915 void MyFrame::ShowCustomAboutDialog(wxCommandEvent
& WXUNUSED(event
))
1917 wxAboutDialogInfo info
;
1918 InitAboutInfoAll(info
);
1920 MyAboutDialog
dlg(info
, this);
1924 #endif // wxUSE_ABOUTDLG
1928 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
1930 wxWindowDisabler disableAll
;
1932 wxBusyInfo
info(wxT("Working, please wait..."), this);
1934 for ( int i
= 0; i
< 18; i
++ )
1944 #endif // wxUSE_BUSYINFO
1946 #if wxUSE_FINDREPLDLG
1948 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
1952 delete m_dlgReplace
;
1953 m_dlgReplace
= NULL
;
1957 m_dlgReplace
= new wxFindReplaceDialog
1961 wxT("Find and replace dialog"),
1965 m_dlgReplace
->Show(true);
1969 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
1978 m_dlgFind
= new wxFindReplaceDialog
1987 m_dlgFind
->Show(true);
1991 static wxString
DecodeFindDialogEventFlags(int flags
)
1994 str
<< (flags
& wxFR_DOWN
? wxT("down") : wxT("up")) << wxT(", ")
1995 << (flags
& wxFR_WHOLEWORD
? wxT("whole words only, ") : wxT(""))
1996 << (flags
& wxFR_MATCHCASE
? wxT("") : wxT("not "))
1997 << wxT("case sensitive");
2002 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
2004 wxEventType type
= event
.GetEventType();
2006 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
2008 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
2009 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
2010 event
.GetFindString().c_str(),
2011 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
2013 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
2014 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
2016 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
2017 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? wxT("all ") : wxT(""),
2018 event
.GetFindString().c_str(),
2019 event
.GetReplaceString().c_str(),
2020 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
2022 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
2024 wxFindReplaceDialog
*dlg
= event
.GetDialog();
2028 if ( dlg
== m_dlgFind
)
2031 idMenu
= DIALOGS_FIND
;
2034 else if ( dlg
== m_dlgReplace
)
2036 txt
= wxT("Replace");
2037 idMenu
= DIALOGS_REPLACE
;
2038 m_dlgReplace
= NULL
;
2042 txt
= wxT("Unknown");
2045 wxFAIL_MSG( wxT("unexpected event") );
2048 wxLogMessage(wxT("%s dialog is being closed."), txt
);
2050 if ( idMenu
!= wxID_ANY
)
2052 GetMenuBar()->Check(idMenu
, false);
2059 wxLogError(wxT("Unknown find dialog event!"));
2063 #endif // wxUSE_FINDREPLDLG
2065 // ----------------------------------------------------------------------------
2067 // ----------------------------------------------------------------------------
2069 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
2072 dc
.SetBackgroundMode(wxTRANSPARENT
);
2074 wxT("wxWidgets common dialogs")
2075 #if !defined(__SMARTPHONE__)
2076 wxT(" test application")
2081 #if USE_MODAL_PRESENTATION
2083 // ----------------------------------------------------------------------------
2085 // ----------------------------------------------------------------------------
2087 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
2088 : wxDialog(parent
, wxID_ANY
, wxString(wxT("Modeless dialog")))
2090 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
2092 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, wxT("Press me"));
2093 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, wxT("Should be disabled"));
2096 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
2097 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
2099 SetSizerAndFit(sizerTop
);
2102 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
2104 wxMessageBox(wxT("Button pressed in modeless dialog"), wxT("Info"),
2105 wxOK
| wxICON_INFORMATION
, this);
2108 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
2110 if ( event
.CanVeto() )
2112 wxMessageBox(wxT("Use the menu item to close this dialog"),
2113 wxT("Modeless dialog"),
2114 wxOK
| wxICON_INFORMATION
, this);
2120 // ----------------------------------------------------------------------------
2122 // ----------------------------------------------------------------------------
2124 MyModalDialog::MyModalDialog(wxWindow
*parent
)
2125 : wxDialog(parent
, wxID_ANY
, wxString(wxT("Modal dialog")))
2127 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
2129 m_btnModal
= new wxButton(this, wxID_ANY
, wxT("&Modal dialog..."));
2130 m_btnModeless
= new wxButton(this, wxID_ANY
, wxT("Mode&less dialog"));
2131 m_btnDelete
= new wxButton(this, wxID_ANY
, wxT("&Delete button"));
2133 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
2134 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
2135 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
2136 sizerTop
->Add(new wxButton(this, wxID_CLOSE
), 0, wxALIGN_CENTER
| wxALL
, 5);
2138 SetSizerAndFit(sizerTop
);
2140 SetEscapeId(wxID_CLOSE
);
2142 m_btnModal
->SetFocus();
2143 m_btnModal
->SetDefault();
2146 void MyModalDialog::OnButton(wxCommandEvent
& event
)
2148 if ( event
.GetEventObject() == m_btnDelete
)
2153 m_btnDelete
->Disable();
2155 else if ( event
.GetEventObject() == m_btnModal
)
2158 wxGetTextFromUser(wxT("Dummy prompt"),
2159 wxT("Modal dialog called from dialog"),
2160 wxEmptyString
, this);
2162 wxMessageBox(wxT("Modal dialog called from dialog"));
2163 #endif // wxUSE_TEXTDLG
2165 else if ( event
.GetEventObject() == m_btnModeless
)
2167 (new MyModelessDialog(this))->Show();
2175 #endif // USE_MODAL_PRESENTATION
2177 // ----------------------------------------------------------------------------
2178 // StdButtonSizerDialog
2179 // ----------------------------------------------------------------------------
2181 StdButtonSizerDialog::StdButtonSizerDialog(wxWindow
*parent
)
2182 : wxDialog(parent
, wxID_ANY
, wxString(wxT("StdButtonSizer dialog")),
2183 wxDefaultPosition
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
),
2184 m_buttonsSizer(NULL
)
2186 wxBoxSizer
*const sizerTop
= new wxBoxSizer(wxVERTICAL
);
2188 wxBoxSizer
*const sizer
= new wxBoxSizer(wxHORIZONTAL
);
2189 wxBoxSizer
*const sizerInside1
= new wxBoxSizer(wxVERTICAL
);
2191 m_chkboxAffirmativeButton
= new wxCheckBox(this, wxID_ANY
, _("Enable Affirmative Button"));
2193 wxStaticBoxSizer
*const sizer1
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Affirmative Button"));
2195 m_radiobtnOk
= new wxRadioButton(this, wxID_ANY
, _("Ok"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
2196 m_radiobtnYes
= new wxRadioButton(this, wxID_ANY
, _("Yes"));
2198 wxBoxSizer
*const sizerInside2
= new wxBoxSizer(wxVERTICAL
);
2200 m_chkboxDismissButton
= new wxCheckBox(this, wxID_ANY
, _("Enable Dismiss Button"));
2202 wxStaticBoxSizer
*const sizer2
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Dismiss Button"));
2204 m_radiobtnCancel
= new wxRadioButton(this, wxID_ANY
, _("Cancel"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
2205 m_radiobtnClose
= new wxRadioButton(this, wxID_ANY
, _("Close"));
2207 wxBoxSizer
*const sizer3
= new wxBoxSizer(wxHORIZONTAL
);
2209 m_chkboxNo
= new wxCheckBox(this, wxID_ANY
, _("No"));
2210 m_chkboxHelp
= new wxCheckBox(this, wxID_ANY
, _("Help"));
2211 m_chkboxApply
= new wxCheckBox(this, wxID_ANY
, _("Apply"));
2213 m_chkboxNoDefault
= new wxCheckBox(this, wxID_ANY
, wxT("No Default"));
2215 sizer1
->Add(m_radiobtnOk
, 0, wxALL
, 5);
2216 sizer1
->Add(m_radiobtnYes
, 0, wxALL
, 5);
2218 sizer
->Add(sizerInside1
, 0, 0, 0);
2219 sizerInside1
->Add(m_chkboxAffirmativeButton
, 0, wxALL
, 5);
2220 sizerInside1
->Add(sizer1
, 0, wxALL
, 5);
2221 sizerInside1
->SetItemMinSize(sizer1
, sizer1
->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
2223 sizer2
->Add(m_radiobtnCancel
, 0, wxALL
, 5);
2224 sizer2
->Add(m_radiobtnClose
, 0, wxALL
, 5);
2226 sizer
->Add(sizerInside2
, 0, 0, 0);
2227 sizerInside2
->Add(m_chkboxDismissButton
, 0, wxALL
, 5);
2228 sizerInside2
->Add(sizer2
, 0, wxALL
, 5);
2229 sizerInside2
->SetItemMinSize(sizer2
, sizer2
->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
2231 sizerTop
->Add(sizer
, 0, wxALL
, 5);
2233 sizer3
->Add(m_chkboxNo
, 0, wxALL
, 5);
2234 sizer3
->Add(m_chkboxHelp
, 0, wxALL
, 5);
2235 sizer3
->Add(m_chkboxApply
, 0, wxALL
, 5);
2237 sizerTop
->Add(sizer3
, 0, wxALL
, 5);
2239 sizerTop
->Add(m_chkboxNoDefault
, 0, wxLEFT
|wxRIGHT
, 10);
2241 EnableDisableControls();
2243 SetSizerAndFit(sizerTop
);
2249 void StdButtonSizerDialog::OnEvent(wxCommandEvent
& WXUNUSED(event
))
2253 m_buttonsSizer
->DeleteWindows();
2254 GetSizer()->Remove(m_buttonsSizer
);
2257 EnableDisableControls();
2260 unsigned long numButtons
= 0;
2262 if (m_chkboxAffirmativeButton
->IsChecked())
2264 if (m_radiobtnOk
->GetValue())
2269 else if (m_radiobtnYes
->GetValue())
2276 if (m_chkboxDismissButton
->IsChecked())
2278 if (m_radiobtnCancel
->GetValue())
2284 else if (m_radiobtnClose
->GetValue())
2292 if (m_chkboxApply
->IsChecked())
2298 if (m_chkboxNo
->IsChecked())
2304 if (m_chkboxHelp
->IsChecked())
2310 if (m_chkboxNoDefault
->IsChecked())
2312 flags
|= wxNO_DEFAULT
;
2315 m_buttonsSizer
= CreateStdDialogButtonSizer(flags
);
2316 GetSizer()->Add(m_buttonsSizer
, 0, wxGROW
|wxALL
, 5);
2319 GetSizer()->SetSizeHints(this);
2322 void StdButtonSizerDialog::EnableDisableControls()
2324 const bool affButtonEnabled
= m_chkboxAffirmativeButton
->IsChecked();
2326 m_radiobtnOk
->Enable(affButtonEnabled
);
2327 m_radiobtnYes
->Enable(affButtonEnabled
);
2329 const bool dismissButtonEnabled
= m_chkboxDismissButton
->IsChecked();
2331 m_radiobtnCancel
->Enable(dismissButtonEnabled
);
2332 m_radiobtnClose
->Enable(dismissButtonEnabled
);
2335 #if USE_SETTINGS_DIALOG
2336 // ----------------------------------------------------------------------------
2338 // ----------------------------------------------------------------------------
2340 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
2342 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
2345 SettingsDialog::SettingsDialog(wxWindow
* win
, int dialogType
)
2347 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
2352 bool useToolBook
= (dialogType
== DIALOGS_PROPERTY_SHEET_TOOLBOOK
|| dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
);
2353 int resizeBorder
= wxRESIZE_BORDER
;
2361 int sheetStyle
= wxPROPSHEET_SHRINKTOFIT
;
2362 if (dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
)
2363 sheetStyle
|= wxPROPSHEET_BUTTONTOOLBOOK
;
2365 sheetStyle
|= wxPROPSHEET_TOOLBOOK
;
2367 SetSheetStyle(sheetStyle
);
2368 SetSheetInnerBorder(0);
2369 SetSheetOuterBorder(0);
2371 // create a dummy image list with a few icons
2372 const wxSize
imageSize(32, 32);
2374 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
2376 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
2378 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
2380 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
2382 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
2387 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
2388 wxDEFAULT_DIALOG_STYLE
| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, resizeBorder
)
2391 // If using a toolbook, also follow Mac style and don't create buttons
2393 CreateButtons(wxOK
| wxCANCEL
|
2394 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, wxHELP
)
2397 wxBookCtrlBase
* notebook
= GetBookCtrl();
2398 notebook
->SetImageList(m_imageList
);
2400 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
2401 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
2403 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
2404 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
2409 SettingsDialog::~SettingsDialog()
2414 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
2416 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
2418 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
2419 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
2423 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
2424 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
2425 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2426 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
2430 wxString autoSaveLabel
= _("&Auto-save every");
2431 wxString minsLabel
= _("mins");
2433 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
2434 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
2437 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
2438 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
2441 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2443 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2445 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2446 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
2450 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
2451 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
2452 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2453 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
2455 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
2457 panel
->SetSizerAndFit(topSizer
);
2462 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
2464 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
2466 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
2467 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
2469 //// PROJECT OR GLOBAL
2470 wxString globalOrProjectChoices
[2];
2471 globalOrProjectChoices
[0] = _("&New projects");
2472 globalOrProjectChoices
[1] = _("&This project");
2474 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
2475 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
2476 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
2478 projectOrGlobal
->SetSelection(0);
2480 //// BACKGROUND STYLE
2481 wxArrayString backgroundStyleChoices
;
2482 backgroundStyleChoices
.Add(wxT("Colour"));
2483 backgroundStyleChoices
.Add(wxT("Image"));
2484 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
2486 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
2487 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
2489 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
2491 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
2493 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2494 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
2495 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2497 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
2500 //// FONT SIZE SELECTION
2502 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
2503 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
2505 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
2506 wxSize(80, wxDefaultCoord
));
2507 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
2509 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
2512 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
2513 topSizer
->AddSpacer(5);
2515 panel
->SetSizerAndFit(topSizer
);
2520 // ----------------------------------------------------------------------------
2521 // TestMessageBoxDialog
2522 // ----------------------------------------------------------------------------
2525 const TestMessageBoxDialog::BtnInfo
TestMessageBoxDialog::ms_btnInfo
[] =
2530 { wxCANCEL
, "&Cancel" },
2533 BEGIN_EVENT_TABLE(TestMessageBoxDialog
, wxDialog
)
2534 EVT_BUTTON(wxID_APPLY
, TestMessageBoxDialog::OnApply
)
2535 EVT_BUTTON(wxID_CLOSE
, TestMessageBoxDialog::OnClose
)
2538 TestMessageBoxDialog::TestMessageBoxDialog(wxWindow
*parent
)
2539 : wxDialog(parent
, wxID_ANY
, "Message Box Test Dialog",
2540 wxDefaultPosition
, wxDefaultSize
,
2541 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
2543 wxSizer
* const sizerTop
= new wxBoxSizer(wxVERTICAL
);
2545 // this sizer allows to configure the messages shown in the message box
2547 sizerMsgs
= new wxStaticBoxSizer(wxVERTICAL
, this, "&Messages");
2548 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Main message:"));
2549 m_textMsg
= new wxTextCtrl(this, wxID_ANY
, "Hello from a box!",
2550 wxDefaultPosition
, wxDefaultSize
,
2552 sizerMsgs
->Add(m_textMsg
, wxSizerFlags(1).Expand().Border(wxBOTTOM
));
2554 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Extended message:"));
2555 m_textExtMsg
= new wxTextCtrl(this, wxID_ANY
, "",
2556 wxDefaultPosition
, wxDefaultSize
,
2558 sizerMsgs
->Add(m_textExtMsg
, wxSizerFlags(1).Expand());
2560 sizerTop
->Add(sizerMsgs
, wxSizerFlags(1).Expand().Border());
2563 // this one is for configuring the buttons
2565 sizerBtnsBox
= new wxStaticBoxSizer(wxVERTICAL
, this, "&Buttons");
2567 wxFlexGridSizer
* const sizerBtns
= new wxFlexGridSizer(2, 5, 5);
2568 sizerBtns
->AddGrowableCol(1);
2570 sizerBtns
->Add(new wxStaticText(this, wxID_ANY
, "Button(s)"));
2571 sizerBtns
->Add(new wxStaticText(this, wxID_ANY
, "Custom label"));
2573 for ( int n
= 0; n
< Btn_Max
; n
++ )
2575 m_buttons
[n
] = new wxCheckBox(this, wxID_ANY
, ms_btnInfo
[n
].name
);
2576 sizerBtns
->Add(m_buttons
[n
], wxSizerFlags().Centre().Left());
2578 m_labels
[n
] = new wxTextCtrl(this, wxID_ANY
);
2579 sizerBtns
->Add(m_labels
[n
], wxSizerFlags(1).Centre().Expand());
2581 m_labels
[n
]->Connect(wxEVT_UPDATE_UI
,
2582 wxUpdateUIEventHandler(
2583 TestMessageBoxDialog::OnUpdateLabelUI
),
2588 sizerBtnsBox
->Add(sizerBtns
, wxSizerFlags(1).Expand());
2589 sizerTop
->Add(sizerBtnsBox
, wxSizerFlags().Expand().Border());
2593 const wxString icons
[] =
2597 "&Information icon",
2603 wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons
) == MsgDlgIcon_Max
, IconMismatch
);
2605 m_icons
= new wxRadioBox(this, wxID_ANY
, "&Icon style",
2606 wxDefaultPosition
, wxDefaultSize
,
2607 WXSIZEOF(icons
), icons
,
2608 2, wxRA_SPECIFY_ROWS
);
2609 // Make the 'Information' icon the default one:
2610 m_icons
->SetSelection(MsgDlgIcon_Info
);
2611 sizerTop
->Add(m_icons
, wxSizerFlags().Expand().Border());
2614 // miscellaneous other stuff
2616 sizerFlags
= new wxStaticBoxSizer(wxHORIZONTAL
, this, "&Other flags");
2618 m_chkNoDefault
= new wxCheckBox(this, wxID_ANY
, "Make \"No\" &default");
2619 m_chkNoDefault
->Connect(wxEVT_UPDATE_UI
,
2620 wxUpdateUIEventHandler(
2621 TestMessageBoxDialog::OnUpdateNoDefaultUI
),
2624 sizerFlags
->Add(m_chkNoDefault
, wxSizerFlags(1).Border());
2626 m_chkCentre
= new wxCheckBox(this, wxID_ANY
, "Centre on &parent");
2627 sizerFlags
->Add(m_chkCentre
, wxSizerFlags(1).Border());
2629 sizerTop
->Add(sizerFlags
, wxSizerFlags().Expand().Border());
2631 // finally buttons to show the resulting message box and close this dialog
2632 sizerTop
->Add(CreateStdDialogButtonSizer(wxAPPLY
| wxCLOSE
),
2633 wxSizerFlags().Right().Border());
2635 SetSizerAndFit(sizerTop
);
2637 m_buttons
[Btn_Ok
]->SetValue(true);
2640 void TestMessageBoxDialog::OnUpdateLabelUI(wxUpdateUIEvent
& event
)
2642 for ( int n
= 0; n
< Btn_Max
; n
++ )
2644 if ( event
.GetEventObject() == m_labels
[n
] )
2646 event
.Enable( m_buttons
[n
]->IsChecked() );
2651 wxFAIL_MSG( "called for unknown label" );
2654 void TestMessageBoxDialog::OnUpdateNoDefaultUI(wxUpdateUIEvent
& event
)
2656 event
.Enable( m_buttons
[Btn_No
]->IsChecked() );
2659 void TestMessageBoxDialog::OnApply(wxCommandEvent
& WXUNUSED(event
))
2663 for ( int n
= 0; n
< Btn_Max
; n
++ )
2665 if ( m_buttons
[n
]->IsChecked() )
2666 style
|= ms_btnInfo
[n
].flag
;
2669 switch ( m_icons
->GetSelection() )
2671 case MsgDlgIcon_Max
:
2672 wxFAIL_MSG( "unexpected selection" );
2677 case MsgDlgIcon_None
:
2678 style
|= wxICON_NONE
;
2681 case MsgDlgIcon_Info
:
2682 style
|= wxICON_INFORMATION
;
2685 case MsgDlgIcon_Question
:
2686 style
|= wxICON_QUESTION
;
2689 case MsgDlgIcon_Warning
:
2690 style
|= wxICON_WARNING
;
2693 case MsgDlgIcon_Error
:
2694 style
|= wxICON_ERROR
;
2698 if ( m_chkCentre
->IsChecked() )
2701 if ( m_chkNoDefault
->IsEnabled() && m_chkNoDefault
->IsChecked() )
2702 style
|= wxNO_DEFAULT
;
2705 wxMessageDialog
dlg(this, m_textMsg
->GetValue(), "Test Message Box",
2707 if ( !m_textExtMsg
->IsEmpty() )
2708 dlg
.SetExtendedMessage(m_textExtMsg
->GetValue());
2710 if ( style
& wxYES_NO
)
2712 if ( style
& wxCANCEL
)
2714 dlg
.SetYesNoCancelLabels(m_labels
[Btn_Yes
]->GetValue(),
2715 m_labels
[Btn_No
]->GetValue(),
2716 m_labels
[Btn_Cancel
]->GetValue());
2720 dlg
.SetYesNoLabels(m_labels
[Btn_Yes
]->GetValue(),
2721 m_labels
[Btn_No
]->GetValue());
2726 if ( style
& wxCANCEL
)
2728 dlg
.SetOKCancelLabels(m_labels
[Btn_Ok
]->GetValue(),
2729 m_labels
[Btn_Cancel
]->GetValue());
2733 dlg
.SetOKLabel(m_labels
[Btn_Ok
]->GetValue());
2740 void TestMessageBoxDialog::OnClose(wxCommandEvent
& WXUNUSED(event
))
2742 EndModal(wxID_CANCEL
);
2745 #endif // USE_SETTINGS_DIALOG
2749 // ----------------------------------------------------------------------------
2750 // custom log target
2751 // ----------------------------------------------------------------------------
2753 class MyLogGui
: public wxLogGui
2756 virtual void DoShowSingleLogMessage(const wxString
& message
,
2757 const wxString
& title
,
2760 wxMessageDialog
dlg(NULL
, message
, title
,
2761 wxOK
| wxCANCEL
| wxCANCEL_DEFAULT
| style
);
2762 dlg
.SetOKCancelLabels(wxID_COPY
, wxID_OK
);
2763 dlg
.SetExtendedMessage("Note that this is a custom log dialog.");
2768 wxLog
*MyAppTraits::CreateLogTarget()
2770 return new MyLogGui
;