]>
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"
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 err
= PMSessionPrintDialog(nativeData
->GetPrintSession(), nativeData
->GetPrintSettings(),
43 nativeData
->GetPageFormat(), &accepted
);
45 if ((err
== noErr
) && !accepted
)
47 // user clicked Cancel button
56 if ((err
!= noErr
) && (err
!= kPMCancel
))
60 message
.Printf( wxT("Print Error %d"), err
);
61 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
65 if (result
== wxID_OK
)
67 m_printDialogData
.GetPrintData().ConvertFromNative();
68 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
);
73 int wxMacPageSetupDialog::ShowModal()
75 m_pageSetupData
.GetPrintData().ConvertToNative();
76 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData();
77 nativeData
->TransferFrom( &m_pageSetupData
);
79 int result
= wxID_CANCEL
;
83 err
= PMSessionPageSetupDialog( nativeData
->GetPrintSession(), nativeData
->GetPageFormat(),
86 if ((err
== noErr
) && !accepted
)
88 // user clicked Cancel button
92 // If the user did not cancel, flatten and save the PageFormat object
99 if ((err
!= noErr
) && (err
!= kPMCancel
))
103 message
.Printf( wxT("Print Error %d"), err
);
104 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
108 if (result
== wxID_OK
)
110 m_pageSetupData
.GetPrintData().ConvertFromNative();
111 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() );
112 nativeData
->TransferTo( &m_pageSetupData
);