+#if wxUSE_PROGRESSDLG
+
+void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
+{
+ static const int max = 10;
+
+ wxProgressDialog dialog(_T("Progress dialog example"),
+ _T("An informative message"),
+ max, // range
+ this, // parent
+ wxPD_CAN_ABORT |
+ wxPD_APP_MODAL |
+ // wxPD_AUTO_HIDE | -- try this as well
+ wxPD_ELAPSED_TIME |
+ wxPD_ESTIMATED_TIME |
+ wxPD_REMAINING_TIME);
+
+ bool cont = TRUE;
+ for ( int i = 0; i <= max; i++ )
+ {
+ wxSleep(1);
+ if ( i == max )
+ {
+ cont = dialog.Update(i, _T("That's all, folks!"));
+ }
+ else if ( i == max / 2 )
+ {
+ cont = dialog.Update(i, _T("Only a half left (very long message)!"));
+ }
+ else
+ {
+ cont = dialog.Update(i);
+ }
+
+ if ( !cont )
+ {
+ if ( wxMessageBox(_T("Do you really want to cancel?"),
+ _T("Progress dialog question"), // caption
+ wxYES_NO | wxICON_QUESTION) == wxYES )
+ break;
+
+ dialog.Resume();
+ }
+ }
+
+ 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(_T("Working, please wait..."), this);
+
+ for ( int i = 0; i < 18; i++ )
+ {
+ //wxUsleep(100);
+ wxTheApp->Yield();
+ }
+
+ wxSleep(2);
+ //wxWakeUpIdle();
+}
+
+#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,
+ _T("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,
+ _T("Find dialog"),
+ // just for testing
+ wxFR_NOWHOLEWORD
+ );
+
+ m_dlgFind->Show(TRUE);
+ }
+}
+
+static wxString DecodeFindDialogEventFlags(int flags)
+{
+ wxString str;
+ str << (flags & wxFR_DOWN ? _T("down") : _T("up")) << _T(", ")
+ << (flags & wxFR_WHOLEWORD ? _T("whole words only, ") : _T(""))
+ << (flags & wxFR_MATCHCASE ? _T("") : _T("not "))
+ << _T("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 ? wxT("next ") : wxT(""),
+ 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 ? _T("all ") : wxT(""),
+ event.GetFindString().c_str(),
+ event.GetReplaceString().c_str(),
+ DecodeFindDialogEventFlags(event.GetFlags()).c_str());
+ }
+ else if ( type == wxEVT_COMMAND_FIND_CLOSE )
+ {
+ wxFindReplaceDialog *dlg = event.GetDialog();
+
+ int idMenu;
+ const wxChar *txt;
+ if ( dlg == m_dlgFind )
+ {
+ txt = _T("Find");
+ idMenu = DIALOGS_FIND;
+ m_dlgFind = NULL;
+ }
+ else if ( dlg == m_dlgReplace )
+ {
+ txt = _T("Replace");
+ idMenu = DIALOGS_REPLACE;
+ m_dlgReplace = NULL;
+ }
+ else
+ {
+ txt = _T("Unknown");
+ idMenu = -1;
+
+ wxFAIL_MSG( _T("unexpected event") );
+ }
+
+ wxLogMessage(wxT("%s dialog is being closed."), txt);
+
+ if ( idMenu != -1 )
+ {
+ GetMenuBar()->Check(idMenu, FALSE);
+ }
+
+ dlg->Destroy();
+ }
+ else
+ {
+ wxLogError(wxT("Unknown find dialog event!"));
+ }
+}
+
+#endif // wxUSE_FINDREPLDLG
+
+// ----------------------------------------------------------------------------
+// MyCanvas
+// ----------------------------------------------------------------------------
+