X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f518afb5dcd87eca4287a442e5cc78baf3ab9d4b..797e38dde12c5dc2d99070eef25d9b8c2549d621:/src/mac/carbon/dcprint.cpp?ds=inline diff --git a/src/mac/carbon/dcprint.cpp b/src/mac/carbon/dcprint.cpp index 34af3cc1cb..93102ac245 100644 --- a/src/mac/carbon/dcprint.cpp +++ b/src/mac/carbon/dcprint.cpp @@ -219,18 +219,19 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc ) #if wxMAC_USE_CORE_GRAPHICS PMRect paperRect ; PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ; - CGContextTranslateCTM( pageContext , -paperRect.left , -paperRect.top + ( rPage.bottom - rPage.top ) ) ; + // 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 , -paperRect.left , paperRect.bottom ) ; CGContextScaleCTM( pageContext , 1 , -1 ) ; #else - dc->m_macLocalOrigin.x = (int) rPage.left; - dc->m_macLocalOrigin.y = (int) rPage.top; + dc->SetDeviceLocalOrigin( (wxCoord) rPage.left, (wxCoord) rPage.top ); #endif } // since this is a non-critical error, we set the flag back m_err = noErr ; } #if wxMAC_USE_CORE_GRAPHICS - dc->MacSetCGContext(pageContext) ; + dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) ); #endif } @@ -247,7 +248,8 @@ void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc ) PMSessionEndDocument(native->m_macPrintSession); } #if wxMAC_USE_CORE_GRAPHICS - dc->MacSetCGContext(NULL) ; + // the cg context we got when starting the page isn't valid anymore, so replace it + dc->SetGraphicsContext( wxGraphicsContext::Create() ); #endif } @@ -291,10 +293,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) m_mm_to_pix_y = mm2inches * sz.y; } #if wxMAC_USE_CORE_GRAPHICS -/* - // the cgContext will only be handed over page by page - m_graphicContext = new wxMacCGContext() ; - */ + // we need at least a measuring context because people start measuring before a page + // gets printed at all + SetGraphicsContext( wxGraphicsContext::Create() ); #endif } } @@ -306,23 +307,9 @@ wxSize wxPrinterDC::GetPPI() const wxPrinterDC::~wxPrinterDC(void) { -#if wxMAC_USE_CORE_GRAPHICS -/* - // this context was borrowed - ((wxMacCGContext*)(m_graphicContext))->SetNativeContext( NULL ) ; - */ -#endif delete m_nativePrinterDC ; } -#if wxMAC_USE_CORE_GRAPHICS -void wxPrinterDC::MacSetCGContext( void * cg ) -{ - SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); - m_graphicContext->SetPen( m_pen ) ; - m_graphicContext->SetBrush( m_brush ) ; -} -#endif bool wxPrinterDC::StartDoc( const wxString& message ) { wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;