From a3d3d3bf6cd84e44521a1617df5e38ed02c6fee2 Mon Sep 17 00:00:00 2001 From: Gilles Depeyrot Date: Thu, 10 Jan 2002 21:31:35 +0000 Subject: [PATCH] unified UMAPrOpen/UMAPrClose prototypes for session and non-session printing git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13492 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/uma.h | 9 ++------ src/mac/carbon/dcprint.cpp | 45 +++++++++++++++++++++---------------- src/mac/carbon/printdlg.cpp | 15 +++++++++---- src/mac/carbon/uma.cpp | 26 ++++++++++----------- src/mac/dcprint.cpp | 45 +++++++++++++++++++++---------------- src/mac/printdlg.cpp | 15 +++++++++---- src/mac/uma.cpp | 26 ++++++++++----------- 7 files changed, 100 insertions(+), 81 deletions(-) diff --git a/include/wx/mac/uma.h b/include/wx/mac/uma.h index b242acb961..e688d09aff 100644 --- a/include/wx/mac/uma.h +++ b/include/wx/mac/uma.h @@ -54,13 +54,8 @@ void UMAInsertMenuItem( MenuRef menu , StringPtr label , MenuItemIndex item , void UMAShowWatchCursor() ; void UMAShowArrowCursor() ; -#if TARGET_CARBON && PM_USE_SESSION_APIS -OSStatus UMAPrOpen(PMPrintSession *macPrintSession) ; -OSStatus UMAPrClose(PMPrintSession *macPrintSession) ; -#else -OSStatus UMAPrOpen() ; -OSStatus UMAPrClose() ; -#endif +OSStatus UMAPrOpen(void *macPrintSession) ; +OSStatus UMAPrClose(void *macPrintSession) ; // window manager diff --git a/src/mac/carbon/dcprint.cpp b/src/mac/carbon/dcprint.cpp index f772e44dcd..d50e8b3933 100644 --- a/src/mac/carbon/dcprint.cpp +++ b/src/mac/carbon/dcprint.cpp @@ -28,6 +28,13 @@ #include #include "wx/mac/uma.h" +#if defined(TARGET_CARBON) && !defined(__DARWIN__) +# if PM_USE_SESSION_APIS +# include +# endif +# include +#endif + #if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxPrinterDC, wxDC) #endif @@ -43,10 +50,10 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) m_printData.ConvertToNative() ; #if TARGET_CARBON && PM_USE_SESSION_APIS - err = UMAPrOpen((PMPrintSession *)&m_macPrintSessionPort) ; + err = UMAPrOpen(&m_macPrintSessionPort) ; if ( err != noErr || m_macPrintSessionPort == kPMNoData ) #else - err = UMAPrOpen() ; + err = UMAPrOpen(NULL) ; if ( err != noErr ) #endif { @@ -54,9 +61,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif m_ok = FALSE; return; @@ -74,7 +81,7 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) message.Printf( "Print Error %d", err ) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); - UMAPrClose() ; + UMAPrClose(NULL) ; m_ok = FALSE; return; } @@ -86,7 +93,7 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) message.Printf( "Print Error %d", err ) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); - UMAPrClose() ; + UMAPrClose(NULL) ; m_ok = FALSE; return; } @@ -111,9 +118,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif m_ok = FALSE; return; @@ -133,9 +140,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif m_ok = FALSE; return; @@ -172,7 +179,7 @@ wxPrinterDC::~wxPrinterDC(void) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; // ::SetPort( macPrintFormerPort ) ; ::SetPort( LMGetWMgrPort() ) ; } @@ -191,9 +198,9 @@ wxPrinterDC::~wxPrinterDC(void) dialog.ShowModal(); } #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif } #endif @@ -247,7 +254,7 @@ void wxPrinterDC::StartPage(void) dialog.ShowModal(); ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; } @@ -267,11 +274,11 @@ void wxPrinterDC::StartPage(void) #if PM_USE_SESSION_APIS PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else PMEndPage(m_macPrintSessionPort); PMEndDocument(m_macPrintSessionPort); - UMAPrClose() ; + UMAPrClose(NULL) ; #endif ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; @@ -296,7 +303,7 @@ void wxPrinterDC::EndPage(void) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; } @@ -313,10 +320,10 @@ void wxPrinterDC::EndPage(void) dialog.ShowModal(); #if PM_USE_SESSION_APIS PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else PMEndDocument(m_macPrintSessionPort); - UMAPrClose() ; + UMAPrClose(NULL) ; #endif ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; diff --git a/src/mac/carbon/printdlg.cpp b/src/mac/carbon/printdlg.cpp index 51a22db84f..8f59b0d2e3 100644 --- a/src/mac/carbon/printdlg.cpp +++ b/src/mac/carbon/printdlg.cpp @@ -19,6 +19,13 @@ #include "wx/msgdlg.h" #include "wx/mac/uma.h" +#if defined(TARGET_CARBON) && !defined(__DARWIN__) +# if PM_USE_SESSION_APIS +# include +# endif +# include +#endif + // Use generic page setup dialog: use your own native one if one exists. #if !USE_SHARED_LIBRARY @@ -72,7 +79,7 @@ int wxPrintDialog::ShowModal() wxString message ; #if !TARGET_CARBON - err = ::UMAPrOpen() ; + err = ::UMAPrOpen(NULL) ; if ( err == noErr ) { m_printDialogData.ConvertToNative() ; @@ -89,7 +96,7 @@ int wxPrintDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; #else #if PM_USE_SESSION_APIS PMPrintSession macPrintSession = kPMNoReference; @@ -224,7 +231,7 @@ int wxPageSetupDialog::ShowModal() wxString message ; #if !TARGET_CARBON - err = ::UMAPrOpen() ; + err = ::UMAPrOpen(NULL) ; if ( err == noErr ) { m_pageSetupData.ConvertToNative() ; @@ -241,7 +248,7 @@ int wxPageSetupDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; #else #if PM_USE_SESSION_APIS PMPrintSession macPrintSession = kPMNoReference; diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 2e50863903..c899f87471 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -4,7 +4,13 @@ #include #ifndef __DARWIN__ - #include +# include +# if defined(TARGET_CARBON) +# if PM_USE_SESSION_APIS +# include +# endif +# include +# endif #endif // since we have decided that we only support 8.6 upwards we are @@ -255,11 +261,7 @@ void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 int gPrOpenCounter = 0 ; -#if TARGET_CARBON && PM_USE_SESSION_APIS -OSStatus UMAPrOpen(PMPrintSession *macPrintSession) -#else -OSStatus UMAPrOpen() -#endif +OSStatus UMAPrOpen(void *macPrintSession) { #if !TARGET_CARBON OSErr err = noErr ; @@ -277,7 +279,7 @@ OSStatus UMAPrOpen() if ( gPrOpenCounter == 1 ) { #if PM_USE_SESSION_APIS - err = PMCreateSession(macPrintSession) ; + err = PMCreateSession((PMPrintSession *)macPrintSession) ; #else err = PMBegin() ; #endif @@ -287,11 +289,7 @@ OSStatus UMAPrOpen() #endif } -#if TARGET_CARBON && PM_USE_SESSION_APIS -OSStatus UMAPrClose(PMPrintSession *macPrintSession) -#else -OSStatus UMAPrClose() -#endif +OSStatus UMAPrClose(void *macPrintSession) { #if !TARGET_CARBON OSErr err = noErr ; @@ -310,8 +308,8 @@ OSStatus UMAPrClose() if ( gPrOpenCounter == 1 ) { #if PM_USE_SESSION_APIS - err = PMRelease(*macPrintSession) ; - *macPrintSession = kPMNoReference; + err = PMRelease(*(PMPrintSession *)macPrintSession) ; + *(PMPrintSession *)macPrintSession = kPMNoReference; #else err = PMEnd() ; #endif diff --git a/src/mac/dcprint.cpp b/src/mac/dcprint.cpp index f772e44dcd..d50e8b3933 100644 --- a/src/mac/dcprint.cpp +++ b/src/mac/dcprint.cpp @@ -28,6 +28,13 @@ #include #include "wx/mac/uma.h" +#if defined(TARGET_CARBON) && !defined(__DARWIN__) +# if PM_USE_SESSION_APIS +# include +# endif +# include +#endif + #if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxPrinterDC, wxDC) #endif @@ -43,10 +50,10 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) m_printData.ConvertToNative() ; #if TARGET_CARBON && PM_USE_SESSION_APIS - err = UMAPrOpen((PMPrintSession *)&m_macPrintSessionPort) ; + err = UMAPrOpen(&m_macPrintSessionPort) ; if ( err != noErr || m_macPrintSessionPort == kPMNoData ) #else - err = UMAPrOpen() ; + err = UMAPrOpen(NULL) ; if ( err != noErr ) #endif { @@ -54,9 +61,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif m_ok = FALSE; return; @@ -74,7 +81,7 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) message.Printf( "Print Error %d", err ) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); - UMAPrClose() ; + UMAPrClose(NULL) ; m_ok = FALSE; return; } @@ -86,7 +93,7 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) message.Printf( "Print Error %d", err ) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); - UMAPrClose() ; + UMAPrClose(NULL) ; m_ok = FALSE; return; } @@ -111,9 +118,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif m_ok = FALSE; return; @@ -133,9 +140,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif m_ok = FALSE; return; @@ -172,7 +179,7 @@ wxPrinterDC::~wxPrinterDC(void) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; // ::SetPort( macPrintFormerPort ) ; ::SetPort( LMGetWMgrPort() ) ; } @@ -191,9 +198,9 @@ wxPrinterDC::~wxPrinterDC(void) dialog.ShowModal(); } #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose() ; + UMAPrClose(NULL) ; #endif } #endif @@ -247,7 +254,7 @@ void wxPrinterDC::StartPage(void) dialog.ShowModal(); ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; } @@ -267,11 +274,11 @@ void wxPrinterDC::StartPage(void) #if PM_USE_SESSION_APIS PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else PMEndPage(m_macPrintSessionPort); PMEndDocument(m_macPrintSessionPort); - UMAPrClose() ; + UMAPrClose(NULL) ; #endif ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; @@ -296,7 +303,7 @@ void wxPrinterDC::EndPage(void) wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; } @@ -313,10 +320,10 @@ void wxPrinterDC::EndPage(void) dialog.ShowModal(); #if PM_USE_SESSION_APIS PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose((PMPrintSession *)&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else PMEndDocument(m_macPrintSessionPort); - UMAPrClose() ; + UMAPrClose(NULL) ; #endif ::SetPort( macPrintFormerPort ) ; m_ok = FALSE ; diff --git a/src/mac/printdlg.cpp b/src/mac/printdlg.cpp index 51a22db84f..8f59b0d2e3 100644 --- a/src/mac/printdlg.cpp +++ b/src/mac/printdlg.cpp @@ -19,6 +19,13 @@ #include "wx/msgdlg.h" #include "wx/mac/uma.h" +#if defined(TARGET_CARBON) && !defined(__DARWIN__) +# if PM_USE_SESSION_APIS +# include +# endif +# include +#endif + // Use generic page setup dialog: use your own native one if one exists. #if !USE_SHARED_LIBRARY @@ -72,7 +79,7 @@ int wxPrintDialog::ShowModal() wxString message ; #if !TARGET_CARBON - err = ::UMAPrOpen() ; + err = ::UMAPrOpen(NULL) ; if ( err == noErr ) { m_printDialogData.ConvertToNative() ; @@ -89,7 +96,7 @@ int wxPrintDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; #else #if PM_USE_SESSION_APIS PMPrintSession macPrintSession = kPMNoReference; @@ -224,7 +231,7 @@ int wxPageSetupDialog::ShowModal() wxString message ; #if !TARGET_CARBON - err = ::UMAPrOpen() ; + err = ::UMAPrOpen(NULL) ; if ( err == noErr ) { m_pageSetupData.ConvertToNative() ; @@ -241,7 +248,7 @@ int wxPageSetupDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - ::UMAPrClose() ; + ::UMAPrClose(NULL) ; #else #if PM_USE_SESSION_APIS PMPrintSession macPrintSession = kPMNoReference; diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 2e50863903..c899f87471 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -4,7 +4,13 @@ #include #ifndef __DARWIN__ - #include +# include +# if defined(TARGET_CARBON) +# if PM_USE_SESSION_APIS +# include +# endif +# include +# endif #endif // since we have decided that we only support 8.6 upwards we are @@ -255,11 +261,7 @@ void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 int gPrOpenCounter = 0 ; -#if TARGET_CARBON && PM_USE_SESSION_APIS -OSStatus UMAPrOpen(PMPrintSession *macPrintSession) -#else -OSStatus UMAPrOpen() -#endif +OSStatus UMAPrOpen(void *macPrintSession) { #if !TARGET_CARBON OSErr err = noErr ; @@ -277,7 +279,7 @@ OSStatus UMAPrOpen() if ( gPrOpenCounter == 1 ) { #if PM_USE_SESSION_APIS - err = PMCreateSession(macPrintSession) ; + err = PMCreateSession((PMPrintSession *)macPrintSession) ; #else err = PMBegin() ; #endif @@ -287,11 +289,7 @@ OSStatus UMAPrOpen() #endif } -#if TARGET_CARBON && PM_USE_SESSION_APIS -OSStatus UMAPrClose(PMPrintSession *macPrintSession) -#else -OSStatus UMAPrClose() -#endif +OSStatus UMAPrClose(void *macPrintSession) { #if !TARGET_CARBON OSErr err = noErr ; @@ -310,8 +308,8 @@ OSStatus UMAPrClose() if ( gPrOpenCounter == 1 ) { #if PM_USE_SESSION_APIS - err = PMRelease(*macPrintSession) ; - *macPrintSession = kPMNoReference; + err = PMRelease(*(PMPrintSession *)macPrintSession) ; + *(PMPrintSession *)macPrintSession = kPMNoReference; #else err = PMEnd() ; #endif -- 2.49.0