]>
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 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "printdlg.h"
16 #include "wx/object.h"
17 #include "wx/printdlg.h"
18 #include "wx/dcprint.h"
19 #include "wx/msgdlg.h"
20 #include "wx/mac/uma.h"
25 #if defined(TARGET_CARBON) && !defined(__DARWIN__)
26 # if PM_USE_SESSION_APIS
29 # include <PMApplication.h>
32 // Use generic page setup dialog: use your own native one if one exists.
34 #if !USE_SHARED_LIBRARY
35 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog
, wxDialog
)
36 IMPLEMENT_CLASS(wxPageSetupDialog
, wxDialog
)
39 wxPrintDialog::wxPrintDialog()
41 m_dialogParent
= NULL
;
46 wxPrintDialog::wxPrintDialog(wxWindow
*p
, wxPrintDialogData
* data
)
51 wxPrintDialog::wxPrintDialog(wxWindow
*p
, wxPrintData
* data
)
53 wxPrintDialogData data2
;
60 bool wxPrintDialog::Create(wxWindow
*p
, wxPrintDialogData
* data
)
67 m_printDialogData
= *data
;
72 wxPrintDialog::~wxPrintDialog()
74 if (m_destroyDC
&& m_printerDC
) {
80 int wxPrintDialog::ShowModal()
82 int result
= wxID_CANCEL
;
87 err
= ::UMAPrOpen(NULL
) ;
90 m_printDialogData
.ConvertToNative() ;
91 if ( ::PrJobDialog( (THPrint
) m_printDialogData
.GetPrintData().m_macPrintSettings
) )
93 m_printDialogData
.ConvertFromNative() ;
100 message
.Printf( wxT("Print Error %d"), err
) ;
101 wxMessageDialog
dialog( NULL
, message
, wxT(""), wxICON_HAND
| wxOK
) ;
106 #if PM_USE_SESSION_APIS
110 m_printDialogData
.ConvertToNative() ;
111 // Display the Print dialog.
114 err
= PMSessionPrintDialog((PMPrintSession
)m_printDialogData
.GetPrintData().m_macPrintSession
,
115 (PMPrintSettings
)m_printDialogData
.GetPrintData().m_macPrintSettings
,
116 (PMPageFormat
)m_printDialogData
.GetPrintData().m_macPageFormat
,
118 if ((err
== noErr
) && !accepted
)
120 err
= kPMCancel
; // user clicked Cancel button
125 m_printDialogData
.ConvertFromNative() ;
129 if ((err
!= noErr
) && (err
!= kPMCancel
))
131 message
.Printf( wxT("Print Error %d"), err
) ;
132 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
136 #pragma warning "TODO: Printing for carbon without session apis"
142 wxDC
*wxPrintDialog::GetPrintDC()
144 return new wxPrinterDC( m_printDialogData
.GetPrintData() ) ;
151 wxPageSetupDialog::wxPageSetupDialog():
154 m_dialogParent
= NULL
;
157 wxPageSetupDialog::wxPageSetupDialog(wxWindow
*p
, wxPageSetupData
*data
):
163 bool wxPageSetupDialog::Create(wxWindow
*p
, wxPageSetupData
*data
)
168 m_pageSetupData
= (*data
);
173 wxPageSetupDialog::~wxPageSetupDialog()
177 int wxPageSetupDialog::ShowModal()
179 int result
= wxID_CANCEL
;
184 err
= ::UMAPrOpen(NULL
) ;
187 m_pageSetupData
.ConvertToNative() ;
188 if ( ::PrStlDialog( (THPrint
) m_pageSetupData
.GetPrintData().m_macPrintSettings
) )
190 m_pageSetupData
.ConvertFromNative() ;
197 message
.Printf( wxT("Print Error %d"), err
) ;
198 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
203 #if PM_USE_SESSION_APIS
206 m_pageSetupData
.ConvertToNative() ;
208 // Display the Page Setup dialog.
211 err
= PMSessionPageSetupDialog((PMPrintSession
)m_pageSetupData
.GetPrintData().m_macPrintSession
,
212 (PMPageFormat
)m_pageSetupData
.GetPrintData().m_macPageFormat
,
214 if ((err
== noErr
) && !accepted
)
216 err
= kPMCancel
; // user clicked Cancel button
220 // If the user did not cancel, flatten and save the PageFormat object
221 // with our document.
223 // err = FlattenAndSavePageFormat(m_pageSetupData.GetPrintData().m_macPageFormat);
224 m_pageSetupData
.ConvertFromNative() ;
228 if ((err
!= noErr
) && (err
!= kPMCancel
))
230 message
.Printf( wxT("Print Error %d"), err
) ;
231 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
) ;
235 #pragma warning "TODO: Printing for carbon without session apis"