]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dcprint.cpp
Include wx/scrolbar.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / mac / carbon / dcprint.cpp
index ba563f3f48d23c96887af357f411184979100ea5..490b0830659ac93e1f322c591b7ae81d22874995 100644 (file)
@@ -1,39 +1,34 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        dcprint.cpp
+// Name:        src/mac/carbon/dcprint.cpp
 // Purpose:     wxPrinterDC class
 // Author:      Julian Smart
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:       wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "dcprint.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #if wxUSE_PRINTING_ARCHITECTURE
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
+#include "wx/dcprint.h"
+
 #ifndef WX_PRECOMP
+    #include "wx/msgdlg.h"
 #endif
 
-#include "wx/dcprint.h"
-#include "wx/msgdlg.h"
 #include "wx/math.h"
 #include "wx/mac/uma.h"
 #include "wx/mac/private/print.h"
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_CLASS(wxPrinterDC, wxDC)
-#endif
 
 class wxNativePrinterDC
 {
@@ -182,8 +177,11 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
         if ( !m_err )
         {
 #if wxMAC_USE_CORE_GRAPHICS
-            CGContextTranslateCTM( pageContext , 0 , rPage.bottom - rPage.top ) ;
+            PMRect paperRect ;
+            PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ;
+            CGContextTranslateCTM( pageContext , -paperRect.left , -paperRect.top + ( rPage.bottom - rPage.top ) ) ;
             CGContextScaleCTM( pageContext , 1 , -1 ) ;
+            CGContextSaveGState( pageContext ) ;
 #else
             dc->m_macLocalOrigin.x = (int) rPage.left;
             dc->m_macLocalOrigin.y = (int) rPage.top;
@@ -210,7 +208,7 @@ void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
 
 wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
 {
-    m_ok = FALSE ;
+    m_ok = false ;
     m_printData = printdata ;
     m_printData.ConvertToNative() ;
     m_nativePrinterDC = wxNativePrinterDC::Create( &m_printData ) ;
@@ -233,11 +231,15 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
 
 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 ) 
+void wxPrinterDC::MacSetCGContext( void * cg )
 {
     ((wxMacCGContext*)(m_graphicContext))->SetNativeContext( (CGContextRef) cg ) ;
     m_graphicContext->SetPen( m_pen ) ;