// returns 0 in case of no Error, otherwise platform specific error codes
virtual wxUint32 GetStatus() const = 0 ;
- bool Ok() { return GetStatus() == 0 ; }
+ bool IsOk() { return GetStatus() == 0 ; }
static wxNativePrinterDC* Create(wxPrintData* data) ;
} ;
m_maxY = wxCoord(rPage.bottom - rPage.top);
PMResolution res;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if ( PMPrinterGetOutputResolution != NULL )
+ PMPrinter printer;
+ m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
+ if ( m_err == noErr )
{
- PMPrinter printer;
- m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
- if ( m_err == noErr )
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ if ( PMPrinterGetOutputResolution != NULL )
{
- m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ;
- if ( m_err == -9589 /* kPMKeyNotFound */ )
{
- m_err = noErr ;
- res.hRes = res.vRes = 300;
+ m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ;
+ if ( m_err == -9589 /* kPMKeyNotFound */ )
+ {
+ m_err = noErr ;
+ res.hRes = res.vRes = 300;
+ }
}
}
- }
- else
+ else
#endif
- {
+ {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
- m_err = PMGetResolution((PMPageFormat) (native->GetPageFormat()), &res);
+ m_err = PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &res);
+ if ( m_err != noErr )
+ {
+ m_err = PMGetResolution((PMPageFormat) (native->GetPageFormat()), &res);
+ }
#endif
+ }
+ }
+ else
+ {
+ res.hRes = res.vRes = 300;
}
+ m_maxX = wxCoord((double)m_maxX * res.hRes / 72.0);
+ m_maxY = wxCoord((double)m_maxY * res.vRes / 72.0);
+
m_ppi = wxSize(int(res.hRes), int(res.vRes));
}
wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl();
wxOSXPrintData *native = (wxOSXPrintData*) impl->GetPrintData().GetNativeData() ;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- if ( PMPrintSettingsSetJobName != NULL )
- PMPrintSettingsSetJobName(native->GetPrintSettings(), wxCFStringRef(message));
-#endif
+ PMPrintSettingsSetJobName(native->GetPrintSettings(), wxCFStringRef(message));
m_err = PMSessionBeginCGDocumentNoDialog(native->GetPrintSession(),
native->GetPrintSettings(),
m_maxY = wxCoord(rPage.bottom - rPage.top);
PMResolution res;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if ( PMPrinterGetOutputResolution != NULL )
+ PMPrinter printer;
+
+ m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
+ if (m_err == noErr)
{
- PMPrinter printer;
- m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer);
- if ( m_err == noErr )
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ if ( PMPrinterGetOutputResolution != NULL )
{
m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ;
if ( m_err == -9589 /* kPMKeyNotFound */ )
res.hRes = res.vRes = 300;
}
}
- }
- else
+ else
#endif
- {
+ {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
- m_err = PMGetResolution((PMPageFormat) (native->GetPageFormat()), &res);
+ if ( PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &res) != noErr )
+ {
+ res.hRes = res.vRes = 300;
+ }
#endif
+ }
}
+ m_maxX = wxCoord((double)m_maxX * res.hRes / 72.0);
+ m_maxY = wxCoord((double)m_maxY * res.vRes / 72.0);
+
m_ppi = wxSize(int(res.hRes), int(res.vRes));
return true ;
}
m_err = PMSessionBeginPageNoDialog(native->GetPrintSession(),
native->GetPageFormat(),
- nil);
+ NULL);
CGContextRef pageContext;
}
else
{
- PMRect rPage;
-
- m_err = PMGetAdjustedPageRect(native->GetPageFormat(), &rPage);
+ PMRect paperRect ;
+ m_err = PMGetAdjustedPaperRect( native->GetPageFormat() , &paperRect ) ;
+ // make sure (0,0) is at the upper left of the printable area (wx conventions)
+ // Core Graphics initially has the lower left of the paper as 0,0
if ( !m_err )
- {
- PMRect paperRect ;
- PMGetAdjustedPaperRect( native->GetPageFormat() , &paperRect ) ;
- // make sure (0,0) is at the upper left of the printable area (wx conventions)
- // Core Graphics initially has the lower left of the paper as 0,0
CGContextTranslateCTM( pageContext , (CGFloat) -paperRect.left , (CGFloat) paperRect.bottom ) ;
- CGContextScaleCTM( pageContext , 1 , -1 ) ;
- }
+
// since this is a non-critical error, we set the flag back
m_err = noErr ;
+
+ // Leopard deprecated PMSetResolution() which will not be available in 64 bit mode, so we avoid using it.
+ // To set the proper drawing resolution, the docs suggest the use of CGContextScaleCTM(), so here we go; as a
+ // consequence though, PMGetAdjustedPaperRect() and PMGetAdjustedPageRect() return unscaled rects, so we
+ // have to manually scale them later.
+ CGContextScaleCTM( pageContext, 72.0 / (double)m_ppi.x, -72.0 / (double)m_ppi.y);
+
+ impl->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) );
}
- impl->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) );
}
void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
m_nativePrinterDC = wxNativePrinterDC::Create( &m_printData ) ;
if ( m_nativePrinterDC )
{
- m_ok = m_nativePrinterDC->Ok() ;
+ m_ok = m_nativePrinterDC->IsOk() ;
if ( !m_ok )
{
wxString message ;
{
// in case we have to do additional things when successful
}
- m_ok = m_nativePrinterDC->Ok() ;
+ m_ok = m_nativePrinterDC->IsOk() ;
if ( !m_ok )
{
wxString message ;
return ;
m_nativePrinterDC->EndDoc( (wxPrinterDC*) GetOwner() ) ;
- m_ok = m_nativePrinterDC->Ok() ;
+ m_ok = m_nativePrinterDC->IsOk() ;
if ( !m_ok )
{
err = PMGetAdjustedPaperRect(native->GetPageFormat(), &rPaper);
if ( err != noErr )
return pageRect;
+
+ wxSize ppi = GetOwner()->GetPPI();
+ rPaper.right *= (ppi.x / 72.0);
+ rPaper.bottom *= (ppi.y / 72.0);
+ rPaper.left *= (ppi.x / 72.0);
+ rPaper.top *= (ppi.y / 72.0);
+
return wxRect(wxCoord(rPaper.left), wxCoord(rPaper.top),
wxCoord(rPaper.right - rPaper.left), wxCoord(rPaper.bottom - rPaper.top));
}
m_backgroundBrush = *wxWHITE_BRUSH;
m_nativePrinterDC->StartPage( (wxPrinterDC*) GetOwner() ) ;
- m_ok = m_nativePrinterDC->Ok() ;
+ m_ok = m_nativePrinterDC->IsOk() ;
}
return ;
m_nativePrinterDC->EndPage( (wxPrinterDC*) GetOwner() );
- m_ok = m_nativePrinterDC->Ok() ;
+ m_ok = m_nativePrinterDC->IsOk() ;
}
void wxPrinterDCImpl::DoGetSize(int *width, int *height) const