]>
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
17 #include "wx/object.h"
20 #include "wx/printdlg.h"
21 #include "wx/mac/printdlg.h"
22 #include "wx/dcprint.h"
23 #include "wx/msgdlg.h"
24 #include "wx/mac/private/print.h"
27 // Use generic page setup dialog: use your own native one if one exists.
29 IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog
, wxPrintDialogBase
)
32 wxMacPrintDialog::wxMacPrintDialog()
34 m_dialogParent
= NULL
;
39 wxMacPrintDialog::wxMacPrintDialog( wxWindow
*p
, wxPrintDialogData
*data
)
44 wxMacPrintDialog::wxMacPrintDialog( wxWindow
*p
, wxPrintData
*data
)
46 wxPrintDialogData data2
;
53 bool wxMacPrintDialog::Create( wxWindow
*p
, wxPrintDialogData
*data
)
60 m_printDialogData
= *data
;
65 wxMacPrintDialog::~wxMacPrintDialog()
67 if (m_destroyDC
&& m_printerDC
)
74 int wxMacPrintDialog::ShowModal()
76 m_printDialogData
.GetPrintData().ConvertToNative();
77 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
);
79 int result
= wxID_CANCEL
;
83 err
= PMSessionPrintDialog(
84 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSession
,
85 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSettings
,
86 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPageFormat
,
89 if ((err
== noErr
) && !accepted
)
91 // user clicked Cancel button
100 if ((err
!= noErr
) && (err
!= kPMCancel
))
104 message
.Printf( wxT("Print Error %d"), err
);
105 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
109 if (result
== wxID_OK
)
111 m_printDialogData
.GetPrintData().ConvertFromNative();
112 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
);
118 wxDC
* wxMacPrintDialog::GetPrintDC()
120 return new wxPrinterDC( m_printDialogData
.GetPrintData() );
123 IMPLEMENT_CLASS(wxMacPageSetupDialog
, wxPageSetupDialogBase
)
125 wxMacPageSetupDialog::wxMacPageSetupDialog( wxWindow
*p
, wxPageSetupDialogData
*data
)
126 : wxPageSetupDialogBase()
131 bool wxMacPageSetupDialog::Create( wxWindow
*p
, wxPageSetupDialogData
*data
)
136 m_pageSetupData
= (*data
);
141 wxMacPageSetupDialog::~wxMacPageSetupDialog()
145 wxPageSetupData
& wxMacPageSetupDialog::GetPageSetupDialogData()
147 return m_pageSetupData
;
150 int wxMacPageSetupDialog::ShowModal()
152 m_pageSetupData
.GetPrintData().ConvertToNative();
153 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData
);
155 int result
= wxID_CANCEL
;
159 err
= PMSessionPageSetupDialog(
160 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPrintSession
,
161 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPageFormat
,
164 if ((err
== noErr
) && !accepted
)
166 // user clicked Cancel button
170 // If the user did not cancel, flatten and save the PageFormat object
171 // with our document.
177 if ((err
!= noErr
) && (err
!= kPMCancel
))
181 message
.Printf( wxT("Print Error %d"), err
);
182 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
186 if (result
== wxID_OK
)
188 m_pageSetupData
.GetPrintData().ConvertFromNative();
189 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() );
190 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData
);