- }
-
-#if !TARGET_CARBON
- if ( ::PrValidate( (THPrint) m_printData.m_macPrintSettings ) )
- {
- ::PrStlDialog( (THPrint) m_printData.m_macPrintSettings ) ;
- // the driver has changed in the mean time, should we pop up a page setup dialog ?
- }
- err = PrError() ;
- if ( err != noErr )
+
+ m_maxX = wxCoord(rPage.right - rPage.left) ;
+ m_maxY = wxCoord(rPage.bottom - rPage.top);
+}
+
+wxMacCarbonPrinterDC::~wxMacCarbonPrinterDC()
+{
+ // nothing to release from print data, as wxPrinterDC has all data in its wxPrintData member
+ ::SetPort( m_macPrintFormerPort ) ;
+}
+
+wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
+{
+ return new wxMacCarbonPrinterDC(data) ;
+}
+
+bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED(message) )
+{
+ if ( m_err )
+ return false ;
+
+ wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
+
+ m_err = PMSessionBeginDocument(native->m_macPrintSession,
+ native->m_macPrintSettings,
+ native->m_macPageFormat);
+ if ( m_err != noErr )
+ return false;
+
+ PMRect rPage;
+ m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
+ if ( m_err != noErr )
+ return false;
+
+ m_maxX = (wxCoord)(rPage.right - rPage.left);
+ m_maxY = (wxCoord)(rPage.bottom - rPage.top);
+ return true ;
+}
+
+void wxMacCarbonPrinterDC::EndDoc( wxPrinterDC* dc )
+{
+ if ( m_err )
+ return ;
+
+ wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
+
+ m_err = PMSessionEndDocument(native->m_macPrintSession);
+}
+
+void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
+{
+ if ( m_err )
+ return ;
+
+ wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
+
+ m_err = PMSessionBeginPage(native->m_macPrintSession,
+ native->m_macPageFormat,
+ nil);
+
+ if ( m_err == noErr )