use Print Manager session APIs if PM_USE_SESSION_APIS is true

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Gilles Depeyrot 2001-06-23 17:18:09 +00:00
parent 0ab2593768
commit a689a4d09a
4 changed files with 146 additions and 26 deletions

View File

@ -41,13 +41,21 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
m_printData = printdata ; m_printData = printdata ;
m_printData.ConvertToNative() ; m_printData.ConvertToNative() ;
#if !TARGET_CARBON
err = UMAPrOpen() ; err = UMAPrOpen() ;
#else
err = UMAPrOpen(&m_macPrintPort) ;
#endif
if ( err ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if !TARGET_CARBON
UMAPrClose() ; UMAPrClose() ;
#else
UMAPrClose(&m_macPrintPort) ;
#endif
} }
#if !TARGET_CARBON #if !TARGET_CARBON
@ -76,15 +84,22 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
m_macPort = (GrafPtr ) m_macPrintPort ; m_macPort = (GrafPtr ) m_macPrintPort ;
#else #else
m_macPrintPort = kPMNoReference ; m_macPrintPort = kPMNoReference ;
#if PM_USE_SESSION_APIS
err = PMSessionBeginDocument(
m_macPrintPort,
m_printData.m_macPrintSettings,
m_printData.m_macPageFormat);
#else
err = PMBeginDocument( err = PMBeginDocument(
m_printData.m_macPrintSettings, m_printData.m_macPrintSettings,
m_printData.m_macPageFormat, m_printData.m_macPageFormat,
&m_macPrintPort); &m_macPrintPort);
#endif
if ( err != noErr || m_macPrintPort == kPMNoReference ) if ( err != noErr || m_macPrintPort == kPMNoReference )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
UMAPrClose() ; UMAPrClose(&m_macPrintPort) ;
} }
// sets current port // sets current port
::GetPort( &m_macPort ) ; ::GetPort( &m_macPort ) ;
@ -129,14 +144,26 @@ wxPrinterDC::~wxPrinterDC(void)
#else #else
if ( m_ok ) if ( m_ok )
{ {
err = PMEndDocument(m_macPrintPort); #if PM_USE_SESSION_APIS
err = PMSessionEndDocument(m_macPrintPort);
#else
err = PMEndDocument(m_macPrintPort);
#endif
if ( !err ) if ( !err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if !TARGET_CARBON
UMAPrClose() ; UMAPrClose() ;
#else
UMAPrClose(&m_macPrintPort) ;
#endif
} }
#if !TARGET_CARBON
UMAPrClose() ; UMAPrClose() ;
#else
UMAPrClose(&m_macPrintPort) ;
#endif
} }
#endif #endif
} }
@ -194,14 +221,25 @@ void wxPrinterDC::StartPage(void)
m_ok = FALSE ; m_ok = FALSE ;
} }
#else #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 ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if PM_USE_SESSION_APIS
PMSessionEndPage(m_macPrintPort);
PMSessionEndDocument(m_macPrintPort);
#else
PMEndPage(m_macPrintPort); PMEndPage(m_macPrintPort);
PMEndDocument(m_macPrintPort); PMEndDocument(m_macPrintPort);
UMAPrClose() ; #endif
UMAPrClose(&m_macPrintPort) ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }
@ -229,13 +267,21 @@ void wxPrinterDC::EndPage(void)
m_ok = FALSE ; m_ok = FALSE ;
} }
#else #else
#if PM_USE_SESSION_APIS
err = PMSessionEndPage(m_macPrintPort);
#else
err = PMEndPage(m_macPrintPort); err = PMEndPage(m_macPrintPort);
#endif
if ( err ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if PM_USE_SESSION_APIS
PMSessionEndDocument(m_macPrintPort);
#else
PMEndDocument(m_macPrintPort); PMEndDocument(m_macPrintPort);
UMAPrClose() ; #endif
UMAPrClose(&m_macPrintPort) ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }

View File

