1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart, Vadim Zeitlin, ABX
7 // Copyright: (c) Julian Smart
10 // Licence: wxWindows licence
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/richmsgdlg.h"
38 #endif // wxUSE_RICHMSGDLG
41 #include "wx/colordlg.h"
42 #endif // wxUSE_COLOURDLG
45 #include "wx/choicdlg.h"
46 #endif // wxUSE_CHOICEDLG
48 #include "wx/rearrangectrl.h"
50 #if wxUSE_STARTUP_TIPS
51 #include "wx/tipdlg.h"
52 #endif // wxUSE_STARTUP_TIPS
55 #if wxUSE_STOPWATCH && wxUSE_LONGLONG
56 #include "wx/datetime.h" // wxDateTime
59 #include "wx/progdlg.h"
60 #endif // wxUSE_PROGRESSDLG
63 #include "wx/aboutdlg.h"
65 // these headers are only needed for custom about dialog
66 #include "wx/statline.h"
67 #include "wx/generic/aboutdlgg.h"
68 #endif // wxUSE_ABOUTDLG
71 #include "wx/busyinfo.h"
72 #endif // wxUSE_BUSYINFO
75 #include "wx/numdlg.h"
76 #endif // wxUSE_NUMBERDLG
79 #include "wx/filedlg.h"
80 #endif // wxUSE_FILEDLG
83 #include "wx/dirdlg.h"
84 #endif // wxUSE_DIRDLG
87 #include "wx/fontdlg.h"
88 #endif // wxUSE_FONTDLG
91 #include "wx/fdrepdlg.h"
92 #endif // wxUSE_FINDREPLDLG
95 #include "wx/infobar.h"
96 #endif // wxUSE_INFOBAR
98 #include "wx/spinctrl.h"
99 #include "wx/propdlg.h"
103 #if USE_COLOURDLG_GENERIC
104 #include "wx/generic/colrdlgg.h"
105 #endif // USE_COLOURDLG_GENERIC
107 #if USE_DIRDLG_GENERIC
108 #include "wx/generic/dirdlgg.h"
109 #endif // USE_DIRDLG_GENERIC
111 #if USE_FILEDLG_GENERIC
112 #include "wx/generic/filedlgg.h"
113 #endif // USE_FILEDLG_GENERIC
115 #if USE_FONTDLG_GENERIC
116 #include "wx/generic/fontdlgg.h"
117 #endif // USE_FONTDLG_GENERIC
121 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
122 EVT_PAINT(MyCanvas::OnPaint
)
127 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
129 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
130 EVT_MENU(DIALOGS_MESSAGE_BOX_WINDOW_MODAL
, MyFrame::MessageBoxWindowModal
)
131 EVT_MENU(DIALOGS_MESSAGE_DIALOG
, MyFrame::MessageBoxDialog
)
132 EVT_MENU(DIALOGS_MESSAGE_BOX_WXINFO
, MyFrame::MessageBoxInfo
)
133 #endif // wxUSE_MSGDLG
135 EVT_MENU(DIALOGS_RICH_MESSAGE_DIALOG
, MyFrame::RichMessageDialog
)
136 #endif // wxUSE_RICHMSGDLG
138 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
139 EVT_MENU(DIALOGS_GET_COLOUR
, MyFrame::GetColour
)
140 #endif // wxUSE_COLOURDLG
143 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
144 #endif // wxUSE_FONTDLG
147 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
148 #endif // wxUSE_LOG_DIALOG
150 EVT_MENU(DIALOGS_INFOBAR_SIMPLE
, MyFrame::InfoBarSimple
)
151 EVT_MENU(DIALOGS_INFOBAR_ADVANCED
, MyFrame::InfoBarAdvanced
)
152 #endif // wxUSE_INFOBAR
155 EVT_MENU(DIALOGS_LINE_ENTRY
, MyFrame::LineEntry
)
156 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
157 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
158 #endif // wxUSE_TEXTDLG
161 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
162 #endif // wxUSE_NUMBERDLG
165 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
166 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
167 #endif // wxUSE_CHOICEDLG
169 #if wxUSE_REARRANGECTRL
170 EVT_MENU(DIALOGS_REARRANGE
, MyFrame::Rearrange
)
171 #endif // wxUSE_REARRANGECTRL
174 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
175 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
176 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
177 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
178 #endif // wxUSE_FILEDLG
180 #if USE_FILEDLG_GENERIC
181 EVT_MENU(DIALOGS_FILE_OPEN_GENERIC
, MyFrame::FileOpenGeneric
)
182 EVT_MENU(DIALOGS_FILES_OPEN_GENERIC
, MyFrame::FilesOpenGeneric
)
183 EVT_MENU(DIALOGS_FILE_SAVE_GENERIC
, MyFrame::FileSaveGeneric
)
184 #endif // USE_FILEDLG_GENERIC
187 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
188 EVT_MENU(DIALOGS_DIRNEW_CHOOSE
, MyFrame::DirChooseNew
)
189 #endif // wxUSE_DIRDLG
191 #if USE_MODAL_PRESENTATION
192 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
193 #endif // USE_MODAL_PRESENTATION
194 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
195 EVT_MENU(DIALOGS_CENTRE_SCREEN
, MyFrame::DlgCenteredScreen
)
196 EVT_MENU(DIALOGS_CENTRE_PARENT
, MyFrame::DlgCenteredParent
)
198 EVT_MENU(DIALOGS_MINIFRAME
, MyFrame::MiniFrame
)
199 #endif // wxUSE_MINIFRAME
200 EVT_MENU(DIALOGS_ONTOP
, MyFrame::DlgOnTop
)
202 #if wxUSE_STARTUP_TIPS
203 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
204 #endif // wxUSE_STARTUP_TIPS
206 #if USE_FONTDLG_GENERIC
207 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
208 #endif // USE_FONTDLG_GENERIC
210 #if USE_DIRDLG_GENERIC
211 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
212 #endif // wxMSW || wxMAC
214 #if USE_COLOURDLG_GENERIC
215 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
216 #endif // USE_COLOURDLG_GENERIC
218 #if wxUSE_PROGRESSDLG
219 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
220 #endif // wxUSE_PROGRESSDLG
223 EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE
, MyFrame::ShowSimpleAboutDialog
)
224 EVT_MENU(DIALOGS_ABOUTDLG_FANCY
, MyFrame::ShowFancyAboutDialog
)
225 EVT_MENU(DIALOGS_ABOUTDLG_FULL
, MyFrame::ShowFullAboutDialog
)
226 EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM
, MyFrame::ShowCustomAboutDialog
)
227 #endif // wxUSE_ABOUTDLG
230 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
231 #endif // wxUSE_BUSYINFO
233 #if wxUSE_FINDREPLDLG
234 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
235 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
237 EVT_FIND(wxID_ANY
, MyFrame::OnFindDialog
)
238 EVT_FIND_NEXT(wxID_ANY
, MyFrame::OnFindDialog
)
239 EVT_FIND_REPLACE(wxID_ANY
, MyFrame::OnFindDialog
)
240 EVT_FIND_REPLACE_ALL(wxID_ANY
, MyFrame::OnFindDialog
)
241 EVT_FIND_CLOSE(wxID_ANY
, MyFrame::OnFindDialog
)
242 #endif // wxUSE_FINDREPLDLG
244 #if USE_SETTINGS_DIALOG
245 EVT_MENU(DIALOGS_PROPERTY_SHEET
, MyFrame::OnPropertySheet
)
246 EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, MyFrame::OnPropertySheet
)
247 EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, MyFrame::OnPropertySheet
)
248 #endif // USE_SETTINGS_DIALOG
250 EVT_MENU(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
, MyFrame::OnStandardButtonsSizerDialog
)
251 EVT_MENU(DIALOGS_TEST_DEFAULT_ACTION
, MyFrame::OnTestDefaultActionDialog
)
253 EVT_MENU(DIALOGS_REQUEST
, MyFrame::OnRequestUserAttention
)
254 #if wxUSE_NOTIFICATION_MESSAGE
255 EVT_MENU(DIALOGS_NOTIFY_AUTO
, MyFrame::OnNotifMsgAuto
)
256 EVT_MENU(DIALOGS_NOTIFY_SHOW
, MyFrame::OnNotifMsgShow
)
257 EVT_MENU(DIALOGS_NOTIFY_HIDE
, MyFrame::OnNotifMsgHide
)
258 #endif // wxUSE_NOTIFICATION_MESSAGE
260 #if wxUSE_RICHTOOLTIP
261 EVT_MENU(DIALOGS_RICHTIP_DIALOG
, MyFrame::OnRichTipDialog
)
262 #endif // wxUSE_RICHTOOLTIP
264 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
267 #if USE_MODAL_PRESENTATION
269 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
270 EVT_BUTTON(wxID_ANY
, MyModalDialog::OnButton
)
273 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
274 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
275 EVT_CLOSE(MyModelessDialog::OnClose
)
278 #endif // USE_MODAL_PRESENTATION
280 BEGIN_EVENT_TABLE(StdButtonSizerDialog
, wxDialog
)
281 EVT_CHECKBOX(wxID_ANY
, StdButtonSizerDialog::OnEvent
)
282 EVT_RADIOBUTTON(wxID_ANY
, StdButtonSizerDialog::OnEvent
)
285 #if wxUSE_CMDLINE_PARSER
287 #include "wx/cmdline.h"
289 static const char *PROGRESS_SWITCH
= "progress";
291 void MyApp::OnInitCmdLine(wxCmdLineParser
& parser
)
293 wxApp::OnInitCmdLine(parser
);
295 parser
.AddOption("", PROGRESS_SWITCH
,
296 "Style for the startup progress dialog (wxPD_XXX)",
297 wxCMD_LINE_VAL_NUMBER
);
300 bool MyApp::OnCmdLineParsed(wxCmdLineParser
& parser
)
302 if ( !wxApp::OnCmdLineParsed(parser
) )
305 parser
.Found(PROGRESS_SWITCH
, &m_startupProgressStyle
);
310 #endif // wxUSE_CMDLINE_PARSER
312 // `Main program' equivalent, creating windows and returning main app frame
315 if ( !wxApp::OnInit() )
318 #if wxUSE_PROGRESSDLG
319 if ( m_startupProgressStyle
!= -1 )
321 // Show a test progress dialog before the main event loop is started:
322 // it should still work.
323 const int PROGRESS_COUNT
= 100;
326 "Progress in progress",
327 "Please wait, starting...",
330 m_startupProgressStyle
332 for ( int i
= 0; i
<= PROGRESS_COUNT
; i
++ )
334 if ( !dlg
.Update(i
) )
340 #endif // wxUSE_PROGRESSDLG
343 wxInitAllImageHandlers();
346 // Create the main frame window
347 MyFrame
*frame
= new MyFrame(wxT("wxWidgets dialogs example"));
350 wxMenu
*menuDlg
= new wxMenu
;
352 menuDlg
->Append(DIALOGS_MESSAGE_BOX
, wxT("&Message box\tCtrl-M"));
353 menuDlg
->Append(DIALOGS_MESSAGE_BOX_WINDOW_MODAL
, wxT("Window-Modal Message box "));
354 menuDlg
->Append(DIALOGS_MESSAGE_DIALOG
, wxT("Message dialog\tShift-Ctrl-M"));
356 menuDlg
->Append(DIALOGS_RICH_MESSAGE_DIALOG
, wxT("Rich message dialog"));
357 #endif // wxUSE_RICHMSGDLG
360 #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
362 wxMenu
*choices_menu
= new wxMenu
;
365 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR
, wxT("&Choose bg colour"));
366 choices_menu
->Append(DIALOGS_GET_COLOUR
, wxT("&Choose fg colour"));
367 #endif // wxUSE_COLOURDLG
370 choices_menu
->Append(DIALOGS_CHOOSE_FONT
, wxT("Choose &font"));
371 #endif // wxUSE_FONTDLG
374 choices_menu
->Append(DIALOGS_SINGLE_CHOICE
, wxT("&Single choice\tCtrl-C"));
375 choices_menu
->Append(DIALOGS_MULTI_CHOICE
, wxT("M&ultiple choice\tCtrl-U"));
376 #endif // wxUSE_CHOICEDLG
378 #if wxUSE_REARRANGECTRL
379 choices_menu
->Append(DIALOGS_REARRANGE
, wxT("&Rearrange dialog\tCtrl-R"));
380 #endif // wxUSE_REARRANGECTRL
382 #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
383 choices_menu
->AppendSeparator();
384 #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC
386 #if USE_COLOURDLG_GENERIC
387 choices_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, wxT("&Choose colour (generic)"));
388 #endif // USE_COLOURDLG_GENERIC
390 #if USE_FONTDLG_GENERIC
391 choices_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, wxT("Choose &font (generic)"));
392 #endif // USE_FONTDLG_GENERIC
394 menuDlg
->Append(wxID_ANY
,wxT("&Choices and selectors"),choices_menu
);
395 #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG
398 #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG
400 wxMenu
*entry_menu
= new wxMenu
;
403 entry_menu
->Append(DIALOGS_LINE_ENTRY
, wxT("Single line &entry\tCtrl-E"));
404 entry_menu
->Append(DIALOGS_TEXT_ENTRY
, wxT("Multi line text &entry\tShift-Ctrl-E"));
405 entry_menu
->Append(DIALOGS_PASSWORD_ENTRY
, wxT("&Password entry\tCtrl-P"));
406 #endif // wxUSE_TEXTDLG
409 entry_menu
->Append(DIALOGS_NUM_ENTRY
, wxT("&Numeric entry\tCtrl-N"));
410 #endif // wxUSE_NUMBERDLG
412 menuDlg
->Append(wxID_ANY
,wxT("&Entry dialogs"),entry_menu
);
414 #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
419 wxMenu
*filedlg_menu
= new wxMenu
;
420 filedlg_menu
->Append(DIALOGS_FILE_OPEN
, wxT("&Open file\tCtrl-O"));
421 filedlg_menu
->Append(DIALOGS_FILE_OPEN2
, wxT("&Second open file\tCtrl-2"));
422 filedlg_menu
->Append(DIALOGS_FILES_OPEN
, wxT("Open &files\tCtrl-Q"));
423 filedlg_menu
->Append(DIALOGS_FILE_SAVE
, wxT("Sa&ve file\tCtrl-S"));
425 #if USE_FILEDLG_GENERIC
426 filedlg_menu
->AppendSeparator();
427 filedlg_menu
->Append(DIALOGS_FILE_OPEN_GENERIC
, wxT("&Open file (generic)"));
428 filedlg_menu
->Append(DIALOGS_FILES_OPEN_GENERIC
, wxT("Open &files (generic)"));
429 filedlg_menu
->Append(DIALOGS_FILE_SAVE_GENERIC
, wxT("Sa&ve file (generic)"));
430 #endif // USE_FILEDLG_GENERIC
432 menuDlg
->Append(wxID_ANY
,wxT("&File operations"),filedlg_menu
);
434 #endif // wxUSE_FILEDLG
437 wxMenu
*dir_menu
= new wxMenu
;
439 dir_menu
->Append(DIALOGS_DIR_CHOOSE
, wxT("&Choose a directory\tCtrl-D"));
440 dir_menu
->Append(DIALOGS_DIRNEW_CHOOSE
, wxT("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
441 menuDlg
->Append(wxID_ANY
,wxT("&Directory operations"),dir_menu
);
443 #if USE_DIRDLG_GENERIC
444 dir_menu
->AppendSeparator();
445 dir_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, wxT("&Choose a directory (generic)"));
446 #endif // USE_DIRDLG_GENERIC
448 #endif // wxUSE_DIRDLG
451 #if wxUSE_STARTUP_TIPS || \
452 wxUSE_PROGRESSDLG || \
454 wxUSE_LOG_DIALOG || \
457 wxMenu
*info_menu
= new wxMenu
;
459 #if wxUSE_STARTUP_TIPS
460 info_menu
->Append(DIALOGS_TIP
, wxT("&Tip of the day\tCtrl-T"));
461 #endif // wxUSE_STARTUP_TIPS
463 #if wxUSE_PROGRESSDLG
464 info_menu
->Append(DIALOGS_PROGRESS
, wxT("Pro&gress dialog\tCtrl-G"));
465 #endif // wxUSE_PROGRESSDLG
468 info_menu
->Append(DIALOGS_BUSYINFO
, wxT("&Busy info dialog\tCtrl-B"));
469 #endif // wxUSE_BUSYINFO
472 info_menu
->Append(DIALOGS_LOG_DIALOG
, wxT("&Log dialog\tCtrl-L"));
473 #endif // wxUSE_LOG_DIALOG
476 info_menu
->Append(DIALOGS_INFOBAR_SIMPLE
, "Simple &info bar\tCtrl-I");
477 info_menu
->Append(DIALOGS_INFOBAR_ADVANCED
, "&Advanced info bar\tShift-Ctrl-I");
478 #endif // wxUSE_INFOBAR
481 info_menu
->Append(DIALOGS_MESSAGE_BOX_WXINFO
,
482 wxT("&wxWidgets information\tCtrl-W"));
483 #endif // wxUSE_MSGDLG
485 menuDlg
->Append(wxID_ANY
,wxT("&Informative dialogs"),info_menu
);
487 #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG
490 #if wxUSE_FINDREPLDLG
491 wxMenu
*find_menu
= new wxMenu
;
492 find_menu
->AppendCheckItem(DIALOGS_FIND
, wxT("&Find dialog\tCtrl-F"));
493 find_menu
->AppendCheckItem(DIALOGS_REPLACE
, wxT("Find and &replace dialog\tShift-Ctrl-F"));
494 menuDlg
->Append(wxID_ANY
,wxT("&Searching"),find_menu
);
495 #endif // wxUSE_FINDREPLDLG
497 wxMenu
*dialogs_menu
= new wxMenu
;
498 #if USE_MODAL_PRESENTATION
499 dialogs_menu
->Append(DIALOGS_MODAL
, wxT("&Modal dialog\tShift-Ctrl-W"));
500 #endif // USE_MODAL_PRESENTATION
501 dialogs_menu
->AppendCheckItem(DIALOGS_MODELESS
, wxT("Mode&less dialog\tShift-Ctrl-Z"));
502 dialogs_menu
->Append(DIALOGS_CENTRE_SCREEN
, wxT("Centered on &screen\tShift-Ctrl-1"));
503 dialogs_menu
->Append(DIALOGS_CENTRE_PARENT
, wxT("Centered on &parent\tShift-Ctrl-2"));
505 dialogs_menu
->Append(DIALOGS_MINIFRAME
, wxT("&Mini frame"));
506 #endif // wxUSE_MINIFRAME
507 dialogs_menu
->Append(DIALOGS_ONTOP
, wxT("Dialog staying on &top"));
508 menuDlg
->Append(wxID_ANY
, wxT("&Generic dialogs"), dialogs_menu
);
510 #if USE_SETTINGS_DIALOG
511 wxMenu
*sheet_menu
= new wxMenu
;
512 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET
, wxT("&Standard property sheet\tShift-Ctrl-P"));
513 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK
, wxT("&Toolbook sheet\tShift-Ctrl-T"));
515 if (wxPlatformIs(wxPORT_MAC
))
516 sheet_menu
->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
, wxT("Button &Toolbook sheet\tShift-Ctrl-U"));
519 sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, wxT("Button &Toolbook sheet\tShift-Ctrl-U"));
522 menuDlg
->Append(wxID_ANY
, wxT("&Property sheets"), sheet_menu
);
523 #endif // USE_SETTINGS_DIALOG
525 wxMenu
*menuNotif
= new wxMenu
;
526 menuNotif
->Append(DIALOGS_REQUEST
, wxT("&Request user attention\tCtrl-Shift-R"));
527 #if wxUSE_NOTIFICATION_MESSAGE
528 menuNotif
->Append(DIALOGS_NOTIFY_AUTO
, "&Automatically hidden notification");
529 menuNotif
->Append(DIALOGS_NOTIFY_SHOW
, "&Show manual notification");
530 menuNotif
->Append(DIALOGS_NOTIFY_HIDE
, "&Hide manual notification");
531 #endif // wxUSE_NOTIFICATION_MESSAGE
532 menuDlg
->AppendSubMenu(menuNotif
, "&User notifications");
534 #if wxUSE_RICHTOOLTIP
535 menuDlg
->Append(DIALOGS_RICHTIP_DIALOG
, "Rich &tooltip dialog...\tCtrl-H");
536 menuDlg
->AppendSeparator();
537 #endif // wxUSE_RICHTOOLTIP
539 menuDlg
->Append(DIALOGS_STANDARD_BUTTON_SIZER_DIALOG
, wxT("&Standard Buttons Sizer Dialog"));
540 menuDlg
->Append(DIALOGS_TEST_DEFAULT_ACTION
, wxT("&Test dialog default action"));
542 menuDlg
->AppendSeparator();
543 menuDlg
->Append(wxID_EXIT
, wxT("E&xit\tAlt-X"));
546 wxMenu
*menuHelp
= new wxMenu
;
547 menuHelp
->Append(DIALOGS_ABOUTDLG_SIMPLE
, wxT("&About (simple)...\tF1"));
548 menuHelp
->Append(DIALOGS_ABOUTDLG_FANCY
, wxT("About (&fancy)...\tShift-F1"));
549 menuHelp
->Append(DIALOGS_ABOUTDLG_FULL
, wxT("About (f&ull)...\tCtrl-F1"));
550 menuHelp
->Append(DIALOGS_ABOUTDLG_CUSTOM
, wxT("About (&custom)...\tCtrl-Shift-F1"));
551 #endif // wxUSE_ABOUTDLG
553 wxMenu
* editMenu
= new wxMenu
;
554 editMenu
->Append(wxID_UNDO
, _("&Undo\tCtrl+Z"));
555 editMenu
->Append(wxID_REDO
, _("&Redo\tCtrl+Y"));
556 editMenu
->AppendSeparator();
557 editMenu
->Append(wxID_CUT
, _("Cu&t\tCtrl+X"));
558 editMenu
->Append(wxID_COPY
, _("&Copy\tCtrl+C"));
559 editMenu
->Append(wxID_PASTE
, _("&Paste\tCtrl+V"));
560 editMenu
->Append(wxID_CLEAR
, _("&Delete"));
562 editMenu
->AppendSeparator();
563 editMenu
->Append(wxID_SELECTALL
, _("Select All\tCtrl+A"));
565 wxMenuBar
*menubar
= new wxMenuBar
;
566 menubar
->Append(menuDlg
, wxT("&Dialogs"));
568 menubar
->Append(editMenu
, wxT("&Edit"));
571 menubar
->Append(menuHelp
, wxT("&Help"));
572 #endif // wxUSE_ABOUTDLG
574 frame
->SetMenuBar(menubar
);
576 frame
->Centre(wxBOTH
);
582 // My frame constructor
583 MyFrame::MyFrame(const wxString
& title
)
584 : wxFrame(NULL
, wxID_ANY
, title
)
586 SetIcon(wxICON(sample
));
588 #if USE_MODAL_PRESENTATION
589 m_dialog
= (MyModelessDialog
*)NULL
;
590 #endif // USE_MODAL_PRESENTATION
592 #if wxUSE_FINDREPLDLG
598 m_clrData
.SetChooseFull(true);
599 for (int i
= 0; i
< wxColourData::NUM_CUSTOM
; i
++)
601 unsigned char n
= i
*16;
602 m_clrData
.SetCustomColour(i
, wxColour(n
, n
, n
));
604 #endif // wxUSE_COLOURDLG
606 #if wxUSE_NOTIFICATION_MESSAGE
608 #endif // wxUSE_NOTIFICATION_MESSAGE
612 #endif // wxUSE_STATUSBAR
614 m_canvas
= new MyCanvas(this);
617 // an info bar can be created very simply and used without any extra effort
618 m_infoBarSimple
= new wxInfoBar(this);
620 // or it can also be customized by
621 m_infoBarAdvanced
= new wxInfoBar(this);
623 // ... adding extra buttons (but more than two will usually be too many)
624 m_infoBarAdvanced
->AddButton(wxID_UNDO
);
625 m_infoBarAdvanced
->AddButton(wxID_REDO
);
627 m_infoBarAdvanced
->Connect(wxID_REDO
, wxEVT_COMMAND_BUTTON_CLICKED
,
628 wxCommandEventHandler(MyFrame::OnInfoBarRedo
),
632 // adding and removing a button immediately doesn't make sense here, of
633 // course, it's done just to show that it is possible
634 m_infoBarAdvanced
->AddButton(wxID_EXIT
);
635 m_infoBarAdvanced
->RemoveButton(wxID_EXIT
);
637 // ... changing the colours and/or fonts
638 m_infoBarAdvanced
->SetOwnBackgroundColour(0xc8ffff);
639 m_infoBarAdvanced
->SetFont(GetFont().Bold().Larger());
641 // ... and changing the effect (only does anything under MSW currently)
642 m_infoBarAdvanced
->SetShowHideEffects(wxSHOW_EFFECT_EXPAND
,
643 wxSHOW_EFFECT_EXPAND
);
644 m_infoBarAdvanced
->SetEffectDuration(1500);
647 // to use the info bars we need to use sizer for the window layout
648 wxBoxSizer
* const sizer
= new wxBoxSizer(wxVERTICAL
);
649 sizer
->Add(m_infoBarSimple
, wxSizerFlags().Expand());
650 sizer
->Add(m_canvas
, wxSizerFlags(1).Expand());
651 sizer
->Add(m_infoBarAdvanced
, wxSizerFlags().Expand());
654 // final touch: under MSW the info bars are shown progressively and parts
655 // of the parent window can be seen during the process, so use the same
656 // background colour for our background as for the canvas window which
657 // covers our entire client area to avoid jarring colour jumps
658 SetOwnBackgroundColour(m_canvas
->GetBackgroundColour());
659 #endif // wxUSE_INFOBAR
662 // Test MSW-specific function allowing to access the "system" menu.
663 wxMenu
* const menu
= MSWGetSystemMenu();
666 menu
->AppendSeparator();
668 // The ids of the menu commands in MSW system menu must be multiple of
669 // 16 so we can't use DIALOGS_ABOUTDLG_SIMPLE here because it might not
670 // satisfy this condition and need to define and connect a separate id.
671 static const int DIALOGS_SYSTEM_ABOUT
= 0x4010;
673 menu
->Append(DIALOGS_SYSTEM_ABOUT
, "&About");
674 Connect(DIALOGS_SYSTEM_ABOUT
, wxEVT_COMMAND_MENU_SELECTED
,
675 wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog
));
682 #if wxUSE_NOTIFICATION_MESSAGE
684 #endif // wxUSE_NOTIFICATION_MESSAGE
689 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
))
691 m_clrData
.SetColour(m_canvas
->GetBackgroundColour());
693 wxColourDialog
dialog(this, &m_clrData
);
694 dialog
.SetTitle(_("Please choose the background colour"));
695 if ( dialog
.ShowModal() == wxID_OK
)
697 m_clrData
= dialog
.GetColourData();
698 m_canvas
->SetBackgroundColour(m_clrData
.GetColour());
699 m_canvas
->ClearBackground();
704 void MyFrame::GetColour(wxCommandEvent
& WXUNUSED(event
))
706 wxColour clr
= wxGetColourFromUser
709 m_canvas
->GetForegroundColour(),
710 "Please choose the foreground colour"
714 m_canvas
->SetForegroundColour(clr
);
717 //else: dialog cancelled by user
720 #endif // wxUSE_COLOURDLG
723 #if USE_COLOURDLG_GENERIC
724 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
726 m_clrData
.SetColour(m_canvas
->GetBackgroundColour());
728 //FIXME:TODO:This has no effect...
729 m_clrData
.SetChooseFull(true);
731 for (int i
= 0; i
< 16; i
++)
734 (unsigned char)(i
*16),
735 (unsigned char)(i
*16),
736 (unsigned char)(i
*16)
738 m_clrData
.SetCustomColour(i
, colour
);
741 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &m_clrData
);
742 if (dialog
->ShowModal() == wxID_OK
)
744 m_clrData
= dialog
->GetColourData();
745 m_canvas
->SetBackgroundColour(m_clrData
.GetColour());
746 m_canvas
->ClearBackground();
751 #endif // USE_COLOURDLG_GENERIC
754 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
757 data
.SetInitialFont(m_canvas
->GetFont());
758 data
.SetColour(m_canvas
->GetForegroundColour());
760 // you might also do this:
762 // wxFontDialog dialog;
763 // if ( !dialog.Create(this, data) { ... error ... }
765 wxFontDialog
dialog(this, data
);
767 if (dialog
.ShowModal() == wxID_OK
)
769 wxFontData retData
= dialog
.GetFontData();
770 m_canvas
->SetFont(retData
.GetChosenFont());
771 m_canvas
->SetForegroundColour(retData
.GetColour());
774 //else: cancelled by the user, don't change the font
776 #endif // wxUSE_FONTDLG
778 #if USE_FONTDLG_GENERIC
779 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
782 data
.SetInitialFont(m_canvas
->GetFont());
783 data
.SetColour(m_canvas
->GetForegroundColour());
785 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, data
);
786 if (dialog
->ShowModal() == wxID_OK
)
788 wxFontData retData
= dialog
->GetFontData();
789 m_canvas
->SetFont(retData
.GetChosenFont());
790 m_canvas
->SetForegroundColour(retData
.GetColour());
795 #endif // USE_FONTDLG_GENERIC
798 void MyFrame::LogDialog(wxCommandEvent
& WXUNUSED(event
))
800 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
801 // being flushed -- test it
804 wxLogMessage(wxT("This is some message - everything is ok so far."));
805 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
806 wxLogWarning(wxT("And then something went wrong!"));
808 // and if ~wxBusyCursor doesn't do it, then call it manually
812 wxLogError(wxT("Intermediary error handler decided to abort."));
813 wxLogError(wxT("The top level caller detected an unrecoverable error."));
815 wxLog::FlushActive();
817 wxLogMessage(wxT("And this is the same dialog but with only one message."));
819 #endif // wxUSE_LOG_DIALOG
823 void MyFrame::InfoBarSimple(wxCommandEvent
& WXUNUSED(event
))
825 static int s_count
= 0;
826 m_infoBarSimple
->ShowMessage
828 wxString::Format("Message #%d in the info bar.", ++s_count
)
832 void MyFrame::InfoBarAdvanced(wxCommandEvent
& WXUNUSED(event
))
834 m_infoBarAdvanced
->ShowMessage("Sorry, it didn't work out.", wxICON_WARNING
);
837 void MyFrame::OnInfoBarRedo(wxCommandEvent
& WXUNUSED(event
))
839 m_infoBarAdvanced
->ShowMessage("Still no, sorry again.", wxICON_ERROR
);
842 #endif // wxUSE_INFOBAR
846 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
))
848 wxMessageDialog
dialog(this,
849 "This is a message box\n"
850 "This is a long, long string to test out if the message box "
851 "is laid out properly.",
854 wxNO_DEFAULT
| wxYES_NO
| wxCANCEL
|
858 if ( dialog
.SetYesNoCancelLabels
865 extmsg
= "This platform supports custom button labels,\n"
866 "so you should see the descriptive labels below.";
870 extmsg
= "Custom button labels are not supported on this platform,\n"
871 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
873 dialog
.SetExtendedMessage(extmsg
);
875 switch ( dialog
.ShowModal() )
878 wxLogStatus(wxT("You pressed \"Yes\""));
882 wxLogStatus(wxT("You pressed \"No\""));
886 wxLogStatus(wxT("You pressed \"Cancel\""));
890 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
894 void MyFrame::MessageBoxWindowModal(wxCommandEvent
& WXUNUSED(event
))
896 wxMessageDialog
* dialog
= new wxMessageDialog(this,
897 "This is a message box\n"
898 "This is a long, long string to test out if the message box "
899 "is laid out properly.",
902 wxNO_DEFAULT
| wxYES_NO
| wxCANCEL
|
906 if ( dialog
->SetYesNoCancelLabels
913 extmsg
= "This platform supports custom button labels,\n"
914 "so you should see the descriptive labels below.";
918 extmsg
= "Custom button labels are not supported on this platform,\n"
919 "so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
921 dialog
->SetExtendedMessage(extmsg
);
922 dialog
->Connect( wxEVT_WINDOW_MODAL_DIALOG_CLOSED
, wxWindowModalDialogEventHandler(MyFrame::MessageBoxWindowModalClosed
), NULL
, this );
923 dialog
->ShowWindowModal();
926 void MyFrame::MessageBoxWindowModalClosed(wxWindowModalDialogEvent
& event
)
928 wxDialog
* dialog
= event
.GetDialog();
929 switch ( dialog
->GetReturnCode() )
932 wxLogStatus(wxT("You pressed \"Yes\""));
936 wxLogStatus(wxT("You pressed \"No\""));
940 wxLogStatus(wxT("You pressed \"Cancel\""));
944 wxLogError(wxT("Unexpected wxMessageDialog return code!"));
949 void MyFrame::MessageBoxDialog(wxCommandEvent
& WXUNUSED(event
))
951 TestMessageBoxDialog
dlg(this);
956 void MyFrame::MessageBoxInfo(wxCommandEvent
& WXUNUSED(event
))
958 ::wxInfoMessageBox(this);
960 #endif // wxUSE_MSGDLG
963 void MyFrame::RichMessageDialog(wxCommandEvent
& WXUNUSED(event
))
965 TestRichMessageDialog
dlg(this);
969 #endif // wxUSE_RICHMSGDLG
972 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
))
974 long res
= wxGetNumberFromUser( wxT("This is some text, actually a lot of text.\n")
975 wxT("Even two rows of text."),
976 wxT("Enter a number:"), wxT("Numeric input test"),
983 msg
= wxT("Invalid number entered or dialog cancelled.");
988 msg
.Printf(wxT("You've entered %lu"), res
);
989 icon
= wxICON_INFORMATION
;
992 wxMessageBox(msg
, wxT("Numeric test result"), wxOK
| icon
, this);
994 #endif // wxUSE_NUMBERDLG
997 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
999 wxString pwd
= wxGetPasswordFromUser(wxT("Enter password:"),
1000 wxT("Password entry dialog"),
1005 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
1006 wxT("Got password"), wxOK
| wxICON_INFORMATION
, this);
1010 void MyFrame::LineEntry(wxCommandEvent
& WXUNUSED(event
))
1012 wxTextEntryDialog
dialog(this,
1013 wxT("This is a small sample\n")
1014 wxT("A long, long string to test out the text entrybox"),
1015 wxT("Please enter a string"),
1016 wxT("Default value"),
1019 if (dialog
.ShowModal() == wxID_OK
)
1021 wxMessageBox(dialog
.GetValue(), wxT("Got string"), wxOK
| wxICON_INFORMATION
, this);
1025 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
1027 wxTextEntryDialog
dialog(this, "You can enter a multiline string here.",
1028 "Please enter some text",
1029 "First line\nSecond one\nAnd another one too",
1030 wxOK
| wxCANCEL
| wxTE_MULTILINE
);
1032 if (dialog
.ShowModal() == wxID_OK
)
1034 wxMessageBox(dialog
.GetValue(), wxT("Got text"), wxOK
| wxICON_INFORMATION
, this);
1037 #endif // wxUSE_TEXTDLG
1040 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
1042 const wxString choices
[] = { wxT("One"), wxT("Two"), wxT("Three"), wxT("Four"), wxT("Five") } ;
1044 wxSingleChoiceDialog
dialog(this,
1045 wxT("This is a small sample\n")
1046 wxT("A single-choice convenience dialog"),
1047 wxT("Please select a value"),
1048 WXSIZEOF(choices
), choices
);
1050 dialog
.SetSelection(2);
1052 if (dialog
.ShowModal() == wxID_OK
)
1054 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), wxT("Got string"));
1055 dialog2
.ShowModal();
1059 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
1061 const wxString choices
[] =
1063 wxT("One"), wxT("Two"), wxT("Three"), wxT("Four"), wxT("Five"),
1064 wxT("Six"), wxT("Seven"), wxT("Eight"), wxT("Nine"), wxT("Ten"),
1065 wxT("Eleven"), wxT("Twelve"), wxT("Seventeen"),
1068 wxArrayInt selections
;
1069 const int count
= wxGetSelectedChoices(selections
,
1070 wxT("This is a small sample\n")
1071 wxT("A multi-choice convenience dialog"),
1072 wxT("Please select a value"),
1073 WXSIZEOF(choices
), choices
,
1080 msg
= wxT("You did not select any items");
1084 msg
.Printf(wxT("You selected %u items:\n"), (unsigned)count
);
1085 for ( int n
= 0; n
< count
; n
++ )
1087 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"),
1088 (unsigned)n
, (unsigned)selections
[n
],
1089 choices
[selections
[n
]].c_str());
1096 #endif // wxUSE_CHOICEDLG
1098 #if wxUSE_REARRANGECTRL
1099 // custom rearrange dialog: it adds the possibility to rename an item to the
1100 // base class functionality
1101 class MyRearrangeDialog
: public wxRearrangeDialog
1104 MyRearrangeDialog(wxWindow
*parent
,
1106 wxArrayString
& labels
,
1107 wxArrayString
& labelsOrig
)
1111 "Configure the columns shown:",
1112 "wxRearrangeDialog example",
1118 m_labelsOrig(labelsOrig
)
1120 m_sel
= wxNOT_FOUND
;
1122 wxPanel
* const panel
= new wxPanel(this);
1123 wxSizer
* const sizer
= new wxBoxSizer(wxHORIZONTAL
);
1125 m_labelOrig
= new wxStaticText(panel
, wxID_ANY
, "");
1126 sizer
->Add(m_labelOrig
, wxSizerFlags().Centre().Border(wxRIGHT
));
1128 m_text
= new wxTextCtrl(panel
, wxID_ANY
, "",
1129 wxDefaultPosition
, wxDefaultSize
,
1130 wxTE_PROCESS_ENTER
);
1131 sizer
->Add(m_text
, wxSizerFlags().Centre().Border(wxRIGHT
));
1133 sizer
->Add(new wxButton(panel
, wxID_APPLY
, "&Rename"),
1134 wxSizerFlags().Centre());
1136 panel
->SetSizer(sizer
);
1138 // call this first to ensure that the controls have a reasonable best
1139 // size before they're added
1140 DoUpdateExtraControls(GetList()->GetSelection());
1142 AddExtraControls(panel
);
1145 // another customization not directly supported by the dialog: add a
1147 wxWindow
* const btnOk
= FindWindow(wxID_OK
);
1148 wxCHECK_RET( btnOk
, "no Ok button?" );
1150 wxSizer
* const sizerBtns
= btnOk
->GetContainingSizer();
1151 wxCHECK_RET( sizerBtns
, "no buttons sizer?" );
1153 sizerBtns
->Add(new wxButton(this, wxID_RESET
, "&Reset all"),
1154 wxSizerFlags().Border(wxLEFT
));
1157 // call this instead of ShowModal() to update order and labels array in
1158 // case the dialog was not cancelled
1161 switch ( ShowModal() )
1167 m_order
= GetOrder();
1171 // order already reset
1179 void OnSelChange(wxCommandEvent
& event
)
1181 DoUpdateExtraControls(event
.GetInt());
1184 void OnUpdateUIRename(wxUpdateUIEvent
& event
)
1186 event
.Enable( CanRename() );
1189 void OnRename(wxCommandEvent
& WXUNUSED(event
))
1194 m_labels
[m_sel
] = m_text
->GetValue();
1195 GetList()->SetString(m_sel
, m_labels
[m_sel
]);
1198 void OnReset(wxCommandEvent
& WXUNUSED(event
))
1200 // in a real program we should probably ask if the user really wants to
1201 // do this but here we just go ahead and reset all columns labels and
1202 // their order without confirmation
1203 const unsigned count
= m_order
.size();
1204 for ( unsigned n
= 0; n
< count
; n
++ )
1207 m_labels
[n
] = m_labelsOrig
[n
];
1210 EndModal(wxID_RESET
);
1213 bool CanRename() const
1215 // only allow renaming if the user modified the currently selected item
1216 // text (which presupposes that we do have a current item)
1217 return m_sel
!= wxNOT_FOUND
&& m_text
->GetValue() != m_labels
[m_sel
];
1220 void DoUpdateExtraControls(int sel
)
1224 if ( m_sel
== wxNOT_FOUND
)
1226 m_labelOrig
->SetLabel("<no selection>");
1230 else // have valid item
1232 m_labelOrig
->SetLabelText(m_labelsOrig
[m_sel
]);
1234 m_text
->SetValue(m_labels
[m_sel
]);
1238 wxArrayInt
& m_order
;
1239 wxArrayString
& m_labels
,
1243 wxStaticText
*m_labelOrig
;
1246 DECLARE_EVENT_TABLE()
1247 wxDECLARE_NO_COPY_CLASS(MyRearrangeDialog
);
1250 BEGIN_EVENT_TABLE(MyRearrangeDialog
, wxRearrangeDialog
)
1251 EVT_LISTBOX(wxID_ANY
, MyRearrangeDialog::OnSelChange
)
1253 EVT_UPDATE_UI(wxID_APPLY
, MyRearrangeDialog::OnUpdateUIRename
)
1255 EVT_TEXT_ENTER(wxID_ANY
, MyRearrangeDialog::OnRename
)
1256 EVT_BUTTON(wxID_APPLY
, MyRearrangeDialog::OnRename
)
1257 EVT_BUTTON(wxID_RESET
, MyRearrangeDialog::OnReset
)
1260 void MyFrame::Rearrange(wxCommandEvent
& WXUNUSED(event
))
1262 // the arrays are static so that we preserve the items order between calls
1264 static wxArrayInt s_order
;
1265 static wxArrayString s_labels
,
1268 // initialize them on the first call
1269 if ( s_labelsOrig
.empty() )
1271 static const struct ItemInfo
1274 const char *labelOrig
;
1278 { "File name", "Name", 0 },
1279 { "File type", "Ext", 1 },
1280 { "Size", "Size", 2 },
1281 { "Creation time", "Ctime", ~3 }, // negated so hidden
1282 { "Last accessed", "Atime", ~4 },
1283 { "Last modified", "Mtime", 5 },
1286 s_order
.reserve(WXSIZEOF(items
));
1287 s_labels
.reserve(WXSIZEOF(items
));
1288 s_labelsOrig
.reserve(WXSIZEOF(items
));
1289 for ( unsigned n
= 0; n
< WXSIZEOF(items
); n
++ )
1291 const ItemInfo
& item
= items
[n
];
1292 s_order
.push_back(item
.order
);
1293 s_labels
.push_back(item
.label
);
1294 s_labelsOrig
.push_back(item
.labelOrig
);
1298 MyRearrangeDialog
dlg(this, s_order
, s_labels
, s_labelsOrig
);
1299 if ( !dlg
.Rearrange() )
1303 for ( unsigned n
= 0; n
< s_order
.size(); n
++ )
1305 columns
+= wxString::Format("\n %u: ", n
);
1306 int idx
= s_order
[n
];
1309 columns
+= "[hidden] ";
1313 columns
+= s_labels
[idx
];
1314 if ( s_labels
[idx
] != s_labelsOrig
[idx
] )
1316 columns
+= wxString::Format(" (original label: \"%s\")",
1321 wxLogMessage("The columns order now is:%s", columns
);
1323 #endif // wxUSE_REARRANGECTRL
1327 // panel with custom controls for file dialog
1328 class MyExtraPanel
: public wxPanel
1331 MyExtraPanel(wxWindow
*parent
);
1332 void OnCheckBox(wxCommandEvent
& event
) { m_btn
->Enable(event
.IsChecked()); }
1333 wxString
GetInfo() const
1335 return wxString::Format("checkbox value = %d", (int) m_cb
->GetValue());
1342 MyExtraPanel::MyExtraPanel(wxWindow
*parent
)
1345 m_btn
= new wxButton(this, -1, wxT("Custom Button"));
1346 m_btn
->Enable(false);
1347 m_cb
= new wxCheckBox(this, -1, wxT("Enable Custom Button"));
1348 m_cb
->Connect(wxID_ANY
, wxEVT_COMMAND_CHECKBOX_CLICKED
,
1349 wxCommandEventHandler(MyExtraPanel::OnCheckBox
), NULL
, this);
1350 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
1351 sizerTop
->Add(m_cb
, wxSizerFlags().Centre().Border());
1352 sizerTop
->AddStretchSpacer();
1353 sizerTop
->Add(m_btn
, wxSizerFlags().Right().Border());
1354 SetSizerAndFit(sizerTop
);
1357 // a static method can be used instead of a function with most of compilers
1358 static wxWindow
* createMyExtraPanel(wxWindow
*parent
)
1360 return new MyExtraPanel(parent
);
1363 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
1368 wxT("Testing open file dialog"),
1372 wxT("C++ files (*.cpp)|*.cpp")
1374 wxT("C++ files (*.cpp;*.h)|*.cpp;*.h")
1378 dialog
.SetExtraControlCreator(&createMyExtraPanel
);
1379 dialog
.CentreOnParent();
1380 dialog
.SetDirectory(wxGetHomeDir());
1382 if (dialog
.ShowModal() == wxID_OK
)
1385 wxWindow
* const extra
= dialog
.GetExtraControl();
1386 info
.Printf(wxT("Full file name: %s\n")
1389 wxT("Custom window: %s"),
1390 dialog
.GetPath().c_str(),
1391 dialog
.GetDirectory().c_str(),
1392 dialog
.GetFilename().c_str(),
1393 extra
? static_cast<MyExtraPanel
*>(extra
)->GetInfo()
1394 : wxString("None"));
1395 wxMessageDialog
dialog2(this, info
, wxT("Selected file"));
1396 dialog2
.ShowModal();
1400 // this shows how to take advantage of specifying a default extension in the
1401 // call to wxFileSelector: it is remembered after each new call and the next
1402 // one will use it by default
1403 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
1405 static wxString s_extDef
;
1406 wxString path
= wxFileSelector(
1407 wxT("Select the file to load"),
1408 wxEmptyString
, wxEmptyString
,
1412 wxT("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
1413 wxFileSelectorDefaultWildcardStr
,
1414 wxFileSelectorDefaultWildcardStr
1416 wxFD_OPEN
|wxFD_CHANGE_DIR
|wxFD_PREVIEW
,
1423 // it is just a sample, would use wxSplitPath in real program
1424 s_extDef
= path
.AfterLast(wxT('.'));
1426 wxLogMessage(wxT("You selected the file '%s', remembered extension '%s'"),
1430 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
1432 wxString wildcards
=
1434 wxT("C++ files (*.cpp)|*.cpp");
1438 wxT("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
1439 wxFileSelectorDefaultWildcardStr
,
1440 wxFileSelectorDefaultWildcardStr
1443 wxFileDialog
dialog(this, wxT("Testing open multiple file dialog"),
1444 wxEmptyString
, wxEmptyString
, wildcards
,
1445 wxFD_OPEN
|wxFD_MULTIPLE
);
1447 if (dialog
.ShowModal() == wxID_OK
)
1449 wxArrayString paths
, filenames
;
1451 dialog
.GetPaths(paths
);
1452 dialog
.GetFilenames(filenames
);
1455 size_t count
= paths
.GetCount();
1456 for ( size_t n
= 0; n
< count
; n
++ )
1458 s
.Printf(wxT("File %d: %s (%s)\n"),
1459 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
1463 s
.Printf(wxT("Filter index: %d"), dialog
.GetFilterIndex());
1466 wxMessageDialog
dialog2(this, msg
, wxT("Selected files"));
1467 dialog2
.ShowModal();
1471 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
1473 wxFileDialog
dialog(this,
1474 wxT("Testing save file dialog"),
1476 wxT("myletter.doc"),
1477 wxT("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
1478 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1480 dialog
.SetFilterIndex(1);
1482 if (dialog
.ShowModal() == wxID_OK
)
1484 wxLogMessage(wxT("%s, filter %d"),
1485 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
1488 #endif // wxUSE_FILEDLG
1490 #if USE_FILEDLG_GENERIC
1491 void MyFrame::FileOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
1493 wxGenericFileDialog dialog
1496 wxT("Testing open file dialog"),
1499 wxT("C++ files (*.cpp;*.h)|*.cpp;*.h")
1502 dialog
.SetExtraControlCreator(&createMyExtraPanel
);
1503 dialog
.SetDirectory(wxGetHomeDir());
1505 if (dialog
.ShowModal() == wxID_OK
)
1508 info
.Printf(wxT("Full file name: %s\n")
1511 dialog
.GetPath().c_str(),
1512 dialog
.GetDirectory().c_str(),
1513 dialog
.GetFilename().c_str());
1514 wxMessageDialog
dialog2(this, info
, wxT("Selected file"));
1515 dialog2
.ShowModal();
1519 void MyFrame::FilesOpenGeneric(wxCommandEvent
& WXUNUSED(event
) )
1521 // On PocketPC you can disable OK-only dialogs policy using system option
1522 int buttons
= wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
1523 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
1525 wxString wildcards
= wxT("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
1526 wxGenericFileDialog
dialog(this, wxT("Testing open multiple file dialog"),
1527 wxEmptyString
, wxEmptyString
, wildcards
,
1530 if (dialog
.ShowModal() == wxID_OK
)
1532 wxArrayString paths
, filenames
;
1534 dialog
.GetPaths(paths
);
1535 dialog
.GetFilenames(filenames
);
1538 size_t count
= paths
.GetCount();
1539 for ( size_t n
= 0; n
< count
; n
++ )
1541 s
.Printf(wxT("File %d: %s (%s)\n"),
1542 (int)n
, paths
[n
].c_str(), filenames
[n
].c_str());
1546 s
.Printf(wxT("Filter index: %d"), dialog
.GetFilterIndex());
1549 wxMessageDialog
dialog2(this, msg
, wxT("Selected files"));
1550 dialog2
.ShowModal();
1553 // restore system option
1554 wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons
);
1557 void MyFrame::FileSaveGeneric(wxCommandEvent
& WXUNUSED(event
) )
1559 wxGenericFileDialog
dialog(this,
1560 wxT("Testing save file dialog"),
1562 wxT("myletter.doc"),
1563 wxT("Text files (*.txt)|*.txt|Document files (*.doc;*.ods)|*.doc;*.ods"),
1564 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1566 dialog
.SetFilterIndex(1);
1568 if (dialog
.ShowModal() == wxID_OK
)
1570 wxLogMessage(wxT("%s, filter %d"),
1571 dialog
.GetPath().c_str(), dialog
.GetFilterIndex());
1574 #endif // USE_FILEDLG_GENERIC
1577 void MyFrame::DoDirChoose(int style
)
1579 // pass some initial dir to wxDirDialog
1581 wxGetHomeDir(&dirHome
);
1583 wxDirDialog
dialog(this, wxT("Testing directory picker"), dirHome
, style
);
1585 if (dialog
.ShowModal() == wxID_OK
)
1587 wxLogMessage(wxT("Selected path: %s"), dialog
.GetPath().c_str());
1591 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
1593 DoDirChoose(wxDD_DEFAULT_STYLE
| wxDD_DIR_MUST_EXIST
);
1596 void MyFrame::DirChooseNew(wxCommandEvent
& WXUNUSED(event
) )
1598 DoDirChoose(wxDD_DEFAULT_STYLE
& ~wxDD_DIR_MUST_EXIST
);
1600 #endif // wxUSE_DIRDLG
1602 #if USE_DIRDLG_GENERIC
1603 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
1605 // pass some initial dir to wxDirDialog
1607 wxGetHomeDir(&dirHome
);
1609 wxGenericDirDialog
dialog(this, wxT("Testing generic directory picker"), dirHome
);
1611 if (dialog
.ShowModal() == wxID_OK
)
1613 wxMessageDialog
dialog2(this, dialog
.GetPath(), wxT("Selected path"));
1614 dialog2
.ShowModal();
1617 #endif // USE_DIRDLG_GENERIC
1619 #if USE_MODAL_PRESENTATION
1620 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
1622 MyModalDialog
dlg(this);
1625 #endif // USE_MODAL_PRESENTATION
1627 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
1629 bool show
= GetMenuBar()->IsChecked(event
.GetId());
1635 m_dialog
= new MyModelessDialog(this);
1638 m_dialog
->Show(true);
1642 // If m_dialog is NULL, then possibly the system
1643 // didn't report the checked menu item status correctly.
1644 // It should be true just after the menu item was selected,
1645 // if there was no modeless dialog yet.
1647 wxASSERT( m_dialog
!= NULL
);
1653 void MyFrame::DlgCenteredScreen(wxCommandEvent
& WXUNUSED(event
))
1655 wxDialog
dlg(this, wxID_ANY
, wxT("Dialog centered on screen"),
1656 wxDefaultPosition
, wxSize(200, 100));
1657 (new wxButton(&dlg
, wxID_OK
, wxT("Close")))->Centre();
1658 dlg
.CentreOnScreen();
1662 void MyFrame::DlgCenteredParent(wxCommandEvent
& WXUNUSED(event
))
1664 wxDialog
dlg(this, wxID_ANY
, wxT("Dialog centered on parent"),
1665 wxDefaultPosition
, wxSize(200, 100));
1666 (new wxButton(&dlg
, wxID_OK
, wxT("Close")))->Centre();
1667 dlg
.CentreOnParent();
1672 void MyFrame::MiniFrame(wxCommandEvent
& WXUNUSED(event
))
1674 wxFrame
*frame
= new wxMiniFrame(this, wxID_ANY
, wxT("Mini frame"),
1675 wxDefaultPosition
, wxSize(300, 100),
1676 wxCAPTION
| wxCLOSE_BOX
);
1677 new wxStaticText(frame
,
1679 wxT("Mini frames have slightly different appearance"),
1681 new wxStaticText(frame
,
1683 wxT("from the normal frames but that's the only difference."),
1686 frame
->CentreOnParent();
1689 #endif // wxUSE_MINIFRAME
1691 void MyFrame::DlgOnTop(wxCommandEvent
& WXUNUSED(event
))
1693 wxDialog
dlg(this, wxID_ANY
, wxT("Dialog staying on top of other windows"),
1694 wxDefaultPosition
, wxSize(300, 100),
1695 wxDEFAULT_DIALOG_STYLE
| wxSTAY_ON_TOP
);
1696 (new wxButton(&dlg
, wxID_OK
, wxT("Close")))->Centre();
1700 #if wxUSE_STARTUP_TIPS
1701 void MyFrame::ShowTip(wxCommandEvent
& WXUNUSED(event
))
1703 static size_t s_index
= (size_t)-1;
1705 if ( s_index
== (size_t)-1 )
1709 // this is completely bogus, we don't know how many lines are there
1710 // in the file, but who cares, it's a demo only...
1711 s_index
= rand() % 5;
1714 wxTipProvider
*tipProvider
= wxCreateFileTipProvider(wxT("tips.txt"), s_index
);
1716 bool showAtStartup
= wxShowTip(this, tipProvider
);
1718 if ( showAtStartup
)
1720 wxMessageBox(wxT("Will show tips on startup"), wxT("Tips dialog"),
1721 wxOK
| wxICON_INFORMATION
, this);
1724 s_index
= tipProvider
->GetCurrentTip();
1727 #endif // wxUSE_STARTUP_TIPS
1729 #if USE_SETTINGS_DIALOG
1730 void MyFrame::OnPropertySheet(wxCommandEvent
& event
)
1732 SettingsDialog
dialog(this, event
.GetId());
1735 #endif // USE_SETTINGS_DIALOG
1737 void MyFrame::OnRequestUserAttention(wxCommandEvent
& WXUNUSED(event
))
1739 wxLogStatus(wxT("Sleeping for 3 seconds to allow you to switch to another window"));
1743 RequestUserAttention(wxUSER_ATTENTION_ERROR
);
1746 #if wxUSE_NOTIFICATION_MESSAGE
1748 void MyFrame::OnNotifMsgAuto(wxCommandEvent
& WXUNUSED(event
))
1750 // Notice that the notification remains shown even after the
1751 // wxNotificationMessage object itself is destroyed so we can show simple
1752 // notifications using temporary objects.
1753 if ( !wxNotificationMessage
1755 "Automatic Notification",
1756 "Nothing important has happened\n"
1757 "this notification will disappear soon."
1760 wxLogStatus("Failed to show notification message");
1763 // But it doesn't have to be a temporary, of course.
1764 wxNotificationMessage
n("Dummy Warning", "Example of a warning notification.");
1765 n
.SetFlags(wxICON_ERROR
);
1766 n
.Show(5); // Just for testing, use 5 second delay.
1769 void MyFrame::OnNotifMsgShow(wxCommandEvent
& WXUNUSED(event
))
1773 m_notifMsg
= new wxNotificationMessage
1775 "wxWidgets Manual Notification",
1776 "You can hide this notification from the menu",
1781 if ( !m_notifMsg
->Show(wxNotificationMessage::Timeout_Never
) )
1783 wxLogStatus("Failed to show manual notification message");
1787 void MyFrame::OnNotifMsgHide(wxCommandEvent
& WXUNUSED(event
))
1789 if ( m_notifMsg
&& !m_notifMsg
->Close() )
1791 wxLogStatus("Failed to hide manual notification message");
1795 #endif // wxUSE_NOTIFICATION_MESSAGE
1797 #if wxUSE_RICHTOOLTIP
1799 #include "wx/richtooltip.h"
1803 class RichTipDialog
: public wxDialog
1806 RichTipDialog(wxWindow
* parent
)
1807 : wxDialog(parent
, wxID_ANY
, "wxRichToolTip Test",
1808 wxDefaultPosition
, wxDefaultSize
,
1809 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
1811 // Create the controls.
1812 m_textTitle
= new wxTextCtrl(this, wxID_ANY
, "Tooltip title");
1813 m_textBody
= new wxTextCtrl(this, wxID_ANY
, "Main tooltip text\n"
1814 "possibly on several\n"
1816 wxDefaultPosition
, wxDefaultSize
,
1818 wxButton
* btnShowText
= new wxButton(this, wxID_ANY
, "Show for &text");
1819 wxButton
* btnShowBtn
= new wxButton(this, wxID_ANY
, "Show for &button");
1821 const wxString icons
[] =
1829 wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons
) == Icon_Max
, IconMismatch
);
1830 m_icons
= new wxRadioBox(this, wxID_ANY
, "&Icon choice:",
1831 wxDefaultPosition
, wxDefaultSize
,
1832 WXSIZEOF(icons
), icons
,
1833 1, wxRA_SPECIFY_ROWS
);
1834 m_icons
->SetSelection(Icon_Info
);
1836 const wxString tipKinds
[] =
1838 "&None", "Top left", "Top", "Top right",
1839 "Bottom left", "Bottom", "Bottom right", "&Auto"
1841 m_tipKinds
= new wxRadioBox(this, wxID_ANY
, "Tip &kind:",
1842 wxDefaultPosition
, wxDefaultSize
,
1843 WXSIZEOF(tipKinds
), tipKinds
,
1844 4, wxRA_SPECIFY_COLS
);
1845 m_tipKinds
->SetSelection(wxTipKind_Auto
);
1847 const wxString bgStyles
[] =
1849 "&Default", "&Solid", "&Gradient",
1851 wxCOMPILE_TIME_ASSERT( WXSIZEOF(bgStyles
) == Bg_Max
, BgMismatch
);
1852 m_bgStyles
= new wxRadioBox(this, wxID_ANY
, "Background style:",
1853 wxDefaultPosition
, wxDefaultSize
,
1854 WXSIZEOF(bgStyles
), bgStyles
,
1855 1, wxRA_SPECIFY_ROWS
);
1857 const wxString timeouts
[] = { "&None", "&Default", "&3 seconds" };
1858 wxCOMPILE_TIME_ASSERT( WXSIZEOF(timeouts
) == Timeout_Max
, TmMismatch
);
1859 m_timeouts
= new wxRadioBox(this, wxID_ANY
, "Timeout:",
1860 wxDefaultPosition
, wxDefaultSize
,
1861 WXSIZEOF(timeouts
), timeouts
,
1862 1, wxRA_SPECIFY_ROWS
);
1863 m_timeouts
->SetSelection(Timeout_Default
);
1866 m_textBody
->SetMinSize(wxSize(300, 200));
1868 wxBoxSizer
* const sizer
= new wxBoxSizer(wxVERTICAL
);
1869 sizer
->Add(m_textTitle
, wxSizerFlags().Expand().Border());
1870 sizer
->Add(m_textBody
, wxSizerFlags(1).Expand().Border());
1871 sizer
->Add(m_icons
, wxSizerFlags().Expand().Border());
1872 sizer
->Add(m_tipKinds
, wxSizerFlags().Centre().Border());
1873 sizer
->Add(m_bgStyles
, wxSizerFlags().Centre().Border());
1874 sizer
->Add(m_timeouts
, wxSizerFlags().Centre().Border());
1875 wxBoxSizer
* const sizerBtns
= new wxBoxSizer(wxHORIZONTAL
);
1876 sizerBtns
->Add(btnShowText
, wxSizerFlags().Border(wxRIGHT
));
1877 sizerBtns
->Add(btnShowBtn
, wxSizerFlags().Border(wxLEFT
));
1878 sizer
->Add(sizerBtns
, wxSizerFlags().Centre().Border());
1879 sizer
->Add(CreateStdDialogButtonSizer(wxOK
),
1880 wxSizerFlags().Expand().Border());
1881 SetSizerAndFit(sizer
);
1884 // And connect the event handlers.
1885 btnShowText
->Connect
1887 wxEVT_COMMAND_BUTTON_CLICKED
,
1888 wxCommandEventHandler(RichTipDialog::OnShowTipForText
),
1895 wxEVT_COMMAND_BUTTON_CLICKED
,
1896 wxCommandEventHandler(RichTipDialog::OnShowTipForBtn
),
1930 void OnShowTipForText(wxCommandEvent
& WXUNUSED(event
))
1932 DoShowTip(m_textTitle
);
1935 void OnShowTipForBtn(wxCommandEvent
& WXUNUSED(event
))
1937 DoShowTip(FindWindow(wxID_OK
));
1940 void DoShowTip(wxWindow
* win
)
1942 wxRichToolTip
tip(m_textTitle
->GetValue(), m_textBody
->GetValue());
1943 const int iconSel
= m_icons
->GetSelection();
1944 if ( iconSel
== Icon_Custom
)
1946 tip
.SetIcon(tip_xpm
);
1948 else // Use a standard icon.
1950 static const int stdIcons
[] =
1958 tip
.SetIcon(stdIcons
[iconSel
]);
1961 switch ( m_bgStyles
->GetSelection() )
1967 tip
.SetBackgroundColour(*wxLIGHT_GREY
);
1971 tip
.SetBackgroundColour(*wxWHITE
, wxColour(0xe4, 0xe5, 0xf0));
1975 switch ( m_timeouts
->GetSelection() )
1981 case Timeout_Default
:
1985 tip
.SetTimeout(3000);
1989 tip
.SetTipKind(static_cast<wxTipKind
>(m_tipKinds
->GetSelection()));
1994 wxTextCtrl
* m_textTitle
;
1995 wxTextCtrl
* m_textBody
;
1996 wxRadioBox
* m_icons
;
1997 wxRadioBox
* m_tipKinds
;
1998 wxRadioBox
* m_bgStyles
;
1999 wxRadioBox
* m_timeouts
;
2002 void MyFrame::OnRichTipDialog(wxCommandEvent
& WXUNUSED(event
))
2004 RichTipDialog
dialog(this);
2008 #endif // wxUSE_RICHTOOLTIP
2010 void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent
& WXUNUSED(event
))
2012 StdButtonSizerDialog
dialog(this);
2016 // TestDefaultAction
2018 #define ID_CATCH_LISTBOX_DCLICK 100
2019 #define ID_LISTBOX 101
2020 #define ID_DISABLE_OK 102
2021 #define ID_DISABLE_CANCEL 103
2023 BEGIN_EVENT_TABLE(TestDefaultActionDialog
, wxDialog
)
2024 EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK
, TestDefaultActionDialog::OnCatchListBoxDClick
)
2025 EVT_CHECKBOX(ID_DISABLE_OK
, TestDefaultActionDialog::OnDisableOK
)
2026 EVT_CHECKBOX(ID_DISABLE_CANCEL
, TestDefaultActionDialog::OnDisableCancel
)
2027 EVT_LISTBOX_DCLICK(ID_LISTBOX
, TestDefaultActionDialog::OnListBoxDClick
)
2028 EVT_TEXT_ENTER(wxID_ANY
, TestDefaultActionDialog::OnTextEnter
)
2031 TestDefaultActionDialog::TestDefaultActionDialog( wxWindow
*parent
) :
2032 wxDialog( parent
, -1, "Test default action" )
2034 m_catchListBoxDClick
= false;
2036 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
2038 wxFlexGridSizer
*grid_sizer
= new wxFlexGridSizer( 2, 5, 5 );
2041 wxListBox
*listbox
= new wxListBox( this, ID_LISTBOX
);
2042 listbox
->Append( "String 1" );
2043 listbox
->Append( "String 2" );
2044 listbox
->Append( "String 3" );
2045 listbox
->Append( "String 4" );
2046 grid_sizer
->Add( listbox
);
2047 #endif // wxUSE_LISTBOX
2049 grid_sizer
->Add( new wxCheckBox( this, ID_CATCH_LISTBOX_DCLICK
, "Catch DoubleClick from wxListBox" ), 0, wxALIGN_CENTRE_VERTICAL
);
2051 grid_sizer
->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxSize(80,-1), 0 ), 0, wxALIGN_CENTRE_VERTICAL
);
2052 grid_sizer
->Add( new wxStaticText( this, -1, "wxTextCtrl without wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL
);
2054 grid_sizer
->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxSize(80,-1), wxTE_PROCESS_ENTER
), 0, wxALIGN_CENTRE_VERTICAL
);
2055 grid_sizer
->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL
);
2057 grid_sizer
->Add( new wxCheckBox(this, ID_DISABLE_OK
, "Disable \"OK\""), 0, wxALIGN_CENTRE_VERTICAL
);
2058 grid_sizer
->Add( new wxCheckBox(this, ID_DISABLE_CANCEL
, "Disable \"Cancel\""), 0, wxALIGN_CENTRE_VERTICAL
);
2060 main_sizer
->Add( grid_sizer
, 0, wxALL
, 10 );
2062 wxSizer
*button_sizer
= CreateSeparatedButtonSizer( wxOK
|wxCANCEL
);
2064 main_sizer
->Add( button_sizer
, 0, wxALL
|wxGROW
, 5 );
2066 SetSizerAndFit( main_sizer
);
2069 void TestDefaultActionDialog::OnDisableOK(wxCommandEvent
& event
)
2071 FindWindow(wxID_OK
)->Enable(!event
.IsChecked());
2074 void TestDefaultActionDialog::OnDisableCancel(wxCommandEvent
& event
)
2076 FindWindow(wxID_CANCEL
)->Enable(!event
.IsChecked());
2079 void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent
& event
)
2081 event
.Skip( !m_catchListBoxDClick
);
2084 void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent
& WXUNUSED(event
))
2086 m_catchListBoxDClick
= !m_catchListBoxDClick
;
2089 void TestDefaultActionDialog::OnTextEnter(wxCommandEvent
& event
)
2091 wxLogMessage("Text \"%s\" entered.", event
.GetString());
2094 void MyFrame::OnTestDefaultActionDialog(wxCommandEvent
& WXUNUSED(event
))
2096 TestDefaultActionDialog
dialog( this );
2100 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
2105 #if wxUSE_PROGRESSDLG
2107 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
2109 static const int max
= 100;
2111 wxProgressDialog
dialog("Progress dialog example",
2112 // "Reserve" enough space for the multiline
2113 // messages below, we'll change it anyhow
2114 // immediately in the loop below
2115 wxString(' ', 100) + "\n\n\n\n",
2121 //wxPD_AUTO_HIDE | // -- try this as well
2123 wxPD_ESTIMATED_TIME
|
2124 wxPD_REMAINING_TIME
|
2125 wxPD_SMOOTH
// - makes indeterminate mode bar on WinXP very small
2129 for ( int i
= 0; i
<= max
; i
++ )
2133 // test both modes of wxProgressDialog behaviour: start in
2134 // indeterminate mode but switch to the determinate one later
2135 const bool determinate
= i
> max
/2;
2139 msg
= "That's all, folks!\n"
2141 "Nothing to see here any more.";
2143 else if ( !determinate
)
2145 msg
= "Testing indeterminate mode\n"
2147 "This mode allows you to show to the user\n"
2148 "that something is going on even if you don't know\n"
2149 "when exactly will you finish.";
2151 else if ( determinate
)
2153 msg
= "Now in standard determinate mode\n"
2155 "This is the standard usage mode in which you\n"
2156 "update the dialog after performing each new step of work.\n"
2157 "It requires knowing the total number of steps in advance.";
2160 // will be set to true if "Skip" button was pressed
2164 cont
= dialog
.Update(i
, msg
, &skip
);
2168 cont
= dialog
.Pulse(msg
, &skip
);
2171 // each skip will move progress about quarter forward
2182 if ( wxMessageBox(wxT("Do you really want to cancel?"),
2183 wxT("Progress dialog question"), // caption
2184 wxYES_NO
| wxICON_QUESTION
) == wxYES
)
2196 wxLogStatus(wxT("Progress dialog aborted!"));
2200 wxLogStatus(wxT("Countdown from %d finished"), max
);
2204 #endif // wxUSE_PROGRESSDLG
2208 static void InitAboutInfoMinimal(wxAboutDialogInfo
& info
)
2210 info
.SetName(wxT("Dialogs Sample"));
2211 info
.SetVersion(wxVERSION_NUM_DOT_STRING
,
2215 wxMINOR_VERSION
% 2 ? "Development" : "Stable",
2216 wxVERSION_NUM_DOT_STRING
2218 info
.SetDescription(wxT("This sample shows different wxWidgets dialogs"));
2219 info
.SetCopyright(wxT("(C) 1998-2006 wxWidgets dev team"));
2220 info
.AddDeveloper(wxT("Vadim Zeitlin"));
2223 static void InitAboutInfoWebsite(wxAboutDialogInfo
& info
)
2225 InitAboutInfoMinimal(info
);
2227 info
.SetWebSite(wxT("http://www.wxwidgets.org/"), wxT("wxWidgets web site"));
2230 static void InitAboutInfoAll(wxAboutDialogInfo
& info
)
2232 InitAboutInfoWebsite(info
);
2234 // we can add a second developer
2235 info
.AddDeveloper(wxT("A.N. Other"));
2237 // or we can add several persons at once like this
2238 static const wxChar
*docwriters
[] =
2240 wxT("First D. Writer"),
2244 info
.SetDocWriters(wxArrayString(WXSIZEOF(docwriters
), docwriters
));
2245 info
.SetLicence(wxString::FromAscii(
2246 " wxWindows Library Licence, Version 3.1\n"
2247 " ======================================\n"
2249 " Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
2251 " Everyone is permitted to copy and distribute verbatim copies\n"
2252 " of this licence document, but changing it is not allowed.\n"
2254 " WXWINDOWS LIBRARY LICENCE\n"
2255 " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
2257 " ...and so on and so forth...\n"
2260 info
.AddTranslator(wxT("Wun Ngo Wen (Martian)"));
2263 void MyFrame::ShowSimpleAboutDialog(wxCommandEvent
& WXUNUSED(event
))
2265 wxAboutDialogInfo info
;
2266 InitAboutInfoMinimal(info
);
2268 wxAboutBox(info
, this);
2271 void MyFrame::ShowFancyAboutDialog(wxCommandEvent
& WXUNUSED(event
))
2273 wxAboutDialogInfo info
;
2274 InitAboutInfoWebsite(info
);
2276 wxAboutBox(info
, this);
2279 void MyFrame::ShowFullAboutDialog(wxCommandEvent
& WXUNUSED(event
))
2281 wxAboutDialogInfo info
;
2282 InitAboutInfoAll(info
);
2284 wxAboutBox(info
, this);
2287 // a trivial example of a custom dialog class
2288 class MyAboutDialog
: public wxGenericAboutDialog
2291 MyAboutDialog(const wxAboutDialogInfo
& info
, wxWindow
* parent
)
2293 Create(info
, parent
);
2296 // add some custom controls
2297 virtual void DoAddCustomControls()
2299 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
2300 AddText(wxT("Some custom text"));
2301 AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
2305 void MyFrame::ShowCustomAboutDialog(wxCommandEvent
& WXUNUSED(event
))
2307 wxAboutDialogInfo info
;
2308 InitAboutInfoAll(info
);
2310 MyAboutDialog
dlg(info
, this);
2314 #endif // wxUSE_ABOUTDLG
2318 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
2320 wxWindowDisabler disableAll
;
2322 wxBusyInfo
info(wxT("Working, please wait..."), this);
2324 for ( int i
= 0; i
< 18; i
++ )
2334 #endif // wxUSE_BUSYINFO
2336 #if wxUSE_FINDREPLDLG
2338 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
2342 wxDELETE(m_dlgReplace
);
2346 m_dlgReplace
= new wxFindReplaceDialog
2350 wxT("Find and replace dialog"),
2354 m_dlgReplace
->Show(true);
2358 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
2362 wxDELETE(m_dlgFind
);
2366 m_dlgFind
= new wxFindReplaceDialog
2375 m_dlgFind
->Show(true);
2379 static wxString
DecodeFindDialogEventFlags(int flags
)
2382 str
<< (flags
& wxFR_DOWN
? wxT("down") : wxT("up")) << wxT(", ")
2383 << (flags
& wxFR_WHOLEWORD
? wxT("whole words only, ") : wxT(""))
2384 << (flags
& wxFR_MATCHCASE
? wxT("") : wxT("not "))
2385 << wxT("case sensitive");
2390 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
2392 wxEventType type
= event
.GetEventType();
2394 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
2396 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
2397 type
== wxEVT_COMMAND_FIND_NEXT
? wxT("next ") : wxT(""),
2398 event
.GetFindString().c_str(),
2399 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
2401 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
2402 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
2404 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
2405 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? wxT("all ") : wxT(""),
2406 event
.GetFindString().c_str(),
2407 event
.GetReplaceString().c_str(),
2408 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
2410 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
2412 wxFindReplaceDialog
*dlg
= event
.GetDialog();
2416 if ( dlg
== m_dlgFind
)
2419 idMenu
= DIALOGS_FIND
;
2422 else if ( dlg
== m_dlgReplace
)
2424 txt
= wxT("Replace");
2425 idMenu
= DIALOGS_REPLACE
;
2426 m_dlgReplace
= NULL
;
2430 txt
= wxT("Unknown");
2433 wxFAIL_MSG( wxT("unexpected event") );
2436 wxLogMessage(wxT("%s dialog is being closed."), txt
);
2438 if ( idMenu
!= wxID_ANY
)
2440 GetMenuBar()->Check(idMenu
, false);
2447 wxLogError(wxT("Unknown find dialog event!"));
2451 #endif // wxUSE_FINDREPLDLG
2453 // ----------------------------------------------------------------------------
2455 // ----------------------------------------------------------------------------
2457 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
2460 dc
.SetBackgroundMode(wxTRANSPARENT
);
2462 wxT("wxWidgets common dialogs")
2463 #if !defined(__SMARTPHONE__)
2464 wxT(" test application")
2469 #if USE_MODAL_PRESENTATION
2471 // ----------------------------------------------------------------------------
2473 // ----------------------------------------------------------------------------
2475 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
2476 : wxDialog(parent
, wxID_ANY
, wxString(wxT("Modeless dialog")))
2478 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
2480 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, wxT("Press me"));
2481 wxCheckBox
*check
= new wxCheckBox(this, wxID_ANY
, wxT("Should be disabled"));
2484 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
2485 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
2487 SetSizerAndFit(sizerTop
);
2490 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
2492 wxMessageBox(wxT("Button pressed in modeless dialog"), wxT("Info"),
2493 wxOK
| wxICON_INFORMATION
, this);
2496 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
2498 if ( event
.CanVeto() )
2500 wxMessageBox(wxT("Use the menu item to close this dialog"),
2501 wxT("Modeless dialog"),
2502 wxOK
| wxICON_INFORMATION
, this);
2508 // ----------------------------------------------------------------------------
2510 // ----------------------------------------------------------------------------
2512 MyModalDialog::MyModalDialog(wxWindow
*parent
)
2513 : wxDialog(parent
, wxID_ANY
, wxString(wxT("Modal dialog")))
2515 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
2517 m_btnModal
= new wxButton(this, wxID_ANY
, wxT("&Modal dialog..."));
2518 m_btnModeless
= new wxButton(this, wxID_ANY
, wxT("Mode&less dialog"));
2519 m_btnDelete
= new wxButton(this, wxID_ANY
, wxT("&Delete button"));
2521 sizerTop
->Add(m_btnModal
, 0, wxALIGN_CENTER
| wxALL
, 5);
2522 sizerTop
->Add(m_btnModeless
, 0, wxALIGN_CENTER
| wxALL
, 5);
2523 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
2524 sizerTop
->Add(new wxButton(this, wxID_CLOSE
), 0, wxALIGN_CENTER
| wxALL
, 5);
2526 SetSizerAndFit(sizerTop
);
2528 SetEscapeId(wxID_CLOSE
);
2530 m_btnModal
->SetFocus();
2531 m_btnModal
->SetDefault();
2534 void MyModalDialog::OnButton(wxCommandEvent
& event
)
2536 if ( event
.GetEventObject() == m_btnDelete
)
2538 wxDELETE(m_btnModal
);
2539 m_btnDelete
->Disable();
2541 else if ( event
.GetEventObject() == m_btnModal
)
2544 wxGetTextFromUser(wxT("Dummy prompt"),
2545 wxT("Modal dialog called from dialog"),
2546 wxEmptyString
, this);
2548 wxMessageBox(wxT("Modal dialog called from dialog"));
2549 #endif // wxUSE_TEXTDLG
2551 else if ( event
.GetEventObject() == m_btnModeless
)
2553 (new MyModelessDialog(this))->Show();
2561 #endif // USE_MODAL_PRESENTATION
2563 // ----------------------------------------------------------------------------
2564 // StdButtonSizerDialog
2565 // ----------------------------------------------------------------------------
2567 StdButtonSizerDialog::StdButtonSizerDialog(wxWindow
*parent
)
2568 : wxDialog(parent
, wxID_ANY
, wxString(wxT("StdButtonSizer dialog")),
2569 wxDefaultPosition
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
),
2570 m_buttonsSizer(NULL
)
2572 wxBoxSizer
*const sizerTop
= new wxBoxSizer(wxVERTICAL
);
2574 wxBoxSizer
*const sizer
= new wxBoxSizer(wxHORIZONTAL
);
2575 wxBoxSizer
*const sizerInside1
= new wxBoxSizer(wxVERTICAL
);
2577 m_chkboxAffirmativeButton
= new wxCheckBox(this, wxID_ANY
, _("Enable Affirmative Button"));
2579 wxStaticBoxSizer
*const sizer1
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Affirmative Button"));
2581 m_radiobtnOk
= new wxRadioButton(this, wxID_ANY
, _("Ok"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
2582 m_radiobtnYes
= new wxRadioButton(this, wxID_ANY
, _("Yes"));
2584 wxBoxSizer
*const sizerInside2
= new wxBoxSizer(wxVERTICAL
);
2586 m_chkboxDismissButton
= new wxCheckBox(this, wxID_ANY
, _("Enable Dismiss Button"));
2588 wxStaticBoxSizer
*const sizer2
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Dismiss Button"));
2590 m_radiobtnCancel
= new wxRadioButton(this, wxID_ANY
, _("Cancel"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
2591 m_radiobtnClose
= new wxRadioButton(this, wxID_ANY
, _("Close"));
2593 wxBoxSizer
*const sizer3
= new wxBoxSizer(wxHORIZONTAL
);
2595 m_chkboxNo
= new wxCheckBox(this, wxID_ANY
, _("No"));
2596 m_chkboxHelp
= new wxCheckBox(this, wxID_ANY
, _("Help"));
2597 m_chkboxApply
= new wxCheckBox(this, wxID_ANY
, _("Apply"));
2599 m_chkboxNoDefault
= new wxCheckBox(this, wxID_ANY
, wxT("No Default"));
2601 sizer1
->Add(m_radiobtnOk
, 0, wxALL
, 5);
2602 sizer1
->Add(m_radiobtnYes
, 0, wxALL
, 5);
2604 sizer
->Add(sizerInside1
, 0, 0, 0);
2605 sizerInside1
->Add(m_chkboxAffirmativeButton
, 0, wxALL
, 5);
2606 sizerInside1
->Add(sizer1
, 0, wxALL
, 5);
2607 sizerInside1
->SetItemMinSize(sizer1
, sizer1
->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
2609 sizer2
->Add(m_radiobtnCancel
, 0, wxALL
, 5);
2610 sizer2
->Add(m_radiobtnClose
, 0, wxALL
, 5);
2612 sizer
->Add(sizerInside2
, 0, 0, 0);
2613 sizerInside2
->Add(m_chkboxDismissButton
, 0, wxALL
, 5);
2614 sizerInside2
->Add(sizer2
, 0, wxALL
, 5);
2615 sizerInside2
->SetItemMinSize(sizer2
, sizer2
->GetStaticBox()->GetBestSize()); // to prevent wrapping of static box label
2617 sizerTop
->Add(sizer
, 0, wxALL
, 5);
2619 sizer3
->Add(m_chkboxNo
, 0, wxALL
, 5);
2620 sizer3
->Add(m_chkboxHelp
, 0, wxALL
, 5);
2621 sizer3
->Add(m_chkboxApply
, 0, wxALL
, 5);
2623 sizerTop
->Add(sizer3
, 0, wxALL
, 5);
2625 sizerTop
->Add(m_chkboxNoDefault
, 0, wxLEFT
|wxRIGHT
, 10);
2627 EnableDisableControls();
2629 SetSizerAndFit(sizerTop
);
2635 void StdButtonSizerDialog::OnEvent(wxCommandEvent
& WXUNUSED(event
))
2639 m_buttonsSizer
->DeleteWindows();
2640 GetSizer()->Remove(m_buttonsSizer
);
2643 EnableDisableControls();
2646 unsigned long numButtons
= 0;
2648 if (m_chkboxAffirmativeButton
->IsChecked())
2650 if (m_radiobtnOk
->GetValue())
2655 else if (m_radiobtnYes
->GetValue())
2662 if (m_chkboxDismissButton
->IsChecked())
2664 if (m_radiobtnCancel
->GetValue())
2670 else if (m_radiobtnClose
->GetValue())
2678 if (m_chkboxApply
->IsChecked())
2684 if (m_chkboxNo
->IsChecked())
2690 if (m_chkboxHelp
->IsChecked())
2696 if (m_chkboxNoDefault
->IsChecked())
2698 flags
|= wxNO_DEFAULT
;
2701 m_buttonsSizer
= CreateStdDialogButtonSizer(flags
);
2702 GetSizer()->Add(m_buttonsSizer
, 0, wxGROW
|wxALL
, 5);
2705 GetSizer()->SetSizeHints(this);
2708 void StdButtonSizerDialog::EnableDisableControls()
2710 const bool affButtonEnabled
= m_chkboxAffirmativeButton
->IsChecked();
2712 m_radiobtnOk
->Enable(affButtonEnabled
);
2713 m_radiobtnYes
->Enable(affButtonEnabled
);
2715 const bool dismissButtonEnabled
= m_chkboxDismissButton
->IsChecked();
2717 m_radiobtnCancel
->Enable(dismissButtonEnabled
);
2718 m_radiobtnClose
->Enable(dismissButtonEnabled
);
2721 #if USE_SETTINGS_DIALOG
2722 // ----------------------------------------------------------------------------
2724 // ----------------------------------------------------------------------------
2726 IMPLEMENT_CLASS(SettingsDialog
, wxPropertySheetDialog
)
2728 BEGIN_EVENT_TABLE(SettingsDialog
, wxPropertySheetDialog
)
2731 SettingsDialog::SettingsDialog(wxWindow
* win
, int dialogType
)
2733 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
|wxWS_EX_VALIDATE_RECURSIVELY
);
2738 bool useToolBook
= (dialogType
== DIALOGS_PROPERTY_SHEET_TOOLBOOK
|| dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
);
2739 int resizeBorder
= wxRESIZE_BORDER
;
2747 int sheetStyle
= wxPROPSHEET_SHRINKTOFIT
;
2748 if (dialogType
== DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK
)
2749 sheetStyle
|= wxPROPSHEET_BUTTONTOOLBOOK
;
2751 sheetStyle
|= wxPROPSHEET_TOOLBOOK
;
2753 SetSheetStyle(sheetStyle
);
2754 SetSheetInnerBorder(0);
2755 SetSheetOuterBorder(0);
2757 // create a dummy image list with a few icons
2758 const wxSize
imageSize(32, 32);
2760 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
2762 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
2764 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
2766 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
2768 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
2773 Create(win
, wxID_ANY
, _("Preferences"), wxDefaultPosition
, wxDefaultSize
,
2774 wxDEFAULT_DIALOG_STYLE
| (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, resizeBorder
)
2777 // If using a toolbook, also follow Mac style and don't create buttons
2779 CreateButtons(wxOK
| wxCANCEL
|
2780 (int)wxPlatform::IfNot(wxOS_WINDOWS_CE
, wxHELP
)
2783 wxBookCtrlBase
* notebook
= GetBookCtrl();
2784 notebook
->SetImageList(m_imageList
);
2786 wxPanel
* generalSettings
= CreateGeneralSettingsPage(notebook
);
2787 wxPanel
* aestheticSettings
= CreateAestheticSettingsPage(notebook
);
2789 notebook
->AddPage(generalSettings
, _("General"), true, tabImage1
);
2790 notebook
->AddPage(aestheticSettings
, _("Aesthetics"), false, tabImage2
);
2795 SettingsDialog::~SettingsDialog()
2800 wxPanel
* SettingsDialog::CreateGeneralSettingsPage(wxWindow
* parent
)
2802 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
2804 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
2805 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
2809 wxBoxSizer
* itemSizer3
= new wxBoxSizer( wxHORIZONTAL
);
2810 wxCheckBox
* checkBox3
= new wxCheckBox(panel
, ID_LOAD_LAST_PROJECT
, _("&Load last project on startup"), wxDefaultPosition
, wxDefaultSize
);
2811 itemSizer3
->Add(checkBox3
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2812 item0
->Add(itemSizer3
, 0, wxGROW
|wxALL
, 0);
2816 wxString autoSaveLabel
= _("&Auto-save every");
2817 wxString minsLabel
= _("mins");
2819 wxBoxSizer
* itemSizer12
= new wxBoxSizer( wxHORIZONTAL
);
2820 wxCheckBox
* checkBox12
= new wxCheckBox(panel
, ID_AUTO_SAVE
, autoSaveLabel
, wxDefaultPosition
, wxDefaultSize
);
2823 wxSpinCtrl
* spinCtrl12
= new wxSpinCtrl(panel
, ID_AUTO_SAVE_MINS
, wxEmptyString
,
2824 wxDefaultPosition
, wxSize(40, wxDefaultCoord
), wxSP_ARROW_KEYS
, 1, 60, 1);
2827 itemSizer12
->Add(checkBox12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2829 itemSizer12
->Add(spinCtrl12
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2831 itemSizer12
->Add(new wxStaticText(panel
, wxID_STATIC
, minsLabel
), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2832 item0
->Add(itemSizer12
, 0, wxGROW
|wxALL
, 0);
2836 wxBoxSizer
* itemSizer8
= new wxBoxSizer( wxHORIZONTAL
);
2837 wxCheckBox
* checkBox6
= new wxCheckBox(panel
, ID_SHOW_TOOLTIPS
, _("Show &tooltips"), wxDefaultPosition
, wxDefaultSize
);
2838 itemSizer8
->Add(checkBox6
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2839 item0
->Add(itemSizer8
, 0, wxGROW
|wxALL
, 0);
2841 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
2843 panel
->SetSizerAndFit(topSizer
);
2848 wxPanel
* SettingsDialog::CreateAestheticSettingsPage(wxWindow
* parent
)
2850 wxPanel
* panel
= new wxPanel(parent
, wxID_ANY
);
2852 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
2853 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
2855 //// PROJECT OR GLOBAL
2856 wxString globalOrProjectChoices
[2];
2857 globalOrProjectChoices
[0] = _("&New projects");
2858 globalOrProjectChoices
[1] = _("&This project");
2860 wxRadioBox
* projectOrGlobal
= new wxRadioBox(panel
, ID_APPLY_SETTINGS_TO
, _("&Apply settings to:"),
2861 wxDefaultPosition
, wxDefaultSize
, 2, globalOrProjectChoices
);
2862 item0
->Add(projectOrGlobal
, 0, wxGROW
|wxALL
, 5);
2864 projectOrGlobal
->SetSelection(0);
2866 //// BACKGROUND STYLE
2867 wxArrayString backgroundStyleChoices
;
2868 backgroundStyleChoices
.Add(wxT("Colour"));
2869 backgroundStyleChoices
.Add(wxT("Image"));
2870 wxStaticBox
* staticBox3
= new wxStaticBox(panel
, wxID_ANY
, _("Background style:"));
2872 wxBoxSizer
* styleSizer
= new wxStaticBoxSizer( staticBox3
, wxVERTICAL
);
2873 item0
->Add(styleSizer
, 0, wxGROW
|wxALL
, 5);
2875 wxBoxSizer
* itemSizer2
= new wxBoxSizer( wxHORIZONTAL
);
2877 wxChoice
* choice2
= new wxChoice(panel
, ID_BACKGROUND_STYLE
, wxDefaultPosition
, wxDefaultSize
, backgroundStyleChoices
);
2879 itemSizer2
->Add(new wxStaticText(panel
, wxID_ANY
, _("&Window:")), 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2880 itemSizer2
->Add(5, 5, 1, wxALL
, 0);
2881 itemSizer2
->Add(choice2
, 0, wxALL
|wxALIGN_CENTER_VERTICAL
, 5);
2883 styleSizer
->Add(itemSizer2
, 0, wxGROW
|wxALL
, 5);
2886 //// FONT SIZE SELECTION
2888 wxStaticBox
* staticBox1
= new wxStaticBox(panel
, wxID_ANY
, _("Tile font size:"));
2889 wxBoxSizer
* itemSizer5
= new wxStaticBoxSizer( staticBox1
, wxHORIZONTAL
);
2891 wxSpinCtrl
* spinCtrl
= new wxSpinCtrl(panel
, ID_FONT_SIZE
, wxEmptyString
, wxDefaultPosition
,
2892 wxSize(80, wxDefaultCoord
));
2893 itemSizer5
->Add(spinCtrl
, 0, wxALL
|wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
2895 item0
->Add(itemSizer5
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
2898 topSizer
->Add( item0
, 1, wxGROW
|wxALIGN_CENTRE
|wxALL
, 5 );
2899 topSizer
->AddSpacer(5);
2901 panel
->SetSizerAndFit(topSizer
);
2906 #endif // USE_SETTINGS_DIALOG
2909 // ----------------------------------------------------------------------------
2910 // TestMessageBoxDialog
2911 // ----------------------------------------------------------------------------
2914 const TestMessageBoxDialog::BtnInfo
TestMessageBoxDialog::ms_btnInfo
[] =
2919 { wxCANCEL
, "&Cancel" },
2920 { wxHELP
, "&Help" },
2923 BEGIN_EVENT_TABLE(TestMessageBoxDialog
, wxDialog
)
2924 EVT_BUTTON(wxID_APPLY
, TestMessageBoxDialog::OnApply
)
2925 EVT_BUTTON(wxID_CLOSE
, TestMessageBoxDialog::OnClose
)
2928 TestMessageBoxDialog::TestMessageBoxDialog(wxWindow
*parent
)
2929 : wxDialog(parent
, wxID_ANY
, "Message Box Test Dialog",
2930 wxDefaultPosition
, wxDefaultSize
,
2931 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
2935 bool TestMessageBoxDialog::Create()
2937 wxSizer
* const sizerTop
= new wxBoxSizer(wxVERTICAL
);
2939 // this sizer allows to configure the messages shown in the message box
2941 sizerMsgs
= new wxStaticBoxSizer(wxVERTICAL
, this, "&Messages");
2942 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Title:"));
2943 m_textTitle
= new wxTextCtrl(this, wxID_ANY
, "Test Message Box");
2944 sizerMsgs
->Add(m_textTitle
, wxSizerFlags().Expand().Border(wxBOTTOM
));
2946 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Main message:"));
2947 m_textMsg
= new wxTextCtrl(this, wxID_ANY
, "Hello from a box!",
2948 wxDefaultPosition
, wxDefaultSize
,
2950 sizerMsgs
->Add(m_textMsg
, wxSizerFlags(1).Expand().Border(wxBOTTOM
));
2952 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Extended message:"));
2953 m_textExtMsg
= new wxTextCtrl(this, wxID_ANY
, "",
2954 wxDefaultPosition
, wxDefaultSize
,
2956 sizerMsgs
->Add(m_textExtMsg
, wxSizerFlags(1).Expand());
2958 sizerTop
->Add(sizerMsgs
, wxSizerFlags(1).Expand().Border());
2960 // if a derived class provides more message configurations, add these.
2961 AddAdditionalTextOptions(sizerTop
);
2963 // this one is for configuring the buttons
2965 sizerBtnsBox
= new wxStaticBoxSizer(wxVERTICAL
, this, "&Buttons");
2967 wxFlexGridSizer
* const sizerBtns
= new wxFlexGridSizer(2, 5, 5);
2968 sizerBtns
->AddGrowableCol(1);
2970 sizerBtns
->Add(new wxStaticText(this, wxID_ANY
, "Button(s)"));
2971 sizerBtns
->Add(new wxStaticText(this, wxID_ANY
, "Custom label"));
2973 for ( int n
= 0; n
< Btn_Max
; n
++ )
2975 m_buttons
[n
] = new wxCheckBox(this, wxID_ANY
, ms_btnInfo
[n
].name
);
2976 sizerBtns
->Add(m_buttons
[n
], wxSizerFlags().Centre().Left());
2978 m_labels
[n
] = new wxTextCtrl(this, wxID_ANY
);
2979 sizerBtns
->Add(m_labels
[n
], wxSizerFlags(1).Centre().Expand());
2981 m_labels
[n
]->Connect(wxEVT_UPDATE_UI
,
2982 wxUpdateUIEventHandler(
2983 TestMessageBoxDialog::OnUpdateLabelUI
),
2988 sizerBtnsBox
->Add(sizerBtns
, wxSizerFlags(1).Expand());
2989 sizerTop
->Add(sizerBtnsBox
, wxSizerFlags().Expand().Border());
2993 const wxString icons
[] =
2997 "&Information icon",
3003 wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons
) == MsgDlgIcon_Max
, IconMismatch
);
3005 m_icons
= new wxRadioBox(this, wxID_ANY
, "&Icon style",
3006 wxDefaultPosition
, wxDefaultSize
,
3007 WXSIZEOF(icons
), icons
,
3008 2, wxRA_SPECIFY_ROWS
);
3009 // Make the 'Information' icon the default one:
3010 m_icons
->SetSelection(MsgDlgIcon_Info
);
3011 sizerTop
->Add(m_icons
, wxSizerFlags().Expand().Border());
3014 // miscellaneous other stuff
3016 sizerFlags
= new wxStaticBoxSizer(wxHORIZONTAL
, this, "&Other flags");
3018 m_chkNoDefault
= new wxCheckBox(this, wxID_ANY
, "Make \"No\" &default");
3019 m_chkNoDefault
->Connect(wxEVT_UPDATE_UI
,
3020 wxUpdateUIEventHandler(
3021 TestMessageBoxDialog::OnUpdateNoDefaultUI
),
3024 sizerFlags
->Add(m_chkNoDefault
, wxSizerFlags(1).Border());
3026 m_chkCentre
= new wxCheckBox(this, wxID_ANY
, "Centre on &parent");
3027 sizerFlags
->Add(m_chkCentre
, wxSizerFlags(1).Border());
3029 // add any additional flag from subclasses
3030 AddAdditionalFlags(sizerFlags
);
3032 sizerTop
->Add(sizerFlags
, wxSizerFlags().Expand().Border());
3034 // finally buttons to show the resulting message box and close this dialog
3035 sizerTop
->Add(CreateStdDialogButtonSizer(wxAPPLY
| wxCLOSE
),
3036 wxSizerFlags().Right().Border());
3038 SetSizerAndFit(sizerTop
);
3040 m_buttons
[Btn_Ok
]->SetValue(true);
3045 void TestMessageBoxDialog::OnUpdateLabelUI(wxUpdateUIEvent
& event
)
3047 for ( int n
= 0; n
< Btn_Max
; n
++ )
3049 if ( event
.GetEventObject() == m_labels
[n
] )
3051 event
.Enable( m_buttons
[n
]->IsChecked() );
3056 wxFAIL_MSG( "called for unknown label" );
3059 void TestMessageBoxDialog::OnUpdateNoDefaultUI(wxUpdateUIEvent
& event
)
3061 event
.Enable( m_buttons
[Btn_No
]->IsChecked() );
3064 long TestMessageBoxDialog::GetStyle()
3068 for ( int n
= 0; n
< Btn_Max
; n
++ )
3070 if ( m_buttons
[n
]->IsChecked() )
3071 style
|= ms_btnInfo
[n
].flag
;
3074 switch ( m_icons
->GetSelection() )
3076 case MsgDlgIcon_Max
:
3077 wxFAIL_MSG( "unexpected selection" );
3082 case MsgDlgIcon_None
:
3083 style
|= wxICON_NONE
;
3086 case MsgDlgIcon_Info
:
3087 style
|= wxICON_INFORMATION
;
3090 case MsgDlgIcon_Question
:
3091 style
|= wxICON_QUESTION
;
3094 case MsgDlgIcon_Warning
:
3095 style
|= wxICON_WARNING
;
3098 case MsgDlgIcon_Error
:
3099 style
|= wxICON_ERROR
;
3103 if ( m_chkCentre
->IsChecked() )
3106 if ( m_chkNoDefault
->IsEnabled() && m_chkNoDefault
->IsChecked() )
3107 style
|= wxNO_DEFAULT
;
3112 void TestMessageBoxDialog::PrepareMessageDialog(wxMessageDialogBase
&dlg
)
3114 long style
= dlg
.GetMessageDialogStyle();
3116 if ( !m_textExtMsg
->IsEmpty() )
3117 dlg
.SetExtendedMessage(m_textExtMsg
->GetValue());
3119 if ( style
& wxYES_NO
)
3121 if ( style
& wxCANCEL
)
3123 dlg
.SetYesNoCancelLabels(m_labels
[Btn_Yes
]->GetValue(),
3124 m_labels
[Btn_No
]->GetValue(),
3125 m_labels
[Btn_Cancel
]->GetValue());
3129 dlg
.SetYesNoLabels(m_labels
[Btn_Yes
]->GetValue(),
3130 m_labels
[Btn_No
]->GetValue());
3135 if ( style
& wxCANCEL
)
3137 dlg
.SetOKCancelLabels(m_labels
[Btn_Ok
]->GetValue(),
3138 m_labels
[Btn_Cancel
]->GetValue());
3142 dlg
.SetOKLabel(m_labels
[Btn_Ok
]->GetValue());
3146 if ( style
& wxHELP
)
3148 dlg
.SetHelpLabel(m_labels
[Btn_Help
]->GetValue());
3152 void TestMessageBoxDialog::OnApply(wxCommandEvent
& WXUNUSED(event
))
3154 wxMessageDialog
dlg(this, GetMessage(), GetBoxTitle(), GetStyle());
3155 PrepareMessageDialog(dlg
);
3158 switch ( dlg
.ShowModal() )
3165 // Avoid the extra message box if the dialog was cancelled.
3181 btnName
= "Unknown";
3184 wxLogMessage("Dialog was closed with the \"%s\" button.", btnName
);
3187 void TestMessageBoxDialog::OnClose(wxCommandEvent
& WXUNUSED(event
))
3189 EndModal(wxID_CANCEL
);
3191 #endif // wxUSE_MSGDLG
3193 #if wxUSE_RICHMSGDLG
3194 // ----------------------------------------------------------------------------
3195 // TestRichMessageDialog
3196 // ----------------------------------------------------------------------------
3198 BEGIN_EVENT_TABLE(TestRichMessageDialog
, TestMessageBoxDialog
)
3199 EVT_BUTTON(wxID_APPLY
, TestRichMessageDialog::OnApply
)
3202 TestRichMessageDialog::TestRichMessageDialog(wxWindow
*parent
)
3203 : TestMessageBoxDialog(parent
)
3205 SetTitle("Rich Message Dialog Test Dialog");
3208 void TestRichMessageDialog::AddAdditionalTextOptions(wxSizer
*sizer
)
3210 wxSizer
* const sizerMsgs
= new wxStaticBoxSizer(wxVERTICAL
, this,
3211 "&Additional Elements");
3213 // add a option to show a check box.
3214 wxFlexGridSizer
* const sizerCheckBox
= new wxFlexGridSizer(2, 5, 5);
3215 sizerCheckBox
->AddGrowableCol(1);
3216 sizerCheckBox
->Add(new wxStaticText(this, wxID_ANY
, "&Check box:"));
3217 m_textCheckBox
= new wxTextCtrl(this, wxID_ANY
);
3218 sizerCheckBox
->Add(m_textCheckBox
, wxSizerFlags(1).Expand().Border(wxBOTTOM
));
3219 sizerMsgs
->Add(sizerCheckBox
, wxSizerFlags(1).Expand());
3221 // add option to show a detailed text.
3222 sizerMsgs
->Add(new wxStaticText(this, wxID_ANY
, "&Detailed message:"));
3223 m_textDetailed
= new wxTextCtrl(this, wxID_ANY
, "",
3224 wxDefaultPosition
, wxDefaultSize
,
3226 sizerMsgs
->Add(m_textDetailed
, wxSizerFlags(1).Expand());
3228 sizer
->Add(sizerMsgs
, wxSizerFlags(1).Expand().Border());
3231 void TestRichMessageDialog::AddAdditionalFlags(wxSizer
*sizer
)
3233 // add checkbox to set the initial state for the checkbox shown
3235 m_initialValueCheckBox
=
3236 new wxCheckBox(this, wxID_ANY
, "Checkbox initially checked");
3237 sizer
->Add(m_initialValueCheckBox
, wxSizerFlags(1).Border());
3240 void TestRichMessageDialog::OnApply(wxCommandEvent
& WXUNUSED(event
))
3242 wxRichMessageDialog
dlg(this, GetMessage(), GetBoxTitle(), GetStyle());
3243 PrepareMessageDialog(dlg
);
3245 dlg
.ShowCheckBox(m_textCheckBox
->GetValue(),
3246 m_initialValueCheckBox
->GetValue());
3247 dlg
.ShowDetailedText(m_textDetailed
->GetValue());
3252 #endif // wxUSE_RICHMSGDLG
3256 // ----------------------------------------------------------------------------
3257 // custom log target
3258 // ----------------------------------------------------------------------------
3260 class MyLogGui
: public wxLogGui
3263 virtual void DoShowSingleLogMessage(const wxString
& message
,
3264 const wxString
& title
,
3267 wxMessageDialog
dlg(NULL
, message
, title
,
3268 wxOK
| wxCANCEL
| wxCANCEL_DEFAULT
| style
);
3269 dlg
.SetOKCancelLabels(wxID_COPY
, wxID_OK
);
3270 dlg
.SetExtendedMessage("Note that this is a custom log dialog.");
3275 wxLog
*MyAppTraits::CreateLogTarget()
3277 return new MyLogGui
;