]> git.saurik.com Git - wxWidgets.git/commitdiff
use Print Manager session APIs if PM_USE_SESSION_APIS is true
authorGilles Depeyrot <gilles_depeyrot@mac.com>
Sat, 23 Jun 2001 17:18:09 +0000 (17:18 +0000)
committerGilles Depeyrot <gilles_depeyrot@mac.com>
Sat, 23 Jun 2001 17:18:09 +0000 (17:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/dcprint.cpp
src/mac/carbon/uma.cpp
src/mac/dcprint.cpp
src/mac/uma.cpp

index 1467c4970fb88afaf96f74bfc16e45c8e3e219de..2238c6ecfd75dbdbc118189bb98e5262ac84fe4c 100644 (file)
@@ -41,13 +41,21 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
        
        m_printData = printdata ;
        m_printData.ConvertToNative() ;
-       
+
+#if !TARGET_CARBON
        err = UMAPrOpen() ;
+#else
+       err = UMAPrOpen(&m_macPrintPort) ;
+#endif
        if ( err )
        {
                message.Printf( "Print Error %d", err ) ;
                wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+#if !TARGET_CARBON
                UMAPrClose() ;
+#else
+               UMAPrClose(&m_macPrintPort) ;
+#endif
        }
        
 #if !TARGET_CARBON
@@ -76,15 +84,22 @@ 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) ;
-               UMAPrClose() ;
+               UMAPrClose(&m_macPrintPort) ;
     }
        // sets current port
        ::GetPort( &m_macPort ) ;
@@ -129,14 +144,26 @@ wxPrinterDC::~wxPrinterDC(void)
 #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 !TARGET_CARBON
                        UMAPrClose() ;
+  #else
+                       UMAPrClose(&m_macPrintPort) ;
+  #endif
        }
+  #if !TARGET_CARBON
        UMAPrClose() ;
+  #else
+       UMAPrClose(&m_macPrintPort) ;
+  #endif
        }
 #endif
 }
@@ -194,14 +221,25 @@ 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);
+  #else
                PMEndPage(m_macPrintPort);
                PMEndDocument(m_macPrintPort);
-               UMAPrClose() ;
+  #endif
+               UMAPrClose(&m_macPrintPort) ;
                ::SetPort( macPrintFormerPort ) ;
                m_ok = FALSE ;
        }
@@ -229,13 +267,21 @@ 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);
+  #else
                PMEndDocument(m_macPrintPort);
-               UMAPrClose() ;
+  #endif
+               UMAPrClose(&m_macPrintPort) ;
                ::SetPort( macPrintFormerPort ) ;
                m_ok = FALSE ;
        }
index 49ce364221e11998dfcf7cb990791dc5113b4e6e..044ef97c966d66fbbe52d7e81b3b766160f8e00a 100644 (file)
@@ -3,9 +3,7 @@
 #include "wx/mac/uma.h"
 #include "wx/mac/aga.h"
 
-#ifdef __UNIX__
-  #include <Carbon/Carbon.h>
-#else
+#ifndef __UNIX__
   #include <Navigation.h>
 #endif
 
@@ -291,7 +289,11 @@ void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
 
 int gPrOpenCounter = 0 ;
 
-OSStatus UMAPrOpen() 
+#if !TARGET_CARBON
+OSStatus UMAPrOpen()
+#else
+OSStatus UMAPrOpen(PMPrintSession *macPrintPort)
+#endif
 {
 #if !TARGET_CARBON
        OSErr err = noErr ;
@@ -308,14 +310,22 @@ OSStatus UMAPrOpen()
        ++gPrOpenCounter ;
        if ( gPrOpenCounter == 1 )
        {
-               err = PMBegin() ;
+  #if PM_USE_SESSION_APIS
+           err = PMCreateSession(macPrintPort) ;
+  #else
+           err = PMBegin() ;
+  #endif
                wxASSERT( err == noErr ) ;
        }
        return err ;
 #endif
 }
 