@ -3,9 +3,7 @@
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/mac/aga.h" #include "wx/mac/aga.h"
#ifdef __UNIX__ #ifndef __UNIX__
#include <Carbon/Carbon.h>
#else
#include <Navigation.h> #include <Navigation.h>
#endif #endif
@ -291,7 +289,11 @@ void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
int gPrOpenCounter = 0 ; int gPrOpenCounter = 0 ;
OSStatus UMAPrOpen() #if !TARGET_CARBON
OSStatus UMAPrOpen()
#else
OSStatus UMAPrOpen(PMPrintSession *macPrintPort)
#endif
{ {
#if !TARGET_CARBON #if !TARGET_CARBON
OSErr err = noErr ; OSErr err = noErr ;
@ -308,14 +310,22 @@ OSStatus UMAPrOpen()
++gPrOpenCounter ; ++gPrOpenCounter ;
if ( gPrOpenCounter == 1 ) if ( gPrOpenCounter == 1 )
{ {
err = PMBegin() ; #if PM_USE_SESSION_APIS
err = PMCreateSession(macPrintPort) ;
#else
err = PMBegin() ;
#endif
wxASSERT( err == noErr ) ; wxASSERT( err == noErr ) ;
} }
return err ; return err ;
#endif #endif
} }
OSStatus UMAPrClose() #if !TARGET_CARBON
OSStatus UMAPrClose()
#else
OSStatus UMAPrClose(PMPrintSession *macPrintPort)
#endif
{ {
#if !TARGET_CARBON #if !TARGET_CARBON
OSErr err = noErr ; OSErr err = noErr ;
@ -333,7 +343,11 @@ OSStatus UMAPrClose()
wxASSERT( gPrOpenCounter >= 1 ) ; wxASSERT( gPrOpenCounter >= 1 ) ;
if ( gPrOpenCounter == 1 ) if ( gPrOpenCounter == 1 )
{ {
err = PMEnd() ; #if PM_USE_SESSION_APIS
err = PMRelease(*macPrintPort) ;
#else
err = PMEnd() ;
#endif
} }
--gPrOpenCounter ; --gPrOpenCounter ;
return err ; return err ;

View File

@ -41,13 +41,21 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
m_printData = printdata ; m_printData = printdata ;
m_printData.ConvertToNative() ; m_printData.ConvertToNative() ;
#if !TARGET_CARBON
err = UMAPrOpen() ; err = UMAPrOpen() ;
#else
err = UMAPrOpen(&m_macPrintPort) ;
#endif
if ( err ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if !TARGET_CARBON
UMAPrClose() ; UMAPrClose() ;
#else
UMAPrClose(&m_macPrintPort) ;
#endif
} }
#if !TARGET_CARBON #if !TARGET_CARBON
@ -76,15 +84,22 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
m_macPort = (GrafPtr ) m_macPrintPort ; m_macPort = (GrafPtr ) m_macPrintPort ;
#else #else
m_macPrintPort = kPMNoReference ; m_macPrintPort = kPMNoReference ;
#if PM_USE_SESSION_APIS
err = PMSessionBeginDocument(
m_macPrintPort,
m_printData.m_macPrintSettings,
m_printData.m_macPageFormat);
#else
err = PMBeginDocument( err = PMBeginDocument(
m_printData.m_macPrintSettings, m_printData.m_macPrintSettings,
m_printData.m_macPageFormat, m_printData.m_macPageFormat,
&m_macPrintPort); &m_macPrintPort);
#endif
if ( err != noErr || m_macPrintPort == kPMNoReference ) if ( err != noErr || m_macPrintPort == kPMNoReference )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
UMAPrClose() ; UMAPrClose(&m_macPrintPort) ;
} }
// sets current port // sets current port
::GetPort( &m_macPort ) ; ::GetPort( &m_macPort ) ;
@ -129,14 +144,26 @@ wxPrinterDC::~wxPrinterDC(void)
#else #else
if ( m_ok ) if ( m_ok )
{ {
err = PMEndDocument(m_macPrintPort); #if PM_USE_SESSION_APIS
err = PMSessionEndDocument(m_macPrintPort);
#else
err = PMEndDocument(m_macPrintPort);
#endif
if ( !err ) if ( !err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if !TARGET_CARBON
UMAPrClose() ; UMAPrClose() ;
#else
UMAPrClose(&m_macPrintPort) ;
#endif
} }
#if !TARGET_CARBON
UMAPrClose() ; UMAPrClose() ;
#else
UMAPrClose(&m_macPrintPort) ;
#endif
} }
#endif #endif
} }
@ -194,14 +221,25 @@ void wxPrinterDC::StartPage(void)
m_ok = FALSE ; m_ok = FALSE ;
} }
#else #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 ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if PM_USE_SESSION_APIS
PMSessionEndPage(m_macPrintPort);
PMSessionEndDocument(m_macPrintPort);
#else
PMEndPage(m_macPrintPort); PMEndPage(m_macPrintPort);
PMEndDocument(m_macPrintPort); PMEndDocument(m_macPrintPort);
UMAPrClose() ; #endif
UMAPrClose(&m_macPrintPort) ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }
@ -229,13 +267,21 @@ void wxPrinterDC::EndPage(void)
m_ok = FALSE ; m_ok = FALSE ;
} }
#else #else
#if PM_USE_SESSION_APIS
err = PMSessionEndPage(m_macPrintPort);
#else
err = PMEndPage(m_macPrintPort); err = PMEndPage(m_macPrintPort);
#endif
if ( err ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
#if PM_USE_SESSION_APIS
PMSessionEndDocument(m_macPrintPort);
#else
PMEndDocument(m_macPrintPort); PMEndDocument(m_macPrintPort);
UMAPrClose() ; #endif
UMAPrClose(&m_macPrintPort) ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }

