]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
13 #if wxUSE_PRINTING_ARCHITECTURE
15 #include "wx/printdlg.h"
18 #include "wx/object.h"
19 #include "wx/dcprint.h"
20 #include "wx/msgdlg.h"
21 #include "wx/textctrl.h"
23 #include "wx/stattext.h"
26 #include "wx/osx/printdlg.h"
27 #include "wx/osx/private/print.h"
28 #include "wx/osx/private.h"
29 #include "wx/statline.h"
30 #include "wx/modalhook.h"
32 int wxMacPrintDialog::ShowModal()
34 WX_HOOK_MODAL_DIALOG();
36 m_printDialogData
.GetPrintData().ConvertToNative();
37 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData
);
39 int result
= wxID_CANCEL
;
43 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData();
44 wxDialog::OSXBeginModalDialog();
45 err
= PMSessionPrintDialog(nativeData
->GetPrintSession(), nativeData
->GetPrintSettings(),
46 nativeData
->GetPageFormat(), &accepted
);
47 wxDialog::OSXEndModalDialog();
49 if ((err
== noErr
) && !accepted
)
51 // user clicked Cancel button
60 if ((err
!= noErr
) && (err
!= kPMCancel
))
64 message
.Printf( wxT("Print Error %d"), err
);
65 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
69 if (result
== wxID_OK
)
71 m_printDialogData
.GetPrintData().ConvertFromNative();
72 ((wxOSXPrintData
*)m_printDialogData
.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData
);
77 int wxMacPageSetupDialog::ShowModal()
79 WX_HOOK_MODAL_DIALOG();
81 m_pageSetupData
.GetPrintData().ConvertToNative();
82 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)m_pageSetupData
.GetPrintData().GetNativeData();
83 nativeData
->TransferFrom( &m_pageSetupData
);
85 int result
= wxID_CANCEL
;
89 wxDialog::OSXBeginModalDialog();
90 err
= PMSessionPageSetupDialog( nativeData
->GetPrintSession(), nativeData
->GetPageFormat(),
92 wxDialog::OSXEndModalDialog();
94 if ((err
== noErr
) && !accepted
)
96 // user clicked Cancel button
100 // If the user did not cancel, flatten and save the PageFormat object
101 // with our document.
107 if ((err
!= noErr
) && (err
!= kPMCancel
))
111 message
.Printf( wxT("Print Error %d"), err
);
112 wxMessageDialog
dialog( NULL
, message
, wxEmptyString
, wxICON_HAND
| wxOK
);
116 if (result
== wxID_OK
)
118 m_pageSetupData
.GetPrintData().ConvertFromNative();
119 m_pageSetupData
.SetPaperSize( m_pageSetupData
.GetPrintData().GetPaperSize() );
120 nativeData
->TransferTo( &m_pageSetupData
);