]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/printdlg.cpp
removed code for non-compositing case to fix the compilation after recent commits
[wxWidgets.git] / src / mac / carbon / printdlg.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
cc224d6e 2// Name: src/mac/carbon/printdlg.cpp
e9576ca5 3// Purpose: wxPrintDialog, wxPageSetupDialog
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
8e3f3880 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
179e085f
RN
14#if wxUSE_PRINTING_ARCHITECTURE
15
246c5004
WS
16#include "wx/printdlg.h"
17
8e3f3880
WS
18#ifndef WXPRECOMP
19 #include "wx/object.h"
6d50343d 20 #include "wx/dcprint.h"
246c5004 21 #include "wx/msgdlg.h"
8e3f3880
WS
22#endif
23
08680429 24#include "wx/mac/printdlg.h"
746d7582 25#include "wx/mac/private/print.h"
a3d3d3bf 26
cc224d6e 27
e9576ca5 28// Use generic page setup dialog: use your own native one if one exists.
e9576ca5 29
c061373d 30IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog, wxPrintDialogBase)
e9576ca5 31
cc224d6e 32
c061373d 33wxMacPrintDialog::wxMacPrintDialog()
e9576ca5
SC
34{
35 m_dialogParent = NULL;
e7549107 36 m_printerDC = NULL;
cc224d6e 37 m_destroyDC = true;
e9576ca5
SC
38}
39
cc224d6e 40wxMacPrintDialog::wxMacPrintDialog( wxWindow *p, wxPrintDialogData *data )
e9576ca5 41{
cc224d6e 42 Create( p, data );
e9576ca5
SC
43}
44
cc224d6e 45wxMacPrintDialog::wxMacPrintDialog( wxWindow *p, wxPrintData *data )
e7549107
SC
46{
47 wxPrintDialogData data2;
cc224d6e 48 if (data != NULL)
e7549107 49 data2 = *data;
cc224d6e
DS
50
51 Create( p, &data2 );
e7549107
SC
52}
53
cc224d6e 54bool wxMacPrintDialog::Create( wxWindow *p, wxPrintDialogData *data )
e9576ca5
SC
55{
56 m_dialogParent = p;
e7549107 57 m_printerDC = NULL;
cc224d6e
DS
58 m_destroyDC = true;
59
60 if (data != NULL)
e7549107 61 m_printDialogData = *data;
cc224d6e
DS
62
63 return true;
e9576ca5
SC
64}
65
c061373d 66wxMacPrintDialog::~wxMacPrintDialog()
e9576ca5 67{
cc224d6e
DS
68 if (m_destroyDC && m_printerDC)
69 {
e7549107 70 delete m_printerDC;
f5bb2251
GD
71 m_printerDC = NULL;
72 }
e9576ca5
SC
73}
74
c061373d 75int wxMacPrintDialog::ShowModal()
e9576ca5 76{
dc7ccb9c 77 m_printDialogData.GetPrintData().ConvertToNative();
cc224d6e
DS
78 ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData );
79
80 int result = wxID_CANCEL;
81 OSErr err = noErr;
82 Boolean accepted;
83
84 err = PMSessionPrintDialog(
85 ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->m_macPrintSession,
dc7ccb9c
SC
86 ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->m_macPrintSettings,
87 ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->m_macPageFormat,
cc224d6e
DS
88 &accepted );
89
dc7ccb9c
SC
90 if ((err == noErr) && !accepted)
91 {
cc224d6e
DS
92 // user clicked Cancel button
93 err = kPMCancel;
dc7ccb9c
SC
94 }
95
cc224d6e 96 if (err == noErr)
dc7ccb9c 97 {
cc224d6e 98 result = wxID_OK;
dc7ccb9c
SC
99 }
100
101 if ((err != noErr) && (err != kPMCancel))
102 {
cc224d6e
DS
103 wxString message;
104
105 message.Printf( wxT("Print Error %d"), err );
106 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
dc7ccb9c
SC
107 dialog.ShowModal();
108 }
109
cc224d6e 110 if (result == wxID_OK)
dc7ccb9c
SC
111 {
112 m_printDialogData.GetPrintData().ConvertFromNative();
cc224d6e 113 ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
dc7ccb9c 114 }
cc224d6e
DS
115
116 return result;
e9576ca5
SC
117}
118
cc224d6e 119wxDC * wxMacPrintDialog::GetPrintDC()
e9576ca5 120{
cc224d6e 121 return new wxPrinterDC( m_printDialogData.GetPrintData() );
e9576ca5
SC
122}
123
08680429 124IMPLEMENT_CLASS(wxMacPageSetupDialog, wxPageSetupDialogBase)
e9576ca5 125
cc224d6e
DS
126wxMacPageSetupDialog::wxMacPageSetupDialog( wxWindow *p, wxPageSetupDialogData *data )
127 : wxPageSetupDialogBase()
e9576ca5 128{
cc224d6e 129 Create( p, data );
e9576ca5
SC
130}
131
cc224d6e 132bool wxMacPageSetupDialog::Create( wxWindow *p, wxPageSetupDialogData *data )
e9576ca5
SC
133{
134 m_dialogParent = p;
cc224d6e
DS
135
136 if (data != NULL)
e9576ca5 137 m_pageSetupData = (*data);
cc224d6e
DS
138
139 return true;
e9576ca5
SC
140}
141
08680429 142wxMacPageSetupDialog::~wxMacPageSetupDialog()
e9576ca5
SC
143{
144}
145
08680429 146wxPageSetupData& wxMacPageSetupDialog::GetPageSetupDialogData()
cc224d6e 147{
08680429
RR
148 return m_pageSetupData;
149}
150
151int wxMacPageSetupDialog::ShowModal()
e9576ca5 152{
dc7ccb9c 153 m_pageSetupData.GetPrintData().ConvertToNative();
cc224d6e 154 ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData );
dc7ccb9c 155
cc224d6e
DS
156 int result = wxID_CANCEL;
157 OSErr err = noErr;
158 Boolean accepted;
dc7ccb9c 159
cc224d6e
DS
160 err = PMSessionPageSetupDialog(
161 ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->m_macPrintSession,
dc7ccb9c 162 ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->m_macPageFormat,
cc224d6e
DS
163 &accepted );
164
dc7ccb9c
SC
165 if ((err == noErr) && !accepted)
166 {
cc224d6e
DS
167 // user clicked Cancel button
168 err = kPMCancel;
dc7ccb9c
SC
169 }
170
cc224d6e
DS
171 // If the user did not cancel, flatten and save the PageFormat object
172 // with our document.
173 if (err == noErr)
dc7ccb9c 174 {
cc224d6e 175 result = wxID_OK;
dc7ccb9c 176 }
cc224d6e 177
dc7ccb9c
SC
178 if ((err != noErr) && (err != kPMCancel))
179 {
cc224d6e
DS
180 wxString message;
181
182 message.Printf( wxT("Print Error %d"), err );
183 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
dc7ccb9c
SC
184 dialog.ShowModal();
185 }
186
cc224d6e 187 if (result == wxID_OK)
dc7ccb9c
SC
188 {
189 m_pageSetupData.GetPrintData().ConvertFromNative();
cc224d6e
DS
190 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
191 ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData );
192 }
193
08680429 194 return result;
e9576ca5
SC
195}
196
179e085f 197#endif