View File

@ -3,9 +3,7 @@
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/mac/aga.h" #include "wx/mac/aga.h"
#ifdef __UNIX__ #ifndef __UNIX__
#include <Carbon/Carbon.h>
#else
#include <Navigation.h> #include <Navigation.h>
#endif #endif
@ -291,7 +289,11 @@ void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
int gPrOpenCounter = 0 ; int gPrOpenCounter = 0 ;
OSStatus UMAPrOpen() #if !TARGET_CARBON
OSStatus UMAPrOpen()
#else
OSStatus UMAPrOpen(PMPrintSession *macPrintPort)
#endif
{ {
#if !TARGET_CARBON #if !TARGET_CARBON
OSErr err = noErr ; OSErr err = noErr ;
@ -308,14 +310,22 @@ OSStatus UMAPrOpen()
++gPrOpenCounter ; ++gPrOpenCounter ;
if ( gPrOpenCounter == 1 ) if ( gPrOpenCounter == 1 )
{ {
err = PMBegin() ; #if PM_USE_SESSION_APIS
err = PMCreateSession(macPrintPort) ;
#else
err = PMBegin() ;
#endif
wxASSERT( err == noErr ) ; wxASSERT( err == noErr ) ;
} }
return err ; return err ;
#endif #endif
} }
OSStatus UMAPrClose() #if !TARGET_CARBON
OSStatus UMAPrClose()
#else
OSStatus UMAPrClose(PMPrintSession *macPrintPort)
#endif
{ {
#if !TARGET_CARBON #if !TARGET_CARBON
OSErr err = noErr ; OSErr err = noErr ;
@ -333,7 +343,11 @@ OSStatus UMAPrClose()
wxASSERT( gPrOpenCounter >= 1 ) ; wxASSERT( gPrOpenCounter >= 1 ) ;
if ( gPrOpenCounter == 1 ) if ( gPrOpenCounter == 1 )
{ {
err = PMEnd() ; #if PM_USE_SESSION_APIS
err = PMRelease(*macPrintPort) ;
#else
err = PMEnd() ;
#endif
} }
--gPrOpenCounter ; --gPrOpenCounter ;
return err ; return err ;