1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dc.h"
16 #include "wx/wxprec.h"
20 #if !wxMAC_USE_CORE_GRAPHICS
22 #include "wx/mac/uma.h"
23 #include "wx/dcmemory.h"
24 #include "wx/dcprint.h"
25 #include "wx/region.h"
34 #include "wx/mac/private.h"
35 #include <ATSUnicode.h>
36 #include <TextCommon.h>
37 #include <TextEncodingConverter.h>
38 #if !USE_SHARED_LIBRARY
39 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 const double RAD2DEG
= 180.0 / M_PI
;
47 const short kEmulatedMode
= -1 ;
48 const short kUnsupportedMode
= -2 ;
50 extern TECObjectRef s_TECNativeCToUnicode
;
52 // set to 0 if problems arise
53 #define wxMAC_EXPERIMENTAL_DC 1
55 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
56 m_ph( (GrafPtr
) dc
->m_macPort
)
58 wxASSERT( dc
->Ok() ) ;
60 dc
->MacSetupPort(&m_ph
) ;
62 wxMacPortSetter::~wxMacPortSetter()
64 m_dc
->MacCleanupPort(&m_ph
) ;
67 #if wxMAC_EXPERIMENTAL_DC
68 class wxMacFastPortSetter
71 wxMacFastPortSetter( const wxDC
*dc
)
73 wxASSERT( dc
->Ok() ) ;
74 m_swapped
= QDSwapPort( (GrafPtr
) dc
->m_macPort
, &m_oldPort
) ;
75 m_clipRgn
= NewRgn() ;
76 GetClip( m_clipRgn
) ;
78 dc
->MacSetupPort( NULL
) ;
80 ~wxMacFastPortSetter()
82 // SetPort( (GrafPtr) m_dc->m_macPort ) ;
83 SetClip( m_clipRgn
) ;
85 SetPort( m_oldPort
) ;
86 m_dc
->MacCleanupPort( NULL
) ;
87 DisposeRgn( m_clipRgn
) ;
97 typedef wxMacPortSetter wxMacFastPortSetter
;
100 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
101 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
103 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
104 m_formerClip
= NewRgn() ;
105 m_newClip
= NewRgn() ;
106 GetClip( m_formerClip
) ;
111 win
->MacWindowToRootWindow( &x
,&y
) ;
112 // get area including focus rect
113 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
114 if ( !EmptyRgn( m_newClip
) )
115 OffsetRgn( m_newClip
, x
, y
) ;
117 SetClip( m_newClip
) ;
121 wxMacWindowClipper::~wxMacWindowClipper()
123 SetPort( m_newPort
) ;
124 SetClip( m_formerClip
) ;
125 DisposeRgn( m_newClip
) ;
126 DisposeRgn( m_formerClip
) ;
129 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
130 wxMacWindowClipper( win
)
132 // the port is already set at this point
133 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
134 GetThemeDrawingState( &m_themeDrawingState
) ;
137 wxMacWindowStateSaver::~wxMacWindowStateSaver()
139 SetPort( m_newPort
) ;
140 SetThemeDrawingState( m_themeDrawingState
, true ) ;
143 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
146 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
147 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
148 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
150 //-----------------------------------------------------------------------------
152 //-----------------------------------------------------------------------------
153 // this function emulates all wx colour manipulations, used to verify the implementation
154 // by setting the mode in the blitting functions to kEmulatedMode
155 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
157 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
159 switch ( logical_func
)
161 case wxAND
: // src AND dst
162 dstColor
.red
= dstColor
.red
& srcColor
.red
;
163 dstColor
.green
= dstColor
.green
& srcColor
.green
;
164 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
166 case wxAND_INVERT
: // (NOT src) AND dst
167 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
168 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
169 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
171 case wxAND_REVERSE
:// src AND (NOT dst)
172 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
173 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
174 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
182 dstColor
.red
= srcColor
.red
;
183 dstColor
.green
= srcColor
.green
;
184 dstColor
.blue
= srcColor
.blue
;
186 case wxEQUIV
: // (NOT src) XOR dst
187 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
188 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
189 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
191 case wxINVERT
: // NOT dst
192 dstColor
.red
= ~dstColor
.red
;
193 dstColor
.green
= ~dstColor
.green
;
194 dstColor
.blue
= ~dstColor
.blue
;
196 case wxNAND
: // (NOT src) OR (NOT dst)
197 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
198 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
199 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
201 case wxNOR
: // (NOT src) AND (NOT dst)
202 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
203 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
204 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
208 case wxOR
: // src OR dst
209 dstColor
.red
= dstColor
.red
| srcColor
.red
;
210 dstColor
.green
= dstColor
.green
| srcColor
.green
;
211 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
213 case wxOR_INVERT
: // (NOT src) OR dst
214 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
215 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
216 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
218 case wxOR_REVERSE
: // src OR (NOT dst)
219 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
220 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
221 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
224 dstColor
.red
= 0xFFFF ;
225 dstColor
.green
= 0xFFFF ;
226 dstColor
.blue
= 0xFFFF ;
228 case wxSRC_INVERT
: // (NOT src)
229 dstColor
.red
= ~srcColor
.red
;
230 dstColor
.green
= ~srcColor
.green
;
231 dstColor
.blue
= ~srcColor
.blue
;
233 case wxXOR
: // src XOR dst
234 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
235 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
236 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
245 m_mm_to_pix_x
= mm2pt
;
246 m_mm_to_pix_y
= mm2pt
;
247 m_internalDeviceOriginX
= 0;
248 m_internalDeviceOriginY
= 0;
249 m_externalDeviceOriginX
= 0;
250 m_externalDeviceOriginY
= 0;
251 m_logicalScaleX
= 1.0;
252 m_logicalScaleY
= 1.0;
257 m_needComputeScaleX
= false;
258 m_needComputeScaleY
= false;
262 m_macFontInstalled
= false ;
263 m_macBrushInstalled
= false ;
264 m_macPenInstalled
= false ;
265 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
266 m_macBoundaryClipRgn
= NewRgn() ;
267 m_macCurrentClipRgn
= NewRgn() ;
268 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
269 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
270 m_pen
= *wxBLACK_PEN
;
271 m_font
= *wxNORMAL_FONT
;
272 m_brush
= *wxWHITE_BRUSH
;
274 // needed to debug possible errors with two active drawing methods at the same time on
276 m_macCurrentPortStateHelper
= NULL
;
278 m_macATSUIStyle
= NULL
;
279 m_macAliasWasEnabled
= false;
280 m_macForegroundPixMap
= NULL
;
281 m_macBackgroundPixMap
= NULL
;
286 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
287 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
290 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
293 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
294 m_macCurrentPortStateHelper
= help
;
296 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
297 #if ! wxMAC_EXPERIMENTAL_DC
298 m_macFontInstalled
= false ;
299 m_macBrushInstalled
= false ;
300 m_macPenInstalled
= false ;
303 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
306 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
307 m_macCurrentPortStateHelper
= NULL
;
309 if( m_macATSUIStyle
)
311 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
312 m_macATSUIStyle
= NULL
;
314 if ( m_macAliasWasEnabled
)
316 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
317 m_macAliasWasEnabled
= false ;
319 if ( m_macForegroundPixMap
)
322 ::PenPat(GetQDGlobalsBlack(&blackColor
));
323 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
324 m_macForegroundPixMap
= NULL
;
326 if ( m_macBackgroundPixMap
)
329 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
330 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
331 m_macBackgroundPixMap
= NULL
;
335 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
337 wxCHECK_RET( Ok(), wxT("invalid window dc") );
338 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
339 wxMacFastPortSetter
helper(this) ;
340 wxCoord xx
= XLOG2DEVMAC(x
);
341 wxCoord yy
= YLOG2DEVMAC(y
);
342 wxCoord w
= bmp
.GetWidth();
343 wxCoord h
= bmp
.GetHeight();
344 wxCoord ww
= XLOG2DEVREL(w
);
345 wxCoord hh
= YLOG2DEVREL(h
);
346 // Set up drawing mode
347 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
348 //m_logicalFunction == wxCLEAR ? WHITENESS :
349 //m_logicalFunction == wxSET ? BLACKNESS :
350 m_logicalFunction
== wxINVERT
? hilite
:
351 //m_logicalFunction == wxAND ? MERGECOPY :
352 m_logicalFunction
== wxOR
? srcOr
:
353 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
354 m_logicalFunction
== wxXOR
? srcXor
:
355 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
356 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
357 //m_logicalFunction == wxSRC_OR ? srcOr :
358 //m_logicalFunction == wxSRC_AND ? SRCAND :
361 GWorldPtr maskworld
= NULL
;
362 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP((WXHBITMAP
*)&maskworld
) );
363 PixMapHandle bmappixels
;
364 // Set foreground and background colours (for bitmaps depth = 1)
365 if(bmp
.GetDepth() == 1)
367 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
368 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
374 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
375 RGBColor black
= { 0,0,0} ;
376 RGBForeColor( &black
) ;
377 RGBBackColor( &white
) ;
379 bmappixels
= GetGWorldPixMap( bmapworld
) ;
380 wxCHECK_RET(LockPixels(bmappixels
),
381 wxT("DoDrawBitmap: Unable to lock pixels"));
382 Rect source
= { 0, 0, h
, w
};
383 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
384 if ( useMask
&& maskworld
)
386 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
))))
390 GetPortBitMapForCopyBits(bmapworld
),
391 GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld
)),
392 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
393 &source
, &source
, &dest
, mode
, NULL
395 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
)));
399 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
400 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
401 &source
, &dest
, mode
, NULL
) ;
403 UnlockPixels( bmappixels
) ;
405 m_macPenInstalled
= false ;
406 m_macBrushInstalled
= false ;
407 m_macFontInstalled
= false ;
410 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
412 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
413 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
414 wxMacFastPortSetter
helper(this) ;
416 wxCoord xx
= XLOG2DEVMAC(x
);
417 wxCoord yy
= YLOG2DEVMAC(y
);
419 Rect r
= { yy
, xx
, yy
+ 32 , xx
+ 32 } ;
420 PlotIconRef( &r
, kAlignNone
, kTransformNone
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
423 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
425 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
426 wxCoord xx
, yy
, ww
, hh
;
429 ww
= XLOG2DEVREL(width
);
430 hh
= YLOG2DEVREL(height
);
431 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
432 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
435 m_clipX1
= wxMax( m_clipX1
, xx
);
436 m_clipY1
= wxMax( m_clipY1
, yy
);
437 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
438 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
450 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
452 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
455 DestroyClippingRegion();
458 wxMacFastPortSetter
helper(this) ;
460 region
.GetBox( x
, y
, w
, h
);
461 wxCoord xx
, yy
, ww
, hh
;
466 // if we have a scaling that we cannot map onto native regions
467 // we must use the box
468 if ( ww
!= w
|| hh
!= h
)
470 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
474 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
475 if ( xx
!= x
|| yy
!= y
)
477 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
479 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
482 m_clipX1
= wxMax( m_clipX1
, xx
);
483 m_clipY1
= wxMax( m_clipY1
, yy
);
484 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
485 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
498 void wxDC::DestroyClippingRegion()
500 wxMacFastPortSetter
helper(this) ;
501 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
505 void wxDC::DoGetSizeMM( int* width
, int* height
) const
510 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
511 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
514 void wxDC::SetTextForeground( const wxColour
&col
)
516 wxCHECK_RET(Ok(), wxT("Invalid DC"));
517 m_textForegroundColour
= col
;
518 m_macFontInstalled
= false ;
521 void wxDC::SetTextBackground( const wxColour
&col
)
523 wxCHECK_RET(Ok(), wxT("Invalid DC"));
524 m_textBackgroundColour
= col
;
525 m_macFontInstalled
= false ;
528 void wxDC::SetMapMode( int mode
)
533 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
536 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
539 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
542 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
546 SetLogicalScale( 1.0, 1.0 );
549 if (mode
!= wxMM_TEXT
)
551 m_needComputeScaleX
= true;
552 m_needComputeScaleY
= true;
556 void wxDC::SetUserScale( double x
, double y
)
558 // allow negative ? -> no
561 ComputeScaleAndOrigin();
564 void wxDC::SetLogicalScale( double x
, double y
)
569 ComputeScaleAndOrigin();
572 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
574 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
575 m_logicalOriginY
= y
* m_signY
;
576 ComputeScaleAndOrigin();
579 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
581 m_externalDeviceOriginX
= x
;
582 m_externalDeviceOriginY
= y
;
583 ComputeScaleAndOrigin();
586 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
588 m_signX
= (xLeftRight
? 1 : -1);
589 m_signY
= (yBottomUp
? -1 : 1);
590 ComputeScaleAndOrigin();
593 wxSize
wxDC::GetPPI() const
595 return wxSize(72, 72);
598 int wxDC::GetDepth() const
600 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
602 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
607 void wxDC::ComputeScaleAndOrigin()
609 // CMB: copy scale to see if it changes
610 double origScaleX
= m_scaleX
;
611 double origScaleY
= m_scaleY
;
612 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
613 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
614 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
615 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
616 // CMB: if scale has changed call SetPen to recalulate the line width
617 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
619 // this is a bit artificial, but we need to force wxDC to think
620 // the pen has changed
627 void wxDC::SetPalette( const wxPalette
& palette
)
631 void wxDC::SetBackgroundMode( int mode
)
633 m_backgroundMode
= mode
;
636 void wxDC::SetFont( const wxFont
&font
)
639 m_macFontInstalled
= false ;
642 void wxDC::SetPen( const wxPen
&pen
)
647 m_macPenInstalled
= false ;
650 void wxDC::SetBrush( const wxBrush
&brush
)
652 if (m_brush
== brush
)
655 m_macBrushInstalled
= false ;
658 void wxDC::SetBackground( const wxBrush
&brush
)
660 if (m_backgroundBrush
== brush
)
662 m_backgroundBrush
= brush
;
663 if (!m_backgroundBrush
.Ok())
665 m_macBrushInstalled
= false ;
668 void wxDC::SetLogicalFunction( int function
)
670 if (m_logicalFunction
== function
)
672 m_logicalFunction
= function
;
673 m_macFontInstalled
= false ;
674 m_macBrushInstalled
= false ;
675 m_macPenInstalled
= false ;
678 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
679 const wxColour
& col
, int style
);
681 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
682 const wxColour
& col
, int style
)
684 return wxDoFloodFill(this, x
, y
, col
, style
);
687 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
689 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
690 wxMacFastPortSetter
helper(this) ;
692 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
693 // Convert from Mac colour to wx
694 col
->Set( colour
.red
>> 8,
700 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
702 wxCHECK_RET(Ok(), wxT("Invalid DC"));
703 wxMacFastPortSetter
helper(this) ;
704 if (m_pen
.GetStyle() != wxTRANSPARENT
)
707 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
708 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
709 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
710 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
711 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
712 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
713 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
714 (m_pen
.GetWidth() <= 1))
716 // Implement LAST_NOT for MAC at least for
717 // orthogonal lines. RR.
738 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
740 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
741 wxMacFastPortSetter
helper(this) ;
742 if (m_pen
.GetStyle() != wxTRANSPARENT
)
747 wxCoord xx
= XLOG2DEVMAC(x
);
748 wxCoord yy
= YLOG2DEVMAC(y
);
750 ::MoveTo( XLOG2DEVMAC(0), yy
);
751 ::LineTo( XLOG2DEVMAC(w
), yy
);
752 ::MoveTo( xx
, YLOG2DEVMAC(0) );
753 ::LineTo( xx
, YLOG2DEVMAC(h
) );
754 CalcBoundingBox(x
, y
);
755 CalcBoundingBox(x
+w
, y
+h
);
760 * To draw arcs properly the angles need to be converted from the WX style:
761 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
762 * a normal axis on paper).
765 * Angles start on the +ve y axis and go clockwise.
768 static double wxConvertWXangleToMACangle(double angle
)
770 double newAngle
= 90 - angle
;
771 while ( newAngle
> 360 ) newAngle
-= 360 ;
772 while ( newAngle
< 0 ) newAngle
+= 360 ;
776 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
777 wxCoord x2
, wxCoord y2
,
778 wxCoord xc
, wxCoord yc
)
780 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
781 wxMacFastPortSetter
helper(this) ;
782 wxCoord xx1
= XLOG2DEVMAC(x1
);
783 wxCoord yy1
= YLOG2DEVMAC(y1
);
784 wxCoord xx2
= XLOG2DEVMAC(x2
);
785 wxCoord yy2
= YLOG2DEVMAC(y2
);
786 wxCoord xxc
= XLOG2DEVMAC(xc
);
787 wxCoord yyc
= YLOG2DEVMAC(yc
);
788 double dx
= xx1
- xxc
;
789 double dy
= yy1
- yyc
;
790 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
791 wxCoord rad
= (wxCoord
)radius
;
792 double radius1
, radius2
;
793 if (xx1
== xx2
&& yy1
== yy2
)
798 else if (radius
== 0.0)
800 radius1
= radius2
= 0.0;
804 radius1
= (xx1
- xxc
== 0) ?
805 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
806 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
807 radius2
= (xx2
- xxc
== 0) ?
808 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
809 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
811 wxCoord alpha2
= wxCoord(radius2
- radius1
);
812 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
813 while( alpha2
< 0 ) alpha2
+= 360 ;
815 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
816 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
818 PaintArc(&r
, alpha1
, alpha2
);
820 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
822 FrameArc(&r
, alpha1
, alpha2
);
826 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
827 double sa
, double ea
)
829 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
830 wxMacFastPortSetter
helper(this) ;
832 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
833 // we have to make sure that the filling is always counter-clockwise
836 wxCoord xx
= XLOG2DEVMAC(x
);
837 wxCoord yy
= YLOG2DEVMAC(y
);
838 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
839 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
840 // handle -ve width and/or height
841 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
842 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
843 sa
= wxConvertWXangleToMACangle(sa
);
848 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
850 PaintArc(&r
, (short)sa
, (short)angle
);
852 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
854 FrameArc(&r
, (short)sa
, (short)angle
);
858 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
860 wxCHECK_RET(Ok(), wxT("Invalid DC"));
861 wxMacFastPortSetter
helper(this) ;
862 if (m_pen
.GetStyle() != wxTRANSPARENT
)
864 wxCoord xx1
= XLOG2DEVMAC(x
);
865 wxCoord yy1
= YLOG2DEVMAC(y
);
866 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
867 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
868 CalcBoundingBox(x
, y
);
872 void wxDC::DoDrawLines(int n
, wxPoint points
[],
873 wxCoord xoffset
, wxCoord yoffset
)
875 wxCHECK_RET(Ok(), wxT("Invalid DC"));
876 wxMacFastPortSetter
helper(this) ;
877 if (m_pen
.GetStyle() == wxTRANSPARENT
)
880 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
881 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
882 wxCoord x1
, x2
, y1
, y2
;
883 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
884 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
885 ::MoveTo(x1
- offset
, y1
- offset
);
886 for (int i
= 0; i
< n
-1; i
++)
888 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
889 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
890 ::LineTo( x2
- offset
, y2
- offset
);
894 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
895 wxCoord xoffset
, wxCoord yoffset
,
898 wxCHECK_RET(Ok(), wxT("Invalid DC"));
899 wxMacFastPortSetter
helper(this) ;
900 wxCoord x1
, x2
, y1
, y2
;
901 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
903 PolyHandle polygon
= OpenPoly();
904 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
905 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
907 for (int i
= 1; i
< n
; i
++)
909 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
910 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
913 // close the polyline if necessary
914 if ( x1
!= x2
|| y1
!= y2
)
919 if (m_brush
.GetStyle() != wxTRANSPARENT
)
922 ::PaintPoly( polygon
);
924 if (m_pen
.GetStyle() != wxTRANSPARENT
)
927 ::FramePoly( polygon
) ;
932 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
934 wxCHECK_RET(Ok(), wxT("Invalid DC"));
935 wxMacFastPortSetter
helper(this) ;
936 wxCoord xx
= XLOG2DEVMAC(x
);
937 wxCoord yy
= YLOG2DEVMAC(y
);
938 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
939 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
940 // CMB: draw nothing if transformed w or h is 0
941 if (ww
== 0 || hh
== 0)
943 // CMB: handle -ve width and/or height
954 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
955 if (m_brush
.GetStyle() != wxTRANSPARENT
)
958 ::PaintRect( &rect
) ;
960 if (m_pen
.GetStyle() != wxTRANSPARENT
)
963 ::FrameRect( &rect
) ;
967 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
968 wxCoord width
, wxCoord height
,
971 wxCHECK_RET(Ok(), wxT("Invalid DC"));
972 wxMacFastPortSetter
helper(this) ;
974 radius
= - radius
* ((width
< height
) ? width
: height
);
975 wxCoord xx
= XLOG2DEVMAC(x
);
976 wxCoord yy
= YLOG2DEVMAC(y
);
977 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
978 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
979 // CMB: draw nothing if transformed w or h is 0
980 if (ww
== 0 || hh
== 0)
982 // CMB: handle -ve width and/or height
993 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
994 if (m_brush
.GetStyle() != wxTRANSPARENT
)
997 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
999 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1002 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1006 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1008 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1009 wxMacFastPortSetter
helper(this) ;
1010 wxCoord xx
= XLOG2DEVMAC(x
);
1011 wxCoord yy
= YLOG2DEVMAC(y
);
1012 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1013 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1014 // CMB: draw nothing if transformed w or h is 0
1015 if (ww
== 0 || hh
== 0)
1017 // CMB: handle -ve width and/or height
1028 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1029 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1032 ::PaintOval( &rect
) ;
1034 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1037 ::FrameOval( &rect
) ;
1041 bool wxDC::CanDrawBitmap(void) const
1046 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1047 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1048 wxCoord xsrcMask
, wxCoord ysrcMask
)
1050 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1051 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1052 if ( logical_func
== wxNO_OP
)
1054 if (xsrcMask
== -1 && ysrcMask
== -1)
1056 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1058 // correct the parameter in case this dc does not have a mask at all
1059 if ( useMask
&& !source
->m_macMask
)
1061 Rect srcrect
, dstrect
;
1062 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1063 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1064 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1065 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1066 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1067 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1068 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1069 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1070 short mode
= kUnsupportedMode
;
1071 bool invertDestinationFirst
= false ;
1072 switch ( logical_func
)
1074 case wxAND
: // src AND dst
1075 mode
= adMin
; // ok
1077 case wxAND_INVERT
: // (NOT src) AND dst
1078 mode
= notSrcOr
; // ok
1080 case wxAND_REVERSE
:// src AND (NOT dst)
1081 invertDestinationFirst
= true ;
1085 mode
= kEmulatedMode
;
1088 mode
= srcCopy
; // ok
1090 case wxEQUIV
: // (NOT src) XOR dst
1091 mode
= srcXor
; // ok
1093 case wxINVERT
: // NOT dst
1094 mode
= kEmulatedMode
; //or hilite ;
1096 case wxNAND
: // (NOT src) OR (NOT dst)
1097 invertDestinationFirst
= true ;
1100 case wxNOR
: // (NOT src) AND (NOT dst)
1101 invertDestinationFirst
= true ;
1104 case wxNO_OP
: // dst
1105 mode
= kEmulatedMode
; // this has already been handled upon entry
1107 case wxOR
: // src OR dst
1110 case wxOR_INVERT
: // (NOT src) OR dst
1113 case wxOR_REVERSE
: // src OR (NOT dst)
1114 invertDestinationFirst
= true ;
1118 mode
= kEmulatedMode
;
1120 case wxSRC_INVERT
: // (NOT src)
1121 mode
= notSrcCopy
; // ok
1123 case wxXOR
: // src XOR dst
1124 mode
= notSrcXor
; // ok
1129 if ( mode
== kUnsupportedMode
)
1131 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1134 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1135 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1136 if ( LockPixels(bmappixels
) )
1138 wxMacFastPortSetter
helper(this) ;
1139 if ( source
->GetDepth() == 1 )
1141 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1142 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1146 // the modes need this, otherwise we'll end up having really nice colors...
1147 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1148 RGBColor black
= { 0,0,0} ;
1149 RGBForeColor( &black
) ;
1150 RGBBackColor( &white
) ;
1152 if ( useMask
&& source
->m_macMask
)
1154 if ( mode
== srcCopy
)
1156 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1158 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1159 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1160 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1161 &srcrect
, &srcrect
, &dstrect
) ;
1162 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1167 RgnHandle clipRgn
= NewRgn() ;
1168 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1169 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1170 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1171 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1172 if ( mode
== kEmulatedMode
)
1175 ::PenPat(GetQDGlobalsBlack(&pat
));
1176 if ( logical_func
== wxSET
)
1178 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1179 ::RGBForeColor( &col
) ;
1180 ::PaintRgn( clipRgn
) ;
1182 else if ( logical_func
== wxCLEAR
)
1184 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1185 ::RGBForeColor( &col
) ;
1186 ::PaintRgn( clipRgn
) ;
1188 else if ( logical_func
== wxINVERT
)
1190 MacInvertRgn( clipRgn
) ;
1194 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1196 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1198 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1199 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1200 if ( PtInRgn( dstPoint
, clipRgn
) )
1204 SetPort( (GrafPtr
) sourcePort
) ;
1205 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1206 SetPort( (GrafPtr
) m_macPort
) ;
1207 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1208 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1209 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1217 if ( invertDestinationFirst
)
1219 MacInvertRgn( clipRgn
) ;
1221 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1222 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1223 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1225 DisposeRgn( clipRgn
) ;
1230 RgnHandle clipRgn
= NewRgn() ;
1231 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1232 if ( mode
== kEmulatedMode
)
1235 ::PenPat(GetQDGlobalsBlack(&pat
));
1236 if ( logical_func
== wxSET
)
1238 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1239 ::RGBForeColor( &col
) ;
1240 ::PaintRgn( clipRgn
) ;
1242 else if ( logical_func
== wxCLEAR
)
1244 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1245 ::RGBForeColor( &col
) ;
1246 ::PaintRgn( clipRgn
) ;
1248 else if ( logical_func
== wxINVERT
)
1250 MacInvertRgn( clipRgn
) ;
1254 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1256 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1258 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1259 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1263 SetPort( (GrafPtr
) sourcePort
) ;
1264 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1265 SetPort( (GrafPtr
) m_macPort
) ;
1266 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1267 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1268 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1276 if ( invertDestinationFirst
)
1278 MacInvertRgn( clipRgn
) ;
1280 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1281 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1282 &srcrect
, &dstrect
, mode
, NULL
) ;
1284 DisposeRgn( clipRgn
) ;
1286 UnlockPixels( bmappixels
) ;
1288 m_macPenInstalled
= false ;
1289 m_macBrushInstalled
= false ;
1290 m_macFontInstalled
= false ;
1294 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1297 // TODO support text background color (only possible by hand, ATSUI does not support it)
1298 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1300 if ( str
.Length() == 0 )
1303 wxMacFastPortSetter
helper(this) ;
1308 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1309 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1310 m_macAliasWasEnabled
= true ;
1312 OSStatus status
= noErr
;
1313 ATSUTextLayout atsuLayout
;
1314 UniCharCount chars
= str
.Length() ;
1315 UniChar
* ubuf
= NULL
;
1316 #if SIZEOF_WCHAR_T == 4
1317 wxMBConvUTF16BE converter
;
1319 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1320 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1321 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1323 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1324 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1325 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1326 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1328 chars
= unicharlen
/ 2 ;
1331 ubuf
= (UniChar
*) str
.wc_str() ;
1333 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1334 chars
= wxWcslen( wchar
.data() ) ;
1335 ubuf
= (UniChar
*) wchar
.data() ;
1339 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1340 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1342 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1343 int iAngle
= int( angle
);
1344 int drawX
= XLOG2DEVMAC(x
) ;
1345 int drawY
= YLOG2DEVMAC(y
) ;
1347 ATSUTextMeasurement textBefore
;
1348 ATSUTextMeasurement textAfter
;
1349 ATSUTextMeasurement ascent
;
1350 ATSUTextMeasurement descent
;
1353 if ( abs(iAngle
) > 0 )
1355 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1356 ATSUAttributeTag atsuTags
[] =
1358 kATSULineRotationTag
,
1360 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1364 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1368 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1369 atsuTags
, atsuSizes
, atsuValues
) ;
1371 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1372 &textBefore
, &textAfter
, &ascent
, &descent
);
1374 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1375 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1376 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1377 IntToFixed(drawX
) , IntToFixed(drawY
) );
1378 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1380 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1381 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1382 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1383 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1384 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1385 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1386 ::ATSUDisposeTextLayout(atsuLayout
);
1387 #if SIZEOF_WCHAR_T == 4
1392 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1394 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1396 wxMacFastPortSetter
helper(this) ;
1397 long xx
= XLOG2DEVMAC(x
);
1398 long yy
= YLOG2DEVMAC(y
);
1400 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1401 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1402 useDrawThemeText
= false ;
1407 ::GetFontInfo( &fi
) ;
1409 if ( !useDrawThemeText
)
1412 ::MoveTo( xx
, yy
);
1413 if ( m_backgroundMode
== wxTRANSPARENT
)
1415 ::TextMode( srcOr
) ;
1419 ::TextMode( srcCopy
) ;
1423 wxString linetext
= strtext
;
1425 if ( useDrawThemeText
)
1427 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1428 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1430 if ( m_backgroundMode
!= wxTRANSPARENT
)
1432 Point bounds
={0,0} ;
1433 Rect background
= frame
;
1435 ::GetThemeTextDimensions( mString
,
1436 m_font
.MacGetThemeFontID() ,
1441 background
.right
= background
.left
+ bounds
.h
;
1442 background
.bottom
= background
.top
+ bounds
.v
;
1443 ::EraseRect( &background
) ;
1445 ::DrawThemeTextBox( mString
,
1446 m_font
.MacGetThemeFontID() ,
1456 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1457 ::DrawText( text
, 0 , strlen(text
) ) ;
1460 ::TextMode( srcOr
) ;
1463 bool wxDC::CanGetTextExtent() const
1465 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1469 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1470 wxCoord
*descent
, wxCoord
*externalLeading
,
1471 wxFont
*theFont
) const
1473 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1474 wxMacFastPortSetter
helper(this) ;
1475 wxFont formerFont
= m_font
;
1478 // work around the constness
1479 *((wxFont
*)(&m_font
)) = *theFont
;
1483 ::GetFontInfo( &fi
) ;
1485 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1486 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1487 useGetThemeText
= false ;
1490 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1492 *descent
=YDEV2LOGREL( fi
.descent
);
1493 if ( externalLeading
)
1494 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1500 wxString linetext
= strtext
;
1502 if ( useGetThemeText
)
1504 Point bounds
={0,0} ;
1506 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1507 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1508 ::GetThemeTextDimensions( mString
,
1514 curwidth
= bounds
.h
;
1518 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1519 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1521 if ( curwidth
> *width
)
1522 *width
= XDEV2LOGREL( curwidth
) ;
1526 // work around the constness
1527 *((wxFont
*)(&m_font
)) = formerFont
;
1528 m_macFontInstalled
= false ;
1533 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1535 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1538 widths
.Add(0, text
.Length());
1540 if (text
.Length() == 0)
1543 wxMacFastPortSetter
helper(this) ;
1546 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1547 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1548 useGetThemeText
= false ;
1550 if ( useGetThemeText
)
1552 // If anybody knows how to do this more efficiently yet still handle
1553 // the fractional glyph widths that may be present when using AA
1554 // fonts, please change it. Currently it is measuring from the
1555 // begining of the string for each succeding substring, which is much
1556 // slower than this should be.
1557 for (size_t i
=0; i
<text
.Length(); i
++)
1559 wxString
str(text
.Left(i
+1));
1560 Point bounds
= {0,0};
1562 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1563 ::GetThemeTextDimensions( mString
,
1564 m_font
.MacGetThemeFontID(),
1569 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1575 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1576 size_t len
= strlen(buff
);
1577 short* measurements
= new short[len
+1];
1578 MeasureText(len
, buff
.data(), measurements
);
1580 // Copy to widths, starting at measurements[1]
1581 // NOTE: this doesn't take into account any multi-byte characters
1582 // in buff, it probabkly should...
1583 for (size_t i
=0; i
<text
.Length(); i
++)
1584 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1586 delete [] measurements
;
1594 wxCoord
wxDC::GetCharWidth(void) const
1596 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1597 wxMacFastPortSetter
helper(this) ;
1601 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1602 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1603 useGetThemeText
= false ;
1607 if ( useGetThemeText
)
1609 Point bounds
={0,0} ;
1611 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1612 ::GetThemeTextDimensions( mString
,
1613 m_font
.MacGetThemeFontID(),
1618 CFRelease( mString
) ;
1624 width
= ::TextWidth( text
, 0 , 1 ) ;
1626 return YDEV2LOGREL(width
) ;
1629 wxCoord
wxDC::GetCharHeight(void) const
1631 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1632 wxMacFastPortSetter
helper(this) ;
1635 ::GetFontInfo( &fi
) ;
1636 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1639 void wxDC::Clear(void)
1641 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1642 wxMacFastPortSetter
helper(this) ;
1643 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1644 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1647 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1648 ::EraseRect( &rect
) ;
1652 void wxDC::MacInstallFont() const
1654 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1655 // if ( m_macFontInstalled )
1657 Pattern blackColor
;
1658 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1659 if ( m_backgroundMode
!= wxTRANSPARENT
)
1661 Pattern whiteColor
;
1662 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1665 wxASSERT( m_font
.Ok() ) ;
1668 ::TextFont( m_font
.MacGetFontNum() ) ;
1669 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1670 ::TextFace( m_font
.MacGetFontStyle() ) ;
1671 m_macFontInstalled
= true ;
1672 m_macBrushInstalled
= false ;
1673 m_macPenInstalled
= false ;
1674 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1675 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1676 ::RGBForeColor( &forecolor
);
1677 ::RGBBackColor( &backcolor
);
1679 short mode
= patCopy
;
1681 switch( m_logicalFunction
)
1686 case wxINVERT
: // NOT dst
1687 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1690 case wxXOR
: // src XOR dst
1693 case wxOR_REVERSE
: // src OR (NOT dst)
1696 case wxSRC_INVERT
: // (NOT src)
1699 case wxAND
: // src AND dst
1704 case wxAND_REVERSE
:// src AND (NOT dst)
1705 case wxAND_INVERT
: // (NOT src) AND dst
1706 case wxNO_OP
: // dst
1707 case wxNOR
: // (NOT src) AND (NOT dst)
1708 case wxEQUIV
: // (NOT src) XOR dst
1709 case wxOR_INVERT
: // (NOT src) OR dst
1710 case wxNAND
: // (NOT src) OR (NOT dst)
1711 case wxOR
: // src OR dst
1713 // case wxSRC_OR: // source _bitmap_ OR destination
1714 // case wxSRC_AND: // source _bitmap_ AND destination
1718 OSStatus status
= noErr
;
1719 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1720 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1722 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1723 ATSUAttributeTag atsuTags
[] =
1727 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1731 // Boolean kTrue = true ;
1732 // Boolean kFalse = false ;
1734 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
1735 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1739 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1740 atsuTags
, atsuSizes
, atsuValues
);
1742 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1746 Pattern gPatterns
[] =
1748 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1749 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1750 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1751 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1752 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1753 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1754 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1756 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1757 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1758 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1759 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1762 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1764 int index
= 0; // solid pattern by default
1768 case wxBDIAGONAL_HATCH
: index
= 1; break;
1769 case wxFDIAGONAL_HATCH
: index
= 2; break;
1770 case wxCROSS_HATCH
: index
= 3; break;
1771 case wxHORIZONTAL_HATCH
: index
= 4; break;
1772 case wxVERTICAL_HATCH
: index
= 5; break;
1773 case wxCROSSDIAG_HATCH
: index
= 6; break;
1775 case wxDOT
: index
= 7; break;
1776 case wxLONG_DASH
: index
= 8; break;
1777 case wxSHORT_DASH
: index
= 9; break;
1778 case wxDOT_DASH
: index
= 10; break;
1780 *pattern
= gPatterns
[index
];
1783 void wxDC::MacInstallPen() const
1785 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1786 //Pattern blackColor;
1787 // if ( m_macPenInstalled )
1789 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1790 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1791 ::RGBForeColor( &forecolor
);
1792 ::RGBBackColor( &backcolor
);
1794 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1795 // null means only one pixel, at whatever resolution
1796 if ( penWidth
== 0 )
1798 ::PenSize(penWidth
, penWidth
);
1800 int penStyle
= m_pen
.GetStyle();
1802 if (penStyle
== wxUSER_DASH
)
1804 // FIXME: there should be exactly 8 items in the dash
1806 int number
= m_pen
.GetDashes(&dash
) ;
1808 for ( int i
= 0 ; i
< 8 ; ++i
)
1810 pat
.pat
[i
] = dash
[index
] ;
1811 if (index
< number
- 1)
1817 wxMacGetPattern(penStyle
, &pat
);
1821 short mode
= patCopy
;
1823 switch( m_logicalFunction
)
1825 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1828 case wxINVERT
: // NOT dst
1829 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1832 case wxXOR
: // src XOR dst
1835 case wxOR_REVERSE
: // src OR (NOT dst)
1838 case wxSRC_INVERT
: // (NOT src)
1841 case wxAND
: // src AND dst
1846 case wxAND_REVERSE
:// src AND (NOT dst)
1847 case wxAND_INVERT
: // (NOT src) AND dst
1848 case wxNO_OP
: // dst
1849 case wxNOR
: // (NOT src) AND (NOT dst)
1850 case wxEQUIV
: // (NOT src) XOR dst
1851 case wxOR_INVERT
: // (NOT src) OR dst
1852 case wxNAND
: // (NOT src) OR (NOT dst)
1853 case wxOR
: // src OR dst
1855 // case wxSRC_OR: // source _bitmap_ OR destination
1856 // case wxSRC_AND: // source _bitmap_ AND destination
1860 m_macPenInstalled
= true ;
1861 m_macBrushInstalled
= false ;
1862 m_macFontInstalled
= false ;
1865 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1867 Pattern whiteColor
;
1868 if ( background
.Ok() )
1870 switch( background
.MacGetBrushKind() )
1872 case kwxMacBrushTheme
:
1874 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1877 case kwxMacBrushThemeBackground
:
1880 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1881 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1884 case kwxMacBrushColour
:
1886 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1887 int brushStyle
= background
.GetStyle();
1888 if (brushStyle
== wxSOLID
)
1889 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1890 else if (background
.IsHatch())
1893 wxMacGetPattern(brushStyle
, &pat
);
1898 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1906 void wxDC::MacInstallBrush() const
1908 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1909 Pattern blackColor
;
1910 // if ( m_macBrushInstalled )
1913 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1914 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1915 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1916 int brushStyle
= m_brush
.GetStyle();
1917 if (brushStyle
== wxSOLID
)
1919 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1921 else if (m_brush
.IsHatch())
1924 wxMacGetPattern(brushStyle
, &pat
);
1927 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1929 // we force this in order to be compliant with wxMSW
1930 backgroundTransparent
= false ;
1931 // for these the text fore (and back for MASK_OPAQUE) colors are used
1932 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1933 int width
= bitmap
->GetWidth() ;
1934 int height
= bitmap
->GetHeight() ;
1935 GWorldPtr gw
= NULL
;
1936 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1937 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
1939 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
1940 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1941 LockPixels( gwpixmaphandle
) ;
1942 bool isMonochrome
= !IsPortColor( gw
) ;
1943 if ( !isMonochrome
)
1945 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1946 isMonochrome
= true ;
1948 if ( isMonochrome
&& width
== 8 && height
== 8 )
1950 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1951 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1952 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1953 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1954 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1956 for ( int i
= 0 ; i
< 8 ; ++i
)
1958 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1960 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1965 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1966 // caching scheme before putting this into production
1969 PixPatHandle pixpat
= NewPixPat() ;
1970 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1971 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1972 ((**(**pixpat
).patMap
).bounds
.bottom
-
1973 (**(**pixpat
).patMap
).bounds
.top
);
1974 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1975 (**pixpat
).patData
= image
;
1978 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1979 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1980 if ( ctspec
[0].rgb
.red
== 0x0000 )
1982 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1983 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1987 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1988 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1990 ::CTabChanged( ctable
) ;
1992 ::PenPixPat(pixpat
);
1993 m_macForegroundPixMap
= pixpat
;
1995 UnlockPixels( gwpixmaphandle
) ;
1999 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2001 short mode
= patCopy
;
2002 switch( m_logicalFunction
)
2005 if ( backgroundTransparent
)
2010 case wxINVERT
: // NOT dst
2011 if ( !backgroundTransparent
)
2013 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2017 case wxXOR
: // src XOR dst
2020 case wxOR_REVERSE
: // src OR (NOT dst)
2023 case wxSRC_INVERT
: // (NOT src)
2026 case wxAND
: // src AND dst
2031 case wxAND_REVERSE
:// src AND (NOT dst)
2032 case wxAND_INVERT
: // (NOT src) AND dst
2033 case wxNO_OP
: // dst
2034 case wxNOR
: // (NOT src) AND (NOT dst)
2035 case wxEQUIV
: // (NOT src) XOR dst
2036 case wxOR_INVERT
: // (NOT src) OR dst
2037 case wxNAND
: // (NOT src) OR (NOT dst)
2038 case wxOR
: // src OR dst
2040 // case wxSRC_OR: // source _bitmap_ OR destination
2041 // case wxSRC_AND: // source _bitmap_ AND destination
2045 m_macBrushInstalled
= true ;
2046 m_macPenInstalled
= false ;
2047 m_macFontInstalled
= false ;
2050 // ---------------------------------------------------------------------------
2051 // coordinates transformations
2052 // ---------------------------------------------------------------------------
2054 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2056 return ((wxDC
*)this)->XDEV2LOG(x
);
2059 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2061 return ((wxDC
*)this)->YDEV2LOG(y
);
2064 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2066 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2069 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2071 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2074 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2076 return ((wxDC
*)this)->XLOG2DEV(x
);
2079 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2081 return ((wxDC
*)this)->YLOG2DEV(y
);
2084 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2086 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2089 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2091 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2094 #endif // !wxMAC_USE_CORE_GRAPHICS