-OSStatus UMAPrClose() 
+#if !TARGET_CARBON
+OSStatus UMAPrClose()
+#else
+OSStatus UMAPrClose(PMPrintSession *macPrintPort)
+#endif
 {
 #if !TARGET_CARBON
        OSErr err = noErr ;
@@ -333,7 +343,11 @@ OSStatus UMAPrClose()
        wxASSERT( gPrOpenCounter >= 1 ) ;
        if ( gPrOpenCounter == 1 )
        {
-               err = PMEnd() ;
+  #if PM_USE_SESSION_APIS
+           err = PMRelease(*macPrintPort) ;
+  #else
+           err = PMEnd() ;
+  #endif
        }
        --gPrOpenCounter ;
        return err ;
index 1467c4970fb88afaf96f74bfc16e45c8e3e219de..2238c6ecfd75dbdbc118189bb98e5262ac84fe4c 100644 (file)
@@ -41,13 +41,21 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
        
        m_printData = printdata ;
        m_printData.ConvertToNative() ;
-       
+
+#if !TARGET_CARBON
        err = UMAPrOpen() ;
+#else
+       err = UMAPrOpen(&m_macPrintPort) ;
+#endif
        if ( err )
        {
                message.Printf( "Print Error %d", err ) ;
                wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
+#if !TARGET_CARBON
                UMAPrClose() ;
+#else
+               UMAPrClose(&m_macPrintPort) ;
+#endif
        }
        
 #if !TARGET_CARBON
@@ -76,15 +84,22 @@ 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) ;
-               UMAPrClose() ;
+               UMAPrClose(&m_macPrintPort) ;
     }
        // sets current port
        ::GetPort( &m_macPort ) ;
@@ -129,14 +144,26 @@ wxPrinterDC::~wxPrinterDC(void)
 #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 !TARGET_CARBON
                        UMAPrClose() ;
+  #else
+                       UMAPrClose(&m_macPrintPort) ;
+  #endif
        }
+  #if !TARGET_CARBON
        UMAPrClose() ;
+  #else
+       UMAPrClose(&m_macPrintPort) ;
+  #endif
        }
 #endif
 }
@@ -194,14 +221,25 @@ 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);
+  #else
                PMEndPage(m_macPrintPort);
                PMEndDocument(m_macPrintPort);
-               UMAPrClose() ;
+  #endif
+               UMAPrClose(&m_macPrintPort) ;
                ::SetPort( macPrintFormerPort ) ;
                m_ok = FALSE ;
        }
@@ -229,13 +267,21 @@ 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);
+  #else
                PMEndDocument(m_macPrintPort);
-               UMAPrClose() ;
+  #endif
+               UMAPrClose(&m_macPrintPort) ;
                ::SetPort( macPrintFormerPort ) ;
                m_ok = FALSE ;
        }
index 49ce364221e11998dfcf7cb990791dc5113b4e6e..044ef97c966d66fbbe52d7e81b3b766160f8e00a 100644 (file)
@@ -3,9 +3,7 @@
 #include "wx/mac/uma.h"
 #include "wx/mac/aga.h"
 
-#ifdef __UNIX__
-  #include <Carbon/Carbon.h>
-#else
+#ifndef __UNIX__
   #include <Navigation.h>
 #endif
 
@@ -291,7 +289,11 @@ void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
 
 int gPrOpenCounter = 0 ;
 
-OSStatus UMAPrOpen() 
+#if !TARGET_CARBON
+OSStatus UMAPrOpen()
+#else
+OSStatus UMAPrOpen(PMPrintSession *macPrintPort)
+#endif
 {
 #if !TARGET_CARBON
        OSErr err = noErr ;
@@ -308,14 +310,22 @@ OSStatus UMAPrOpen()
        ++gPrOpenCounter ;
        if ( gPrOpenCounter == 1 )
        {
-               err = PMBegin() ;
+  #if PM_USE_SESSION_APIS
+           err = PMCreateSession(macPrintPort) ;
+  #else
+           err = PMBegin() ;
+  #endif
                wxASSERT( err == noErr ) ;
        }
        return err ;
 #endif
 }
 
-OSStatus UMAPrClose() 
+#if !TARGET_CARBON
+OSStatus UMAPrClose()
+#else
+OSStatus UMAPrClose(PMPrintSession *macPrintPort)
+#endif
 {
 #if !TARGET_CARBON
        OSErr err = noErr ;
@@ -333,7 +343,11 @@ OSStatus UMAPrClose()
        wxASSERT( gPrOpenCounter >= 1 ) ;
        if ( gPrOpenCounter == 1 )
        {
-               err = PMEnd() ;
+  #if PM_USE_SESSION_APIS
+           err = PMRelease(*macPrintPort) ;
+  #else
+           err = PMEnd() ;
+  #endif
        }
        --gPrOpenCounter ;
        return err ;