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"
27 #include "wx/msgdlg.h"
29 #include "wx/mac/uma.h"
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_CLASS(wxPrinterDC
, wxDC
)
35 GrafPtr macPrintFormerPort
= NULL
;
37 wxPrinterDC::wxPrinterDC(const wxPrintData
& printdata
)
42 m_printData
= printdata
;
43 m_printData
.ConvertToNative() ;
48 message
.Printf( "Print Error %d", err
) ;
49 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
54 if ( ::PrValidate( m_printData
.m_macPrintInfo
) )
56 ::PrStlDialog( m_printData
.m_macPrintInfo
) ;
57 // the driver has changed in the mean time, should we pop up a page setup dialog ?
62 message
.Printf( "Print Error %d", err
) ;
63 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
66 ::GetPort( &macPrintFormerPort
) ;
67 m_macPrintPort
= ::PrOpenDoc( m_printData
.m_macPrintInfo
, NULL
, NULL
) ;
71 message
.Printf( "Print Error %d", err
) ;
72 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
76 m_macPort
= (GrafPtr
) m_macPrintPort
;
78 m_macPrintPort
= kPMNoReference
;
79 err
= PMBeginDocument(
80 m_printData
.m_macPrintSettings
,
81 m_printData
.m_macPageFormat
,
83 if ( err
!= noErr
|| m_macPrintPort
== kPMNoReference
)
85 message
.Printf( "Print Error %d", err
) ;
86 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
90 ::GetPort( &m_macPort
) ;
96 m_maxX
= (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).rPaper
.left
;
97 m_maxY
= (**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).rPaper
.top
;
101 wxPrinterDC::~wxPrinterDC(void)
108 ::PrCloseDoc( m_macPrintPort
) ;
113 if ( (**m_printData
.m_macPrintInfo
).prJob
.bJDocLoop
== bSpoolLoop
)
116 ::PrPicFile( m_printData
.m_macPrintInfo
, NULL
, NULL
, NULL
, &status
) ;
121 message
.Printf( "Print Error %d", err
) ;
122 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
126 // ::SetPort( macPrintFormerPort ) ;
127 ::SetPort( LMGetWMgrPort() ) ;
128 m_macPortHelper
.Clear() ;
133 err
= PMEndDocument(m_macPrintPort
);
136 message
.Printf( "Print Error %d", err
) ;
137 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
145 bool wxPrinterDC::StartDoc( const wxString
& WXUNUSED(message
) )
150 void wxPrinterDC::EndDoc(void)
154 void wxPrinterDC::StartPage(void)
159 m_logicalFunction
= wxCOPY
;
160 // m_textAlignment = wxALIGN_TOP_LEFT;
161 m_backgroundMode
= wxTRANSPARENT
;
163 m_textForegroundColour
= *wxBLACK
;
164 m_textBackgroundColour
= *wxWHITE
;
165 m_pen
= *wxBLACK_PEN
;
166 m_font
= *wxNORMAL_FONT
;
167 m_brush
= *wxTRANSPARENT_BRUSH
;
168 m_backgroundBrush
= *wxWHITE_BRUSH
;
170 m_macFontInstalled
= false ;
171 m_macBrushInstalled
= false ;
172 m_macPenInstalled
= false ;
179 PrOpenPage( m_macPrintPort
, NULL
) ;
180 m_macLocalOrigin
.h
= (**m_printData
.m_macPrintInfo
).rPaper
.left
;
181 m_macLocalOrigin
.v
= (**m_printData
.m_macPrintInfo
).rPaper
.top
;
183 SetOrigin( - m_macLocalOrigin
.h
, - m_macLocalOrigin
.v
) ;
184 Rect clip
= { -32000 , -32000 , 32000 , 32000 } ;
185 ::ClipRect( &clip
) ;
189 message
.Printf( "Print Error %d", err
) ;
190 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
191 ::PrClosePage( m_macPrintPort
) ;
192 ::PrCloseDoc( m_macPrintPort
) ;
194 ::SetPort( macPrintFormerPort
) ;
198 err
= PMBeginPage(m_macPrintPort
, nil
);
201 message
.Printf( "Print Error %d", err
) ;
202 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
203 PMEndPage(m_macPrintPort
);
204 PMEndDocument(m_macPrintPort
);
206 ::SetPort( macPrintFormerPort
) ;
212 void wxPrinterDC::EndPage(void)
221 PrClosePage( (TPrPort
*) m_macPort
) ;
225 message
.Printf( "Print Error %d", err
) ;
226 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
227 ::PrCloseDoc( m_macPrintPort
) ;
229 ::SetPort( macPrintFormerPort
) ;
233 err
= PMEndPage(m_macPrintPort
);
236 message
.Printf( "Print Error %d", err
) ;
237 wxMessageDialog
dialog( NULL
, message
, "", wxICON_HAND
| wxOK
) ;
238 PMEndDocument(m_macPrintPort
);
240 ::SetPort( macPrintFormerPort
) ;