]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
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/object.h"
17 #include "wx/printdlg.h"
18 #include "wx/mac/printdlg.h"
19 #include "wx/dcprint.h"
20 #include "wx/msgdlg.h"
21 #include "wx/mac/private/print.h"
23 // Use generic page setup dialog: use your own native one if one exists.
25 IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog
, wxPrintDialogBase
)
27 wxMacPrintDialog::wxMacPrintDialog()
29 m_dialogParent
= NULL
;
34 wxMacPrintDialog::wxMacPrintDialog(wxWindow
*p
, wxPrintDialogData
* data
)
39 wxMacPrintDialog::wxMacPrintDialog(wxWindow
*p
, wxPrintData
* data
)
41 wxPrintDialogData data2
;
48 bool wxMacPrintDialog::Create(wxWindow
*p
, wxPrintDialogData
* data
)
55 m_printDialogData
= *data
;
60 wxMacPrintDialog::~wxMacPrintDialog()
62 if (m_destroyDC
&& m_printerDC
) {
68 int wxMacPrintDialog::ShowModal()
70 m_printDialogData
.GetPrintData().ConvertToNative();
71 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
) ;
73 int result
= wxID_CANCEL
;
79 err
= PMSessionPrintDialog( ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSession
,
80 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSettings
,
81 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPageFormat
,
83 if ((err
== noErr
) && !accepted
)
85 err
= kPMCancel
; // user clicked Cancel button
93 if ((err
!= noErr
) && (err
!= kPMCancel
))
95 message
.Printf( wxT("Print Error %d"), err
) ;
96 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
100 if ( result
== wxID_OK
)
102 m_printDialogData
.GetPrintData().ConvertFromNative();
103 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
) ;
109 wxDC
*wxMacPrintDialog::GetPrintDC()
111 return new wxPrinterDC( m_printDialogData
.GetPrintData() ) ;
115 * wxMacPageSetupDialog
118 IMPLEMENT_CLASS(wxMacPageSetupDialog
, wxPageSetupDialogBase
)
120 wxMacPageSetupDialog::wxMacPageSetupDialog(wxWindow
*p
, wxPageSetupDialogData
*data
) :
121 wxPageSetupDialogBase()
126 bool wxMacPageSetupDialog::Create(wxWindow
*p
, wxPageSetupDialogData
*data
)
131 m_pageSetupData
= (*data
);
136 wxMacPageSetupDialog::~wxMacPageSetupDialog()
140 wxPageSetupData
& wxMacPageSetupDialog::GetPageSetupDialogData()
142 return m_pageSetupData
;
145 int wxMacPageSetupDialog::ShowModal()
147 m_pageSetupData
.GetPrintData().ConvertToNative();
148 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData
) ;
150 int result
= wxID_CANCEL
;
156 err
= PMSessionPageSetupDialog( ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPrintSession
,
157 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPageFormat
,
159 if ((err
== noErr
) && !accepted
)
161 err
= kPMCancel
; // user clicked Cancel button
164 // If the user did not cancel, flatten and save the PageFormat object
165 // with our document.
170 if ((err
!= noErr
) && (err
!= kPMCancel
))
172 message
.Printf( wxT("Print Error %d"), err
) ;
173 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
177 if (result
== wxID_OK
)
179 m_pageSetupData
.GetPrintData().ConvertFromNative();
180 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() ) ;
181 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData
) ;