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 IMPLEMENT_CLASS(wxPrinterDC
, wxDC
)
32 GrafPtr macPrintFormerPort
= NULL
;
34 wxPrinterDC::wxPrinterDC(const wxPrintData
& printdata
)
39 m_printData
= printdata
;
40 m_printData
.ConvertToNative() ;
46 message
.Printf( "Print Error %d", err
) ;
47 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
51 if ( ::PrValidate( m_printData
.m_macPrintInfo
) )
53 // the driver has changed in the mean time, should we pop up a page setup dialog ?
58 message
.Printf( "Print Error %d", err
) ;
59 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
62 ::GetPort( &macPrintFormerPort
) ;
63 m_macPrintPort
= ::PrOpenDoc( m_printData
.m_macPrintInfo
, NULL
, NULL
) ;
65 m_macPort
= (GrafPtr
) m_macPrintPort
;
68 m_maxX
= (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).rPaper
.left
;
69 m_maxY
= (**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).rPaper
.top
;
72 wxPrinterDC::~wxPrinterDC(void)
79 ::PrCloseDoc( m_macPrintPort
) ;
84 if ( (**m_printData
.m_macPrintInfo
).prJob
.bJDocLoop
== bSpoolLoop
)
87 ::PrPicFile( m_printData
.m_macPrintInfo
, NULL
, NULL
, NULL
, &status
) ;
92 message
.Printf( "Print Error %d", err
) ;
93 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
97 ::SetPort( macPrintFormerPort
) ;
101 bool wxPrinterDC::StartDoc( const wxString
& WXUNUSED(message
) )
106 void wxPrinterDC::EndDoc(void)
110 void wxPrinterDC::StartPage(void)
118 PrOpenPage( m_macPrintPort
, NULL
) ;
119 SetOrigin( - (**m_printData
.m_macPrintInfo
).rPaper
.left
, - (**m_printData
.m_macPrintInfo
).rPaper
.top
) ;
120 Rect clip
= { -32000 , -32000 , 32000 , 32000 } ;
121 ::ClipRect( &clip
) ;
125 message
.Printf( "Print Error %d", err
) ;
126 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
127 ::PrClosePage( m_macPrintPort
) ;
128 ::PrCloseDoc( m_macPrintPort
) ;
130 ::SetPort( macPrintFormerPort
) ;
135 void wxPrinterDC::EndPage(void)
143 PrClosePage( (TPrPort
*) m_macPort
) ;
147 message
.Printf( "Print Error %d", err
) ;
148 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
149 ::PrCloseDoc( m_macPrintPort
) ;
151 ::SetPort( macPrintFormerPort
) ;