+ // pass some initial dir to wxDirDialog
+ wxString dirHome;
+ wxGetHomeDir(&dirHome);
+
+ wxDirDialog dialog(this, "Testing directory picker", dirHome);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path");
+ dialog2.ShowModal();
+ }
+}
+
+void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
+{
+#if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG
+ // pass some initial dir to wxDirDialog
+ wxString dirHome;
+ wxGetHomeDir(&dirHome);
+
+ wxGenericDirDialog dialog(this, "Testing generic directory picker", dirHome);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path");
+ dialog2.ShowModal();
+ }
+#else
+ wxLogError("Sorry, generic dir dialog not available:\n"
+ "set wxUSE_DIRDLGG to 1 and recompile");
+#endif
+}
+
+void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
+{
+ MyModalDialog dlg(this);
+ dlg.ShowModal();
+}
+
+void MyFrame::ModelessDlg(wxCommandEvent& event)
+{
+ bool show = GetMenuBar()->IsChecked(event.GetId());
+
+ if ( show )
+ {
+ if ( !m_dialog )
+ {
+ m_dialog = new MyModelessDialog(this);
+ }
+
+ m_dialog->Show(TRUE);
+ }
+ else // hide
+ {
+ m_dialog->Hide();
+ }
+}
+
+void MyFrame::OnButton(wxCommandEvent& WXUNUSED(event))
+{
+ wxMessageBox("Button pressed in modeless dialog", "Info",
+ wxOK | wxICON_INFORMATION, this);
+}
+
+void MyFrame::ShowTip(wxCommandEvent& event)
+{
+#if wxUSE_STARTUP_TIPS
+ static size_t s_index = (size_t)-1;
+
+ if ( s_index == (size_t)-1 )
+ {
+ srand(time(NULL));
+
+ // this is completely bogus, we don't know how many lines are there
+ // in the file, but who cares, it's a demo only...
+ s_index = rand() % 5;
+ }
+
+ wxTipProvider *tipProvider = wxCreateFileTipProvider("tips.txt", s_index);
+
+ bool showAtStartup = wxShowTip(this, tipProvider);
+
+ if ( showAtStartup )
+ {
+ wxMessageBox("Will show tips on startup", "Tips dialog",
+ wxOK | wxICON_INFORMATION, this);
+ }
+
+ s_index = tipProvider->GetCurrentTip();
+ delete tipProvider;
+#endif
+}
+
+void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
+{
+ Close(TRUE);
+}
+
+#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("Progress dialog aborted!");
+ }
+ else
+ {
+ wxLogStatus("Countdown from %d finished", max);
+ }
+}
+
+#endif // wxUSE_PROGRESSDLG
+
+// ----------------------------------------------------------------------------
+// MyCanvas
+// ----------------------------------------------------------------------------
+
+void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
+{
+ wxPaintDC dc(this);