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