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