- err = PMEndPage(m_macPrintPort);
- if ( err )
- {
- message.Printf( "Print Error %d", err ) ;
- wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
- PMEndDocument(m_macPrintPort);
- UMAPrClose() ;
- ::SetPort( macPrintFormerPort ) ;
- m_ok = FALSE ;
- }
+ dc->m_macLocalOrigin.x = (int) rPage.left;
+ dc->m_macLocalOrigin.y = (int) rPage.top;
+#endif
+ }
+ // since this is a non-critical error, we set the flag back
+ m_err = noErr ;
+ }
+}
+
+void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
+{
+ if ( m_err )
+ return ;
+
+ wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ;
+
+ m_err = PMSessionEndPage(native->m_macPrintSession);
+ if ( m_err != noErr )
+ {
+ PMSessionEndDocument(native->m_macPrintSession);
+ }
+}
+
+void wxMacCarbonPrinterDC::GetSize( int *w , int *h) const
+{
+ if ( w )
+ *w = m_maxX ;
+ if ( h )
+ *h = m_maxY ;
+}
+
+wxSize wxMacCarbonPrinterDC::GetPPI() const
+{
+ return m_ppi ;
+};
+
+//
+//
+//
+
+wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
+{
+ m_ok = false ;
+ m_printData = printdata ;
+ m_printData.ConvertToNative() ;
+ m_nativePrinterDC = wxNativePrinterDC::Create( &m_printData ) ;
+ if ( m_nativePrinterDC )
+ {
+ m_ok = m_nativePrinterDC->Ok() ;
+ if ( !m_ok )
+ {
+ wxString message ;
+ message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
+ wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
+ dialog.ShowModal();
+ }
+ else
+ {
+ wxSize sz = GetPPI();
+ m_mm_to_pix_x = mm2inches * sz.x;
+ 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() ;
+ */
+#endif
+ }
+}
+
+wxSize wxPrinterDC::GetPPI() const
+{
+ return m_nativePrinterDC->GetPPI() ;
+}
+
+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 ) ;
+}