]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dcprint.cpp
use wx-style header and commets; fix indentation to be 4 spaces; move Doxygen comment...
[wxWidgets.git] / src / mac / carbon / dcprint.cpp
index 10c79a07eff7e1d71be425c5943e23757b0861f2..ccc58d99ffcf845534d3988aeffa3b732446948a 100644 (file)
@@ -84,13 +84,30 @@ wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
     m_maxY = wxCoord(rPage.bottom - rPage.top);
 
     PMResolution res;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 
-    PMPrinter printer;
-    PMSessionGetCurrentPrinter(native->m_macPrintSession, &printer);
-    PMPrinterGetOutputResolution( printer, native->m_macPrintSettings, &res) ;
-#else
-    m_err = PMGetResolution((PMPageFormat) (native->m_macPageFormat), &res);
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 
+    if ( PMPrinterGetOutputResolution != NULL )
+    {
+        PMPrinter printer;
+        m_err = PMSessionGetCurrentPrinter(native->m_macPrintSession, &printer);
+        if ( m_err == noErr )
+        {
+            m_err = PMPrinterGetOutputResolution( printer, native->m_macPrintSettings, &res) ;
+            if ( m_err == -9589 /* kPMKeyNotFound */ )
+            {
+                m_err = noErr ;
+                res.hRes = res.vRes = 300;
+            }
+        }
+    }
+    else
 #endif
+    {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 
+        m_err = PMGetResolution((PMPageFormat) (native->m_macPageFormat), &res);
+#endif
+    }
+    
     m_ppi = wxSize(int(res.hRes), int(res.vRes));
 }
 
@@ -132,7 +149,14 @@ bool wxMacCarbonPrinterDC::StartDoc(  wxPrinterDC* dc , const wxString& WXUNUSED
         PMPrinter printer;
         m_err = PMSessionGetCurrentPrinter(native->m_macPrintSession, &printer);
         if ( m_err == noErr )
+        {
             m_err = PMPrinterGetOutputResolution( printer, native->m_macPrintSettings, &res) ;
+            if ( m_err == -9589 /* kPMKeyNotFound */ )
+            {
+                m_err = noErr ;
+                res.hRes = res.vRes = 300;
+            }
+        }
     }
     else
 #endif
@@ -193,7 +217,7 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
             PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ;
             // make sure (0,0) is at the upper left of the printable area (wx conventions)
             // Core Graphics initially has the lower left of the paper as 0,0
-            CGContextTranslateCTM( pageContext , -paperRect.left , paperRect.bottom ) ;
+            CGContextTranslateCTM( pageContext , (CGFloat) -paperRect.left , (CGFloat) paperRect.bottom ) ;
             CGContextScaleCTM( pageContext , 1 , -1 ) ;
         }
         // since this is a non-critical error, we set the flag back