- m_pageSetupData.ConvertToNative();
-
- int result = m_pageSetupData.GetPrintData().m_nativePrintData->ShowPageSetupDialog();
-
- if (result == wxID_OK )
- m_pageSetupData.ConvertFromNative();
-
+ m_pageSetupData.GetPrintData().ConvertToNative();
+ ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData );
+
+ int result = wxID_CANCEL;
+ OSErr err = noErr;
+ Boolean accepted;
+
+ err = PMSessionPageSetupDialog(
+ ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->m_macPrintSession,
+ ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->m_macPageFormat,
+ &accepted );
+
+ if ((err == noErr) && !accepted)
+ {
+ // user clicked Cancel button
+ err = kPMCancel;
+ }
+
+ // If the user did not cancel, flatten and save the PageFormat object
+ // with our document.
+ if (err == noErr)
+ {
+ result = wxID_OK;
+ }
+
+ if ((err != noErr) && (err != kPMCancel))
+ {
+ wxString message;
+
+ message.Printf( wxT("Print Error %d"), err );
+ wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
+ dialog.ShowModal();
+ }
+
+ if (result == wxID_OK)
+ {
+ m_pageSetupData.GetPrintData().ConvertFromNative();
+ m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
+ ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData );
+ }
+