+ wxDocument *doc = GetCurrentDocument();
+ if (!doc)
+ return;
+ if (doc->Close())
+ {
+ doc->DeleteAllViews();
+ if (m_docs.Member(doc))
+ delete doc;
+ }
+}
+
+void wxDocManager::OnFileCloseAll(wxCommandEvent& WXUNUSED(event))
+{
+ CloseDocuments(FALSE);
+}
+
+void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event))
+{
+ CreateDocument( wxT(""), wxDOC_NEW );
+}
+
+void wxDocManager::OnFileOpen(wxCommandEvent& WXUNUSED(event))
+{
+ if ( !CreateDocument( wxT(""), 0) )
+ {
+ OnOpenFileFailure();
+ }
+}
+
+void wxDocManager::OnFileRevert(wxCommandEvent& WXUNUSED(event))
+{
+ wxDocument *doc = GetCurrentDocument();
+ if (!doc)
+ return;
+ doc->Revert();
+}
+
+void wxDocManager::OnFileSave(wxCommandEvent& WXUNUSED(event))
+{
+ wxDocument *doc = GetCurrentDocument();
+ if (!doc)
+ return;
+ doc->Save();
+}
+
+void wxDocManager::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
+{
+ wxDocument *doc = GetCurrentDocument();
+ if (!doc)
+ return;
+ doc->SaveAs();
+}
+
+void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
+{
+#if wxUSE_PRINTING_ARCHITECTURE
+ wxView *view = GetCurrentView();
+ if (!view)
+ return;
+
+ wxPrintout *printout = view->OnCreatePrintout();
+ if (printout)
+ {
+ wxPrinter printer;
+ printer.Print(view->GetFrame(), printout, TRUE);
+
+ delete printout;
+ }
+#endif // wxUSE_PRINTING_ARCHITECTURE
+}
+
+void wxDocManager::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
+{
+#if wxUSE_PRINTING_ARCHITECTURE
+ wxWindow *parentWin = wxTheApp->GetTopWindow();
+ wxView *view = GetCurrentView();
+ if (view)
+ parentWin = view->GetFrame();
+
+ wxPrintDialogData data;
+
+ wxPrintDialog printerDialog(parentWin, &data);
+ printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
+ printerDialog.ShowModal();
+#endif // wxUSE_PRINTING_ARCHITECTURE
+}
+
+void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
+{
+#if wxUSE_PRINTING_ARCHITECTURE
+ wxView *view = GetCurrentView();
+ if (!view)
+ return;
+
+ wxPrintout *printout = view->OnCreatePrintout();
+ if (printout)
+ {
+ // Pass two printout objects: for preview, and possible printing.
+ wxPrintPreviewBase *preview = new wxPrintPreview(printout, view->OnCreatePrintout());
+ if ( !preview->Ok() )
+ {
+ delete preview;
+ wxMessageBox( _("Sorry, print preview needs a printer to be installed.") );
+ return;
+ }
+
+ wxPreviewFrame *frame = new wxPreviewFrame(preview, (wxFrame *)wxTheApp->GetTopWindow(), _("Print Preview"),
+ wxPoint(100, 100), wxSize(600, 650));
+ frame->Centre(wxBOTH);
+ frame->Initialize();
+ frame->Show(TRUE);
+ }
+#endif // wxUSE_PRINTING_ARCHITECTURE
+}
+
+void wxDocManager::OnUndo(wxCommandEvent& event)
+{
+ wxDocument *doc = GetCurrentDocument();
+ if (!doc)
+ return;
+ if (doc->GetCommandProcessor())
+ doc->GetCommandProcessor()->Undo();
+ else
+ event.Skip();
+}
+
+void wxDocManager::OnRedo(wxCommandEvent& event)
+{
+ wxDocument *doc = GetCurrentDocument();
+ if (!doc)
+ return;
+ if (doc->GetCommandProcessor())
+ doc->GetCommandProcessor()->Redo();
+ else
+ event.Skip();
+}
+
+// Handlers for UI update commands
+
+void wxDocManager::OnUpdateFileOpen(wxUpdateUIEvent& event)
+{
+ event.Enable( TRUE );