]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/printdlg.cpp
supporting disabled items, closes #11130
[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
SC
41 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData();
42 err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(),
43 nativeData->GetPageFormat(), &accepted );
489468fe
SC
44
45 if ((err == noErr) && !accepted)
46 {
47 // user clicked Cancel button
48 err = kPMCancel;
49 }
50
51 if (err == noErr)
52 {
53 result = wxID_OK;
54 }
55
56 if ((err != noErr) && (err != kPMCancel))
57 {
58 wxString message;
59
60 message.Printf( wxT("Print Error %d"), err );
61 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
62 dialog.ShowModal();
63 }
64
65 if (result == wxID_OK)
66 {
67 m_printDialogData.GetPrintData().ConvertFromNative();
c347101b 68 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
489468fe 69 }
489468fe
SC
70 return result;
71}
489468fe 72
489468fe
SC
73int wxMacPageSetupDialog::ShowModal()
74{
75 m_pageSetupData.GetPrintData().ConvertToNative();
c347101b
SC
76 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
77 nativeData->TransferFrom( &m_pageSetupData );
489468fe
SC
78
79 int result = wxID_CANCEL;
489468fe
SC
80 OSErr err = noErr;
81 Boolean accepted;
82
c347101b 83 err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
489468fe
SC
84 &accepted );
85
86 if ((err == noErr) && !accepted)
87 {
88 // user clicked Cancel button
89 err = kPMCancel;
90 }
91
92 // If the user did not cancel, flatten and save the PageFormat object
93 // with our document.
94 if (err == noErr)
95 {
96 result = wxID_OK;
97 }
98
99 if ((err != noErr) && (err != kPMCancel))
100 {
101 wxString message;
102
103 message.Printf( wxT("Print Error %d"), err );
104 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
105 dialog.ShowModal();
106 }
107
108 if (result == wxID_OK)
109 {
110 m_pageSetupData.GetPrintData().ConvertFromNative();
111 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
c347101b 112 nativeData->TransferTo( &m_pageSetupData );
489468fe 113 }
489468fe
SC
114 return result;
115}
489468fe
SC
116
117#endif