+#if wxUSE_PROGRESSDLG
+
+void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
+{
+ static const int max = 10;
+
+ wxProgressDialog dialog("Progress dialog example",
+ "An informative message",
+ max, // range
+ this, // parent
+ wxPD_CAN_ABORT |
+ wxPD_APP_MODAL |
+ wxPD_ELAPSED_TIME |
+ wxPD_ESTIMATED_TIME |
+ wxPD_REMAINING_TIME);
+
+ bool cont = TRUE;
+ for ( int i = 0; i <= max && cont; i++ )
+ {
+ wxSleep(1);
+ if ( i == max )
+ {
+ cont = dialog.Update(i, "That's all, folks!");
+ }
+ else if ( i == max / 2 )
+ {
+ cont = dialog.Update(i, "Only a half left (very long message)!");
+ }
+ else
+ {
+ cont = dialog.Update(i);
+ }
+ }
+
+ if ( !cont )
+ {
+ wxLogStatus(wxT("Progress dialog aborted!"));
+ }
+ else
+ {
+ wxLogStatus(wxT("Countdown from %d finished"), max);
+ }
+}
+
+#endif // wxUSE_PROGRESSDLG
+
+#if wxUSE_BUSYINFO
+
+void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
+{
+ wxWindowDisabler disableAll;
+
+ wxBusyInfo info("Working, please wait...", this);
+
+ for ( int i = 0; i < 30; i++ )
+ {
+ wxUsleep(100);
+ wxTheApp->Yield();
+ }
+}
+
+#endif // wxUSE_BUSYINFO
+
+#if wxUSE_FINDREPLDLG
+
+void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
+{
+ if ( m_dlgReplace )
+ {
+ delete m_dlgReplace;
+ m_dlgReplace = NULL;
+ }
+ else
+ {
+ m_dlgReplace = new wxFindReplaceDialog
+ (
+ this,
+ &m_findData,
+ "Find and replace dialog",
+ wxFR_REPLACEDIALOG
+ );
+
+ m_dlgReplace->Show(TRUE);
+ }
+}
+
+void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
+{
+ if ( m_dlgFind )
+ {
+ delete m_dlgFind;
+ m_dlgFind = NULL;
+ }
+ else
+ {
+ m_dlgFind = new wxFindReplaceDialog
+ (
+ this,
+ &m_findData,
+ "Find dialog",
+ // just for testing
+ wxFR_NOWHOLEWORD
+ );
+
+ m_dlgFind->Show(TRUE);
+ }
+}
+
+static wxString DecodeFindDialogEventFlags(int flags)
+{
+ wxString str;
+ str << (flags & wxFR_DOWN ? "down" : "up") << ", "
+ << (flags & wxFR_WHOLEWORD ? "whole words only, " : "")
+ << (flags & wxFR_MATCHCASE ? "" : "not ")
+ << "case sensitive";
+
+ return str;
+}
+
+void MyFrame::OnFindDialog(wxFindDialogEvent& event)
+{
+ wxEventType type = event.GetEventType();
+
+ if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
+ {
+ wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
+ type == wxEVT_COMMAND_FIND_NEXT ? "next " : "",
+ event.GetFindString().c_str(),
+ DecodeFindDialogEventFlags(event.GetFlags()).c_str());
+ }
+ else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
+ type == wxEVT_COMMAND_FIND_REPLACE_ALL )
+ {
+ wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
+ type == wxEVT_COMMAND_FIND_REPLACE_ALL ? "all " : "",
+ event.GetFindString().c_str(),
+ event.GetReplaceString().c_str(),
+ DecodeFindDialogEventFlags(event.GetFlags()).c_str());
+ }
+ else if ( type == wxEVT_COMMAND_FIND_CLOSE )
+ {
+ wxFindReplaceDialog *dlg = event.GetDialog();
+
+ const wxChar *txt;
+ if ( dlg == m_dlgFind )
+ {
+ txt = _T("Find");
+ m_dlgFind = NULL;
+ }
+ else if ( dlg == m_dlgReplace )
+ {
+ txt = _T("Replace");
+ m_dlgReplace = NULL;
+ }
+ else
+ {
+ txt = _T("Unknown");
+
+ wxFAIL_MSG( _T("unexecpted event") );
+ }
+
+ wxLogMessage(wxT("%s dialog is being closed."), txt),
+
+ dlg->Destroy();
+ }
+ else
+ {
+ wxLogError(wxT("Unknown find dialog event!"));
+ }
+}
+
+#endif // wxUSE_FINDREPLDLG
+
+// ----------------------------------------------------------------------------
+// MyCanvas
+// ----------------------------------------------------------------------------
+