+#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 );
+}
+
+void wxDocManager::OnUpdateFileClose(wxUpdateUIEvent& event)
+{
+ wxDocument *doc = GetCurrentDocument();
+ event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdateFileRevert(wxUpdateUIEvent& event)
+{
+ wxDocument *doc = GetCurrentDocument();
+ event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdateFileNew(wxUpdateUIEvent& event)
+{
+ event.Enable( TRUE );
+}
+
+void wxDocManager::OnUpdateFileSave(wxUpdateUIEvent& event)
+{
+ wxDocument *doc = GetCurrentDocument();
+ event.Enable( doc && doc->IsModified() );
+}