]>
Commit | Line | Data |
---|---|---|
2ac013b1 | 1 | ///////////////////////////////////////////////////////////////////////////// |
e9576ca5 SC |
2 | // Name: dc.cpp |
3 | // Purpose: wxDC class | |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 SC |
5 | // Modified by: |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
e40298d5 | 9 | // Licence: wxWindows licence |
e9576ca5 | 10 | ///////////////////////////////////////////////////////////////////////////// |
e40298d5 | 11 | |
e9576ca5 SC |
12 | #ifdef __GNUG__ |
13 | #pragma implementation "dc.h" | |
14 | #endif | |
e40298d5 | 15 | |
e9576ca5 | 16 | #include "wx/dc.h" |
03e11df5 | 17 | #include "wx/app.h" |
2f1ae414 | 18 | #include "wx/mac/uma.h" |
3dec57ad | 19 | #include "wx/dcmemory.h" |
a7390348 | 20 | #include "wx/dcprint.h" |
3dec57ad SC |
21 | #include "wx/region.h" |
22 | #include "wx/image.h" | |
b1699cd3 | 23 | #include "wx/log.h" |
e9576ca5 | 24 | |
5b781a67 SC |
25 | #if __MSL__ >= 0x6000 |
26 | #include "math.h" | |
b34039cf | 27 | using namespace std ; |
5b781a67 | 28 | #endif |
a7390348 | 29 | |
b34039cf | 30 | #include "wx/mac/private.h" |
66a09d47 SC |
31 | #include "ATSUnicode.h" |
32 | #include "TextCommon.h" | |
33 | #include "TextEncodingConverter.h" | |
2f1ae414 | 34 | #if !USE_SHARED_LIBRARY |
e9576ca5 | 35 | IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) |
2f1ae414 | 36 | #endif |
e40298d5 | 37 | |
e9576ca5 SC |
38 | //----------------------------------------------------------------------------- |
39 | // constants | |
40 | //----------------------------------------------------------------------------- | |
e40298d5 JS |
41 | |
42 | #define mm2inches 0.0393700787402 | |
43 | #define inches2mm 25.4 | |
44 | #define mm2twips 56.6929133859 | |
45 | #define twips2mm 0.0176388888889 | |
46 | #define mm2pt 2.83464566929 | |
47 | #define pt2mm 0.352777777778 | |
84e7f94c | 48 | #if !defined( __DARWIN__ ) || defined(__MWERKS__) |
3dec57ad | 49 | const double M_PI = 3.14159265358979 ; |
2461b2e7 | 50 | #endif |
3dec57ad | 51 | const double RAD2DEG = 180.0 / M_PI; |
76a5e5d2 SC |
52 | const short kEmulatedMode = -1 ; |
53 | const short kUnsupportedMode = -2 ; | |
e40298d5 | 54 | |
66a09d47 | 55 | wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) : |
e40298d5 | 56 | m_ph( (GrafPtr) dc->m_macPort ) |
66a09d47 | 57 | { |
e40298d5 JS |
58 | wxASSERT( dc->Ok() ) ; |
59 | m_dc = dc ; | |
60 | dc->MacSetupPort(&m_ph) ; | |
66a09d47 | 61 | } |
e40298d5 | 62 | |
99030bdf | 63 | wxMacPortSetter::~wxMacPortSetter() |
66a09d47 | 64 | { |
e40298d5 | 65 | m_dc->MacCleanupPort(&m_ph) ; |
66a09d47 | 66 | } |
e40298d5 | 67 | |
15cae9eb SC |
68 | wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) |
69 | { | |
70 | m_formerClip = NewRgn() ; | |
71 | m_newClip = NewRgn() ; | |
72 | GetClip( m_formerClip ) ; | |
73 | ||
74 | if ( win ) | |
75 | { | |
1dd85cc3 | 76 | #if 0 |
e40298d5 JS |
77 | // this clipping area was set to the parent window's drawing area, lead to problems |
78 | // with MacOSX controls drawing outside their wx' rectangle | |
15cae9eb SC |
79 | RgnHandle insidergn = NewRgn() ; |
80 | int x = 0 , y = 0; | |
81 | wxWindow *parent = win->GetParent() ; | |
82 | parent->MacWindowToRootWindow( &x,&y ) ; | |
15cae9eb SC |
83 | wxSize size = parent->GetSize() ; |
84 | SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() , | |
e40298d5 JS |
85 | size.x - parent->MacGetRightBorderSize(), |
86 | size.y - parent->MacGetBottomBorderSize()) ; | |
15cae9eb | 87 | CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ; |
e40298d5 | 88 | SectRgn( m_newClip , insidergn , m_newClip ) ; |
15cae9eb SC |
89 | OffsetRgn( m_newClip , x , y ) ; |
90 | SetClip( m_newClip ) ; | |
e40298d5 | 91 | DisposeRgn( insidergn ) ; |
de996ce0 | 92 | #else |
1dd85cc3 SC |
93 | int x = 0 , y = 0; |
94 | win->MacWindowToRootWindow( &x,&y ) ; | |
95 | CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ; | |
96 | OffsetRgn( m_newClip , x , y ) ; | |
97 | SetClip( m_newClip ) ; | |
de996ce0 | 98 | #endif |
e40298d5 | 99 | } |
15cae9eb | 100 | } |
e40298d5 | 101 | |
15cae9eb SC |
102 | wxMacWindowClipper::~wxMacWindowClipper() |
103 | { | |
104 | SetClip( m_formerClip ) ; | |
e40298d5 JS |
105 | DisposeRgn( m_newClip ) ; |
106 | DisposeRgn( m_formerClip ) ; | |
15cae9eb | 107 | } |
e40298d5 | 108 | |
3dec57ad SC |
109 | //----------------------------------------------------------------------------- |
110 | // Local functions | |
111 | //----------------------------------------------------------------------------- | |
3dec57ad SC |
112 | static inline double dmin(double a, double b) { return a < b ? a : b; } |
113 | static inline double dmax(double a, double b) { return a > b ? a : b; } | |
114 | static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } | |
e40298d5 | 115 | |
e9576ca5 SC |
116 | //----------------------------------------------------------------------------- |
117 | // wxDC | |
118 | //----------------------------------------------------------------------------- | |
76a5e5d2 SC |
119 | // this function emulates all wx colour manipulations, used to verify the implementation |
120 | // by setting the mode in the blitting functions to kEmulatedMode | |
76a5e5d2 | 121 | void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) ; |
e40298d5 | 122 | |
76a5e5d2 SC |
123 | void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) |
124 | { | |
125 | switch ( logical_func ) | |
126 | { | |
e40298d5 JS |
127 | case wxAND: // src AND dst |
128 | dstColor.red = dstColor.red & srcColor.red ; | |
129 | dstColor.green = dstColor.green & srcColor.green ; | |
130 | dstColor.blue = dstColor.blue & srcColor.blue ; | |
131 | break ; | |
132 | case wxAND_INVERT: // (NOT src) AND dst | |
133 | dstColor.red = dstColor.red & ~srcColor.red ; | |
134 | dstColor.green = dstColor.green & ~srcColor.green ; | |
135 | dstColor.blue = dstColor.blue & ~srcColor.blue ; | |
136 | break ; | |
137 | case wxAND_REVERSE:// src AND (NOT dst) | |
138 | dstColor.red = ~dstColor.red & srcColor.red ; | |
139 | dstColor.green = ~dstColor.green & srcColor.green ; | |
140 | dstColor.blue = ~dstColor.blue & srcColor.blue ; | |
141 | break ; | |
142 | case wxCLEAR: // 0 | |
143 | dstColor.red = 0 ; | |
144 | dstColor.green = 0 ; | |
145 | dstColor.blue = 0 ; | |
146 | break ; | |
76a5e5d2 | 147 | case wxCOPY: // src |
e40298d5 JS |
148 | dstColor.red = srcColor.red ; |
149 | dstColor.green = srcColor.green ; | |
150 | dstColor.blue = srcColor.blue ; | |
151 | break ; | |
152 | case wxEQUIV: // (NOT src) XOR dst | |
153 | dstColor.red = dstColor.red ^ ~srcColor.red ; | |
154 | dstColor.green = dstColor.green ^ ~srcColor.green ; | |
155 | dstColor.blue = dstColor.blue ^ ~srcColor.blue ; | |
156 | break ; | |
157 | case wxINVERT: // NOT dst | |
158 | dstColor.red = ~dstColor.red ; | |
159 | dstColor.green = ~dstColor.green ; | |
160 | dstColor.blue = ~dstColor.blue ; | |
161 | break ; | |
162 | case wxNAND: // (NOT src) OR (NOT dst) | |
163 | dstColor.red = ~dstColor.red | ~srcColor.red ; | |
164 | dstColor.green = ~dstColor.green | ~srcColor.green ; | |
165 | dstColor.blue = ~dstColor.blue | ~srcColor.blue ; | |
166 | break ; | |
167 | case wxNOR: // (NOT src) AND (NOT dst) | |
168 | dstColor.red = ~dstColor.red & ~srcColor.red ; | |
169 | dstColor.green = ~dstColor.green & ~srcColor.green ; | |
170 | dstColor.blue = ~dstColor.blue & ~srcColor.blue ; | |
171 | break ; | |
172 | case wxNO_OP: // dst | |
173 | break ; | |
174 | case wxOR: // src OR dst | |
175 | dstColor.red = dstColor.red | srcColor.red ; | |
176 | dstColor.green = dstColor.green | srcColor.green ; | |
177 | dstColor.blue = dstColor.blue | srcColor.blue ; | |
178 | break ; | |
179 | case wxOR_INVERT: // (NOT src) OR dst | |
180 | dstColor.red = dstColor.red | ~srcColor.red ; | |
181 | dstColor.green = dstColor.green | ~srcColor.green ; | |
182 | dstColor.blue = dstColor.blue | ~srcColor.blue ; | |
183 | break ; | |
184 | case wxOR_REVERSE: // src OR (NOT dst) | |
185 | dstColor.red = ~dstColor.red | srcColor.red ; | |
186 | dstColor.green = ~dstColor.green | srcColor.green ; | |
187 | dstColor.blue = ~dstColor.blue | srcColor.blue ; | |
188 | break ; | |
189 | case wxSET: // 1 | |
190 | dstColor.red = 0xFFFF ; | |
191 | dstColor.green = 0xFFFF ; | |
192 | dstColor.blue = 0xFFFF ; | |
193 | break ; | |
194 | case wxSRC_INVERT: // (NOT src) | |
195 | dstColor.red = ~srcColor.red ; | |
196 | dstColor.green = ~srcColor.green ; | |
197 | dstColor.blue = ~srcColor.blue ; | |
198 | break ; | |
199 | case wxXOR: // src XOR dst | |
200 | dstColor.red = dstColor.red ^ srcColor.red ; | |
201 | dstColor.green = dstColor.green ^ srcColor.green ; | |
202 | dstColor.blue = dstColor.blue ^ srcColor.blue ; | |
203 | break ; | |
76a5e5d2 | 204 | } |
76a5e5d2 | 205 | } |
e40298d5 | 206 | |
2f1ae414 | 207 | wxDC::wxDC() |
e9576ca5 | 208 | { |
e40298d5 JS |
209 | m_ok = FALSE; |
210 | m_colour = TRUE; | |
211 | m_mm_to_pix_x = mm2pt; | |
212 | m_mm_to_pix_y = mm2pt; | |
213 | m_internalDeviceOriginX = 0; | |
214 | m_internalDeviceOriginY = 0; | |
215 | m_externalDeviceOriginX = 0; | |
216 | m_externalDeviceOriginY = 0; | |
217 | m_logicalScaleX = 1.0; | |
218 | m_logicalScaleY = 1.0; | |
219 | m_userScaleX = 1.0; | |
220 | m_userScaleY = 1.0; | |
221 | m_scaleX = 1.0; | |
222 | m_scaleY = 1.0; | |
223 | m_needComputeScaleX = FALSE; | |
224 | m_needComputeScaleY = FALSE; | |
225 | m_macPort = NULL ; | |
226 | m_macMask = NULL ; | |
227 | m_ok = FALSE ; | |
228 | m_macFontInstalled = false ; | |
229 | m_macBrushInstalled = false ; | |
230 | m_macPenInstalled = false ; | |
231 | m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; | |
232 | m_macBoundaryClipRgn = NewRgn() ; | |
233 | m_macCurrentClipRgn = NewRgn() ; | |
234 | SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; | |
235 | SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ; | |
9ff647cf SC |
236 | m_pen = *wxBLACK_PEN; |
237 | m_font = *wxNORMAL_FONT; | |
238 | m_brush = *wxWHITE_BRUSH; | |
66a09d47 SC |
239 | m_macCurrentPortStateHelper = NULL ; |
240 | m_macATSUIStyle = NULL ; | |
241 | m_macAliasWasEnabled = false; | |
242 | m_macForegroundPixMap = NULL ; | |
243 | m_macBackgroundPixMap = NULL ; | |
0eaa1d68 | 244 | } |
e40298d5 | 245 | |
e9576ca5 SC |
246 | wxDC::~wxDC(void) |
247 | { | |
76a5e5d2 SC |
248 | DisposeRgn( (RgnHandle) m_macBoundaryClipRgn ) ; |
249 | DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ; | |
3dec57ad | 250 | } |
e40298d5 | 251 | |
76a5e5d2 | 252 | void wxDC::MacSetupPort(wxMacPortStateHelper* help) const |
519cb848 | 253 | { |
66a09d47 SC |
254 | wxASSERT( m_macCurrentPortStateHelper == NULL ) ; |
255 | m_macCurrentPortStateHelper = help ; | |
e40298d5 JS |
256 | SetClip( (RgnHandle) m_macCurrentClipRgn); |
257 | m_macFontInstalled = false ; | |
258 | m_macBrushInstalled = false ; | |
259 | m_macPenInstalled = false ; | |
519cb848 | 260 | } |
e40298d5 | 261 | |
66a09d47 SC |
262 | void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const |
263 | { | |
264 | wxASSERT( m_macCurrentPortStateHelper == help ) ; | |
265 | m_macCurrentPortStateHelper = NULL ; | |
266 | if( m_macATSUIStyle ) | |
267 | { | |
268 | ::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle); | |
269 | m_macATSUIStyle = NULL ; | |
270 | } | |
271 | if ( m_macAliasWasEnabled ) | |
272 | { | |
273 | SetAntiAliasedTextEnabled(m_macFormerAliasState, m_macFormerAliasSize); | |
274 | m_macAliasWasEnabled = false ; | |
275 | } | |
276 | if ( m_macForegroundPixMap ) | |
277 | { | |
278 | Pattern blackColor ; | |
279 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
c99d6f99 | 280 | DisposePixPat( (PixPatHandle) m_macForegroundPixMap ) ; |
66a09d47 SC |
281 | m_macForegroundPixMap = NULL ; |
282 | } | |
283 | if ( m_macBackgroundPixMap ) | |
284 | { | |
285 | Pattern whiteColor ; | |
286 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
c99d6f99 | 287 | DisposePixPat( (PixPatHandle) m_macBackgroundPixMap ) ; |
66a09d47 SC |
288 | m_macBackgroundPixMap = NULL ; |
289 | } | |
290 | } | |
e40298d5 | 291 | |
2f1ae414 | 292 | void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) |
519cb848 | 293 | { |
3dec57ad | 294 | wxCHECK_RET( Ok(), wxT("invalid window dc") ); |
3dec57ad | 295 | wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); |
3dec57ad | 296 | wxMacPortSetter helper(this) ; |
7d9d1fd7 SC |
297 | wxCoord xx = XLOG2DEVMAC(x); |
298 | wxCoord yy = YLOG2DEVMAC(y); | |
3dec57ad SC |
299 | wxCoord w = bmp.GetWidth(); |
300 | wxCoord h = bmp.GetHeight(); | |
301 | wxCoord ww = XLOG2DEVREL(w); | |
302 | wxCoord hh = YLOG2DEVREL(h); | |
3dec57ad SC |
303 | // Set up drawing mode |
304 | short mode = (m_logicalFunction == wxCOPY ? srcCopy : | |
305 | //m_logicalFunction == wxCLEAR ? WHITENESS : | |
306 | //m_logicalFunction == wxSET ? BLACKNESS : | |
307 | m_logicalFunction == wxINVERT ? hilite : | |
308 | //m_logicalFunction == wxAND ? MERGECOPY : | |
309 | m_logicalFunction == wxOR ? srcOr : | |
310 | m_logicalFunction == wxSRC_INVERT ? notSrcCopy : | |
311 | m_logicalFunction == wxXOR ? srcXor : | |
312 | m_logicalFunction == wxOR_REVERSE ? notSrcOr : | |
313 | //m_logicalFunction == wxAND_REVERSE ? SRCERASE : | |
314 | //m_logicalFunction == wxSRC_OR ? srcOr : | |
315 | //m_logicalFunction == wxSRC_AND ? SRCAND : | |
316 | srcCopy ); | |
3dec57ad SC |
317 | if ( bmp.GetBitmapType() == kMacBitmapTypePict ) { |
318 | Rect bitmaprect = { 0 , 0 , hh, ww }; | |
319 | ::OffsetRect( &bitmaprect, xx, yy ) ; | |
76a5e5d2 | 320 | ::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ; |
519cb848 | 321 | } |
3dec57ad SC |
322 | else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld ) |
323 | { | |
76a5e5d2 | 324 | GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() ); |
3dec57ad | 325 | PixMapHandle bmappixels ; |
3dec57ad SC |
326 | // Set foreground and background colours (for bitmaps depth = 1) |
327 | if(bmp.GetDepth() == 1) | |
328 | { | |
76a5e5d2 SC |
329 | RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel()); |
330 | RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()); | |
3dec57ad SC |
331 | RGBForeColor(&fore); |
332 | RGBBackColor(&back); | |
333 | } | |
334 | else | |
335 | { | |
336 | RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; | |
337 | RGBColor black = { 0,0,0} ; | |
338 | RGBForeColor( &black ) ; | |
339 | RGBBackColor( &white ) ; | |
340 | } | |
3dec57ad | 341 | bmappixels = GetGWorldPixMap( bmapworld ) ; |
3dec57ad SC |
342 | wxCHECK_RET(LockPixels(bmappixels), |
343 | wxT("DoDrawBitmap: Unable to lock pixels")); | |
3dec57ad SC |
344 | Rect source = { 0, 0, h, w }; |
345 | Rect dest = { yy, xx, yy + hh, xx + ww }; | |
3dec57ad SC |
346 | if ( useMask && bmp.GetMask() ) |
347 | { | |
76a5e5d2 | 348 | if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())))) |
3dec57ad SC |
349 | { |
350 | CopyDeepMask | |
351 | ( | |
352 | GetPortBitMapForCopyBits(bmapworld), | |
76a5e5d2 SC |
353 | GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())), |
354 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ), | |
3dec57ad SC |
355 | &source, &source, &dest, mode, NULL |
356 | ); | |
76a5e5d2 | 357 | UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))); |
3dec57ad SC |
358 | } |
359 | } | |
360 | else { | |
361 | CopyBits( GetPortBitMapForCopyBits( bmapworld ), | |
76a5e5d2 | 362 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ), |
3dec57ad SC |
363 | &source, &dest, mode, NULL ) ; |
364 | } | |
365 | UnlockPixels( bmappixels ) ; | |
366 | } | |
367 | else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon ) | |
368 | { | |
369 | Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ; | |
370 | OffsetRect( &bitmaprect, xx, yy ) ; | |
76a5e5d2 | 371 | PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ; |
3dec57ad SC |
372 | } |
373 | m_macPenInstalled = false ; | |
374 | m_macBrushInstalled = false ; | |
375 | m_macFontInstalled = false ; | |
519cb848 | 376 | } |
e40298d5 | 377 | |
2f1ae414 | 378 | void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) |
e9576ca5 | 379 | { |
e40298d5 JS |
380 | wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon")); |
381 | wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon")); | |
a2f94f40 | 382 | DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ; |
3dec57ad | 383 | } |
e40298d5 | 384 | |
2f1ae414 | 385 | void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) |
e9576ca5 | 386 | { |
3dec57ad SC |
387 | wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC")); |
388 | wxCoord xx, yy, ww, hh; | |
7d9d1fd7 SC |
389 | xx = XLOG2DEVMAC(x); |
390 | yy = YLOG2DEVMAC(y); | |
3dec57ad SC |
391 | ww = XLOG2DEVREL(width); |
392 | hh = YLOG2DEVREL(height); | |
76a5e5d2 SC |
393 | SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ; |
394 | SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; | |
3dec57ad SC |
395 | if( m_clipping ) |
396 | { | |
397 | m_clipX1 = wxMax( m_clipX1 , xx ); | |
398 | m_clipY1 = wxMax( m_clipY1 , yy ); | |
399 | m_clipX2 = wxMin( m_clipX2, (xx + ww)); | |
400 | m_clipY2 = wxMin( m_clipY2, (yy + hh)); | |
401 | } | |
402 | else | |
403 | { | |
404 | m_clipping = TRUE; | |
405 | m_clipX1 = xx; | |
406 | m_clipY1 = yy; | |
407 | m_clipX2 = xx + ww; | |
408 | m_clipY2 = yy + hh; | |
409 | } | |
3dec57ad | 410 | } |
e40298d5 | 411 | |
2f1ae414 SC |
412 | void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) |
413 | { | |
3dec57ad | 414 | wxCHECK_RET( Ok(), wxT("invalid window dc") ) ; |
e40298d5 | 415 | wxMacPortSetter helper(this) ; |
2f1ae414 SC |
416 | if (region.Empty()) |
417 | { | |
418 | DestroyClippingRegion(); | |
419 | return; | |
420 | } | |
ffba56ed SC |
421 | wxCoord x, y, w, h; |
422 | region.GetBox( x, y, w, h ); | |
2f1ae414 | 423 | wxCoord xx, yy, ww, hh; |
7d9d1fd7 SC |
424 | xx = XLOG2DEVMAC(x); |
425 | yy = YLOG2DEVMAC(y); | |
ffba56ed SC |
426 | ww = XLOG2DEVREL(w); |
427 | hh = YLOG2DEVREL(h); | |
ffba56ed SC |
428 | // if we have a scaling that we cannot map onto native regions |
429 | // we must use the box | |
ffba56ed SC |
430 | if ( ww != w || hh != h ) |
431 | { | |
432 | wxDC::DoSetClippingRegion( x, y, w, h ); | |
433 | } | |
434 | else | |
435 | { | |
76a5e5d2 | 436 | CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ; |
ffba56ed SC |
437 | if ( xx != x || yy != y ) |
438 | { | |
76a5e5d2 | 439 | OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ; |
ffba56ed | 440 | } |
76a5e5d2 | 441 | SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; |
ffba56ed SC |
442 | if( m_clipping ) |
443 | { | |
444 | m_clipX1 = wxMax( m_clipX1 , xx ); | |
445 | m_clipY1 = wxMax( m_clipY1 , yy ); | |
446 | m_clipX2 = wxMin( m_clipX2, (xx + ww)); | |
447 | m_clipY2 = wxMin( m_clipY2, (yy + hh)); | |
448 | } | |
449 | else | |
450 | { | |
451 | m_clipping = TRUE; | |
452 | m_clipX1 = xx; | |
453 | m_clipY1 = yy; | |
454 | m_clipX2 = xx + ww; | |
455 | m_clipY2 = yy + hh; | |
456 | } | |
457 | } | |
ee41971c | 458 | } |
e40298d5 | 459 | |
3dec57ad | 460 | void wxDC::DestroyClippingRegion() |
e9576ca5 | 461 | { |
e40298d5 JS |
462 | wxMacPortSetter helper(this) ; |
463 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; | |
464 | m_clipping = FALSE; | |
99030bdf | 465 | } |
e40298d5 | 466 | |
2f1ae414 | 467 | void wxDC::DoGetSize( int* width, int* height ) const |
e9576ca5 | 468 | { |
e40298d5 JS |
469 | *width = m_maxX-m_minX; |
470 | *height = m_maxY-m_minY; | |
3dec57ad | 471 | } |
e40298d5 | 472 | |
2f1ae414 | 473 | void wxDC::DoGetSizeMM( int* width, int* height ) const |
e9576ca5 | 474 | { |
e40298d5 JS |
475 | int w = 0; |
476 | int h = 0; | |
477 | GetSize( &w, &h ); | |
478 | *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); | |
479 | *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); | |
3dec57ad | 480 | } |
e40298d5 | 481 | |
e9576ca5 SC |
482 | void wxDC::SetTextForeground( const wxColour &col ) |
483 | { | |
3dec57ad SC |
484 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
485 | m_textForegroundColour = col; | |
486 | m_macFontInstalled = false ; | |
487 | } | |
e40298d5 | 488 | |
e9576ca5 SC |
489 | void wxDC::SetTextBackground( const wxColour &col ) |
490 | { | |
3dec57ad SC |
491 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
492 | m_textBackgroundColour = col; | |
493 | m_macFontInstalled = false ; | |
494 | } | |
e40298d5 | 495 | |
e9576ca5 SC |
496 | void wxDC::SetMapMode( int mode ) |
497 | { | |
e40298d5 JS |
498 | switch (mode) |
499 | { | |
e3065973 | 500 | case wxMM_TWIPS: |
e40298d5 JS |
501 | SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); |
502 | break; | |
e3065973 | 503 | case wxMM_POINTS: |
e40298d5 JS |
504 | SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); |
505 | break; | |
e3065973 | 506 | case wxMM_METRIC: |
e40298d5 JS |
507 | SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); |
508 | break; | |
e3065973 | 509 | case wxMM_LOMETRIC: |
e40298d5 JS |
510 | SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); |
511 | break; | |
e9576ca5 | 512 | default: |
e3065973 | 513 | case wxMM_TEXT: |
e40298d5 JS |
514 | SetLogicalScale( 1.0, 1.0 ); |
515 | break; | |
516 | } | |
517 | if (mode != wxMM_TEXT) | |
518 | { | |
519 | m_needComputeScaleX = TRUE; | |
520 | m_needComputeScaleY = TRUE; | |
521 | } | |
3dec57ad | 522 | } |
e40298d5 | 523 | |
e9576ca5 SC |
524 | void wxDC::SetUserScale( double x, double y ) |
525 | { | |
e40298d5 JS |
526 | // allow negative ? -> no |
527 | m_userScaleX = x; | |
528 | m_userScaleY = y; | |
529 | ComputeScaleAndOrigin(); | |
3dec57ad | 530 | } |
e40298d5 | 531 | |
e9576ca5 SC |
532 | void wxDC::SetLogicalScale( double x, double y ) |
533 | { | |
e40298d5 JS |
534 | // allow negative ? |
535 | m_logicalScaleX = x; | |
536 | m_logicalScaleY = y; | |
537 | ComputeScaleAndOrigin(); | |
3dec57ad | 538 | } |
e40298d5 | 539 | |
2f1ae414 | 540 | void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) |
e9576ca5 | 541 | { |
e40298d5 JS |
542 | m_logicalOriginX = x * m_signX; // is this still correct ? |
543 | m_logicalOriginY = y * m_signY; | |
544 | ComputeScaleAndOrigin(); | |
3dec57ad | 545 | } |
e40298d5 | 546 | |
2f1ae414 | 547 | void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) |
e9576ca5 | 548 | { |
e40298d5 JS |
549 | m_externalDeviceOriginX = x; |
550 | m_externalDeviceOriginY = y; | |
551 | ComputeScaleAndOrigin(); | |
3dec57ad | 552 | } |
e40298d5 | 553 | |
3dec57ad | 554 | #if 0 |
e9576ca5 SC |
555 | void wxDC::SetInternalDeviceOrigin( long x, long y ) |
556 | { | |
e40298d5 JS |
557 | m_internalDeviceOriginX = x; |
558 | m_internalDeviceOriginY = y; | |
559 | ComputeScaleAndOrigin(); | |
3dec57ad | 560 | } |
e9576ca5 SC |
561 | void wxDC::GetInternalDeviceOrigin( long *x, long *y ) |
562 | { | |
e40298d5 JS |
563 | if (x) *x = m_internalDeviceOriginX; |
564 | if (y) *y = m_internalDeviceOriginY; | |
3dec57ad SC |
565 | } |
566 | #endif | |
e40298d5 | 567 | |
e9576ca5 SC |
568 | void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) |
569 | { | |
e40298d5 JS |
570 | m_signX = (xLeftRight ? 1 : -1); |
571 | m_signY = (yBottomUp ? -1 : 1); | |
572 | ComputeScaleAndOrigin(); | |
76a5e5d2 | 573 | } |
e40298d5 | 574 | |
2f1ae414 SC |
575 | wxSize wxDC::GetPPI() const |
576 | { | |
577 | return wxSize(72, 72); | |
578 | } | |
e40298d5 | 579 | |
2f1ae414 SC |
580 | int wxDC::GetDepth() const |
581 | { | |
c99d6f99 SC |
582 | if ( IsPortColor( (CGrafPtr) m_macPort ) ) |
583 | { | |
584 | return ( (**GetPortPixMap( (CGrafPtr) m_macPort)).pixelSize ) ; | |
585 | } | |
586 | return 1 ; | |
2f1ae414 | 587 | } |
e40298d5 | 588 | |
3dec57ad | 589 | void wxDC::ComputeScaleAndOrigin() |
e9576ca5 | 590 | { |
e40298d5 JS |
591 | // CMB: copy scale to see if it changes |
592 | double origScaleX = m_scaleX; | |
593 | double origScaleY = m_scaleY; | |
594 | m_scaleX = m_logicalScaleX * m_userScaleX; | |
595 | m_scaleY = m_logicalScaleY * m_userScaleY; | |
596 | m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; | |
597 | m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; | |
598 | // CMB: if scale has changed call SetPen to recalulate the line width | |
599 | if (m_scaleX != origScaleX || m_scaleY != origScaleY) | |
600 | { | |
601 | // this is a bit artificial, but we need to force wxDC to think | |
602 | // the pen has changed | |
603 | wxPen* pen = & GetPen(); | |
604 | wxPen tempPen; | |
605 | m_pen = tempPen; | |
606 | SetPen(* pen); | |
607 | } | |
3dec57ad | 608 | } |
e40298d5 | 609 | |
519cb848 SC |
610 | void wxDC::SetPalette( const wxPalette& palette ) |
611 | { | |
612 | } | |
e40298d5 | 613 | |
519cb848 SC |
614 | void wxDC::SetBackgroundMode( int mode ) |
615 | { | |
e40298d5 | 616 | m_backgroundMode = mode ; |
519cb848 | 617 | } |
e40298d5 | 618 | |
519cb848 SC |
619 | void wxDC::SetFont( const wxFont &font ) |
620 | { | |
3dec57ad SC |
621 | m_font = font; |
622 | m_macFontInstalled = false ; | |
519cb848 | 623 | } |
e40298d5 | 624 | |
519cb848 SC |
625 | void wxDC::SetPen( const wxPen &pen ) |
626 | { | |
e40298d5 JS |
627 | if ( m_pen == pen ) |
628 | return ; | |
629 | m_pen = pen; | |
630 | m_macPenInstalled = false ; | |
519cb848 | 631 | } |
e40298d5 | 632 | |
519cb848 SC |
633 | void wxDC::SetBrush( const wxBrush &brush ) |
634 | { | |
e40298d5 JS |
635 | if (m_brush == brush) |
636 | return; | |
637 | m_brush = brush; | |
638 | m_macBrushInstalled = false ; | |
519cb848 | 639 | } |
e40298d5 | 640 | |
519cb848 SC |
641 | void wxDC::SetBackground( const wxBrush &brush ) |
642 | { | |
e40298d5 JS |
643 | if (m_backgroundBrush == brush) |
644 | return; | |
645 | m_backgroundBrush = brush; | |
646 | if (!m_backgroundBrush.Ok()) | |
647 | return; | |
648 | m_macBrushInstalled = false ; | |
519cb848 | 649 | } |
e40298d5 | 650 | |
519cb848 SC |
651 | void wxDC::SetLogicalFunction( int function ) |
652 | { | |
e40298d5 JS |
653 | if (m_logicalFunction == function) |
654 | return; | |
655 | m_logicalFunction = function ; | |
656 | m_macFontInstalled = false ; | |
657 | m_macBrushInstalled = false ; | |
658 | m_macPenInstalled = false ; | |
519cb848 | 659 | } |
e40298d5 | 660 | |
99030bdf | 661 | extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, |
3a0a5ada | 662 | const wxColour & col, int style); |
e40298d5 | 663 | |
387ebd3e | 664 | bool wxDC::DoFloodFill(wxCoord x, wxCoord y, |
3a0a5ada VS |
665 | const wxColour& col, int style) |
666 | { | |
387ebd3e | 667 | return wxDoFloodFill(this, x, y, col, style); |
71110b40 | 668 | } |
e40298d5 | 669 | |
99030bdf | 670 | bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const |
519cb848 | 671 | { |
3dec57ad SC |
672 | wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") ); |
673 | wxMacPortSetter helper(this) ; | |
3dec57ad | 674 | RGBColor colour; |
7d9d1fd7 | 675 | GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour ); |
3dec57ad SC |
676 | // Convert from Mac colour to wx |
677 | col->Set( colour.red >> 8, | |
e40298d5 JS |
678 | colour.green >> 8, |
679 | colour.blue >> 8); | |
3dec57ad | 680 | return true ; |
519cb848 | 681 | } |
e40298d5 | 682 | |
2f1ae414 | 683 | void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) |
519cb848 | 684 | { |
e40298d5 JS |
685 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
686 | wxMacPortSetter helper(this) ; | |
687 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
688 | { | |
689 | MacInstallPen() ; | |
690 | wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : | |
691 | m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2; | |
7d9d1fd7 SC |
692 | wxCoord xx1 = XLOG2DEVMAC(x1) - offset; |
693 | wxCoord yy1 = YLOG2DEVMAC(y1) - offset; | |
694 | wxCoord xx2 = XLOG2DEVMAC(x2) - offset; | |
695 | wxCoord yy2 = YLOG2DEVMAC(y2) - offset; | |
2301e281 RR |
696 | if ((m_pen.GetCap() == wxCAP_ROUND) && |
697 | (m_pen.GetWidth() <= 1)) | |
e40298d5 JS |
698 | { |
699 | // Implement LAST_NOT for MAC at least for | |
700 | // orthogonal lines. RR. | |
701 | if (xx1 == xx2) | |
702 | { | |
703 | if (yy1 < yy2) | |
704 | yy2--; | |
705 | if (yy1 > yy2) | |
706 | yy2++; | |
707 | } | |
708 | if (yy1 == yy2) | |
709 | { | |
710 | if (xx1 < xx2) | |
711 | xx2--; | |
712 | if (xx1 > xx2) | |
713 | xx2++; | |
714 | } | |
715 | } | |
716 | ::MoveTo(xx1, yy1); | |
717 | ::LineTo(xx2, yy2); | |
718 | } | |
519cb848 | 719 | } |
e40298d5 | 720 | |
2f1ae414 | 721 | void wxDC::DoCrossHair( wxCoord x, wxCoord y ) |
519cb848 | 722 | { |
3dec57ad | 723 | wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") ); |
c1cddfe8 | 724 | wxMacPortSetter helper(this) ; |
3dec57ad SC |
725 | if (m_pen.GetStyle() != wxTRANSPARENT) |
726 | { | |
727 | int w = 0; | |
728 | int h = 0; | |
729 | GetSize( &w, &h ); | |
7d9d1fd7 SC |
730 | wxCoord xx = XLOG2DEVMAC(x); |
731 | wxCoord yy = YLOG2DEVMAC(y); | |
3dec57ad | 732 | MacInstallPen(); |
7d9d1fd7 SC |
733 | ::MoveTo( XLOG2DEVMAC(0), yy ); |
734 | ::LineTo( XLOG2DEVMAC(w), yy ); | |
735 | ::MoveTo( xx, YLOG2DEVMAC(0) ); | |
736 | ::LineTo( xx, YLOG2DEVMAC(h) ); | |
66a09d47 SC |
737 | CalcBoundingBox(x, y); |
738 | CalcBoundingBox(x+w, y+h); | |
3dec57ad SC |
739 | } |
740 | } | |
e40298d5 | 741 | |
3dec57ad | 742 | /* |
e40298d5 JS |
743 | * To draw arcs properly the angles need to be converted from the WX style: |
744 | * Angles start on the +ve X axis and go anti-clockwise (As you would draw on | |
745 | * a normal axis on paper). | |
746 | * TO | |
747 | * the Mac style: | |
748 | * Angles start on the +ve y axis and go clockwise. | |
749 | */ | |
750 | ||
3dec57ad SC |
751 | static double wxConvertWXangleToMACangle(double angle) |
752 | { | |
2beae4b5 SC |
753 | double newAngle = 90 - angle ; |
754 | if ( newAngle < 0 ) | |
755 | newAngle += 360 ; | |
756 | return newAngle ; | |
519cb848 | 757 | } |
e40298d5 | 758 | |
2f1ae414 | 759 | void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, |
e40298d5 JS |
760 | wxCoord x2, wxCoord y2, |
761 | wxCoord xc, wxCoord yc ) | |
519cb848 | 762 | { |
3dec57ad | 763 | wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC")); |
c1cddfe8 | 764 | wxMacPortSetter helper(this) ; |
7d9d1fd7 SC |
765 | wxCoord xx1 = XLOG2DEVMAC(x1); |
766 | wxCoord yy1 = YLOG2DEVMAC(y1); | |
767 | wxCoord xx2 = XLOG2DEVMAC(x2); | |
768 | wxCoord yy2 = YLOG2DEVMAC(y2); | |
769 | wxCoord xxc = XLOG2DEVMAC(xc); | |
770 | wxCoord yyc = YLOG2DEVMAC(yc); | |
3dec57ad SC |
771 | double dx = xx1 - xxc; |
772 | double dy = yy1 - yyc; | |
773 | double radius = sqrt((double)(dx*dx+dy*dy)); | |
774 | wxCoord rad = (wxCoord)radius; | |
775 | double radius1, radius2; | |
3dec57ad SC |
776 | if (xx1 == xx2 && yy1 == yy2) |
777 | { | |
778 | radius1 = 0.0; | |
779 | radius2 = 360.0; | |
780 | } | |
781 | else if (radius == 0.0) | |
782 | { | |
783 | radius1 = radius2 = 0.0; | |
784 | } | |
785 | else | |
786 | { | |
787 | radius1 = (xx1 - xxc == 0) ? | |
788 | (yy1 - yyc < 0) ? 90.0 : -90.0 : | |
e40298d5 JS |
789 | -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; |
790 | radius2 = (xx2 - xxc == 0) ? | |
3dec57ad | 791 | (yy2 - yyc < 0) ? 90.0 : -90.0 : |
e40298d5 JS |
792 | -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; |
793 | } | |
794 | wxCoord alpha2 = wxCoord(radius2 - radius1); | |
3dec57ad | 795 | wxCoord alpha1 = wxCoord(wxConvertWXangleToMACangle(radius1)); |
e40298d5 | 796 | if( (xx1 > xx2) || (yy1 > yy2) ) { |
3dec57ad SC |
797 | alpha2 *= -1; |
798 | } | |
3dec57ad | 799 | Rect r = { yyc - rad, xxc - rad, yyc + rad, xxc + rad }; |
3dec57ad SC |
800 | if(m_brush.GetStyle() != wxTRANSPARENT) { |
801 | MacInstallBrush(); | |
802 | PaintArc(&r, alpha1, alpha2); | |
803 | } | |
804 | if(m_pen.GetStyle() != wxTRANSPARENT) { | |
805 | MacInstallPen(); | |
806 | FrameArc(&r, alpha1, alpha2); | |
807 | } | |
519cb848 | 808 | } |
e40298d5 | 809 | |
2f1ae414 | 810 | void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
e40298d5 | 811 | double sa, double ea ) |
519cb848 | 812 | { |
3dec57ad | 813 | wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC")); |
c1cddfe8 | 814 | wxMacPortSetter helper(this) ; |
3dec57ad SC |
815 | Rect r; |
816 | double angle = sa - ea; // Order important Mac in opposite direction to wx | |
2beae4b5 SC |
817 | // we have to make sure that the filling is always counter-clockwise |
818 | if ( angle > 0 ) | |
819 | angle -= 360 ; | |
7d9d1fd7 SC |
820 | wxCoord xx = XLOG2DEVMAC(x); |
821 | wxCoord yy = YLOG2DEVMAC(y); | |
3dec57ad SC |
822 | wxCoord ww = m_signX * XLOG2DEVREL(w); |
823 | wxCoord hh = m_signY * YLOG2DEVREL(h); | |
3dec57ad SC |
824 | // handle -ve width and/or height |
825 | if (ww < 0) { ww = -ww; xx = xx - ww; } | |
826 | if (hh < 0) { hh = -hh; yy = yy - hh; } | |
3dec57ad | 827 | sa = wxConvertWXangleToMACangle(sa); |
3dec57ad SC |
828 | r.top = yy; |
829 | r.left = xx; | |
830 | r.bottom = yy + hh; | |
831 | r.right = xx + ww; | |
3dec57ad SC |
832 | if(m_brush.GetStyle() != wxTRANSPARENT) { |
833 | MacInstallBrush(); | |
834 | PaintArc(&r, (short)sa, (short)angle); | |
835 | } | |
836 | if(m_pen.GetStyle() != wxTRANSPARENT) { | |
837 | MacInstallPen(); | |
838 | FrameArc(&r, (short)sa, (short)angle); | |
839 | } | |
519cb848 | 840 | } |
e40298d5 | 841 | |
2f1ae414 | 842 | void wxDC::DoDrawPoint( wxCoord x, wxCoord y ) |
519cb848 | 843 | { |
e40298d5 JS |
844 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
845 | wxMacPortSetter helper(this) ; | |
846 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
847 | { | |
99030bdf | 848 | wxCoord xx1 = XLOG2DEVMAC(x); |
7d9d1fd7 | 849 | wxCoord yy1 = YLOG2DEVMAC(y); |
5e420341 SC |
850 | RGBColor pencolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); |
851 | ::SetCPixel( xx1,yy1,&pencolor) ; | |
852 | CalcBoundingBox(x, y); | |
e40298d5 | 853 | } |
519cb848 | 854 | } |
e40298d5 | 855 | |
2f1ae414 | 856 | void wxDC::DoDrawLines(int n, wxPoint points[], |
e40298d5 JS |
857 | wxCoord xoffset, wxCoord yoffset) |
858 | { | |
859 | wxCHECK_RET(Ok(), wxT("Invalid DC")); | |
860 | wxMacPortSetter helper(this) ; | |
861 | if (m_pen.GetStyle() == wxTRANSPARENT) | |
862 | return; | |
863 | MacInstallPen() ; | |
864 | wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : | |
865 | m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ; | |
866 | wxCoord x1, x2 , y1 , y2 ; | |
867 | x1 = XLOG2DEVMAC(points[0].x + xoffset); | |
868 | y1 = YLOG2DEVMAC(points[0].y + yoffset); | |
869 | ::MoveTo(x1 - offset, y1 - offset ); | |
870 | for (int i = 0; i < n-1; i++) | |
871 | { | |
872 | x2 = XLOG2DEVMAC(points[i+1].x + xoffset); | |
873 | y2 = YLOG2DEVMAC(points[i+1].y + yoffset); | |
874 | ::LineTo( x2 - offset, y2 - offset ); | |
875 | } | |
519cb848 | 876 | } |
e40298d5 | 877 | |
2f1ae414 | 878 | void wxDC::DoDrawPolygon(int n, wxPoint points[], |
d84afea9 GD |
879 | wxCoord xoffset, wxCoord yoffset, |
880 | int fillStyle ) | |
519cb848 | 881 | { |
e40298d5 JS |
882 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
883 | wxMacPortSetter helper(this) ; | |
884 | wxCoord x1, x2 , y1 , y2 ; | |
75f7bc3b SC |
885 | if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) |
886 | return ; | |
e40298d5 JS |
887 | PolyHandle polygon = OpenPoly(); |
888 | x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset); | |
889 | y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset); | |
890 | ::MoveTo(x1,y1); | |
891 | for (int i = 1; i < n; i++) | |
892 | { | |
893 | x2 = XLOG2DEVMAC(points[i].x + xoffset); | |
894 | y2 = YLOG2DEVMAC(points[i].y + yoffset); | |
895 | ::LineTo(x2, y2); | |
896 | } | |
76a5e5d2 SC |
897 | // close the polyline if necessary |
898 | if ( x1 != x2 || y1 != y2 ) | |
899 | { | |
900 | ::LineTo(x1,y1 ) ; | |
901 | } | |
e40298d5 JS |
902 | ClosePoly(); |
903 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
904 | { | |
905 | MacInstallBrush(); | |
906 | ::PaintPoly( polygon ); | |
907 | } | |
908 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
909 | { | |
910 | MacInstallPen() ; | |
911 | ::FramePoly( polygon ) ; | |
912 | } | |
913 | KillPoly( polygon ); | |
519cb848 | 914 | } |
e40298d5 | 915 | |
3dec57ad | 916 | void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
519cb848 | 917 | { |
3dec57ad SC |
918 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
919 | wxMacPortSetter helper(this) ; | |
e40298d5 JS |
920 | wxCoord xx = XLOG2DEVMAC(x); |
921 | wxCoord yy = YLOG2DEVMAC(y); | |
922 | wxCoord ww = m_signX * XLOG2DEVREL(width); | |
923 | wxCoord hh = m_signY * YLOG2DEVREL(height); | |
924 | // CMB: draw nothing if transformed w or h is 0 | |
925 | if (ww == 0 || hh == 0) | |
926 | return; | |
927 | // CMB: handle -ve width and/or height | |
928 | if (ww < 0) | |
929 | { | |
930 | ww = -ww; | |
931 | xx = xx - ww; | |
932 | } | |
933 | if (hh < 0) | |
934 | { | |
935 | hh = -hh; | |
936 | yy = yy - hh; | |
937 | } | |
938 | Rect rect = { yy , xx , yy + hh , xx + ww } ; | |
939 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
940 | { | |
941 | MacInstallBrush() ; | |
942 | ::PaintRect( &rect ) ; | |
943 | } | |
944 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
945 | { | |
946 | MacInstallPen() ; | |
947 | ::FrameRect( &rect ) ; | |
948 | } | |
519cb848 | 949 | } |
e40298d5 | 950 | |
2f1ae414 | 951 | void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, |
e40298d5 JS |
952 | wxCoord width, wxCoord height, |
953 | double radius) | |
519cb848 | 954 | { |
3dec57ad SC |
955 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
956 | wxMacPortSetter helper(this) ; | |
99030bdf | 957 | if (radius < 0.0) |
e40298d5 JS |
958 | radius = - radius * ((width < height) ? width : height); |
959 | wxCoord xx = XLOG2DEVMAC(x); | |
960 | wxCoord yy = YLOG2DEVMAC(y); | |
961 | wxCoord ww = m_signX * XLOG2DEVREL(width); | |
962 | wxCoord hh = m_signY * YLOG2DEVREL(height); | |
963 | // CMB: draw nothing if transformed w or h is 0 | |
964 | if (ww == 0 || hh == 0) | |
965 | return; | |
966 | // CMB: handle -ve width and/or height | |
967 | if (ww < 0) | |
968 | { | |
969 | ww = -ww; | |
970 | xx = xx - ww; | |
971 | } | |
972 | if (hh < 0) | |
973 | { | |
974 | hh = -hh; | |
975 | yy = yy - hh; | |
976 | } | |
977 | Rect rect = { yy , xx , yy + hh , xx + ww } ; | |
978 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
979 | { | |
980 | MacInstallBrush() ; | |
981 | ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; | |
982 | } | |
983 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
984 | { | |
985 | MacInstallPen() ; | |
986 | ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; | |
987 | } | |
519cb848 | 988 | } |
e40298d5 | 989 | |
2f1ae414 | 990 | void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
519cb848 | 991 | { |
3dec57ad SC |
992 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
993 | wxMacPortSetter helper(this) ; | |
e40298d5 JS |
994 | wxCoord xx = XLOG2DEVMAC(x); |
995 | wxCoord yy = YLOG2DEVMAC(y); | |
996 | wxCoord ww = m_signX * XLOG2DEVREL(width); | |
997 | wxCoord hh = m_signY * YLOG2DEVREL(height); | |
998 | // CMB: draw nothing if transformed w or h is 0 | |
999 | if (ww == 0 || hh == 0) | |
1000 | return; | |
1001 | // CMB: handle -ve width and/or height | |
1002 | if (ww < 0) | |
1003 | { | |
1004 | ww = -ww; | |
1005 | xx = xx - ww; | |
1006 | } | |
1007 | if (hh < 0) | |
1008 | { | |
1009 | hh = -hh; | |
1010 | yy = yy - hh; | |
1011 | } | |
1012 | Rect rect = { yy , xx , yy + hh , xx + ww } ; | |
1013 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
1014 | { | |
1015 | MacInstallBrush() ; | |
1016 | ::PaintOval( &rect ) ; | |
1017 | } | |
1018 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
1019 | { | |
1020 | MacInstallPen() ; | |
1021 | ::FrameOval( &rect ) ; | |
1022 | } | |
519cb848 SC |
1023 | } |
1024 | ||
99030bdf | 1025 | bool wxDC::CanDrawBitmap(void) const |
519cb848 | 1026 | { |
e40298d5 | 1027 | return true ; |
519cb848 SC |
1028 | } |
1029 | ||
2f1ae414 | 1030 | bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
e40298d5 JS |
1031 | wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, |
1032 | wxCoord xsrcMask, wxCoord ysrcMask ) | |
519cb848 | 1033 | { |
3dec57ad SC |
1034 | wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc")); |
1035 | wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC")); | |
76a5e5d2 SC |
1036 | if ( logical_func == wxNO_OP ) |
1037 | return TRUE ; | |
0cbff120 JS |
1038 | if (xsrcMask == -1 && ysrcMask == -1) |
1039 | { | |
1040 | xsrcMask = xsrc; ysrcMask = ysrc; | |
1041 | } | |
76a5e5d2 | 1042 | // correct the parameter in case this dc does not have a mask at all |
76a5e5d2 SC |
1043 | if ( useMask && !source->m_macMask ) |
1044 | useMask = false ; | |
e40298d5 JS |
1045 | Rect srcrect , dstrect ; |
1046 | srcrect.top = source->YLOG2DEVMAC(ysrc) ; | |
1047 | srcrect.left = source->XLOG2DEVMAC(xsrc) ; | |
1048 | srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; | |
1049 | srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; | |
1050 | dstrect.top = YLOG2DEVMAC(ydest) ; | |
1051 | dstrect.left = XLOG2DEVMAC(xdest) ; | |
1052 | dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; | |
1053 | dstrect.right = XLOG2DEVMAC(xdest + width ) ; | |
76a5e5d2 SC |
1054 | short mode = kUnsupportedMode ; |
1055 | bool invertDestinationFirst = false ; | |
1056 | switch ( logical_func ) | |
1057 | { | |
e40298d5 | 1058 | case wxAND: // src AND dst |
4a95c885 | 1059 | mode = adMin ; // ok |
e40298d5 JS |
1060 | break ; |
1061 | case wxAND_INVERT: // (NOT src) AND dst | |
1062 | mode = notSrcOr ; // ok | |
1063 | break ; | |
1064 | case wxAND_REVERSE:// src AND (NOT dst) | |
1065 | invertDestinationFirst = true ; | |
1066 | mode = srcOr ; | |
1067 | break ; | |
1068 | case wxCLEAR: // 0 | |
1069 | mode = kEmulatedMode ; | |
1070 | break ; | |
1071 | case wxCOPY: // src | |
1072 | mode = srcCopy ; // ok | |
1073 | break ; | |
1074 | case wxEQUIV: // (NOT src) XOR dst | |
1075 | mode = srcXor ; // ok | |
1076 | break ; | |
1077 | case wxINVERT: // NOT dst | |
1078 | mode = kEmulatedMode ; //or hilite ; | |
1079 | break ; | |
1080 | case wxNAND: // (NOT src) OR (NOT dst) | |
1081 | invertDestinationFirst = true ; | |
1082 | mode = srcBic ; | |
1083 | break ; | |
1084 | case wxNOR: // (NOT src) AND (NOT dst) | |
1085 | invertDestinationFirst = true ; | |
1086 | mode = notSrcOr ; | |
1087 | break ; | |
1088 | case wxNO_OP: // dst | |
1089 | mode = kEmulatedMode ; // this has already been handled upon entry | |
1090 | break ; | |
1091 | case wxOR: // src OR dst | |
1092 | mode = notSrcBic ; | |
1093 | break ; | |
1094 | case wxOR_INVERT: // (NOT src) OR dst | |
1095 | mode = srcBic ; | |
1096 | break ; | |
1097 | case wxOR_REVERSE: // src OR (NOT dst) | |
1098 | invertDestinationFirst = true ; | |
1099 | mode = notSrcBic ; | |
1100 | break ; | |
1101 | case wxSET: // 1 | |
1102 | mode = kEmulatedMode ; | |
1103 | break ; | |
1104 | case wxSRC_INVERT: // (NOT src) | |
1105 | mode = notSrcCopy ; // ok | |
1106 | break ; | |
1107 | case wxXOR: // src XOR dst | |
1108 | mode = notSrcXor ; // ok | |
1109 | break ; | |
1110 | default : | |
1111 | break ; | |
76a5e5d2 | 1112 | } |
76a5e5d2 SC |
1113 | if ( mode == kUnsupportedMode ) |
1114 | { | |
427ff662 | 1115 | wxFAIL_MSG(wxT("unsupported blitting mode" )); |
76a5e5d2 SC |
1116 | return FALSE ; |
1117 | } | |
e40298d5 JS |
1118 | CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; |
1119 | PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; | |
1120 | if ( LockPixels(bmappixels) ) | |
1121 | { | |
76a5e5d2 | 1122 | wxMacPortSetter helper(this) ; |
e40298d5 JS |
1123 | if ( source->GetDepth() == 1 ) |
1124 | { | |
1125 | RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ; | |
1126 | RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ; | |
76a5e5d2 SC |
1127 | } |
1128 | else | |
1129 | { | |
1130 | // the modes need this, otherwise we'll end up having really nice colors... | |
e40298d5 JS |
1131 | RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; |
1132 | RGBColor black = { 0,0,0} ; | |
1133 | RGBForeColor( &black ) ; | |
1134 | RGBBackColor( &white ) ; | |
76a5e5d2 | 1135 | } |
e40298d5 JS |
1136 | if ( useMask && source->m_macMask ) |
1137 | { | |
1138 | if ( mode == srcCopy ) | |
1139 | { | |
1140 | if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ) | |
1141 | { | |
1142 | CopyMask( GetPortBitMapForCopyBits( sourcePort ) , | |
1143 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) , | |
1144 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , | |
1145 | &srcrect, &srcrect , &dstrect ) ; | |
1146 | UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; | |
1147 | } | |
1148 | } | |
1149 | else | |
1150 | { | |
1dcbbdcf | 1151 | RgnHandle clipRgn = NewRgn() ; |
76a5e5d2 SC |
1152 | LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; |
1153 | BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; | |
1154 | UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; | |
1dcbbdcf | 1155 | OffsetRgn( clipRgn , -srcrect.left + dstrect.left, -srcrect.top + dstrect.top ) ; |
76a5e5d2 SC |
1156 | if ( mode == kEmulatedMode ) |
1157 | { | |
1158 | Pattern pat ; | |
e40298d5 | 1159 | ::PenPat(GetQDGlobalsBlack(&pat)); |
76a5e5d2 SC |
1160 | if ( logical_func == wxSET ) |
1161 | { | |
1162 | RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; | |
e40298d5 | 1163 | ::RGBForeColor( &col ) ; |
76a5e5d2 SC |
1164 | ::PaintRgn( clipRgn ) ; |
1165 | } | |
1166 | else if ( logical_func == wxCLEAR ) | |
1167 | { | |
1168 | RGBColor col= { 0x0000, 0x0000, 0x0000 } ; | |
e40298d5 | 1169 | ::RGBForeColor( &col ) ; |
76a5e5d2 SC |
1170 | ::PaintRgn( clipRgn ) ; |
1171 | } | |
1172 | else if ( logical_func == wxINVERT ) | |
1173 | { | |
1174 | MacInvertRgn( clipRgn ) ; | |
1175 | } | |
1176 | else | |
1177 | { | |
1178 | for ( int y = 0 ; y < srcrect.right - srcrect.left ; ++y ) | |
1179 | { | |
1180 | for ( int x = 0 ; x < srcrect.bottom - srcrect.top ; ++x ) | |
1181 | { | |
1182 | Point dstPoint = { dstrect.top + y , dstrect.left + x } ; | |
1183 | Point srcPoint = { srcrect.top + y , srcrect.left + x } ; | |
1184 | if ( PtInRgn( dstPoint , clipRgn ) ) | |
1185 | { | |
1186 | RGBColor srcColor ; | |
1187 | RGBColor dstColor ; | |
76a5e5d2 SC |
1188 | SetPort( (GrafPtr) sourcePort ) ; |
1189 | GetCPixel( srcPoint.h , srcPoint.v , &srcColor) ; | |
1190 | SetPort( (GrafPtr) m_macPort ) ; | |
1191 | GetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
76a5e5d2 SC |
1192 | wxMacCalculateColour( logical_func , srcColor , dstColor ) ; |
1193 | SetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
1194 | } | |
1195 | } | |
1196 | } | |
76a5e5d2 SC |
1197 | } |
1198 | } | |
1199 | else | |
1200 | { | |
1201 | if ( invertDestinationFirst ) | |
1202 | { | |
1203 | MacInvertRgn( clipRgn ) ; | |
1204 | } | |
e40298d5 JS |
1205 | CopyBits( GetPortBitMapForCopyBits( sourcePort ) , |
1206 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , | |
1207 | &srcrect, &dstrect, mode, clipRgn ) ; | |
1208 | } | |
1209 | DisposeRgn( clipRgn ) ; | |
1210 | } | |
1211 | } | |
1212 | else | |
1213 | { | |
0d54461f SC |
1214 | RgnHandle clipRgn = NewRgn() ; |
1215 | SetRectRgn( clipRgn , dstrect.left , dstrect.top , dstrect.right , dstrect.bottom ) ; | |
e40298d5 JS |
1216 | if ( mode == kEmulatedMode ) |
1217 | { | |
0d54461f | 1218 | Pattern pat ; |
e40298d5 | 1219 | ::PenPat(GetQDGlobalsBlack(&pat)); |
0d54461f SC |
1220 | if ( logical_func == wxSET ) |
1221 | { | |
1222 | RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; | |
e40298d5 | 1223 | ::RGBForeColor( &col ) ; |
0d54461f SC |
1224 | ::PaintRgn( clipRgn ) ; |
1225 | } | |
1226 | else if ( logical_func == wxCLEAR ) | |
1227 | { | |
1228 | RGBColor col= { 0x0000, 0x0000, 0x0000 } ; | |
e40298d5 | 1229 | ::RGBForeColor( &col ) ; |
0d54461f SC |
1230 | ::PaintRgn( clipRgn ) ; |
1231 | } | |
1232 | else if ( logical_func == wxINVERT ) | |
1233 | { | |
1234 | MacInvertRgn( clipRgn ) ; | |
1235 | } | |
1236 | else | |
1237 | { | |
1238 | for ( int y = 0 ; y < srcrect.right - srcrect.left ; ++y ) | |
1239 | { | |
1240 | for ( int x = 0 ; x < srcrect.bottom - srcrect.top ; ++x ) | |
1241 | { | |
1242 | Point dstPoint = { dstrect.top + y , dstrect.left + x } ; | |
1243 | Point srcPoint = { srcrect.top + y , srcrect.left + x } ; | |
0d54461f SC |
1244 | { |
1245 | RGBColor srcColor ; | |
1246 | RGBColor dstColor ; | |
0d54461f SC |
1247 | SetPort( (GrafPtr) sourcePort ) ; |
1248 | GetCPixel( srcPoint.h , srcPoint.v , &srcColor) ; | |
1249 | SetPort( (GrafPtr) m_macPort ) ; | |
1250 | GetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
0d54461f SC |
1251 | wxMacCalculateColour( logical_func , srcColor , dstColor ) ; |
1252 | SetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
1253 | } | |
1254 | } | |
1255 | } | |
1256 | } | |
e40298d5 JS |
1257 | } |
1258 | else | |
1259 | { | |
0d54461f SC |
1260 | if ( invertDestinationFirst ) |
1261 | { | |
1262 | MacInvertRgn( clipRgn ) ; | |
1263 | } | |
e40298d5 JS |
1264 | CopyBits( GetPortBitMapForCopyBits( sourcePort ) , |
1265 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , | |
1266 | &srcrect, &dstrect, mode, NULL ) ; | |
1267 | } | |
1268 | DisposeRgn( clipRgn ) ; | |
1269 | } | |
1270 | UnlockPixels( bmappixels ) ; | |
1271 | } | |
1272 | m_macPenInstalled = false ; | |
1273 | m_macBrushInstalled = false ; | |
1274 | m_macFontInstalled = false ; | |
1275 | return TRUE; | |
1276 | } | |
1277 | ||
1278 | inline Fixed IntToFixed( int inInt ) | |
1279 | { | |
1280 | return (((SInt32) inInt) << 16); | |
1281 | } | |
1282 | ||
1283 | inline int FixedToInt( Fixed inFixed ) | |
1284 | { | |
1285 | return (((SInt32) inFixed) >> 16); | |
1286 | } | |
2beae4b5 | 1287 | |
66a09d47 | 1288 | void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, |
3dec57ad | 1289 | double angle) |
2f1ae414 | 1290 | { |
3dec57ad | 1291 | wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") ); |
32907dbd | 1292 | if (angle == 0.0 ) |
3dec57ad | 1293 | { |
66a09d47 | 1294 | DrawText(str, x, y); |
3dec57ad SC |
1295 | return; |
1296 | } | |
32907dbd SC |
1297 | if ( str.Length() == 0 ) |
1298 | return ; | |
427ff662 | 1299 | |
3dec57ad | 1300 | wxMacPortSetter helper(this) ; |
66a09d47 | 1301 | MacInstallFont() ; |
427ff662 | 1302 | |
e40298d5 | 1303 | wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; |
66a09d47 | 1304 | if ( 0 ) |
3dec57ad | 1305 | { |
66a09d47 | 1306 | m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); |
3340066a | 1307 | SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * font->m_macFontSize)); |
66a09d47 | 1308 | m_macAliasWasEnabled = true ; |
3dec57ad | 1309 | } |
66a09d47 | 1310 | OSStatus status = noErr ; |
427ff662 SC |
1311 | ATSUTextLayout atsuLayout ; |
1312 | UniCharCount chars = str.Length() ; | |
1313 | #if wxUSE_UNICODE | |
1314 | status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 , | |
1315 | &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; | |
1316 | #else | |
e40298d5 | 1317 | TECObjectRef ec; |
427ff662 SC |
1318 | status = TECCreateConverter(&ec, |
1319 | wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); | |
1320 | ||
1321 | wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ; | |
66a09d47 | 1322 | ByteCount byteOutLen ; |
427ff662 | 1323 | ByteCount byteInLen = str.Length() ; |
66a09d47 SC |
1324 | ByteCount byteBufferLen = byteInLen *2 ; |
1325 | char* buf = new char[byteBufferLen] ; | |
427ff662 | 1326 | status = TECConvertText(ec, (ConstTextPtr)str.c_str() , byteInLen, &byteInLen, |
e40298d5 | 1327 | (TextPtr)buf, byteBufferLen, &byteOutLen); |
427ff662 | 1328 | wxASSERT_MSG( status == noErr , wxT("couldn't convert text") ) ; |
e40298d5 | 1329 | status = TECDisposeConverter(ec); |
427ff662 | 1330 | wxASSERT_MSG( status == noErr , wxT("couldn't dispose converter") ) ; |
66a09d47 SC |
1331 | status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 , |
1332 | &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; | |
427ff662 SC |
1333 | #endif |
1334 | wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); | |
3340066a | 1335 | int iAngle = int( angle ); |
2beae4b5 SC |
1336 | int drawX = XLOG2DEVMAC(x) ; |
1337 | int drawY = YLOG2DEVMAC(y) ; | |
1338 | ||
1339 | ATSUTextMeasurement textBefore ; | |
1340 | ATSUTextMeasurement textAfter ; | |
1341 | ATSUTextMeasurement ascent ; | |
1342 | ATSUTextMeasurement descent ; | |
1343 | ||
1344 | ||
3340066a | 1345 | if ( abs(iAngle) > 0 ) |
32907dbd | 1346 | { |
3340066a | 1347 | Fixed atsuAngle = IntToFixed( iAngle ) ; |
e40298d5 JS |
1348 | ATSUAttributeTag atsuTags[] = |
1349 | { | |
1350 | kATSULineRotationTag , | |
1351 | } ; | |
1352 | ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = | |
1353 | { | |
1354 | sizeof( Fixed ) , | |
1355 | } ; | |
1356 | ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = | |
1357 | { | |
1358 | &atsuAngle , | |
1359 | } ; | |
1360 | status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), | |
1361 | atsuTags, atsuSizes, atsuValues ) ; | |
1362 | } | |
1363 | status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, | |
1364 | &textBefore , &textAfter, &ascent , &descent ); | |
2beae4b5 SC |
1365 | |
1366 | drawX += sin(angle/RAD2DEG) * FixedToInt(ascent) ; | |
1367 | drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; | |
32907dbd | 1368 | status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, |
e40298d5 | 1369 | IntToFixed(drawX) , IntToFixed(drawY) ); |
427ff662 | 1370 | wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") ); |
66a09d47 | 1371 | Rect rect ; |
e40298d5 JS |
1372 | status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, |
1373 | IntToFixed(drawX) , IntToFixed(drawY) , &rect ); | |
427ff662 | 1374 | wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") ); |
66a09d47 SC |
1375 | OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; |
1376 | CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); | |
1377 | CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); | |
1378 | ::ATSUDisposeTextLayout(atsuLayout); | |
427ff662 SC |
1379 | #if wxUSE_UNICODE |
1380 | #else | |
66a09d47 | 1381 | delete[] buf ; |
427ff662 | 1382 | #endif |
2f1ae414 | 1383 | } |
e40298d5 | 1384 | |
2f1ae414 | 1385 | void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) |
99030bdf | 1386 | { |
3dec57ad SC |
1387 | wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC")); |
1388 | wxMacPortSetter helper(this) ; | |
e40298d5 JS |
1389 | long xx = XLOG2DEVMAC(x); |
1390 | long yy = YLOG2DEVMAC(y); | |
99030bdf | 1391 | #if TARGET_CARBON |
e40298d5 | 1392 | bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; |
4a95c885 | 1393 | if ( IsKindOf(CLASSINFO( wxPrinterDC ) ) || m_font.GetNoAntiAliasing() ) |
e40298d5 | 1394 | useDrawThemeText = false ; |
6606ecac | 1395 | #endif |
e40298d5 | 1396 | MacInstallFont() ; |
99030bdf | 1397 | if ( 0 ) |
66a09d47 SC |
1398 | { |
1399 | m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); | |
1400 | SetAntiAliasedTextEnabled(true, 8); | |
1401 | m_macAliasWasEnabled = true ; | |
1402 | } | |
e40298d5 JS |
1403 | FontInfo fi ; |
1404 | ::GetFontInfo( &fi ) ; | |
99030bdf | 1405 | #if TARGET_CARBON |
e40298d5 | 1406 | if ( !useDrawThemeText ) |
6606ecac | 1407 | #endif |
e40298d5 JS |
1408 | yy += fi.ascent ; |
1409 | ::MoveTo( xx , yy ); | |
1410 | if ( m_backgroundMode == wxTRANSPARENT ) | |
1411 | { | |
1412 | ::TextMode( srcOr) ; | |
1413 | } | |
1414 | else | |
1415 | { | |
1416 | ::TextMode( srcCopy ) ; | |
1417 | } | |
427ff662 SC |
1418 | int length = strtext.Length() ; |
1419 | ||
e40298d5 JS |
1420 | int laststop = 0 ; |
1421 | int i = 0 ; | |
1422 | int line = 0 ; | |
1423 | { | |
1424 | while( i < length ) | |
1425 | { | |
427ff662 | 1426 | if( strtext[i] == 13 || strtext[i] == 10) |
e40298d5 | 1427 | { |
427ff662 | 1428 | wxString linetext = strtext.Mid( laststop , i - laststop ) ; |
6606ecac | 1429 | #if TARGET_CARBON |
e40298d5 JS |
1430 | if ( useDrawThemeText ) |
1431 | { | |
1432 | Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; | |
427ff662 | 1433 | wxMacCFStringHolder mString( linetext ) ; |
e40298d5 JS |
1434 | if ( m_backgroundMode != wxTRANSPARENT ) |
1435 | { | |
1436 | Point bounds={0,0} ; | |
1437 | Rect background = frame ; | |
1438 | SInt16 baseline ; | |
1439 | ::GetThemeTextDimensions( mString, | |
1440 | kThemeCurrentPortFont, | |
1441 | kThemeStateActive, | |
1442 | false, | |
1443 | &bounds, | |
1444 | &baseline ); | |
1445 | background.right = background.left + bounds.h ; | |
1446 | background.bottom = background.top + bounds.v ; | |
1447 | ::EraseRect( &background ) ; | |
1448 | } | |
1449 | ::DrawThemeTextBox( mString, | |
1450 | kThemeCurrentPortFont, | |
1451 | kThemeStateActive, | |
1452 | false, | |
1453 | &frame, | |
1454 | teJustLeft, | |
1455 | nil ); | |
e40298d5 | 1456 | line++ ; |
32907dbd | 1457 | } |
e40298d5 | 1458 | else |
6606ecac | 1459 | #endif |
e40298d5 | 1460 | { |
427ff662 SC |
1461 | wxCharBuffer text = wxMacStringToCString(linetext) ; |
1462 | ::DrawText( text , 0 , strlen(text) ) ; | |
e40298d5 JS |
1463 | line++ ; |
1464 | ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); | |
1465 | } | |
1466 | laststop = i+1 ; | |
1467 | } | |
1468 | i++ ; | |
1469 | } | |
427ff662 | 1470 | wxString linetext = strtext.Mid( laststop , i - laststop ) ; |
6606ecac | 1471 | #if TARGET_CARBON |
32907dbd | 1472 | if ( useDrawThemeText ) |
e40298d5 JS |
1473 | { |
1474 | Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; | |
427ff662 | 1475 | wxMacCFStringHolder mString( linetext ) ; |
4a95c885 | 1476 | |
5fa00d24 SC |
1477 | if ( m_backgroundMode != wxTRANSPARENT ) |
1478 | { | |
e40298d5 JS |
1479 | Point bounds={0,0} ; |
1480 | Rect background = frame ; | |
1481 | SInt16 baseline ; | |
1482 | ::GetThemeTextDimensions( mString, | |
1483 | kThemeCurrentPortFont, | |
1484 | kThemeStateActive, | |
1485 | false, | |
1486 | &bounds, | |
1487 | &baseline ); | |
1488 | background.right = background.left + bounds.h ; | |
1489 | background.bottom = background.top + bounds.v ; | |
1490 | ::EraseRect( &background ) ; | |
5fa00d24 | 1491 | } |
e40298d5 JS |
1492 | ::DrawThemeTextBox( mString, |
1493 | kThemeCurrentPortFont, | |
1494 | kThemeStateActive, | |
1495 | false, | |
1496 | &frame, | |
1497 | teJustLeft, | |
1498 | nil ); | |
32907dbd SC |
1499 | } |
1500 | else | |
6606ecac | 1501 | #endif |
99030bdf | 1502 | { |
427ff662 SC |
1503 | wxCharBuffer text = wxMacStringToCString(linetext) ; |
1504 | ::DrawText( text , 0 , strlen(text) ) ; | |
1505 | } | |
e40298d5 JS |
1506 | } |
1507 | ::TextMode( srcOr ) ; | |
519cb848 | 1508 | } |
e40298d5 | 1509 | |
99030bdf | 1510 | bool wxDC::CanGetTextExtent() const |
519cb848 | 1511 | { |
e40298d5 JS |
1512 | wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); |
1513 | return true ; | |
519cb848 | 1514 | } |
e40298d5 | 1515 | |
427ff662 | 1516 | void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *height, |
e40298d5 JS |
1517 | wxCoord *descent, wxCoord *externalLeading , |
1518 | wxFont *theFont ) const | |
1519 | { | |
1520 | wxCHECK_RET(Ok(), wxT("Invalid DC")); | |
1521 | wxMacPortSetter helper(this) ; | |
1522 | wxFont formerFont = m_font ; | |
1523 | if ( theFont ) | |
1524 | { | |
1525 | // work around the constness | |
1526 | *((wxFont*)(&m_font)) = *theFont ; | |
1527 | } | |
1528 | MacInstallFont() ; | |
1529 | FontInfo fi ; | |
1530 | ::GetFontInfo( &fi ) ; | |
1531 | #if TARGET_CARBON | |
1532 | bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; | |
4a95c885 | 1533 | if ( IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) |
e40298d5 | 1534 | useGetThemeText = false ; |
f52640f3 | 1535 | #endif |
e40298d5 JS |
1536 | if ( height ) |
1537 | *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; | |
1538 | if ( descent ) | |
1539 | *descent =YDEV2LOGREL( fi.descent ); | |
1540 | if ( externalLeading ) | |
1541 | *externalLeading = YDEV2LOGREL( fi.leading ) ; | |
427ff662 SC |
1542 | int length = strtext.Length() ; |
1543 | /* | |
e40298d5 | 1544 | const char *text = NULL ; |
e40298d5 JS |
1545 | wxString macText ; |
1546 | if ( wxApp::s_macDefaultEncodingIsPC ) | |
1547 | { | |
1548 | macText = wxMacMakeMacStringFromPC( string ) ; | |
1549 | text = macText ; | |
1550 | length = macText.Length() ; | |
1551 | } | |
1552 | else | |
1553 | { | |
1554 | text = string ; | |
1555 | length = string.Length() ; | |
1556 | } | |
427ff662 | 1557 | */ |
e40298d5 JS |
1558 | int laststop = 0 ; |
1559 | int i = 0 ; | |
1560 | int curwidth = 0 ; | |
1561 | if ( width ) | |
1562 | { | |
1563 | *width = 0 ; | |
1564 | while( i < length ) | |
1565 | { | |
427ff662 | 1566 | if( strtext[i] == 13 || strtext[i] == 10) |
e40298d5 | 1567 | { |
427ff662 | 1568 | wxString linetext = strtext.Mid( laststop , i - laststop ) ; |
e40298d5 JS |
1569 | if ( height ) |
1570 | *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; | |
f52640f3 SC |
1571 | #if TARGET_CARBON |
1572 | if ( useGetThemeText ) | |
1573 | { | |
1574 | Point bounds={0,0} ; | |
aee9fe73 | 1575 | SInt16 baseline ; |
427ff662 | 1576 | wxMacCFStringHolder mString( linetext ) ; |
e40298d5 JS |
1577 | ::GetThemeTextDimensions( mString, |
1578 | kThemeCurrentPortFont, | |
1579 | kThemeStateActive, | |
1580 | false, | |
1581 | &bounds, | |
1582 | &baseline ); | |
e40298d5 | 1583 | curwidth = bounds.h ; |
f52640f3 SC |
1584 | } |
1585 | else | |
1586 | #endif | |
1587 | { | |
427ff662 SC |
1588 | wxCharBuffer text = wxMacStringToCString(linetext) ; |
1589 | curwidth = ::TextWidth( text , 0 , strlen(text) ) ; | |
e40298d5 JS |
1590 | } |
1591 | if ( curwidth > *width ) | |
1592 | *width = XDEV2LOGREL( curwidth ) ; | |
1593 | laststop = i+1 ; | |
1594 | } | |
1595 | i++ ; | |
1596 | } | |
1597 | ||
427ff662 | 1598 | wxString linetext = strtext.Mid( laststop , i - laststop ) ; |
f52640f3 SC |
1599 | #if TARGET_CARBON |
1600 | if ( useGetThemeText ) | |
1601 | { | |
1602 | Point bounds={0,0} ; | |
aee9fe73 | 1603 | SInt16 baseline ; |
427ff662 | 1604 | wxMacCFStringHolder mString( linetext ) ; |
e40298d5 JS |
1605 | ::GetThemeTextDimensions( mString, |
1606 | kThemeCurrentPortFont, | |
1607 | kThemeStateActive, | |
1608 | false, | |
1609 | &bounds, | |
1610 | &baseline ); | |
e40298d5 | 1611 | curwidth = bounds.h ; |
f52640f3 SC |
1612 | } |
1613 | else | |
1614 | #endif | |
1615 | { | |
427ff662 SC |
1616 | wxCharBuffer text = wxMacStringToCString(linetext) ; |
1617 | curwidth = ::TextWidth( text , 0 , strlen(text) ) ; | |
e40298d5 JS |
1618 | } |
1619 | if ( curwidth > *width ) | |
1620 | *width = XDEV2LOGREL( curwidth ) ; | |
1621 | } | |
1622 | if ( theFont ) | |
1623 | { | |
1624 | // work around the constness | |
1625 | *((wxFont*)(&m_font)) = formerFont ; | |
1626 | m_macFontInstalled = false ; | |
1627 | } | |
519cb848 | 1628 | } |
e40298d5 | 1629 | |
ee41971c | 1630 | wxCoord wxDC::GetCharWidth(void) const |
519cb848 | 1631 | { |
3dec57ad | 1632 | wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); |
e40298d5 JS |
1633 | wxMacPortSetter helper(this) ; |
1634 | MacInstallFont() ; | |
2beae4b5 SC |
1635 | int width = 0 ; |
1636 | #if TARGET_CARBON | |
e40298d5 JS |
1637 | bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; |
1638 | if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) | |
1639 | useGetThemeText = false ; | |
2beae4b5 | 1640 | #endif |
e40298d5 | 1641 | char text[] = "H" ; |
2beae4b5 SC |
1642 | #if TARGET_CARBON |
1643 | if ( useGetThemeText ) | |
1644 | { | |
1645 | Point bounds={0,0} ; | |
1646 | SInt16 baseline ; | |
1647 | CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ; | |
e40298d5 JS |
1648 | ::GetThemeTextDimensions( mString, |
1649 | kThemeCurrentPortFont, | |
1650 | kThemeStateActive, | |
1651 | false, | |
1652 | &bounds, | |
1653 | &baseline ); | |
1654 | CFRelease( mString ) ; | |
1655 | width = bounds.h ; | |
2beae4b5 SC |
1656 | } |
1657 | else | |
1658 | #endif | |
1659 | { | |
e40298d5 JS |
1660 | width = ::TextWidth( text , 0 , 1 ) ; |
1661 | } | |
1662 | return YDEV2LOGREL(width) ; | |
519cb848 | 1663 | } |
e40298d5 | 1664 | |
ee41971c | 1665 | wxCoord wxDC::GetCharHeight(void) const |
519cb848 | 1666 | { |
3dec57ad | 1667 | wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); |
3dec57ad | 1668 | wxMacPortSetter helper(this) ; |
e40298d5 JS |
1669 | MacInstallFont() ; |
1670 | FontInfo fi ; | |
1671 | ::GetFontInfo( &fi ) ; | |
1672 | return YDEV2LOGREL( fi.descent + fi.ascent ); | |
519cb848 | 1673 | } |
e40298d5 | 1674 | |
519cb848 SC |
1675 | void wxDC::Clear(void) |
1676 | { | |
99030bdf | 1677 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
3dec57ad | 1678 | wxMacPortSetter helper(this) ; |
e40298d5 JS |
1679 | Rect rect = { -31000 , -31000 , 31000 , 31000 } ; |
1680 | if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) | |
1681 | { | |
1682 | ::PenNormal() ; | |
1683 | //MacInstallBrush() ; | |
76a5e5d2 | 1684 | MacSetupBackgroundForCurrentPort( m_backgroundBrush ) ; |
e40298d5 JS |
1685 | ::EraseRect( &rect ) ; |
1686 | } | |
519cb848 | 1687 | } |
e40298d5 | 1688 | |
519cb848 SC |
1689 | void wxDC::MacInstallFont() const |
1690 | { | |
3dec57ad | 1691 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
e40298d5 JS |
1692 | // if ( m_macFontInstalled ) |
1693 | // return ; | |
1694 | Pattern blackColor ; | |
1695 | MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; | |
1696 | wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; | |
1697 | if ( font ) | |
1698 | { | |
1699 | ::TextFont( font->m_macFontNum ) ; | |
1700 | ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; | |
1701 | ::TextFace( font->m_macFontStyle ) ; | |
1702 | m_macFontInstalled = true ; | |
1703 | m_macBrushInstalled = false ; | |
1704 | m_macPenInstalled = false ; | |
1705 | RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); | |
1706 | RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); | |
1707 | ::RGBForeColor( &forecolor ); | |
1708 | ::RGBBackColor( &backcolor ); | |
1709 | } | |
1710 | else | |
1711 | { | |
32907dbd | 1712 | FontFamilyID fontId ; |
e40298d5 JS |
1713 | Str255 fontName ; |
1714 | SInt16 fontSize ; | |
1715 | Style fontStyle ; | |
1716 | GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; | |
32907dbd | 1717 | GetFNum( fontName, &fontId ); |
e40298d5 JS |
1718 | ::TextFont( fontId ) ; |
1719 | ::TextSize( short(m_scaleY * fontSize) ) ; | |
1720 | ::TextFace( fontStyle ) ; | |
1721 | // todo reset after spacing changes - or store the current spacing somewhere | |
1722 | m_macFontInstalled = true ; | |
1723 | m_macBrushInstalled = false ; | |
1724 | m_macPenInstalled = false ; | |
1725 | RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); | |
1726 | RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); | |
1727 | ::RGBForeColor( &forecolor ); | |
1728 | ::RGBBackColor( &backcolor ); | |
1729 | } | |
1730 | short mode = patCopy ; | |
1731 | // todo : | |
1732 | switch( m_logicalFunction ) | |
1733 | { | |
1734 | case wxCOPY: // src | |
1735 | mode = patCopy ; | |
1736 | break ; | |
1737 | case wxINVERT: // NOT dst | |
1738 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
1739 | mode = patXor ; | |
1740 | break ; | |
1741 | case wxXOR: // src XOR dst | |
1742 | mode = patXor ; | |
1743 | break ; | |
1744 | case wxOR_REVERSE: // src OR (NOT dst) | |
1745 | mode = notPatOr ; | |
1746 | break ; | |
1747 | case wxSRC_INVERT: // (NOT src) | |
1748 | mode = notPatCopy ; | |
1749 | break ; | |
4a95c885 SC |
1750 | case wxAND: // src AND dst |
1751 | mode = adMin ; | |
1752 | break ; | |
e40298d5 JS |
1753 | // unsupported TODO |
1754 | case wxCLEAR: // 0 | |
1755 | case wxAND_REVERSE:// src AND (NOT dst) | |
e40298d5 JS |
1756 | case wxAND_INVERT: // (NOT src) AND dst |
1757 | case wxNO_OP: // dst | |
1758 | case wxNOR: // (NOT src) AND (NOT dst) | |
1759 | case wxEQUIV: // (NOT src) XOR dst | |
1760 | case wxOR_INVERT: // (NOT src) OR dst | |
1761 | case wxNAND: // (NOT src) OR (NOT dst) | |
1762 | case wxOR: // src OR dst | |
1763 | case wxSET: // 1 | |
1764 | // case wxSRC_OR: // source _bitmap_ OR destination | |
1765 | // case wxSRC_AND: // source _bitmap_ AND destination | |
1766 | break ; | |
1767 | } | |
1768 | ::PenMode( mode ) ; | |
66a09d47 | 1769 | OSStatus status = noErr ; |
3340066a | 1770 | Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ; |
66a09d47 | 1771 | Style qdStyle = font->m_macFontStyle ; |
e40298d5 | 1772 | ATSUFontID atsuFont = font->m_macATSUFontID ; |
66a09d47 | 1773 | status = ::ATSUCreateStyle(&(ATSUStyle)m_macATSUIStyle) ; |
427ff662 | 1774 | wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; |
e40298d5 JS |
1775 | ATSUAttributeTag atsuTags[] = |
1776 | { | |
1777 | kATSUFontTag , | |
1778 | kATSUSizeTag , | |
1779 | // kATSUColorTag , | |
1780 | // kATSUBaselineClassTag , | |
1781 | kATSUVerticalCharacterTag, | |
1782 | kATSUQDBoldfaceTag , | |
1783 | kATSUQDItalicTag , | |
1784 | kATSUQDUnderlineTag , | |
1785 | kATSUQDCondensedTag , | |
1786 | kATSUQDExtendedTag , | |
1787 | } ; | |
66a09d47 SC |
1788 | ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = |
1789 | { | |
1790 | sizeof( ATSUFontID ) , | |
e40298d5 JS |
1791 | sizeof( Fixed ) , |
1792 | // sizeof( RGBColor ) , | |
1793 | // sizeof( BslnBaselineClass ) , | |
1794 | sizeof( ATSUVerticalCharacterType), | |
1795 | sizeof( Boolean ) , | |
1796 | sizeof( Boolean ) , | |
1797 | sizeof( Boolean ) , | |
1798 | sizeof( Boolean ) , | |
1799 | sizeof( Boolean ) , | |
66a09d47 | 1800 | } ; |
66a09d47 SC |
1801 | Boolean kTrue = true ; |
1802 | Boolean kFalse = false ; | |
32907dbd | 1803 | BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; |
32907dbd | 1804 | ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; |
e40298d5 JS |
1805 | ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = |
1806 | { | |
1807 | &atsuFont , | |
1808 | &atsuSize , | |
1809 | // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) , | |
1810 | // &kBaselineDefault , | |
1811 | &kHorizontal, | |
1812 | (qdStyle & bold) ? &kTrue : &kFalse , | |
1813 | (qdStyle & italic) ? &kTrue : &kFalse , | |
1814 | (qdStyle & underline) ? &kTrue : &kFalse , | |
1815 | (qdStyle & condense) ? &kTrue : &kFalse , | |
1816 | (qdStyle & extend) ? &kTrue : &kFalse , | |
1817 | } ; | |
1818 | status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), | |
1819 | atsuTags, atsuSizes, atsuValues); | |
427ff662 | 1820 | wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ; |
519cb848 | 1821 | } |
e40298d5 | 1822 | |
ffd67837 | 1823 | Pattern gHatchPatterns[] = |
99030bdf | 1824 | { |
e40298d5 JS |
1825 | { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, |
1826 | { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, | |
1827 | { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, | |
1828 | { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, | |
1829 | { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, | |
1830 | { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, | |
1831 | { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } | |
ffd67837 | 1832 | } ; |
e40298d5 | 1833 | |
519cb848 SC |
1834 | static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) |
1835 | { | |
e40298d5 JS |
1836 | int theIndex = 1 ; |
1837 | switch(hatchStyle) | |
1838 | { | |
1839 | case wxBDIAGONAL_HATCH: | |
1840 | theIndex = 2; | |
1841 | break; | |
1842 | case wxFDIAGONAL_HATCH: | |
1843 | theIndex = 3; | |
1844 | break; | |
1845 | case wxCROSS_HATCH: | |
1846 | theIndex = 4; | |
1847 | break; | |
1848 | case wxHORIZONTAL_HATCH: | |
1849 | theIndex = 5; | |
1850 | break; | |
1851 | case wxVERTICAL_HATCH: | |
1852 | theIndex = 6; | |
1853 | break; | |
1854 | case wxCROSSDIAG_HATCH: | |
1855 | theIndex = 7; | |
1856 | break; | |
1857 | default: | |
1858 | theIndex = 1; // solid pattern | |
1859 | break; | |
1860 | } | |
1861 | *pattern = gHatchPatterns[theIndex-1] ; | |
519cb848 | 1862 | } |
e40298d5 | 1863 | |
519cb848 SC |
1864 | void wxDC::MacInstallPen() const |
1865 | { | |
3dec57ad | 1866 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
e40298d5 JS |
1867 | Pattern blackColor; |
1868 | // if ( m_macPenInstalled ) | |
1869 | // return ; | |
1870 | RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); | |
1871 | RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()); | |
1872 | ::RGBForeColor( &forecolor ); | |
1873 | ::RGBBackColor( &backcolor ); | |
1874 | ::PenNormal() ; | |
1875 | int penWidth = m_pen.GetWidth() * (int) m_scaleX ; | |
1876 | // null means only one pixel, at whatever resolution | |
1877 | if ( penWidth == 0 ) | |
1878 | penWidth = 1 ; | |
1879 | ::PenSize(penWidth, penWidth); | |
1880 | int penStyle = m_pen.GetStyle(); | |
1881 | if (penStyle == wxSOLID) | |
1882 | { | |
1883 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
1884 | } | |
1885 | else if (IS_HATCH(penStyle)) | |
1886 | { | |
1887 | Pattern pat ; | |
1888 | wxMacGetHatchPattern(penStyle, &pat); | |
1889 | ::PenPat(&pat); | |
1890 | } | |
1891 | else | |
1892 | { | |
1893 | Pattern pat = *GetQDGlobalsBlack(&blackColor) ; | |
1894 | switch( penStyle ) | |
1895 | { | |
1896 | case wxDOT : | |
1897 | for ( int i = 0 ; i < 8 ; ++i ) | |
1898 | { | |
1899 | pat.pat[i] = 0xCC ; | |
1900 | } | |
1901 | break ; | |
1902 | case wxLONG_DASH : | |
1903 | for ( int i = 0 ; i < 8 ; ++i ) | |
1904 | { | |
1905 | pat.pat[i] = 0xFE ; | |
1906 | } | |
1907 | break ; | |
1908 | case wxSHORT_DASH : | |
1909 | for ( int i = 0 ; i < 8 ; ++i ) | |
1910 | { | |
1911 | pat.pat[i] = 0xEE ; | |
1912 | } | |
1913 | break ; | |
1914 | case wxDOT_DASH : | |
1915 | for ( int i = 0 ; i < 8 ; ++i ) | |
1916 | { | |
1917 | pat.pat[i] = 0x6F ; | |
1918 | } | |
1919 | break ; | |
1920 | case wxUSER_DASH : | |
1921 | { | |
1922 | wxDash* dash ; | |
1923 | m_pen.GetDashes(&dash) ; | |
1924 | // right now we don't allocate larger pixmaps | |
1925 | // int number = | |
1926 | m_pen.GetDashes(&dash) ; | |
1ff301c4 SC |
1927 | for ( int i = 0 ; i < 8 ; ++i ) |
1928 | { | |
e40298d5 | 1929 | pat.pat[i] = dash[0] ; |
1ff301c4 | 1930 | } |
e40298d5 JS |
1931 | } |
1932 | break ; | |
1933 | } | |
1934 | ::PenPat(&pat); | |
1935 | } | |
1936 | short mode = patCopy ; | |
1937 | // todo : | |
1938 | switch( m_logicalFunction ) | |
1939 | { | |
1940 | case wxCOPY: // only foreground color, leave background (thus not patCopy) | |
1941 | mode = patOr ; | |
1942 | break ; | |
1943 | case wxINVERT: // NOT dst | |
1944 | // ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
1945 | mode = patXor ; | |
1946 | break ; | |
1947 | case wxXOR: // src XOR dst | |
1948 | mode = patXor ; | |
1949 | break ; | |
1950 | case wxOR_REVERSE: // src OR (NOT dst) | |
1951 | mode = notPatOr ; | |
1952 | break ; | |
1953 | case wxSRC_INVERT: // (NOT src) | |
1954 | mode = notPatCopy ; | |
1955 | break ; | |
4a95c885 SC |
1956 | case wxAND: // src AND dst |
1957 | mode = adMin ; | |
1958 | break ; | |
e40298d5 JS |
1959 | // unsupported TODO |
1960 | case wxCLEAR: // 0 | |
1961 | case wxAND_REVERSE:// src AND (NOT dst) | |
e40298d5 JS |
1962 | case wxAND_INVERT: // (NOT src) AND dst |
1963 | case wxNO_OP: // dst | |
1964 | case wxNOR: // (NOT src) AND (NOT dst) | |
1965 | case wxEQUIV: // (NOT src) XOR dst | |
1966 | case wxOR_INVERT: // (NOT src) OR dst | |
1967 | case wxNAND: // (NOT src) OR (NOT dst) | |
1968 | case wxOR: // src OR dst | |
1969 | case wxSET: // 1 | |
1970 | // case wxSRC_OR: // source _bitmap_ OR destination | |
1971 | // case wxSRC_AND: // source _bitmap_ AND destination | |
1972 | break ; | |
1973 | } | |
1974 | ::PenMode( mode ) ; | |
1975 | m_macPenInstalled = true ; | |
1976 | m_macBrushInstalled = false ; | |
1977 | m_macFontInstalled = false ; | |
519cb848 | 1978 | } |
e40298d5 | 1979 | |
99030bdf | 1980 | void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background ) |
1dcbbdcf SC |
1981 | { |
1982 | Pattern whiteColor ; | |
7d9d1fd7 SC |
1983 | switch( background.MacGetBrushKind() ) |
1984 | { | |
e40298d5 | 1985 | case kwxMacBrushTheme : |
7d9d1fd7 | 1986 | { |
e40298d5 JS |
1987 | ::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ; |
1988 | break ; | |
7d9d1fd7 | 1989 | } |
e40298d5 | 1990 | case kwxMacBrushThemeBackground : |
7d9d1fd7 | 1991 | { |
e40298d5 JS |
1992 | Rect extent ; |
1993 | ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ; | |
1994 | ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; | |
1995 | break ; | |
7d9d1fd7 | 1996 | } |
e40298d5 | 1997 | case kwxMacBrushColour : |
7d9d1fd7 | 1998 | { |
e40298d5 JS |
1999 | ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) ); |
2000 | int brushStyle = background.GetStyle(); | |
2001 | if (brushStyle == wxSOLID) | |
2002 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
2003 | else if (IS_HATCH(brushStyle)) | |
2004 | { | |
2005 | Pattern pat ; | |
2006 | wxMacGetHatchPattern(brushStyle, &pat); | |
2007 | ::BackPat(&pat); | |
2008 | } | |
2009 | else | |
2010 | { | |
2011 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
2012 | } | |
2013 | break ; | |
7d9d1fd7 SC |
2014 | } |
2015 | } | |
1dcbbdcf | 2016 | } |
e40298d5 | 2017 | |
519cb848 SC |
2018 | void wxDC::MacInstallBrush() const |
2019 | { | |
3dec57ad | 2020 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
e40298d5 JS |
2021 | Pattern blackColor ; |
2022 | // if ( m_macBrushInstalled ) | |
2023 | // return ; | |
2024 | // foreground | |
2025 | bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ; | |
2026 | ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) ); | |
2027 | ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ); | |
2028 | int brushStyle = m_brush.GetStyle(); | |
2029 | if (brushStyle == wxSOLID) | |
2030 | { | |
2031 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
2032 | } | |
2033 | else if (IS_HATCH(brushStyle)) | |
2034 | { | |
2035 | Pattern pat ; | |
2036 | wxMacGetHatchPattern(brushStyle, &pat); | |
2037 | ::PenPat(&pat); | |
2038 | } | |
2039 | else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) | |
2040 | { | |
2041 | // we force this in order to be compliant with wxMSW | |
2042 | backgroundTransparent = false ; | |
2043 | // for these the text fore (and back for MASK_OPAQUE) colors are used | |
2044 | wxBitmap* bitmap = m_brush.GetStipple() ; | |
2045 | int width = bitmap->GetWidth() ; | |
2046 | int height = bitmap->GetHeight() ; | |
76a5e5d2 | 2047 | GWorldPtr gw = NULL ; |
e40298d5 JS |
2048 | if ( m_brush.GetStyle() == wxSTIPPLE ) |
2049 | gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ; | |
2050 | else | |
2051 | gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ; | |
76a5e5d2 SC |
2052 | PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ; |
2053 | LockPixels( gwpixmaphandle ) ; | |
e40298d5 | 2054 | bool isMonochrome = !IsPortColor( gw ) ; |
76a5e5d2 SC |
2055 | if ( !isMonochrome ) |
2056 | { | |
2057 | if ( (**gwpixmaphandle).pixelSize == 1 ) | |
2058 | isMonochrome = true ; | |
2059 | } | |
66a09d47 | 2060 | if ( isMonochrome && width == 8 && height == 8 ) |
e40298d5 JS |
2061 | { |
2062 | ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ); | |
2063 | ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ); | |
76a5e5d2 SC |
2064 | BitMap* gwbitmap = (BitMap*) *gwpixmaphandle ; // since the color depth is 1 it is a BitMap |
2065 | UInt8 *gwbits = (UInt8*) gwbitmap->baseAddr ; | |
2066 | int alignment = gwbitmap->rowBytes & 0x7FFF ; | |
66a09d47 SC |
2067 | Pattern pat ; |
2068 | for ( int i = 0 ; i < 8 ; ++i ) | |
2069 | { | |
2070 | pat.pat[i] = gwbits[i*alignment+0] ; | |
2071 | } | |
2072 | UnlockPixels( GetGWorldPixMap( gw ) ) ; | |
2073 | ::PenPat( &pat ) ; | |
e40298d5 JS |
2074 | } |
2075 | else | |
2076 | { | |
2077 | // this will be the code to handle power of 2 patterns, we will have to arrive at a nice | |
2078 | // caching scheme before putting this into production | |
2079 | Handle image; | |
2080 | long imageSize; | |
2081 | PixPatHandle pixpat = NewPixPat() ; | |
2082 | CopyPixMap(gwpixmaphandle, (**pixpat).patMap); | |
66a09d47 | 2083 | imageSize = GetPixRowBytes((**pixpat).patMap) * |
e40298d5 JS |
2084 | ((**(**pixpat).patMap).bounds.bottom - |
2085 | (**(**pixpat).patMap).bounds.top); | |
66a09d47 SC |
2086 | PtrToHand( (**gwpixmaphandle).baseAddr, &image, imageSize ); |
2087 | (**pixpat).patData = image; | |
2088 | if ( isMonochrome ) | |
2089 | { | |
e40298d5 JS |
2090 | CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ; |
2091 | ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ; | |
2092 | if ( ctspec[0].rgb.red == 0x0000 ) | |
2093 | { | |
2094 | ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; | |
2095 | ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; | |
2096 | } | |
2097 | else | |
2098 | { | |
2099 | ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; | |
2100 | ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; | |
2101 | } | |
2102 | ::CTabChanged( ctable ) ; | |
66a09d47 SC |
2103 | } |
2104 | ::PenPixPat(pixpat); | |
2105 | m_macForegroundPixMap = pixpat ; | |
e40298d5 JS |
2106 | } |
2107 | UnlockPixels( gwpixmaphandle ) ; | |
2108 | } | |
1ff301c4 SC |
2109 | else |
2110 | { | |
e40298d5 JS |
2111 | ::PenPat(GetQDGlobalsBlack(&blackColor)); |
2112 | } | |
2113 | short mode = patCopy ; | |
2114 | switch( m_logicalFunction ) | |
2115 | { | |
2116 | case wxCOPY: // src | |
2117 | if ( backgroundTransparent ) | |
2118 | mode = patOr ; | |
2119 | else | |
2120 | mode = patCopy ; | |
2121 | break ; | |
2122 | case wxINVERT: // NOT dst | |
2123 | if ( !backgroundTransparent ) | |
2124 | { | |
2125 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
2126 | } | |
2127 | mode = patXor ; | |
2128 | break ; | |
2129 | case wxXOR: // src XOR dst | |
2130 | mode = patXor ; | |
2131 | break ; | |
2132 | case wxOR_REVERSE: // src OR (NOT dst) | |
2133 | mode = notPatOr ; | |
2134 | break ; | |
2135 | case wxSRC_INVERT: // (NOT src) | |
2136 | mode = notPatCopy ; | |
2137 | break ; | |
4a95c885 SC |
2138 | case wxAND: // src AND dst |
2139 | mode = adMin ; | |
2140 | break ; | |
e40298d5 JS |
2141 | // unsupported TODO |
2142 | case wxCLEAR: // 0 | |
2143 | case wxAND_REVERSE:// src AND (NOT dst) | |
e40298d5 JS |
2144 | case wxAND_INVERT: // (NOT src) AND dst |
2145 | case wxNO_OP: // dst | |
2146 | case wxNOR: // (NOT src) AND (NOT dst) | |
2147 | case wxEQUIV: // (NOT src) XOR dst | |
2148 | case wxOR_INVERT: // (NOT src) OR dst | |
2149 | case wxNAND: // (NOT src) OR (NOT dst) | |
2150 | case wxOR: // src OR dst | |
2151 | case wxSET: // 1 | |
2152 | // case wxSRC_OR: // source _bitmap_ OR destination | |
2153 | // case wxSRC_AND: // source _bitmap_ AND destination | |
2154 | break ; | |
2155 | } | |
2156 | ::PenMode( mode ) ; | |
2157 | m_macBrushInstalled = true ; | |
2158 | m_macPenInstalled = false ; | |
2159 | m_macFontInstalled = false ; | |
519cb848 | 2160 | } |
e40298d5 | 2161 | |
2f1ae414 SC |
2162 | // --------------------------------------------------------------------------- |
2163 | // coordinates transformations | |
2164 | // --------------------------------------------------------------------------- | |
519cb848 | 2165 | |
2f1ae414 SC |
2166 | wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const |
2167 | { | |
2168 | return ((wxDC *)this)->XDEV2LOG(x); | |
2169 | } | |
e40298d5 | 2170 | |
2f1ae414 SC |
2171 | wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const |
2172 | { | |
2173 | return ((wxDC *)this)->YDEV2LOG(y); | |
2174 | } | |
e40298d5 | 2175 | |
2f1ae414 SC |
2176 | wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const |
2177 | { | |
2178 | return ((wxDC *)this)->XDEV2LOGREL(x); | |
2179 | } | |
e40298d5 | 2180 | |
2f1ae414 SC |
2181 | wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const |
2182 | { | |
2183 | return ((wxDC *)this)->YDEV2LOGREL(y); | |
2184 | } | |
e40298d5 | 2185 | |
2f1ae414 SC |
2186 | wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const |
2187 | { | |
2188 | return ((wxDC *)this)->XLOG2DEV(x); | |
2189 | } | |
e40298d5 | 2190 | |
2f1ae414 SC |
2191 | wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const |
2192 | { | |
2193 | return ((wxDC *)this)->YLOG2DEV(y); | |
2194 | } | |
e40298d5 | 2195 | |
2f1ae414 SC |
2196 | wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const |
2197 | { | |
2198 | return ((wxDC *)this)->XLOG2DEVREL(x); | |
2199 | } | |
e40298d5 | 2200 | |
2f1ae414 SC |
2201 | wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const |
2202 | { | |
2203 | return ((wxDC *)this)->YLOG2DEVREL(y); | |
a7390348 | 2204 | } |