X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f97c985452b20a8c2f0bbfb1d0275298bf09fb45..520e470fdd0daef09c77938db642e4583933c90d:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 2ab0f4cd24..bbfdf9ab3f 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -46,8 +46,6 @@ #include "wx/choicdlg.h" #include "wx/docview.h" #include "wx/printdlg.h" -#include "wx/generic/prntdlgg.h" -#include "wx/generic/printps.h" #include "wx/confbase.h" #include @@ -55,12 +53,15 @@ #if wxUSE_IOSTREAMH #include +#include #else #include +#include +# ifdef _MSC_VER + using namespace std; +# endif #endif -#include "fstream.h" - #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxDocument, wxEvtHandler) IMPLEMENT_ABSTRACT_CLASS(wxView, wxEvtHandler) @@ -744,20 +745,8 @@ void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event)) wxPrintout *printout = view->OnCreatePrintout(); if (printout) { - // TODO: trouble about this is that it pulls in the postscript - // code unecessarily -#ifdef __WXMSW__ - if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS ) - { - wxWindowsPrinter printer; - printer.Print(view->GetFrame(), printout, TRUE); - } - else -#endif - { - wxPostScriptPrinter printer; - printer.Print(view->GetFrame(), printout, TRUE); - } + wxPrinter printer; + printer.Print(view->GetFrame(), printout, TRUE); delete printout; } @@ -772,20 +761,9 @@ void wxDocManager::OnPrintSetup(wxCommandEvent& WXUNUSED(event)) wxPrintData data; -#ifdef __WXMSW__ - if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS ) - { - wxPrintDialog printerDialog(parentWin, & data); - printerDialog.GetPrintData().SetSetupDialog(TRUE); - printerDialog.ShowModal(); - } - else -#endif - { - wxGenericPrintDialog printerDialog(parentWin, & data); - printerDialog.GetPrintData().SetSetupDialog(TRUE); - printerDialog.ShowModal(); - } + wxPrintDialog printerDialog(parentWin, & data); + printerDialog.GetPrintData().SetSetupDialog(TRUE); + printerDialog.ShowModal(); } void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event)) @@ -799,12 +777,7 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event)) { // Pass two printout objects: for preview, and possible printing. wxPrintPreviewBase *preview = (wxPrintPreviewBase *) NULL; -#ifdef __WXMSW__ - if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS ) - preview = new wxWindowsPrintPreview(printout, view->OnCreatePrintout()); - else -#endif - preview = new wxPostScriptPrintPreview(printout, view->OnCreatePrintout()); + preview = new wxPrintPreview(printout, view->OnCreatePrintout()); wxPreviewFrame *frame = new wxPreviewFrame(preview, (wxFrame *)wxTheApp->GetTopWindow(), _("Print Preview"), wxPoint(100, 100), wxSize(600, 650)); @@ -1340,6 +1313,7 @@ void wxDocManager::ActivateView(wxView *view, bool activate, bool WXUNUSED(delet BEGIN_EVENT_TABLE(wxDocChildFrame, wxFrame) EVT_ACTIVATE(wxDocChildFrame::OnActivate) + EVT_CLOSE(wxDocChildFrame::OnCloseWindow) END_EVENT_TABLE() wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title, @@ -1382,24 +1356,30 @@ void wxDocChildFrame::OnActivate(wxActivateEvent& event) m_childView->Activate(event.GetActive()); } -bool wxDocChildFrame::OnClose(void) +void wxDocChildFrame::OnCloseWindow(wxCloseEvent& event) { - // Close view but don't delete the frame while doing so! - // ...since it will be deleted by wxWindows if we return TRUE. if (m_childView) { - bool ans = m_childView->Close(FALSE); // FALSE means don't delete associated window + bool ans = FALSE; + if (!event.CanVeto()) + ans = TRUE; // Must delete. + else + ans = m_childView->Close(FALSE); // FALSE means don't delete associated window + if (ans) { m_childView->Activate(FALSE); delete m_childView; m_childView = (wxView *) NULL; m_childDocument = (wxDocument *) NULL; + + this->Destroy(); } - - return ans; + else + event.Veto(); } - else return TRUE; + else + event.Veto(); } /* @@ -1409,6 +1389,7 @@ bool wxDocChildFrame::OnClose(void) BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame) EVT_MENU(wxID_EXIT, wxDocParentFrame::OnExit) EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocParentFrame::OnMRUFile) + EVT_CLOSE(wxDocParentFrame::OnCloseWindow) END_EVENT_TABLE() wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, @@ -1442,9 +1423,14 @@ bool wxDocParentFrame::ProcessEvent(wxEvent& event) // Define the behaviour for the frame closing // - must delete all frames except for the main one. -bool wxDocParentFrame::OnClose(void) +void wxDocParentFrame::OnCloseWindow(wxCloseEvent& event) { - return m_docManager->Clear(FALSE); + if (m_docManager->Clear(!event.CanVeto())) + { + this->Destroy(); + } + else + event.Veto(); } #if wxUSE_PRINTING_ARCHITECTURE