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", "", TRUE
);
169 file_menu
->Append(DIALOGS_REPLACE
, "Find and &replace dialog\tShift-Ctrl-F", "", TRUE
);
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
;
202 #if wxUSE_FINDREPLDLG
210 void MyFrame::ChooseColour(wxCommandEvent
& WXUNUSED(event
) )
212 wxColour col
= myCanvas
->GetBackgroundColour();
216 data
.SetChooseFull(TRUE
);
217 for (int i
= 0; i
< 16; i
++)
219 wxColour
colour(i
*16, i
*16, i
*16);
220 data
.SetCustomColour(i
, colour
);
223 wxColourDialog
dialog(this, &data
);
224 dialog
.SetTitle("Choose the background colour");
225 if (dialog
.ShowModal() == wxID_OK
)
227 wxColourData retData
= dialog
.GetColourData();
228 col
= retData
.GetColour();
229 myCanvas
->SetBackgroundColour(col
);
235 void MyFrame::ChooseFont(wxCommandEvent
& WXUNUSED(event
) )
238 data
.SetInitialFont(wxGetApp().m_canvasFont
);
239 data
.SetColour(wxGetApp().m_canvasTextColour
);
241 wxFontDialog
*dialog
= new wxFontDialog(this, &data
);
242 if (dialog
->ShowModal() == wxID_OK
)
244 wxFontData retData
= dialog
->GetFontData();
245 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
246 wxGetApp().m_canvasTextColour
= retData
.GetColour();
252 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
253 void MyFrame::ChooseColourGeneric(wxCommandEvent
& WXUNUSED(event
))
256 data
.SetChooseFull(TRUE
);
257 for (int i
= 0; i
< 16; i
++)
259 wxColour
colour(i
*16, i
*16, i
*16);
260 data
.SetCustomColour(i
, colour
);
263 wxGenericColourDialog
*dialog
= new wxGenericColourDialog(this, &data
);
264 if (dialog
->ShowModal() == wxID_OK
)
266 wxColourData retData
= dialog
->GetColourData();
267 wxColour col
= retData
.GetColour();
268 // wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID);
269 myCanvas
->SetBackgroundColour(col
);
276 void MyFrame::ChooseFontGeneric(wxCommandEvent
& WXUNUSED(event
) )
279 data
.SetInitialFont(wxGetApp().m_canvasFont
);
280 data
.SetColour(wxGetApp().m_canvasTextColour
);
282 wxGenericFontDialog
*dialog
= new wxGenericFontDialog(this, &data
);
283 if (dialog
->ShowModal() == wxID_OK
)
285 wxFontData retData
= dialog
->GetFontData();
286 wxGetApp().m_canvasFont
= retData
.GetChosenFont();
287 wxGetApp().m_canvasTextColour
= retData
.GetColour();
292 #endif // wxTEST_GENERIC_DIALOGS_IN_MSW
294 void MyFrame::LogDialog(wxCommandEvent
& event
)
296 // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
297 // being flushed -- test it
300 wxLogMessage(wxT("This is some message - everything is ok so far."));
301 wxLogMessage(wxT("Another message...\n... this one is on multiple lines"));
302 wxLogWarning(wxT("And then something went wrong!"));
304 // and if ~wxBusyCursor doesn't do it, then call it manually
308 wxLogError(wxT("Intermediary error handler decided to abort."));
309 wxLogError(wxT("The top level caller detected an unrecoverable error."));
311 wxLog::FlushActive();
313 wxLogMessage(wxT("And this is the same dialog but with only one message."));
316 void MyFrame::MessageBox(wxCommandEvent
& WXUNUSED(event
) )
318 wxMessageDialog
dialog( NULL
, "This is a message box\nA long, long string to test out the message box properly",
319 "Message box text", wxYES_NO
|wxCANCEL
|wxICON_INFORMATION
);
324 void MyFrame::NumericEntry(wxCommandEvent
& WXUNUSED(event
) )
326 long res
= wxGetNumberFromUser( "This is some text, actually a lot of text.\n"
327 "Even two rows of text.",
328 "Enter a number:", "Numeric input test",
335 msg
= "Invalid number entered or dialog cancelled.";
340 msg
.Printf(_T("You've entered %lu"), res
);
341 icon
= wxICON_INFORMATION
;
344 wxMessageBox(msg
, "Numeric test result", wxOK
| icon
, this);
347 void MyFrame::PasswordEntry(wxCommandEvent
& WXUNUSED(event
))
349 wxString pwd
= wxGetPasswordFromUser("Enter password:",
350 "Password entry dialog",
355 wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd
.c_str()),
356 "Got password", wxOK
| wxICON_INFORMATION
, this);
360 void MyFrame::TextEntry(wxCommandEvent
& WXUNUSED(event
))
362 wxTextEntryDialog
dialog(this,
363 "This is a small sample\n"
364 "A long, long string to test out the text entrybox",
365 "Please enter a string",
369 if (dialog
.ShowModal() == wxID_OK
)
371 wxMessageDialog
dialog2(this, dialog
.GetValue(), "Got string");
376 void MyFrame::SingleChoice(wxCommandEvent
& WXUNUSED(event
) )
378 const wxString choices
[] = { "One", "Two", "Three", "Four", "Five" } ;
381 wxSingleChoiceDialog
dialog(this, "This is a small sample\nA single-choice convenience dialog",
382 "Please select a value", n
, (const wxString
*)choices
);
384 dialog
.SetSelection(2);
386 if (dialog
.ShowModal() == wxID_OK
)
388 wxMessageDialog
dialog2(this, dialog
.GetStringSelection(), "Got string");
393 void MyFrame::MultiChoice(wxCommandEvent
& WXUNUSED(event
) )
395 const wxString choices
[] = { "One", "Two", "Three", "Four", "Five" } ;
398 wxArrayInt selections
;
399 size_t count
= wxGetMultipleChoices(selections
,
400 "This is a small sample\n"
401 "A multi-choice convenience dialog",
402 "Please select a value",
403 n
, (const wxString
*)choices
,
408 msg
.Printf(wxT("You selected %u items:\n"), count
);
409 for ( size_t n
= 0; n
< count
; n
++ )
411 msg
+= wxString::Format(wxT("\t%u: %u (%s)\n"), n
, selections
[n
],
412 choices
[selections
[n
]].c_str());
416 //else: cancelled or nothing selected
419 void MyFrame::FileOpen(wxCommandEvent
& WXUNUSED(event
) )
421 wxFileDialog
dialog(this, "Testing open file dialog",
423 "C++ files (*.h;*.cpp)|*.h;*.cpp");
425 if (dialog
.ShowModal() == wxID_OK
)
428 info
.Printf(_T("Full file name: %s\n")
431 dialog
.GetPath().c_str(),
432 dialog
.GetDirectory().c_str(),
433 dialog
.GetFilename().c_str());
434 wxMessageDialog
dialog2(this, info
, "Selected file");
439 // this shows how to take advantage of specifying a default extension in the
440 // call to wxFileSelector: it is remembered after each new call and the next
441 // one will use it by default
442 void MyFrame::FileOpen2(wxCommandEvent
& WXUNUSED(event
) )
444 static wxString s_extDef
;
445 wxString path
= wxFileSelector(
446 _T("Select the file to load"),
449 _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*"),
457 // it is just a sample, would use wxSplitPath in real program
458 s_extDef
= path
.AfterLast(_T('.'));
460 wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
461 (const wxChar
*) path
, (const wxChar
*) s_extDef
);
464 void MyFrame::FilesOpen(wxCommandEvent
& WXUNUSED(event
) )
466 wxFileDialog
dialog(this, "Testing open multiple file dialog",
467 "", "", wxFileSelectorDefaultWildcardStr
,
470 if (dialog
.ShowModal() == wxID_OK
)
472 wxArrayString paths
, filenames
;
474 dialog
.GetPaths(paths
);
475 dialog
.GetFilenames(filenames
);
478 size_t count
= paths
.GetCount();
479 for ( size_t n
= 0; n
< count
; n
++ )
481 s
.Printf(_T("File %d: %s (%s)\n"),
482 n
, paths
[n
].c_str(), filenames
[n
].c_str());
487 wxMessageDialog
dialog2(this, msg
, "Selected files");
492 void MyFrame::FileSave(wxCommandEvent
& WXUNUSED(event
) )
494 wxFileDialog
dialog(this, "Testing save file dialog", "", "myletter.txt",
495 "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
496 wxSAVE
|wxOVERWRITE_PROMPT
);
498 if (dialog
.ShowModal() == wxID_OK
)
501 wxSprintf(buf
, _T("%s, filter %d"), (const wxChar
*)dialog
.GetPath(), dialog
.GetFilterIndex());
502 wxMessageDialog
dialog2(this, wxString(buf
), "Selected path");
507 void MyFrame::DirChoose(wxCommandEvent
& WXUNUSED(event
) )
509 // pass some initial dir to wxDirDialog
511 wxGetHomeDir(&dirHome
);
513 wxDirDialog
dialog(this, "Testing directory picker", dirHome
);
515 if (dialog
.ShowModal() == wxID_OK
)
517 wxMessageDialog
dialog2(this, dialog
.GetPath(), "Selected path");
522 void MyFrame::GenericDirChoose(wxCommandEvent
& WXUNUSED(event
) )
524 #if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG
525 // pass some initial dir to wxDirDialog
527 wxGetHomeDir(&dirHome
);
529 wxGenericDirDialog
dialog(this, "Testing generic directory picker", dirHome
);
531 if (dialog
.ShowModal() == wxID_OK
)
533 wxMessageDialog
dialog2(this, dialog
.GetPath(), "Selected path");
537 wxLogError(wxT("Sorry, generic dir dialog not available:\n")
538 wxT("set wxUSE_DIRDLGG to 1 and recompile"));
542 void MyFrame::ModalDlg(wxCommandEvent
& WXUNUSED(event
))
544 MyModalDialog
dlg(this);
548 void MyFrame::ModelessDlg(wxCommandEvent
& event
)
550 bool show
= GetMenuBar()->IsChecked(event
.GetId());
556 m_dialog
= new MyModelessDialog(this);
559 m_dialog
->Show(TRUE
);
567 void MyFrame::ShowTip(wxCommandEvent
& event
)
569 #if wxUSE_STARTUP_TIPS
570 static size_t s_index
= (size_t)-1;
572 if ( s_index
== (size_t)-1 )
576 // this is completely bogus, we don't know how many lines are there
577 // in the file, but who cares, it's a demo only...
578 s_index
= rand() % 5;
581 wxTipProvider
*tipProvider
= wxCreateFileTipProvider("tips.txt", s_index
);
583 bool showAtStartup
= wxShowTip(this, tipProvider
);
587 wxMessageBox("Will show tips on startup", "Tips dialog",
588 wxOK
| wxICON_INFORMATION
, this);
591 s_index
= tipProvider
->GetCurrentTip();
596 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
) )
601 #if wxUSE_PROGRESSDLG
603 void MyFrame::ShowProgress( wxCommandEvent
& WXUNUSED(event
) )
605 static const int max
= 10;
607 wxProgressDialog
dialog("Progress dialog example",
608 "An informative message",
614 wxPD_ESTIMATED_TIME
|
615 wxPD_REMAINING_TIME
);
618 for ( int i
= 0; i
<= max
&& cont
; i
++ )
623 cont
= dialog
.Update(i
, "That's all, folks!");
625 else if ( i
== max
/ 2 )
627 cont
= dialog
.Update(i
, "Only a half left (very long message)!");
631 cont
= dialog
.Update(i
);
637 wxLogStatus(wxT("Progress dialog aborted!"));
641 wxLogStatus(wxT("Countdown from %d finished"), max
);
645 #endif // wxUSE_PROGRESSDLG
649 void MyFrame::ShowBusyInfo(wxCommandEvent
& WXUNUSED(event
))
651 wxWindowDisabler disableAll
;
653 wxBusyInfo
info("Sleep^H^H^H^H^HWorkiing, please wait...", this);
655 for ( int i
= 0; i
< 30; i
++ )
662 #endif // wxUSE_BUSYINFO
664 #if wxUSE_FINDREPLDLG
666 void MyFrame::ShowReplaceDialog( wxCommandEvent
& WXUNUSED(event
) )
675 m_dlgReplace
= new wxFindReplaceDialog
679 "Find and replace dialog",
683 m_dlgReplace
->Show(TRUE
);
687 void MyFrame::ShowFindDialog( wxCommandEvent
& WXUNUSED(event
) )
696 m_dlgFind
= new wxFindReplaceDialog
705 m_dlgFind
->Show(TRUE
);
709 static wxString
DecodeFindDialogEventFlags(int flags
)
712 str
<< (flags
& wxFR_DOWN
? "down" : "up") << ", "
713 << (flags
& wxFR_WHOLEWORD
? "whole words only, " : "")
714 << (flags
& wxFR_MATCHCASE
? "" : "not ")
720 void MyFrame::OnFindDialog(wxFindDialogEvent
& event
)
722 wxEventType type
= event
.GetEventType();
724 if ( type
== wxEVT_COMMAND_FIND
|| type
== wxEVT_COMMAND_FIND_NEXT
)
726 wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
727 type
== wxEVT_COMMAND_FIND_NEXT
? "next " : "",
728 event
.GetFindString().c_str(),
729 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
731 else if ( type
== wxEVT_COMMAND_FIND_REPLACE
||
732 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
)
734 wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
735 type
== wxEVT_COMMAND_FIND_REPLACE_ALL
? "all " : "",
736 event
.GetFindString().c_str(),
737 event
.GetReplaceString().c_str(),
738 DecodeFindDialogEventFlags(event
.GetFlags()).c_str());
740 else if ( type
== wxEVT_COMMAND_FIND_CLOSE
)
742 wxFindReplaceDialog
*dlg
= event
.GetDialog();
745 if ( dlg
== m_dlgFind
)
750 else if ( dlg
== m_dlgReplace
)
759 wxFAIL_MSG( _T("unexecpted event") );
762 wxLogMessage(wxT("%s dialog is being closed."), txt
),
768 wxLogError(wxT("Unknown find dialog event!"));
772 #endif // wxUSE_FINDREPLDLG
774 // ----------------------------------------------------------------------------
776 // ----------------------------------------------------------------------------
778 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
781 dc
.SetFont(wxGetApp().m_canvasFont
);
782 dc
.SetTextForeground(wxGetApp().m_canvasTextColour
);
783 dc
.SetBackgroundMode(wxTRANSPARENT
);
784 dc
.DrawText("wxWindows common dialogs test application", 10, 10);
787 // ----------------------------------------------------------------------------
789 // ----------------------------------------------------------------------------
791 MyModelessDialog::MyModelessDialog(wxWindow
*parent
)
792 : wxDialog(parent
, -1, wxString("Modeless dialog"))
794 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
796 wxButton
*btn
= new wxButton(this, DIALOGS_MODELESS_BTN
, "Press me");
797 wxCheckBox
*check
= new wxCheckBox(this, -1, "Should be disabled");
800 sizerTop
->Add(btn
, 1, wxEXPAND
| wxALL
, 5);
801 sizerTop
->Add(check
, 1, wxEXPAND
| wxALL
, 5);
806 sizerTop
->SetSizeHints(this);
810 void MyModelessDialog::OnButton(wxCommandEvent
& WXUNUSED(event
))
812 wxMessageBox("Button pressed in modeless dialog", "Info",
813 wxOK
| wxICON_INFORMATION
, this);
816 void MyModelessDialog::OnClose(wxCloseEvent
& event
)
818 if ( event
.CanVeto() )
820 wxMessageBox("Use the menu item to close this dialog",
822 wxOK
| wxICON_INFORMATION
, this);
828 // ----------------------------------------------------------------------------
830 // ----------------------------------------------------------------------------
832 MyModalDialog::MyModalDialog(wxWindow
*parent
)
833 : wxDialog(parent
, -1, wxString("Modal dialog"))
835 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxHORIZONTAL
);
837 m_btnFocused
= new wxButton(this, -1, "Default button");
838 m_btnDelete
= new wxButton(this, -1, "&Delete button");
839 sizerTop
->Add(m_btnFocused
, 0, wxALIGN_CENTER
| wxALL
, 5);
840 sizerTop
->Add(m_btnDelete
, 0, wxALIGN_CENTER
| wxALL
, 5);
845 sizerTop
->SetSizeHints(this);
848 m_btnFocused
->SetFocus();
849 m_btnFocused
->SetDefault();
852 void MyModalDialog::OnButton(wxCommandEvent
& event
)
854 if ( event
.GetEventObject() == m_btnDelete
)
859 m_btnDelete
->Disable();
861 else if ( event
.GetEventObject() == m_btnFocused
)
863 wxGetTextFromUser("Dummy prompt", "Modal dialog called from dialog",