X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/161f4f7380e945b0769ad5f7122df55b8777396a..06acc7d9a6cf41c4f80230773cc0bdd2c95cec28:/src/common/cmndata.cpp diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index b039641a07..7d997f1bde 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -82,6 +82,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) #ifdef __WXMAC__ + #include "wx/mac/uma.h" + #define mm2pt 2.83464566929 #define pt2mm 0.352777777778 #endif // Mac @@ -179,6 +181,36 @@ wxPrintData::wxPrintData() #if TARGET_CARBON m_macPageFormat = kPMNoPageFormat; m_macPrintSettings = kPMNoPrintSettings; + + #if PM_USE_SESSION_APIS + PMPrintSession macPrintSession = kPMNoReference; + OSStatus err; + + err = ::UMAPrOpen(&macPrintSession) ; + if ( err == noErr ) + { + err = PMCreatePageFormat(&m_macPageFormat); + + // Note that PMPageFormat is not session-specific, but calling + // PMSessionDefaultPageFormat assigns values specific to the printer + // associated with the current printing session. + if ((err == noErr) && (m_macPageFormat != kPMNoPageFormat)) + { + err = PMSessionDefaultPageFormat(macPrintSession, m_macPageFormat); + } + + err = PMCreatePrintSettings(&m_macPrintSettings); + + // Note that PMPrintSettings is not session-specific, but calling + // PMSessionDefaultPrintSettings assigns values specific to the printer + // associated with the current printing session. + if ((err == noErr) && (m_macPrintSettings != kPMNoPrintSettings)) + { + err = PMSessionDefaultPrintSettings(macPrintSession, m_macPrintSettings); + } + } + ::UMAPrClose(&macPrintSession) ; + #endif #else m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ); (**m_macPrintInfo).iPrVersion = 0; // something invalid @@ -226,7 +258,7 @@ wxPrintData::wxPrintData(const wxPrintData& printData) m_devNames = (void*) NULL; #elif defined( __WXMAC__ ) #if TARGET_CARBON - m_macPageFormat = kPMNoPageFormat; + m_macPageFormat = kPMNoPageFormat; m_macPrintSettings = kPMNoPrintSettings; #else m_macPrintInfo = NULL; @@ -248,15 +280,24 @@ wxPrintData::~wxPrintData() #if TARGET_CARBON if (m_macPageFormat != kPMNoPageFormat) { + #if PM_USE_SESSION_APIS + (void)PMRelease(m_macPageFormat); + #else (void)PMDisposePageFormat(m_macPageFormat); + #endif m_macPageFormat = kPMNoPageFormat; } if (m_macPrintSettings != kPMNoPrintSettings) { + #if PM_USE_SESSION_APIS + (void)PMRelease(m_macPrintSettings); + #else (void)PMDisposePrintSettings(m_macPrintSettings); + #endif m_macPrintSettings = kPMNoPrintSettings; } + #else wxASSERT( m_macPrintInfo ); // we should perhaps delete @@ -725,7 +766,7 @@ void wxPrintData::ConvertFromNative() #ifdef __WXMAC__ void wxPrintData::ConvertToNative() { -#ifdef TARGET_CARBON +#if TARGET_CARBON #else (**m_macPrintInfo).prJob.iCopies = m_printNoCopies; #endif @@ -733,7 +774,7 @@ void wxPrintData::ConvertToNative() void wxPrintData::ConvertFromNative() { -#ifdef TARGET_CARBON +#if TARGET_CARBON #else m_printNoCopies = (**m_macPrintInfo).prJob.iCopies; #endif @@ -743,7 +784,7 @@ void wxPrintData::ConvertFromNative() void wxPrintData::operator=(const wxPrintData& data) { #ifdef __WXMAC__ -#ifdef TARGET_CARBON +#if TARGET_CARBON #else m_macPrintInfo = data.m_macPrintInfo; HandToHand( (Handle*) &m_macPrintInfo ); @@ -1045,7 +1086,7 @@ void wxPrintDialogData::SetOwnerWindow(wxWindow* win) #ifdef __WXMAC__ void wxPrintDialogData::ConvertToNative() { -#ifdef TARGET_CARBON +#if TARGET_CARBON #else (**m_printData.m_macPrintInfo).prJob.iFstPage = m_printFromPage; (**m_printData.m_macPrintInfo).prJob.iLstPage = m_printToPage; @@ -1055,7 +1096,7 @@ void wxPrintDialogData::ConvertToNative() void wxPrintDialogData::ConvertFromNative() { -#ifdef TARGET_CARBON +#if TARGET_CARBON #else m_printData.ConvertFromNative(); m_printFromPage = (**m_printData.m_macPrintInfo).prJob.iFstPage; @@ -1370,7 +1411,7 @@ void wxPageSetupDialogData::ConvertToNative() { m_printData.ConvertToNative(); // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0 -#ifdef TARGET_CARBON +#if TARGET_CARBON #else (**m_printData.m_macPrintInfo).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt ); (**m_printData.m_macPrintInfo).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt ); @@ -1389,7 +1430,7 @@ void wxPageSetupDialogData::ConvertFromNative() { m_printData.ConvertFromNative (); -#ifdef TARGET_CARBON +#if TARGET_CARBON #else m_paperSize.x = ((double) (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ) * pt2mm; m_paperSize.y = ((double) (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ) * pt2mm;