]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "printdlg.h"
16 #include "wx/wxprec.h"
18 #if wxUSE_PRINTING_ARCHITECTURE
20 #include "wx/object.h"
21 #include "wx/printdlg.h"
22 #include "wx/mac/printdlg.h"
23 #include "wx/dcprint.h"
24 #include "wx/msgdlg.h"
25 #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
)
31 wxMacPrintDialog::wxMacPrintDialog()
33 m_dialogParent
= NULL
;
38 wxMacPrintDialog::wxMacPrintDialog(wxWindow
*p
, wxPrintDialogData
* data
)
43 wxMacPrintDialog::wxMacPrintDialog(wxWindow
*p
, wxPrintData
* data
)
45 wxPrintDialogData data2
;
52 bool wxMacPrintDialog::Create(wxWindow
*p
, wxPrintDialogData
* data
)
59 m_printDialogData
= *data
;
64 wxMacPrintDialog::~wxMacPrintDialog()
66 if (m_destroyDC
&& m_printerDC
) {
72 int wxMacPrintDialog::ShowModal()
74 m_printDialogData
.GetPrintData().ConvertToNative();
75 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
) ;
77 int result
= wxID_CANCEL
;
83 err
= PMSessionPrintDialog( ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSession
,
84 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPrintSettings
,
85 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->m_macPageFormat
,
87 if ((err
== noErr
) && !accepted
)
89 err
= kPMCancel
; // user clicked Cancel button
97 if ((err
!= noErr
) && (err
!= kPMCancel
))
99 message
.Printf( wxT("Print Error %d"), err
) ;
100 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
104 if ( result
== wxID_OK
)
106 m_printDialogData
.GetPrintData().ConvertFromNative();
107 ((wxMacCarbonPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
) ;
113 wxDC
*wxMacPrintDialog::GetPrintDC()
115 return new wxPrinterDC( m_printDialogData
.GetPrintData() ) ;
119 * wxMacPageSetupDialog
122 IMPLEMENT_CLASS(wxMacPageSetupDialog
, wxPageSetupDialogBase
)
124 wxMacPageSetupDialog::wxMacPageSetupDialog(wxWindow
*p
, wxPageSetupDialogData
*data
) :
125 wxPageSetupDialogBase()
130 bool wxMacPageSetupDialog::Create(wxWindow
*p
, wxPageSetupDialogData
*data
)
135 m_pageSetupData
= (*data
);
140 wxMacPageSetupDialog::~wxMacPageSetupDialog()
144 wxPageSetupData
& wxMacPageSetupDialog::GetPageSetupDialogData()
146 return m_pageSetupData
;
149 int wxMacPageSetupDialog::ShowModal()
151 m_pageSetupData
.GetPrintData().ConvertToNative();
152 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData
) ;
154 int result
= wxID_CANCEL
;
160 err
= PMSessionPageSetupDialog( ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPrintSession
,
161 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->m_macPageFormat
,
163 if ((err
== noErr
) && !accepted
)
165 err
= kPMCancel
; // user clicked Cancel button
168 // If the user did not cancel, flatten and save the PageFormat object
169 // with our document.
174 if ((err
!= noErr
) && (err
!= kPMCancel
))
176 message
.Printf( wxT("Print Error %d"), err
) ;
177 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
181 if (result
== wxID_OK
)
183 m_pageSetupData
.GetPrintData().ConvertFromNative();
184 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() ) ;
185 ((wxMacCarbonPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData
) ;