]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/printdlg.cpp
3f36361060f38cf6f1bac980e6511d950bc1ad0d
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"
32 int wxMacPrintDialog::ShowModal()
34 m_printDialogData
.GetPrintData().ConvertToNative();
35 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
);
37 int result
= wxID_CANCEL
;
41 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData();
42 wxDialog::OSXBeginModalDialog();
43 err
= PMSessionPrintDialog(nativeData
->GetPrintSession(), nativeData
->GetPrintSettings(),
44 nativeData
->GetPageFormat(), &accepted
);
45 wxDialog::OSXEndModalDialog();
47 if ((err
== noErr
) && !accepted
)
49 // user clicked Cancel button
58 if ((err
!= noErr
) && (err
!= kPMCancel
))
62 message
.Printf( wxT("Print Error %d"), err
);
63 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
67 if (result
== wxID_OK
)
69 m_printDialogData
.GetPrintData().ConvertFromNative();
70 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
);
75 int wxMacPageSetupDialog::ShowModal()
77 m_pageSetupData
.GetPrintData().ConvertToNative();
78 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData();
79 nativeData
->TransferFrom( &m_pageSetupData
);
81 int result
= wxID_CANCEL
;
85 wxDialog::OSXBeginModalDialog();
86 err
= PMSessionPageSetupDialog( nativeData
->GetPrintSession(), nativeData
->GetPageFormat(),
88 wxDialog::OSXEndModalDialog();
90 if ((err
== noErr
) && !accepted
)
92 // user clicked Cancel button
96 // If the user did not cancel, flatten and save the PageFormat object
103 if ((err
!= noErr
) && (err
!= kPMCancel
))
107 message
.Printf( wxT("Print Error %d"), err
);
108 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
112 if (result
== wxID_OK
)
114 m_pageSetupData
.GetPrintData().ConvertFromNative();
115 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() );
116 nativeData
->TransferTo( &m_pageSetupData
);