-void wxPrinterDC::EndPage(void)
-{
- if ( !m_ok )
- return ;
-
- OSStatus err ;
- wxString message ;
-
-#if !TARGET_CARBON
- PrClosePage( (TPrPort*) m_macPort ) ;
- err = PrError() ;
- if ( err )
- {
- message.Printf( "Print Error %d", err ) ;
- wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
- ::PrCloseDoc( m_macPrintPort ) ;
- ::UMAPrClose() ;
- ::SetPort( macPrintFormerPort ) ;
- m_ok = FALSE ;
- }
-#else
- 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 ;
- }
-#endif
+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 ;
+};
+
+//
+//
+//
+
+wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& printdata )
+ : wxGCDCImpl( owner )
+{
+ 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;
+ }
+ // we need at least a measuring context because people start measuring before a page
+ // gets printed at all
+ SetGraphicsContext( wxGraphicsContext::Create() );
+ }
+}
+
+wxSize wxPrinterDCImpl::GetPPI() const
+{
+ return m_nativePrinterDC->GetPPI() ;
+}
+
+wxPrinterDCImpl::~wxPrinterDCImpl()
+{
+ delete m_nativePrinterDC ;
+}
+
+bool wxPrinterDCImpl::StartDoc( const wxString& message )
+{
+ wxASSERT_MSG( IsOk() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
+
+ if ( !m_ok )
+ return false ;
+
+ if ( m_nativePrinterDC->StartDoc( (wxPrinterDC*) GetOwner(), message ) )
+ {
+ // in case we have to do additional things when successful
+ }
+ 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();
+ }
+
+ return m_ok ;
+}
+
+void wxPrinterDCImpl::EndDoc(void)
+{
+ if ( !m_ok )
+ return ;
+
+ m_nativePrinterDC->EndDoc( (wxPrinterDC*) GetOwner() ) ;
+ 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();
+ }
+}