]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #if wxUSE_PRINTING_ARCHITECTURE
16 #include "wx/printdlg.h"
19 #include "wx/object.h"
20 #include "wx/dcprint.h"
21 #include "wx/msgdlg.h"
22 #include "wx/textctrl.h"
24 #include "wx/stattext.h"
27 #include "wx/osx/printdlg.h"
28 #include "wx/osx/private/print.h"
29 #include "wx/osx/private.h"
30 #include "wx/statline.h"
31 #include "wx/testing.h"
33 int wxMacPrintDialog::ShowModal()
35 WX_TESTING_SHOW_MODAL_HOOK();
37 m_printDialogData
.GetPrintData().ConvertToNative();
38 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
);
40 int result
= wxID_CANCEL
;
44 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData();
45 wxDialog::OSXBeginModalDialog();
46 err
= PMSessionPrintDialog(nativeData
->GetPrintSession(), nativeData
->GetPrintSettings(),
47 nativeData
->GetPageFormat(), &accepted
);
48 wxDialog::OSXEndModalDialog();
50 if ((err
== noErr
) && !accepted
)
52 // user clicked Cancel button
61 if ((err
!= noErr
) && (err
!= kPMCancel
))
65 message
.Printf( wxT("Print Error %d"), err
);
66 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
70 if (result
== wxID_OK
)
72 m_printDialogData
.GetPrintData().ConvertFromNative();
73 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
);
78 int wxMacPageSetupDialog::ShowModal()
80 WX_TESTING_SHOW_MODAL_HOOK();
82 m_pageSetupData
.GetPrintData().ConvertToNative();
83 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData();
84 nativeData
->TransferFrom( &m_pageSetupData
);
86 int result
= wxID_CANCEL
;
90 wxDialog::OSXBeginModalDialog();
91 err
= PMSessionPageSetupDialog( nativeData
->GetPrintSession(), nativeData
->GetPageFormat(),
93 wxDialog::OSXEndModalDialog();
95 if ((err
== noErr
) && !accepted
)
97 // user clicked Cancel button
101 // If the user did not cancel, flatten and save the PageFormat object
102 // with our document.
108 if ((err
!= noErr
) && (err
!= kPMCancel
))
112 message
.Printf( wxT("Print Error %d"), err
);
113 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
117 if (result
== wxID_OK
)
119 m_pageSetupData
.GetPrintData().ConvertFromNative();
120 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() );
121 nativeData
->TransferTo( &m_pageSetupData
);