]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/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"
24 #include "wx/mac/printdlg.h"
25 #include "wx/mac/private/print.h"
28 // Use generic page setup dialog: use your own native one if one exists.
30 IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog
, wxPrintDialogBase
)
33 wxMacPrintDialog::wxMacPrintDialog()
35 m_dialogParent
= NULL
;
40 wxMacPrintDialog::wxMacPrintDialog( wxWindow
*p
, wxPrintDialogData
*data
)
45 wxMacPrintDialog::wxMacPrintDialog( wxWindow
*p
, wxPrintData
*data
)
47 wxPrintDialogData data2
;
54 bool wxMacPrintDialog::Create( wxWindow
*p
, wxPrintDialogData
*data
)
61 m_printDialogData
= *data
;
66 wxMacPrintDialog::~wxMacPrintDialog()
68 if (m_destroyDC
&& m_printerDC
)
75 int wxMacPrintDialog::ShowModal()
77 m_printDialogData
.GetPrintData().ConvertToNative();
78 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
);
80 int result
= wxID_CANCEL
;
84 err
= PMSessionPrintDialog(
85 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSession
,
86 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSettings
,
87 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPageFormat
,
90 if ((err
== noErr
) && !accepted
)
92 // user clicked Cancel button
101 if ((err
!= noErr
) && (err
!= kPMCancel
))
105 message
.Printf( wxT("Print Error %d"), err
);
106 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
110 if (result
== wxID_OK
)
112 m_printDialogData
.GetPrintData().ConvertFromNative();
113 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
);
119 wxDC
* wxMacPrintDialog::GetPrintDC()
121 return new wxPrinterDC( m_printDialogData
.GetPrintData() );
124 IMPLEMENT_CLASS(wxMacPageSetupDialog
, wxPageSetupDialogBase
)
126 wxMacPageSetupDialog::wxMacPageSetupDialog( wxWindow
*p
, wxPageSetupDialogData
*data
)
127 : wxPageSetupDialogBase()
132 bool wxMacPageSetupDialog::Create( wxWindow
*p
, wxPageSetupDialogData
*data
)
137 m_pageSetupData
= (*data
);
142 wxMacPageSetupDialog::~wxMacPageSetupDialog()
146 wxPageSetupData
& wxMacPageSetupDialog::GetPageSetupDialogData()
148 return m_pageSetupData
;
151 int wxMacPageSetupDialog::ShowModal()
153 m_pageSetupData
.GetPrintData().ConvertToNative();
154 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData
);
156 int result
= wxID_CANCEL
;
160 err
= PMSessionPageSetupDialog(
161 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPrintSession
,
162 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPageFormat
,
165 if ((err
== noErr
) && !accepted
)
167 // user clicked Cancel button
171 // If the user did not cancel, flatten and save the PageFormat object
172 // with our document.
178 if ((err
!= noErr
) && (err
!= kPMCancel
))
182 message
.Printf( wxT("Print Error %d"), err
);
183 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
187 if (result
== wxID_OK
)
189 m_pageSetupData
.GetPrintData().ConvertFromNative();
190 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() );
191 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData
);