]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/printdlg.cpp
clang compat.
[wxWidgets.git] / src / osx / carbon / printdlg.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/printdlg.cpp
489468fe
SC
3// Purpose: wxPrintDialog, wxPageSetupDialog
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_PRINTING_ARCHITECTURE
15
16#include "wx/printdlg.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/object.h"
20 #include "wx/dcprint.h"
21 #include "wx/msgdlg.h"
22 #include "wx/textctrl.h"
23 #include "wx/sizer.h"
24 #include "wx/stattext.h"
25#endif
26
1f0c8f31
SC
27#include "wx/osx/printdlg.h"
28#include "wx/osx/private/print.h"
29#include "wx/osx/private.h"
489468fe
SC
30#include "wx/statline.h"
31
489468fe
SC
32int wxMacPrintDialog::ShowModal()
33{
34 m_printDialogData.GetPrintData().ConvertToNative();
c347101b 35 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData );
489468fe
SC
36
37 int result = wxID_CANCEL;
03647350 38
489468fe
SC
39 OSErr err = noErr;
40 Boolean accepted;
c347101b 41 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData();
445e564f 42 wxDialog::OSXBeginModalDialog();
c347101b
SC
43 err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(),
44 nativeData->GetPageFormat(), &accepted );
445e564f 45 wxDialog::OSXEndModalDialog();
489468fe
SC
46
47 if ((err == noErr) && !accepted)
48 {
49 // user clicked Cancel button
50 err = kPMCancel;
51 }
52
53 if (err == noErr)
54 {
55 result = wxID_OK;
56 }
57
58 if ((err != noErr) && (err != kPMCancel))
59 {
60 wxString message;
61
62 message.Printf( wxT("Print Error %d"), err );
63 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
64 dialog.ShowModal();
65 }
66
67 if (result == wxID_OK)
68 {
69 m_printDialogData.GetPrintData().ConvertFromNative();
c347101b 70 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
489468fe 71 }
489468fe
SC
72 return result;
73}
489468fe 74
489468fe
SC
75int wxMacPageSetupDialog::ShowModal()
76{
77 m_pageSetupData.GetPrintData().ConvertToNative();
c347101b
SC
78 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
79 nativeData->TransferFrom( &m_pageSetupData );
489468fe
SC
80
81 int result = wxID_CANCEL;
489468fe
SC
82 OSErr err = noErr;
83 Boolean accepted;
84
445e564f 85 wxDialog::OSXBeginModalDialog();
c347101b 86 err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
489468fe 87 &accepted );
445e564f 88 wxDialog::OSXEndModalDialog();
489468fe
SC
89
90 if ((err == noErr) && !accepted)
91 {
92 // user clicked Cancel button
93 err = kPMCancel;
94 }
95
96 // If the user did not cancel, flatten and save the PageFormat object
97 // with our document.
98 if (err == noErr)
99 {
100 result = wxID_OK;
101 }
102
103 if ((err != noErr) && (err != kPMCancel))
104 {
105 wxString message;
106
107 message.Printf( wxT("Print Error %d"), err );
108 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
109 dialog.ShowModal();
110 }
111
112 if (result == wxID_OK)
113 {
114 m_pageSetupData.GetPrintData().ConvertFromNative();
115 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
c347101b 116 nativeData->TransferTo( &m_pageSetupData );
489468fe 117 }
489468fe
SC
118 return result;
119}
489468fe
SC
120
121#endif