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