]> git.saurik.com Git - wxWidgets.git/blob - src/mac/dcprint.cpp
set more event object fields for lbox dbl click events
[wxWidgets.git] / src / mac / dcprint.cpp
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"
28 #include "wx/mac/uma.h"
29
30
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_CLASS(wxPrinterDC, wxDC)
33 #endif
34
35 GrafPtr macPrintFormerPort = NULL ;
36
37 wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
38 {
39 #if !TARGET_CARBON
40 OSErr err ;
41 wxString message ;
42
43 m_printData = printdata ;
44 m_printData.ConvertToNative() ;
45
46 ::UMAPrOpen() ;
47 err = PrError() ;
48 if ( err )
49 {
50 message.Printf( "Print Error %d", err ) ;
51 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
52 UMAPrClose() ;
53 }
54
55 if ( ::PrValidate( m_printData.m_macPrintInfo ) )
56 {
57 ::PrStlDialog( m_printData.m_macPrintInfo ) ;
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) ;
65 UMAPrClose() ;
66 }
67 ::GetPort( &macPrintFormerPort ) ;
68 m_macPrintPort = ::PrOpenDoc( m_printData.m_macPrintInfo , NULL , NULL ) ;
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 }
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 ;
82 #else
83 #pragma warning "TODO:printing support for carbon"
84 #endif
85 }
86
87 wxPrinterDC::~wxPrinterDC(void)
88 {
89 #if !TARGET_CARBON
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) ;
110 UMAPrClose() ;
111 }
112 ::UMAPrClose() ;
113 // ::SetPort( macPrintFormerPort ) ;
114 ::SetPort( LMGetWMgrPort() ) ;
115 m_macPortHelper.Clear() ;
116 }
117 #else
118 #pragma warning "TODO:printing support for carbon"
119 #endif
120 }
121
122 bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) )
123 {
124 return m_ok ;
125 }
126
127 void wxPrinterDC::EndDoc(void)
128 {
129 }
130
131 void wxPrinterDC::StartPage(void)
132 {
133 #if !TARGET_CARBON
134 if ( !m_ok )
135 return ;
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
152
153 OSErr err ;
154 wxString message ;
155
156 PrOpenPage( m_macPrintPort , NULL ) ;
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 ) ;
167 ::UMAPrClose() ;
168 ::SetPort( macPrintFormerPort ) ;
169 m_ok = FALSE ;
170 }
171 #else
172 #pragma warning "TODO:printing support for carbon"
173 #endif
174 }
175
176 void wxPrinterDC::EndPage(void)
177 {
178 #if !TARGET_CARBON
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 ) ;
192 ::UMAPrClose() ;
193 ::SetPort( macPrintFormerPort ) ;
194 m_ok = FALSE ;
195 }
196 #else
197 #pragma warning "TODO:printing support for carbon"
198 #endif
199
200 }