1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common dialogs demo
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
28 #include "wx/colordlg.h"
29 #include "wx/filedlg.h"
30 #include "wx/dirdlg.h"
31 #include "wx/fontdlg.h"
32 #include "wx/choicdlg.h"
33 #include "wx/tipdlg.h"
34 #include "wx/progdlg.h"
35 #include "wx/fdrepdlg.h"
36 #include "wx/busyinfo.h"
38 #define wxTEST_GENERIC_DIALOGS_IN_MSW 0
40 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
41 #include <wx/generic/colrdlgg.h>
42 #include <wx/generic/fontdlgg.h>
45 #if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG
46 // New wxGenericDirCtrl
47 #include "wx/dirctrl.h"
54 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
55 EVT_PAINT(MyCanvas::OnPaint
)
58 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
59 EVT_MENU(DIALOGS_CHOOSE_COLOUR
, MyFrame::ChooseColour
)
60 EVT_MENU(DIALOGS_CHOOSE_FONT
, MyFrame::ChooseFont
)
61 EVT_MENU(DIALOGS_LOG_DIALOG
, MyFrame::LogDialog
)
62 EVT_MENU(DIALOGS_MESSAGE_BOX
, MyFrame::MessageBox
)
63 EVT_MENU(DIALOGS_TEXT_ENTRY
, MyFrame::TextEntry
)
64 EVT_MENU(DIALOGS_PASSWORD_ENTRY
, MyFrame::PasswordEntry
)
65 EVT_MENU(DIALOGS_NUM_ENTRY
, MyFrame::NumericEntry
)
66 EVT_MENU(DIALOGS_SINGLE_CHOICE
, MyFrame::SingleChoice
)
67 EVT_MENU(DIALOGS_MULTI_CHOICE
, MyFrame::MultiChoice
)
68 EVT_MENU(DIALOGS_FILE_OPEN
, MyFrame::FileOpen
)
69 EVT_MENU(DIALOGS_FILE_OPEN2
, MyFrame::FileOpen2
)
70 EVT_MENU(DIALOGS_FILES_OPEN
, MyFrame::FilesOpen
)
71 EVT_MENU(DIALOGS_FILE_SAVE
, MyFrame::FileSave
)
72 EVT_MENU(DIALOGS_DIR_CHOOSE
, MyFrame::DirChoose
)
73 EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE
, MyFrame::GenericDirChoose
)
74 EVT_MENU(DIALOGS_MODAL
, MyFrame::ModalDlg
)
75 EVT_MENU(DIALOGS_MODELESS
, MyFrame::ModelessDlg
)
76 EVT_MENU(DIALOGS_TIP
, MyFrame::ShowTip
)
77 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
78 EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC
, MyFrame::ChooseColourGeneric
)
79 EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC
, MyFrame::ChooseFontGeneric
)
83 EVT_MENU(DIALOGS_PROGRESS
, MyFrame::ShowProgress
)
84 #endif // wxUSE_PROGRESSDLG
87 EVT_MENU(DIALOGS_BUSYINFO
, MyFrame::ShowBusyInfo
)
88 #endif // wxUSE_BUSYINFO
91 EVT_MENU(DIALOGS_FIND
, MyFrame::ShowFindDialog
)
92 EVT_MENU(DIALOGS_REPLACE
, MyFrame::ShowReplaceDialog
)
94 EVT_FIND(-1, MyFrame::OnFindDialog
)
95 EVT_FIND_NEXT(-1, MyFrame::OnFindDialog
)
96 EVT_FIND_REPLACE(-1, MyFrame::OnFindDialog
)
97 EVT_FIND_REPLACE_ALL(-1, MyFrame::OnFindDialog
)
98 EVT_FIND_CLOSE(-1, MyFrame::OnFindDialog
)
99 #endif // wxUSE_FINDREPLDLG
100 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
103 BEGIN_EVENT_TABLE(MyModalDialog
, wxDialog
)
104 EVT_BUTTON(-1, MyModalDialog::OnButton
)
107 BEGIN_EVENT_TABLE(MyModelessDialog
, wxDialog
)
108 EVT_BUTTON(DIALOGS_MODELESS_BTN
, MyModelessDialog::OnButton
)
110 EVT_CLOSE(MyModelessDialog::OnClose
)
113 MyCanvas
*myCanvas
= (MyCanvas
*) NULL
;
115 // `Main program' equivalent, creating windows and returning main app frame
118 #if defined(__WXGTK__) && defined(wxUSE_UNICODE)
119 wxConvCurrent
= &wxConvLibc
;
122 m_canvasTextColour
= wxColour("BLACK");
123 m_canvasFont
= *wxNORMAL_FONT
;
125 // Create the main frame window
126 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, (char *) "wxWindows dialogs example", wxPoint(20, 20), wxSize(400, 300));
129 wxMenu
*file_menu
= new wxMenu
;
131 file_menu
->Append(DIALOGS_CHOOSE_COLOUR
, "&Choose colour");
133 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
134 file_menu
->Append(DIALOGS_CHOOSE_COLOUR_GENERIC
, "Choose colour (&generic)");
137 file_menu
->AppendSeparator();
138 file_menu
->Append(DIALOGS_CHOOSE_FONT
, "Choose &font");
140 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
141 file_menu
->Append(DIALOGS_CHOOSE_FONT_GENERIC
, "Choose f&ont (generic)");
144 file_menu
->AppendSeparator();
145 file_menu
->Append(DIALOGS_LOG_DIALOG
, "&Log dialog\tCtrl-L");
146 file_menu
->Append(DIALOGS_MESSAGE_BOX
, "&Message box\tCtrl-M");
147 file_menu
->Append(DIALOGS_TEXT_ENTRY
, "Text &entry\tCtrl-E");
148 file_menu
->Append(DIALOGS_PASSWORD_ENTRY
, "&Password entry\tCtrl-P");
149 file_menu
->Append(DIALOGS_NUM_ENTRY
, "&Numeric entry\tCtrl-N");
150 file_menu
->Append(DIALOGS_SINGLE_CHOICE
, "&Single choice\tCtrl-C");
151 file_menu
->Append(DIALOGS_MULTI_CHOICE
, "M&ultiple choice\tCtrl-U");
152 file_menu
->AppendSeparator();
153 file_menu
->Append(DIALOGS_TIP
, "&Tip of the day\tCtrl-T");
154 file_menu
->AppendSeparator();
155 file_menu
->Append(DIALOGS_FILE_OPEN
, "&Open file\tCtrl-O");
156 file_menu
->Append(DIALOGS_FILE_OPEN2
, "&Second open file\tCtrl-2");
157 file_menu
->Append(DIALOGS_FILES_OPEN
, "Open &files\tCtrl-Q");
158 file_menu
->Append(DIALOGS_FILE_SAVE
, "Sa&ve file\tCtrl-S");
159 file_menu
->Append(DIALOGS_DIR_CHOOSE
, "&Choose a directory\tCtrl-D");
160 file_menu
->Append(DIALOGS_GENERIC_DIR_CHOOSE
, "&Choose a directory (generic implementation)");
161 #if wxUSE_PROGRESSDLG
162 file_menu
->Append(DIALOGS_PROGRESS
, "Pro&gress dialog\tCtrl-G");
163 #endif // wxUSE_PROGRESSDLG
165 file_menu
->Append(DIALOGS_BUSYINFO
, "&Busy info dialog\tCtrl-B");
166 #endif // wxUSE_BUSYINFO
167 #if wxUSE_FINDREPLDLG
168 file_menu
->Append(DIALOGS_FIND
, "&Find dialog\tCtrl-F");
169 file_menu
->Append(DIALOGS_REPLACE
, "Find and &replace dialog\tShift-Ctrl-F");
170 #endif // wxUSE_FINDREPLDLG
171 file_menu
->AppendSeparator();
172 file_menu
->Append(DIALOGS_MODAL
, "Mo&dal dialog\tCtrl-D");
173 file_menu
->Append(DIALOGS_MODELESS
, "Modeless &dialog\tCtrl-Z", "", TRUE
);
174 file_menu
->AppendSeparator();
175 file_menu
->Append(wxID_EXIT
, "E&xit\tAlt-X");
176 wxMenuBar
*menu_bar
= new wxMenuBar
;
177 menu_bar
->Append(file_menu
, "&File");
178 frame
->SetMenuBar(menu_bar
);
180 myCanvas
= new MyCanvas(frame
);
181 myCanvas
->SetBackgroundColour(*wxWHITE
);
183 frame
->Centre(wxBOTH
);
193 // My frame constructor
194 MyFrame::MyFrame(wxWindow
*parent
,
195 const wxString
& title
,
198 : wxFrame(parent
, -1, title
, pos
, size
)
200 m_dialog
= (MyModelessDialog
*)NULL
;
205 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
208 data
.SetChooseFull(TRUE
);
209 for (int i
= 0; i
< 16; i
++)
211 wxColour
colour(i
*16, i
*16, i
*16);
212 data
.SetCustomColour(i
, colour
);
215 wxColourDialog
*dialog
= new wxColourDialog(this, &data
);
216 dialog
->SetTitle("Choose the background colour");
217 if (dialog
->ShowModal() == wxID_OK
)
219 wxColourData retData
= dialog
->GetColourData();
220 wxColour col
= retData
.GetColour();
221 myCanvas
->SetBackgroundColour(col
);
228 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
231 data
.SetInitialFont(wxGetApp().m_canvasFont
);
232 data
.SetColour(wxGetApp().m_canvasTextColour
);
234 wxFontDialog
*dialog
= new wxFontDialog(this, &data
);
235 if (dialog
->ShowModal() == wxID_OK
)
237 wxFontData retData
= dialog
->GetFontData();
238 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
239 wxGetApp().m_canvasTextColour
= retData
.GetColour();
245 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
246 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
249 data
.SetChooseFull(TRUE
);
250 for (int i
= 0; i
< 16; i
++)
252 wxColour
colour(i
*16, i
*16, i
*16);
253 data
.SetCustomColour(i
, colour
);
256 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &data
);
257 if (dialog
->ShowModal() == wxID_OK
)
259 wxColourData retData
= dialog
->GetColourData();
260 wxColour col
= retData
.GetColour();
261 // wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID);
262 myCanvas
->SetBackgroundColour(col
);
269 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
272 data
.SetInitialFont(wxGetApp().m_canvasFont
);
273 data
.SetColour(wxGetApp().m_canvasTextColour
);
275 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, &data
);
276 if (dialog
->ShowModal() == wxID_OK
)
278 wxFontData retData
= dialog
->GetFontData();
279 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
280 wxGetApp().m_canvasTextColour
= retData
.GetColour();
285 #endif // wxTEST_GENERIC_DIALOGS_IN_MSW
287 void MyFrame::LogDialog(wxCommandEvent
& event
)
289 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
290 // being flushed -- test it
293 wxLogMessage(wxT("This is some message - everything is ok so far."));
294 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
295 wxLogWarning(wxT("And then something went wrong!"));
297 // and if ~wxBusyCursor doesn't do it, then call it manually
301 wxLogError(wxT("Intermediary error handler decided to abort."));
302 wxLogError(wxT("The top level caller detected an unrecoverable error."));
304 wxLog::FlushActive();
306 wxLogMessage(wxT("And this is the same dialog but with only one message."));
309 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
311 wxMessageDialog
dialog( NULL
, "This is a message box\nA long, long string to test out the message box properly",
312 "Message box text", wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
317 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
319 long res
= wxGetNumberFromUser( "This is some text, actually a lot of text.\n"
320 "Even two rows of text.",
321 "Enter a number:", "Numeric input test",
328 msg
= "Invalid number entered or dialog cancelled.";
333 msg
.Printf(_T("You've entered %lu"), res
);
334 icon
= wxICON_INFORMATION
;
337 wxMessageBox(msg
, "Numeric test result", wxOK
| icon
, this);
340 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
342 wxString pwd
= wxGetPasswordFromUser("Enter password:",
343 "Password entry dialog",
348 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
349 "Got password", wxOK
| wxICON_INFORMATION
, this);
353 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
355 wxTextEntryDialog
dialog(this,
356 "This is a small sample\n"
357 "A long, long string to test out the text entrybox",
358 "Please enter a string",
362 if (dialog
.ShowModal() == wxID_OK
)
364 wxMessageDialog
dialog2(this, dialog
.GetValue(), "Got string");
369 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
371 const wxString choices
[] = { "One", "Two", "Three", "Four", "Five" } ;
374 wxSingleChoiceDialog
dialog(this, "This is a small sample\nA single-choice convenience dialog",
375 "Please select a value", n
, (const wxString
*)choices
);
377 dialog
.SetSelection(2);
379 if (dialog
.ShowModal() == wxID_OK
)
381 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), "Got string");
386 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
388 const wxString choices
[] = { "One", "Two", "Three", "Four", "Five" } ;
391 wxArrayInt selections
;
392 size_t count
= wxGetMultipleChoices(selections
,
393 "This is a small sample\n"
394 "A multi-choice convenience dialog",
395 "Please select a value",
396 n
, (const wxString
*)choices
,
401 msg
.Printf(wxT("You selected %u items:\n"), count
);
402 for ( size_t n
= 0; n
< count
; n
++ )
404 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"), n
, selections
[n
],
405 choices
[selections
[n
]].c_str());
409 //else: cancelled or nothing selected
412 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
414 wxFileDialog
dialog(this, "Testing open file dialog",
416 "C++ files (*.h;*.cpp)|*.h;*.cpp");
418 if (dialog
.ShowModal() == wxID_OK
)
421 info
.Printf(_T("Full file name: %s\n")
424 dialog
.GetPath().c_str(),
425 dialog
.GetDirectory().c_str(),
426 dialog
.GetFilename().c_str());
427 wxMessageDialog
dialog2(this, info
, "Selected file");
432 // this shows how to take advantage of specifying a default extension in the
433 // call to wxFileSelector: it is remembered after each new call and the next
434 // one will use it by default
435 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
437 static wxString s_extDef
;
438 wxString path
= wxFileSelector(
439 _T("Select the file to load"),
442 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*"),
450 // it is just a sample, would use wxSplitPath in real program
451 s_extDef
= path
.AfterLast(_T('.'));
453 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
454 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
457 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
459 wxFileDialog
dialog(this, "Testing open multiple file dialog",
460 "", "", wxFileSelectorDefaultWildcardStr
,
463 if (dialog
.ShowModal() == wxID_OK
)
465 wxArrayString paths
, filenames
;
467 dialog
.GetPaths(paths
);
468 dialog
.GetFilenames(filenames
);
471 size_t count
= paths
.GetCount();
472 for ( size_t n
= 0; n
< count
; n
++ )
474 s
.Printf(_T("File %d: %s (%s)\n"),
475 n
, paths
[n
].c_str(), filenames
[n
].c_str());
480 wxMessageDialog
dialog2(this, msg
, "Selected files");
485 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
487 wxFileDialog
dialog(this, "Testing save file dialog", "", "myletter.txt",
488 "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
489 wxSAVE
|wxOVERWRITE_PROMPT
);
491 if (dialog
.ShowModal() == wxID_OK
)
494 wxSprintf(buf
, _T("%s, filter %d"), (const wxChar
*)dialog
.GetPath(), dialog
.GetFilterIndex());
495 wxMessageDialog
dialog2(this, wxString(buf
), "Selected path");
500 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
502 // pass some initial dir to wxDirDialog
504 wxGetHomeDir(&dirHome
);
506 wxDirDialog
dialog(this, "Testing directory picker", dirHome
);
508 if (dialog
.ShowModal() == wxID_OK
)
510 wxMessageDialog
dialog2(this, dialog
.GetPath(), "Selected path");
515 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
517 #if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG
518 // pass some initial dir to wxDirDialog
520 wxGetHomeDir(&dirHome
);
522 wxGenericDirDialog
dialog(this, "Testing generic directory picker", dirHome
);
524 if (dialog
.ShowModal() == wxID_OK
)
526 wxMessageDialog
dialog2(this, dialog
.GetPath(), "Selected path");
530 wxLogError(wxT("Sorry, generic dir dialog not available:\n")
531 wxT("set wxUSE_DIRDLGG to 1 and recompile"));
535 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
537 MyModalDialog
dlg(this);
541 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
543 bool show
= GetMenuBar()->IsChecked(event
.GetId());
549 m_dialog
= new MyModelessDialog(this);
552 m_dialog
->Show(TRUE
);
560 void MyFrame::ShowTip(wxCommandEvent
& event
)
562 #if wxUSE_STARTUP_TIPS
563 static size_t s_index
= (size_t)-1;
565 if ( s_index
== (size_t)-1 )
569 // this is completely bogus, we don't know how many lines are there
570 // in the file, but who cares, it's a demo only...
571 s_index
= rand() % 5;
574 wxTipProvider
*tipProvider
= wxCreateFileTipProvider("tips.txt", s_index
);
576 bool showAtStartup
= wxShowTip(this, tipProvider
);
580 wxMessageBox("Will show tips on startup", "Tips dialog",
581 wxOK
| wxICON_INFORMATION
, this);
584 s_index
= tipProvider
->GetCurrentTip();
589 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
594 #if wxUSE_PROGRESSDLG
596 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
598 static const int max
= 10;
600 wxProgressDialog
dialog("Progress dialog example",
601 "An informative message",
607 wxPD_ESTIMATED_TIME
|
608 wxPD_REMAINING_TIME
);
611 for ( int i
= 0; i
<= max
&& cont
; i
++ )
616 cont
= dialog
.Update(i
, "That's all, folks!");
618 else if ( i
== max
/ 2 )
620 cont
= dialog
.Update(i
, "Only a half left (very long message)!");
624 cont
= dialog
.Update(i
);
630 wxLogStatus(wxT("Progress dialog aborted!"));
634 wxLogStatus(wxT("Countdown from %d finished"), max
);
638 #endif // wxUSE_PROGRESSDLG
642 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
644 wxWindowDisabler disableAll
;
646 wxBusyInfo
info("Sleep^H^H^H^H^HWorkiing, please wait...", this);
648 for ( int i
= 0; i
< 30; i
++ )
655 #endif // wxUSE_BUSYINFO
657 #if wxUSE_FINDREPLDLG
659 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
661 wxFindReplaceDialog
*dialog
= new wxFindReplaceDialog
665 "Find and replace dialog",
671 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
673 wxFindReplaceDialog
*dialog
= new wxFindReplaceDialog
684 static wxString
DecodeFindDialogEventFlags(int flags
)
687 str
<< (flags
& wxFR_DOWN
? "down" : "up") << ", "
688 << (flags
& wxFR_WHOLEWORD
? "whole words only, " : "")
689 << (flags
& wxFR_MATCHCASE
? "" : "not ")
695 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
697 wxEventType type
= event
.GetEventType();
699 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
701 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
702 type
== wxEVT_COMMAND_FIND_NEXT
? "next " : "",
703 event
.GetFindString().c_str(),
704 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
706 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
707 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
709 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
710 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? "all " : "",
711 event
.GetFindString().c_str(),
712 event
.GetReplaceString().c_str(),
713 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
715 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
717 wxLogMessage(wxT("Find dialog is being closed."));
719 event
.GetDialog()->Destroy();
723 wxLogError(wxT("Unknown find dialog event!"));
727 #endif // wxUSE_FINDREPLDLG
729 // ----------------------------------------------------------------------------
731 // ----------------------------------------------------------------------------
733 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
736 dc
.SetFont(wxGetApp().m_canvasFont
);
737 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
738 dc
.SetBackgroundMode(wxTRANSPARENT
);
739 dc
.DrawText("wxWindows common dialogs test application", 10, 10);
742 // ----------------------------------------------------------------------------
744 // ----------------------------------------------------------------------------
746 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
747 : wxDialog(parent
, -1, wxString("Modeless dialog"))
749 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
751 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, "Press me");
752 wxCheckBox
*check
= new wxCheckBox(this, -1, "Should be disabled");
755 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
756 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
761 sizerTop
->SetSizeHints(this);
765 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
767 wxMessageBox("Button pressed in modeless dialog", "Info",
768 wxOK
| wxICON_INFORMATION
, this);
771 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
773 if ( event
.CanVeto() )
775 wxMessageBox("Use the menu item to close this dialog",
777 wxOK
| wxICON_INFORMATION
, this);
783 // ----------------------------------------------------------------------------
785 // ----------------------------------------------------------------------------
787 MyModalDialog::MyModalDialog(wxWindow
*parent
)
788 : wxDialog(parent
, -1, wxString("Modal dialog"))
790 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
792 m_btnFocused
= new wxButton(this, -1, "Default button");
793 m_btnDelete
= new wxButton(this, -1, "&Delete button");
794 sizerTop
->Add(m_btnFocused
, 0, wxALIGN_CENTER
| wxALL
, 5);
795 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
800 sizerTop
->SetSizeHints(this);
803 m_btnFocused
->SetFocus();
804 m_btnFocused
->SetDefault();
807 void MyModalDialog::OnButton(wxCommandEvent
& event
)
809 if ( event
.GetEventObject() == m_btnDelete
)
814 m_btnDelete
->Disable();
816 else if ( event
.GetEventObject() == m_btnFocused
)
818 wxGetTextFromUser("Dummy prompt", "Modal dialog called from dialog",