#include "wx/dcprint.h"
#include "wx/msgdlg.h"
#include "wx/mac/uma.h"
+#ifndef __DARWIN__
+ #include "Printing.h"
+#endif
+
+#if defined(TARGET_CARBON) && !defined(__DARWIN__)
+# if PM_USE_SESSION_APIS
+# include <PMCore.h>
+# endif
+# include <PMApplication.h>
+#endif
// Use generic page setup dialog: use your own native one if one exists.
wxPrintDialog::~wxPrintDialog()
{
- if (m_destroyDC && m_printerDC)
+ if (m_destroyDC && m_printerDC) {
delete m_printerDC;
+ m_printerDC = NULL;
+ }
}
int wxPrintDialog::ShowModal()
wxString message ;
#if !TARGET_CARBON
- err = ::UMAPrOpen() ;
+ err = ::UMAPrOpen(NULL) ;
if ( err == noErr )
{
m_printDialogData.ConvertToNative() ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
dialog.ShowModal();
}
- ::UMAPrClose() ;
+ ::UMAPrClose(NULL) ;
#else
#if PM_USE_SESSION_APIS
- PMPrintSession macPrintSession = kPMNoReference;
Boolean accepted;
- err = ::UMAPrOpen(&macPrintSession) ;
- if ( err == noErr )
{
m_printDialogData.ConvertToNative() ;
if ((err == noErr) &&
(m_printDialogData.GetPrintData().m_macPageFormat != kPMNoPageFormat))
{
- err = PMSessionDefaultPageFormat((PMPrintSession)macPrintSession,
+ err = PMSessionDefaultPageFormat((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession,
(PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat);
}
}
else
{
- err = PMSessionValidatePageFormat((PMPrintSession)macPrintSession,
+ err = PMSessionValidatePageFormat((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession,
(PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat,
kPMDontWantBoolean);
}
if ((err == noErr) &&
(m_printDialogData.GetPrintData().m_macPrintSettings != kPMNoPrintSettings))
{
- err = PMSessionDefaultPrintSettings((PMPrintSession)macPrintSession,
+ err = PMSessionDefaultPrintSettings((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession,
(PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings);
}
}
else
{
- err = PMSessionValidatePrintSettings((PMPrintSession)macPrintSession,
+ err = PMSessionValidatePrintSettings((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession,
(PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings,
kPMDontWantBoolean);
}
// Display the Print dialog.
if (err == noErr)
{
- err = PMSessionPrintDialog((PMPrintSession)macPrintSession,
+ err = PMSessionPrintDialog((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession,
(PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings,
(PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat,
&accepted);
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
dialog.ShowModal();
}
- ::UMAPrClose(&macPrintSession) ;
#else
#pragma warning "TODO: Printing for carbon without session apis"
#endif
wxString message ;
#if !TARGET_CARBON
- err = ::UMAPrOpen() ;
+ err = ::UMAPrOpen(NULL) ;
if ( err == noErr )
{
m_pageSetupData.ConvertToNative() ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
dialog.ShowModal();
}
- ::UMAPrClose() ;
+ ::UMAPrClose(NULL) ;
#else
#if PM_USE_SESSION_APIS
- PMPrintSession macPrintSession = kPMNoReference;
Boolean accepted;
- err = ::UMAPrOpen(&macPrintSession) ;
- if ( err == noErr )
{
m_pageSetupData.ConvertToNative() ;
if ((err == noErr) &&
(m_pageSetupData.GetPrintData().m_macPageFormat != kPMNoPageFormat))
{
- err = PMSessionDefaultPageFormat((PMPrintSession)macPrintSession,
+ err = PMSessionDefaultPageFormat((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession,
(PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat);
}
}
else
{
- err = PMSessionValidatePageFormat((PMPrintSession)macPrintSession,
+ err = PMSessionValidatePageFormat((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession,
(PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat,
kPMDontWantBoolean);
}
// Display the Page Setup dialog.
if (err == noErr)
{
- err = PMSessionPageSetupDialog((PMPrintSession)macPrintSession,
+ err = PMSessionPageSetupDialog((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession,
(PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat,
&accepted);
if ((err == noErr) && !accepted)
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
dialog.ShowModal();
}
- ::UMAPrClose(&macPrintSession) ;
#else
#pragma warning "TODO: Printing for carbon without session apis"
#endif