From 1bd122ddfa1d4d3e5f87ecb1e7dd317439fb6593 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 5 May 2010 12:19:59 +0000 Subject: [PATCH] Replace wxPrintout::SetIsPreview() with SetPreview(). Unlike the old function just indicating whether a printout is being used for previewing, the new one associates the preview object with it. This can be useful if we need to access the window used for the preview, for example. Also remove a bunch of apparently unnecessary SetIsPreview(false) calls as printing (and not previewing) is already the default. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64212 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/prntbase.h | 11 +++++++---- interface/wx/print.h | 17 +++++++++++++++++ src/common/prntbase.cpp | 4 ++-- src/generic/printps.cpp | 2 -- src/gtk/gnome/gprint.cpp | 5 ----- src/gtk/print.cpp | 2 -- src/msw/printwin.cpp | 2 -- src/osx/core/printmac.cpp | 2 -- 8 files changed, 26 insertions(+), 19 deletions(-) diff --git a/include/wx/prntbase.h b/include/wx/prntbase.h index 0a6aecaa46..14a3a05109 100644 --- a/include/wx/prntbase.h +++ b/include/wx/prntbase.h @@ -39,6 +39,7 @@ class WXDLLIMPEXP_FWD_CORE wxPreviewControlBar; class WXDLLIMPEXP_FWD_CORE wxPreviewFrame; class WXDLLIMPEXP_FWD_CORE wxPrintFactory; class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase; +class WXDLLIMPEXP_FWD_CORE wxPrintPreview; //---------------------------------------------------------------------------- // error consts @@ -293,13 +294,17 @@ public: void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; } wxRect GetPaperRectPixels() const { return m_paperRectPixels; } - virtual bool IsPreview() const { return m_isPreview; } + // This must be called by wxPrintPreview to associate itself with the + // printout it uses. + virtual void SetPreview(wxPrintPreview *preview) { m_preview = preview; } - virtual void SetIsPreview(bool p) { m_isPreview = p; } + wxPrintPreview *GetPreview() const { return m_preview; } + virtual bool IsPreview() const { return GetPreview() != NULL; } private: wxString m_printoutTitle; wxDC* m_printoutDC; + wxPrintPreview *m_preview; int m_pageWidthPixels; int m_pageHeightPixels; @@ -314,8 +319,6 @@ private: wxRect m_paperRectPixels; - bool m_isPreview; - private: DECLARE_ABSTRACT_CLASS(wxPrintout) wxDECLARE_NO_COPY_CLASS(wxPrintout); diff --git a/interface/wx/print.h b/interface/wx/print.h index 343dbb5b81..c782f96c9a 100644 --- a/interface/wx/print.h +++ b/interface/wx/print.h @@ -708,9 +708,26 @@ public: /** Returns @true if the printout is currently being used for previewing. + + @see GetPreview() */ virtual bool IsPreview() const; + /** + Returns the associated preview object if any. + + If this printout object is used for previewing, returns the associated + wxPrintPreview. Otherwise returns @NULL. + + The returned pointer is not owned by the printout and must not be + deleted. + + @see IsPreview() + + @since 2.9.1. + */ + wxPrintPreview *GetPreview() const; + /** Set the user scale and device origin of the wxDC associated with this wxPrintout so that one screen pixel maps to one device pixel on the DC. diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index 05d4d729a1..cb7452bd38 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -534,7 +534,7 @@ wxPrintout::wxPrintout(const wxString& title) m_PPIScreenY = 0; m_PPIPrinterX = 0; m_PPIPrinterY = 0; - m_isPreview = false; + m_preview = NULL; } wxPrintout::~wxPrintout() @@ -1375,7 +1375,7 @@ void wxPrintPreviewBase::Init(wxPrintout *printout, m_isOk = true; m_previewPrintout = printout; if (m_previewPrintout) - m_previewPrintout->SetIsPreview(true); + m_previewPrintout->SetPreview(static_cast(this)); m_printPrintout = printoutForPrinting; diff --git a/src/generic/printps.cpp b/src/generic/printps.cpp index d5396c480a..c23f21a9f8 100644 --- a/src/generic/printps.cpp +++ b/src/generic/printps.cpp @@ -80,8 +80,6 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro return false; } - printout->SetIsPreview(false); - if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index 407d422c8c..129f5a64c9 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -843,8 +843,6 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) native->SetPrintJob( job ); - printout->SetIsPreview(false); - if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) @@ -860,9 +858,6 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) dc = new wxGnomePrinterDC( printdata ); // TODO: check that this works #endif - if (m_native_preview) - printout->SetIsPreview(true); - if (!dc) { gs_libGnomePrint->gnome_print_job_close( job ); diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index dcbb0f42e9..451fe2a82a 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -836,8 +836,6 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) native->SetPrintJob( printOp ); - printout->SetIsPreview(false); - wxPrinterToGtkData dataToSend; dataToSend.printer = this; dataToSend.printout = printout; diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp index 26aa924725..37e9018b5d 100644 --- a/src/msw/printwin.cpp +++ b/src/msw/printwin.cpp @@ -90,8 +90,6 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt return false; } - printout->SetIsPreview(false); - if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) diff --git a/src/osx/core/printmac.cpp b/src/osx/core/printmac.cpp index 4b519b82d1..9090aae079 100644 --- a/src/osx/core/printmac.cpp +++ b/src/osx/core/printmac.cpp @@ -558,8 +558,6 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) return false; } - printout->SetIsPreview(false); - if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) -- 2.45.2