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
This commit is contained in:
Vadim Zeitlin
2010-05-05 12:19:59 +00:00
parent 5009cb6acc
commit 1bd122ddfa
8 changed files with 26 additions and 19 deletions

View 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);

View 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.

View 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;

View 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)

View 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 );

View 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;

View 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)

View 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)