From 0ab2de15cbb2bf653f3279d7f8635ee503488396 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 7 Nov 2004 10:11:48 +0000 Subject: [PATCH] Moved deletion of wxPrintFacory to module. Added wxWidgets 2.4 backward comp methods to wxPrintData which make use of the PostScript native print data if used. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30334 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cmndata.h | 23 ++++++ src/common/cmndata.cpp | 158 +++++++++++++++++++++++++++++++++++++++- src/common/prntbase.cpp | 17 +++++ 3 files changed, 197 insertions(+), 1 deletion(-) diff --git a/include/wx/cmndata.h b/include/wx/cmndata.h index 459a78eca9..95f2b7dc14 100644 --- a/include/wx/cmndata.h +++ b/include/wx/cmndata.h @@ -217,6 +217,29 @@ public: void operator=(const wxPrintData& data); +#if WXWIN_COMPATIBILITY_2_4 + // PostScript-specific data + wxString GetPrinterCommand() const; + wxString GetPrinterOptions() const; + wxString GetPreviewCommand() const; + wxString GetFontMetricPath() const; + double GetPrinterScaleX() const; + double GetPrinterScaleY() const; + long GetPrinterTranslateX() const; + long GetPrinterTranslateY() const; + + void SetPrinterCommand(const wxString& command); + void SetPrinterOptions(const wxString& options); + void SetPreviewCommand(const wxString& command); + void SetFontMetricPath(const wxString& path); + void SetPrinterScaleX(double x); + void SetPrinterScaleY(double y); + void SetPrinterScaling(double x, double y); + void SetPrinterTranslateX(long x); + void SetPrinterTranslateY(long y); + void SetPrinterTranslation(long x, long y); +#endif + // Convert between wxPrintData and native data void ConvertToNative(); void ConvertFromNative(); diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index dc13526103..1f839fb728 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -204,7 +204,6 @@ wxPrintData::~wxPrintData() #endif } - void wxPrintData::ConvertToNative() { #ifdef __WXMAC__ @@ -259,6 +258,163 @@ bool wxPrintData::Ok() const return m_nativeData->Ok(); } +#if WXWIN_COMPATIBILITY_2_4 + +#include "wx/generic/prntdlgg.h" + +wxString wxPrintData::GetPrinterCommand() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand(); +#endif + return wxT(""); +} + +wxString wxPrintData::GetPrinterOptions() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions(); +#endif + return wxT(""); +} + +wxString wxPrintData::GetPreviewCommand() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand(); +#endif + return wxT(""); +} + +wxString wxPrintData::GetFontMetricPath() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath(); +#endif + return wxT(""); +} + +double wxPrintData::GetPrinterScaleX() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX(); +#endif + return 1.0; +} + +double wxPrintData::GetPrinterScaleY() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY(); +#endif + return 1.0; +} + +long wxPrintData::GetPrinterTranslateX() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX(); +#endif + return 0; +} + +long wxPrintData::GetPrinterTranslateY() const +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY(); +#endif + return 0; +} + +void wxPrintData::SetPrinterCommand(const wxString& command) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command ); +#endif +} + +void wxPrintData::SetPrinterOptions(const wxString& options) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options ); +#endif +} + +void wxPrintData::SetPreviewCommand(const wxString& command) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command ); +#endif +} + +void wxPrintData::SetFontMetricPath(const wxString& path) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path ); +#endif +} + +void wxPrintData::SetPrinterScaleX(double x) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x ); +#endif +} + +void wxPrintData::SetPrinterScaleY(double y) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y ); +#endif +} + +void wxPrintData::SetPrinterScaling(double x, double y) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y ); +#endif +} + +void wxPrintData::SetPrinterTranslateX(long x) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x ); +#endif +} + +void wxPrintData::SetPrinterTranslateY(long y) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y ); +#endif +} + +void wxPrintData::SetPrinterTranslation(long x, long y) +{ +#if wxUSE_POSTSCRIPT + if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) + ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y ); +#endif +} +#endif + // ---------------------------------------------------------------------------- // Print dialog data // ---------------------------------------------------------------------------- diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index e0a3bbf3a5..6bf627c967 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -246,6 +246,23 @@ wxPrintNativeDataBase::wxPrintNativeDataBase() m_ref = 1; } +//---------------------------------------------------------------------------- +// wxPrintFactoryModule +//---------------------------------------------------------------------------- + +class wxPrintFactoryModule: public wxModule +{ +public: + wxPrintFactoryModule() {} + bool OnInit() { return true; } + void OnExit() { wxPrintFactory::SetPrintFactory( NULL ); } + +private: + DECLARE_DYNAMIC_CLASS(wxPrintFactoryModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxPrintFactoryModule, wxModule) + //---------------------------------------------------------------------------- // wxPrinterBase //---------------------------------------------------------------------------- -- 2.45.2