]> git.saurik.com Git - wxWidgets.git/commitdiff
Replace wxPrintout::SetIsPreview() with SetPreview().
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 5 May 2010 12:19:59 +0000 (12:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 5 May 2010 12:19:59 +0000 (12:19 +0000)
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
interface/wx/print.h
src/common/prntbase.cpp
src/generic/printps.cpp
src/gtk/gnome/gprint.cpp
src/gtk/print.cpp
src/msw/printwin.cpp
src/osx/core/printmac.cpp

index 0a6aecaa463496189fed5bae1c81e974baa4962d..14a3a05109872072f8463c2ec21575c7aea21e2b 100644 (file)
@@ -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);
index 343dbb5b813080605ec5838dc7f7272e2547d6e9..c782f96c9a143ccaef449166c5083ba4a6c37adc 100644 (file)
@@ -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.
index 05d4d729a1b6d171ff9f736648dbae7cedf0cfd2..cb7452bd3804f7617e647dc1fabeb19ca3da5606 100644 (file)
@@ -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<wxPrintPreview *>(this));
 
     m_printPrintout = printoutForPrinting;
 
index d5396c480a940bbfc5c64180d20876e02c2ad879..c23f21a9f86e1a5f23be4c41b0df056c6e2fb0d9 100644 (file)
@@ -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)
index 407d422c8c517215e04c5f7a36b3aaed9a8d6094..129f5a64c911513190d3e877d40ed227b4185172 100644 (file)
@@ -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 );
index dcbb0f42e9a403376a39c326d79c8cea9793e503..451fe2a82a6d748e76b3937121e258fe96d1adaa 100644 (file)
@@ -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;
index 26aa924725b18a5272e0a21b74d530a9439517bd..37e9018b5d4d786f16accd4b9f513902e42e8b93 100644 (file)
@@ -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)
index 4b519b82d132bb78b1068c1f6cca851da4358640..9090aae0798a40576c272b780fff04aee3f06c5b 100644 (file)
@@ -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)