1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPrinterDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dcprint.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/dcprint.h"
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_CLASS(wxPrinterDC
, wxDC
)
34 GrafPtr macPrintFormerPort
= NULL
;
36 wxPrinterDC::wxPrinterDC(const wxPrintData
& printdata
)
41 m_printData
= printdata
;
42 m_printData
.ConvertToNative() ;
48 message
.Printf( "Print Error %d", err
) ;
49 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
53 if ( ::PrValidate( m_printData
.m_macPrintInfo
) )
55 // the driver has changed in the mean time, should we pop up a page setup dialog ?
60 message
.Printf( "Print Error %d", err
) ;
61 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
64 ::GetPort( &macPrintFormerPort
) ;
65 m_macPrintPort
= ::PrOpenDoc( m_printData
.m_macPrintInfo
, NULL
, NULL
) ;
67 m_macPort
= (GrafPtr
) m_macPrintPort
;
70 m_maxX
= (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).rPaper
.left
;
71 m_maxY
= (**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).rPaper
.top
;
74 wxPrinterDC::~wxPrinterDC(void)
81 ::PrCloseDoc( m_macPrintPort
) ;
86 if ( (**m_printData
.m_macPrintInfo
).prJob
.bJDocLoop
== bSpoolLoop
)
89 ::PrPicFile( m_printData
.m_macPrintInfo
, NULL
, NULL
, NULL
, &status
) ;
94 message
.Printf( "Print Error %d", err
) ;
95 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
99 ::SetPort( macPrintFormerPort
) ;
103 bool wxPrinterDC::StartDoc( const wxString
& WXUNUSED(message
) )
108 void wxPrinterDC::EndDoc(void)
112 void wxPrinterDC::StartPage(void)
120 PrOpenPage( m_macPrintPort
, NULL
) ;
121 SetOrigin( - (**m_printData
.m_macPrintInfo
).rPaper
.left
, - (**m_printData
.m_macPrintInfo
).rPaper
.top
) ;
122 Rect clip
= { -32000 , -32000 , 32000 , 32000 } ;
123 ::ClipRect( &clip
) ;
127 message
.Printf( "Print Error %d", err
) ;
128 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
129 ::PrClosePage( m_macPrintPort
) ;
130 ::PrCloseDoc( m_macPrintPort
) ;
132 ::SetPort( macPrintFormerPort
) ;
137 void wxPrinterDC::EndPage(void)
145 PrClosePage( (TPrPort
*) m_macPort
) ;
149 message
.Printf( "Print Error %d", err
) ;
150 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
151 ::PrCloseDoc( m_macPrintPort
) ;
153 ::SetPort( macPrintFormerPort
) ;