-#if !TARGET_CARBON
- if ( m_ok )
- {
- OSErr err ;
- wxString message ;
-
- ::PrCloseDoc( m_macPrintPort ) ;
- err = PrError() ;
-
- if ( !err )
- {
- if ( (**m_printData.m_macPrintInfo).prJob.bJDocLoop == bSpoolLoop )
- {
- TPrStatus status ;
- ::PrPicFile( m_printData.m_macPrintInfo , NULL , NULL , NULL , &status ) ;
- }
- }
- else
- {
- message.Printf( "Print Error %d", err ) ;
- wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
- UMAPrClose() ;
- }
- ::UMAPrClose() ;
-// ::SetPort( macPrintFormerPort ) ;
- ::SetPort( LMGetWMgrPort() ) ;
- m_macPortHelper.Clear() ;
- }
+ if ( m_err )
+ return ;
+
+ wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ;
+
+ m_err = PMSessionEndDocument(native->m_macPrintSession);
+}
+
+void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
+{
+ if ( m_err )
+ return ;
+
+ wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ;
+
+ m_err = PMSessionBeginPage(native->m_macPrintSession,
+ native->m_macPageFormat,
+ nil);
+
+#if wxMAC_USE_CORE_GRAPHICS
+ CGContextRef pageContext;
+#endif
+ if ( m_err == noErr )
+ {
+#if wxMAC_USE_CORE_GRAPHICS
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+ m_err = PMSessionGetCGGraphicsContext(native->m_macPrintSession,
+ &pageContext );
+
+#else
+ m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
+ kPMGraphicsContextCoreGraphics,
+ (void**) &pageContext );
+#endif
+ dc->MacSetCGContext(pageContext) ;
+#else
+ m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
+ kPMGraphicsContextQuickdraw,
+ (void**) &dc->m_macPort );
+#endif
+ }
+
+ if ( m_err != noErr )
+ {
+ PMSessionEndPage(native->m_macPrintSession);
+ PMSessionEndDocument(native->m_macPrintSession);
+ }
+ else
+ {
+ PMRect rPage;
+
+ m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
+ if ( !m_err )
+ {
+#if wxMAC_USE_CORE_GRAPHICS
+ PMRect paperRect ;
+ PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ;
+ CGContextTranslateCTM( pageContext , -paperRect.left , -paperRect.top + ( rPage.bottom - rPage.top ) ) ;
+ CGContextScaleCTM( pageContext , 1 , -1 ) ;
+ CGContextSaveGState( pageContext ) ;