]> git.saurik.com Git - wxWidgets.git/blame - src/mac/dcprint.cpp
cosmetic fixes to font encoding names
[wxWidgets.git] / src / mac / dcprint.cpp
CommitLineData
72e7876b
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcprint.cpp
3// Purpose: wxPrinterDC class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "dcprint.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#endif
25
26#include "wx/dcprint.h"
27#include "math.h"
2f1ae414 28#include "wx/mac/uma.h"
72e7876b
SC
29
30
2f1ae414 31#if !USE_SHARED_LIBRARY
72e7876b 32IMPLEMENT_CLASS(wxPrinterDC, wxDC)
2f1ae414 33#endif
72e7876b
SC
34
35GrafPtr macPrintFormerPort = NULL ;
36
37wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
38{
2f1ae414 39#if !TARGET_CARBON
72e7876b
SC
40 OSErr err ;
41 wxString message ;
42
43 m_printData = printdata ;
44 m_printData.ConvertToNative() ;
45
2f1ae414 46 ::UMAPrOpen() ;
72e7876b
SC
47 err = PrError() ;
48 if ( err )
49 {
50 message.Printf( "Print Error %d", err ) ;
51 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
2f1ae414 52 UMAPrClose() ;
72e7876b
SC
53 }
54
55 if ( ::PrValidate( m_printData.m_macPrintInfo ) )
56 {
2f1ae414 57 ::PrStlDialog( m_printData.m_macPrintInfo ) ;
72e7876b
SC
58 // the driver has changed in the mean time, should we pop up a page setup dialog ?
59 }
60 err = PrError() ;
61 if ( err )
62 {
63 message.Printf( "Print Error %d", err ) ;
64 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
2f1ae414 65 UMAPrClose() ;
72e7876b
SC
66 }
67 ::GetPort( &macPrintFormerPort ) ;
68 m_macPrintPort = ::PrOpenDoc( m_printData.m_macPrintInfo , NULL , NULL ) ;
2f1ae414
SC
69 err = PrError() ;
70 if ( err )
71 {
72 message.Printf( "Print Error %d", err ) ;
73 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
74 UMAPrClose() ;
75 }
72e7876b
SC
76 // sets current port
77 m_macPort = (GrafPtr ) m_macPrintPort ;
78 m_ok = TRUE ;
79 m_minY = m_minX = 0 ;
80 m_maxX = (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ;
81 m_maxY = (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ;
2f1ae414
SC
82#else
83#pragma warning "TODO:printing support for carbon"
84#endif
72e7876b
SC
85}
86
87wxPrinterDC::~wxPrinterDC(void)
88{
2f1ae414 89#if !TARGET_CARBON
72e7876b
SC
90 if ( m_ok )
91 {
92 OSErr err ;
93 wxString message ;
94
95 ::PrCloseDoc( m_macPrintPort ) ;
96 err = PrError() ;
97
98 if ( !err )
99 {
100 if ( (**m_printData.m_macPrintInfo).prJob.bJDocLoop == bSpoolLoop )
101 {
102 TPrStatus status ;
103 ::PrPicFile( m_printData.m_macPrintInfo , NULL , NULL , NULL , &status ) ;
104 }
105 }
106 else
107 {
108 message.Printf( "Print Error %d", err ) ;
109 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
2f1ae414 110 UMAPrClose() ;
72e7876b 111 }
2f1ae414
SC
112 ::UMAPrClose() ;
113// ::SetPort( macPrintFormerPort ) ;
114 ::SetPort( LMGetWMgrPort() ) ;
115 m_macPortHelper.Clear() ;
72e7876b 116 }
2f1ae414
SC
117#else
118#pragma warning "TODO:printing support for carbon"
119#endif
72e7876b
SC
120}
121
122bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) )
123{
124 return m_ok ;
125}
126
127void wxPrinterDC::EndDoc(void)
128{
129}
130
131void wxPrinterDC::StartPage(void)
132{
2f1ae414 133#if !TARGET_CARBON
72e7876b
SC
134 if ( !m_ok )
135 return ;
2f1ae414
SC
136
137 m_logicalFunction = wxCOPY;
138// m_textAlignment = wxALIGN_TOP_LEFT;
139 m_backgroundMode = wxTRANSPARENT;
140
141 m_textForegroundColour = *wxBLACK;
142 m_textBackgroundColour = *wxWHITE;
143 m_pen = *wxBLACK_PEN;
144 m_font = *wxNORMAL_FONT;
145 m_brush = *wxTRANSPARENT_BRUSH;
146 m_backgroundBrush = *wxWHITE_BRUSH;
147
148 m_macFontInstalled = false ;
149 m_macBrushInstalled = false ;
150 m_macPenInstalled = false ;
151
72e7876b
SC
152
153 OSErr err ;
154 wxString message ;
155
2f1ae414 156 PrOpenPage( m_macPrintPort , NULL ) ;
72e7876b
SC
157 SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ;
158 Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
159 ::ClipRect( &clip ) ;
160 err = PrError() ;
161 if ( err )
162 {
163 message.Printf( "Print Error %d", err ) ;
164 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
165 ::PrClosePage( m_macPrintPort) ;
166 ::PrCloseDoc( m_macPrintPort ) ;
2f1ae414 167 ::UMAPrClose() ;
72e7876b
SC
168 ::SetPort( macPrintFormerPort ) ;
169 m_ok = FALSE ;
170 }
2f1ae414
SC
171#else
172#pragma warning "TODO:printing support for carbon"
173#endif
72e7876b
SC
174}
175
176void wxPrinterDC::EndPage(void)
177{
2f1ae414 178#if !TARGET_CARBON
72e7876b
SC
179 if ( !m_ok )
180 return ;
181
182 OSErr err ;
183 wxString message ;
184
185 PrClosePage( (TPrPort*) m_macPort ) ;
186 err = PrError() ;
187 if ( err )
188 {
189 message.Printf( "Print Error %d", err ) ;
190 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
191 ::PrCloseDoc( m_macPrintPort ) ;
2f1ae414 192 ::UMAPrClose() ;
72e7876b
SC
193 ::SetPort( macPrintFormerPort ) ;
194 m_ok = FALSE ;
195 }
2f1ae414
SC
196#else
197#pragma warning "TODO:printing support for carbon"
198#endif
199
72e7876b 200}