]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/dcprint.cpp
compilation fixes - wxGTK compiles but not links
[wxWidgets.git] / src / mac / dcprint.cpp
index b21fe548a253e89261e9b5cfc1e9a78234828152..904c5eedca7ea796554101642b49c6f489c17867 100644 (file)
 #endif
 
 #include "wx/dcprint.h"
-#include "math.h"
+#include "wx/msgdlg.h"
+#include <math.h>
 #include "wx/mac/uma.h"
 
-
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_CLASS(wxPrinterDC, wxDC)
 #endif
@@ -41,13 +41,21 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
        
        m_printData = printdata ;
        m_printData.ConvertToNative() ;
-       
+
+#if PM_USE_SESSION_APIS
+       err = UMAPrOpen(&m_macPrintPort) ;
+#else
        err = UMAPrOpen() ;
+#endif
        if ( err )
        {
                message.Printf( "Print Error %d", err ) ;
                wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+#if PM_USE_SESSION_APIS
+               UMAPrClose(&m_macPrintPort) ;
+#else
                UMAPrClose() ;
+#endif
        }
        
 #if !TARGET_CARBON
@@ -76,15 +84,26 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
        m_macPort = (GrafPtr ) m_macPrintPort ;
 #else
        m_macPrintPort = kPMNoReference ;
+  #if PM_USE_SESSION_APIS
+    err = PMSessionBeginDocument(
+       m_macPrintPort,
+       m_printData.m_macPrintSettings, 
+       m_printData.m_macPageFormat);
+  #else
     err = PMBeginDocument(
        m_printData.m_macPrintSettings, 
        m_printData.m_macPageFormat, 
        &m_macPrintPort);
+  #endif
     if ( err != noErr || m_macPrintPort == kPMNoReference )
     {
                message.Printf( "Print Error %d", err ) ;
                wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+  #if PM_USE_SESSION_APIS
+               UMAPrClose(&m_macPrintPort) ;
+  #else
                UMAPrClose() ;
+  #endif
     }
        // sets current port
        ::GetPort( &m_macPort ) ;
@@ -125,19 +144,30 @@ wxPrinterDC::~wxPrinterDC(void)
                ::UMAPrClose() ;
 //       ::SetPort( macPrintFormerPort ) ;
                ::SetPort( LMGetWMgrPort() ) ;
-               m_macPortHelper.Clear() ;
        }
 #else
        if ( m_ok ) 
        {
-       err = PMEndDocument(m_macPrintPort);
+  #if PM_USE_SESSION_APIS
+           err = PMSessionEndDocument(m_macPrintPort);
+  #else
+           err = PMEndDocument(m_macPrintPort);
+  #endif
        if ( !err )
        {
                        message.Printf( "Print Error %d", err ) ;
                        wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+  #if PM_USE_SESSION_APIS
+                       UMAPrClose(&m_macPrintPort) ;
+  #else
                        UMAPrClose() ;
+  #endif
        }
-       UMAPrClose() ;
+  #if PM_USE_SESSION_APIS
+       UMAPrClose(&m_macPrintPort) ;
+  #else
+           UMAPrClose() ;
+  #endif
        }
 #endif
 }
@@ -195,14 +225,26 @@ void wxPrinterDC::StartPage(void)
                m_ok = FALSE ;
        }
 #else
-    err = PMBeginPage(m_macPrintPort, nil);
+  #if PM_USE_SESSION_APIS
+       err = PMSessionBeginPage(m_macPrintPort,
+                                m_printData.m_macPageFormat,
+                                nil);
+  #else
+       err = PMBeginPage(m_macPrintPort, nil);
+  #endif
        if ( err )
        {
                message.Printf( "Print Error %d", err ) ;
                wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+  #if PM_USE_SESSION_APIS
+               PMSessionEndPage(m_macPrintPort);
+               PMSessionEndDocument(m_macPrintPort);
+               UMAPrClose(&m_macPrintPort) ;
+  #else
                PMEndPage(m_macPrintPort);
                PMEndDocument(m_macPrintPort);
                UMAPrClose() ;
+  #endif
                ::SetPort( macPrintFormerPort ) ;
                m_ok = FALSE ;
        }
@@ -230,13 +272,22 @@ void wxPrinterDC::EndPage(void)
                m_ok = FALSE ;
        }
 #else
+  #if PM_USE_SESSION_APIS
+       err = PMSessionEndPage(m_macPrintPort);
+  #else
        err = PMEndPage(m_macPrintPort);
+  #endif
        if ( err )
        {
                message.Printf( "Print Error %d", err ) ;
                wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+  #if PM_USE_SESSION_APIS
+               PMSessionEndDocument(m_macPrintPort);
+               UMAPrClose(&m_macPrintPort) ;
+  #else
                PMEndDocument(m_macPrintPort);
                UMAPrClose() ;
+  #endif
                ::SetPort( macPrintFormerPort ) ;
                m_ok = FALSE ;
        }