1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #if wxMAC_USE_CORE_GRAPHICS
19 #include "wx/mac/uma.h"
20 #include "wx/dcmemory.h"
21 #include "wx/dcprint.h"
22 #include "wx/region.h"
30 // in case our functions were defined outside std, we make it known all the same
36 #include "wx/mac/private.h"
38 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 #if !defined( __DARWIN__ ) || defined(__MWERKS__)
46 const double M_PI
= 3.14159265358979 ;
49 const double RAD2DEG
= 180.0 / M_PI
;
50 const short kEmulatedMode
= -1 ;
51 const short kUnsupportedMode
= -2 ;
53 extern TECObjectRef s_TECNativeCToUnicode
;
56 // The text ctrl implementation still needs that for the non hiview implementation
58 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
59 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
61 m_newPort
= (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
62 m_formerClip
= NewRgn() ;
63 m_newClip
= NewRgn() ;
64 GetClip( m_formerClip
) ;
68 // guard against half constructed objects, this just leads to a empty clip
72 win
->MacWindowToRootWindow( &x
,&y
) ;
73 // get area including focus rect
74 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
75 if ( !EmptyRgn( m_newClip
) )
76 OffsetRgn( m_newClip
, x
, y
) ;
79 SetClip( m_newClip
) ;
83 wxMacWindowClipper::~wxMacWindowClipper()
85 SetPort( m_newPort
) ;
86 SetClip( m_formerClip
) ;
87 DisposeRgn( m_newClip
) ;
88 DisposeRgn( m_formerClip
) ;
91 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
92 wxMacWindowClipper( win
)
94 // the port is already set at this point
95 m_newPort
= (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
96 GetThemeDrawingState( &m_themeDrawingState
) ;
99 wxMacWindowStateSaver::~wxMacWindowStateSaver()
101 SetPort( m_newPort
) ;
102 SetThemeDrawingState( m_themeDrawingState
, true ) ;
105 // minimal implementation only used for appearance drawing < 10.3
107 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
108 m_ph( (GrafPtr
) dc
->m_macPort
)
110 wxASSERT( dc
->Ok() ) ;
112 // dc->MacSetupPort(&m_ph) ;
115 wxMacPortSetter::~wxMacPortSetter()
117 // m_dc->MacCleanupPort(&m_ph) ;
120 //-----------------------------------------------------------------------------
122 //-----------------------------------------------------------------------------
124 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
125 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
126 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
128 //-----------------------------------------------------------------------------
129 // device context implementation
131 // more and more of the dc functionality should be implemented by calling
132 // the appropricate wxMacCGContext, but we will have to do that step by step
133 // also coordinate conversions should be moved to native matrix ops
134 //-----------------------------------------------------------------------------
136 // we always stock two context states, one at entry, to be able to preserve the
137 // state we were called with, the other one after changing to HI Graphics orientation
138 // (this one is used for getting back clippings etc)
140 wxMacCGPath::wxMacCGPath()
142 m_path
= CGPathCreateMutable() ;
145 wxMacCGPath::~wxMacCGPath()
147 CGPathRelease( m_path
) ;
150 // Starts a new subpath at
151 void wxMacCGPath::MoveToPoint( wxCoord x1
, wxCoord y1
)
153 CGPathMoveToPoint( m_path
, NULL
, x1
, y1
) ;
156 void wxMacCGPath::AddLineToPoint( wxCoord x1
, wxCoord y1
)
158 CGPathAddLineToPoint( m_path
, NULL
, x1
, y1
) ;
161 void wxMacCGPath::AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
)
163 CGPathAddQuadCurveToPoint( m_path
, NULL
, cx1
, cy1
, x1
, y1
);
166 void wxMacCGPath::AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
168 CGRect cgRect
= { { x
, y
} , { w
, h
} } ;
169 CGPathAddRect( m_path
, NULL
, cgRect
) ;
172 void wxMacCGPath::AddCircle( wxCoord x
, wxCoord y
, wxCoord r
)
174 CGPathAddArc( m_path
, NULL
, x
, y
, r
, 0.0 , 2 * M_PI
, true ) ;
177 // closes the current subpath
178 void wxMacCGPath::CloseSubpath()
180 CGPathCloseSubpath( m_path
) ;
183 CGPathRef
wxMacCGPath::GetPath() const
188 wxMacCGContext::wxMacCGContext( CGrafPtr port
)
194 wxMacCGContext::wxMacCGContext( CGContextRef cgcontext
)
197 m_cgContext
= cgcontext
;
198 CGContextSaveGState( m_cgContext
) ;
199 CGContextSaveGState( m_cgContext
) ;
202 wxMacCGContext::wxMacCGContext()
208 wxMacCGContext::~wxMacCGContext()
212 CGContextSynchronize( m_cgContext
) ;
213 CGContextRestoreGState( m_cgContext
) ;
214 CGContextRestoreGState( m_cgContext
) ;
218 CGContextRelease( m_cgContext
) ;
222 void wxMacCGContext::Clip( const wxRegion
®ion
)
224 // ClipCGContextToRegion ( m_cgContext, &bounds , (RgnHandle) dc->m_macCurrentClipRgn ) ;
227 void wxMacCGContext::StrokePath( const wxGraphicPath
*p
)
229 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
230 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
231 CGContextStrokePath( m_cgContext
) ;
234 void wxMacCGContext::DrawPath( const wxGraphicPath
*p
, int fillStyle
)
236 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
237 CGPathDrawingMode mode
= m_mode
;
239 if ( fillStyle
== wxODDEVEN_RULE
)
241 if ( mode
== kCGPathFill
)
242 mode
= kCGPathEOFill
;
243 else if ( mode
== kCGPathFillStroke
)
244 mode
= kCGPathEOFillStroke
;
247 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
248 CGContextDrawPath( m_cgContext
, mode
) ;
251 void wxMacCGContext::FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
)
253 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
254 CGContextSaveGState( m_cgContext
) ;
256 RGBColor col
= MAC_WXCOLORREF( fillColor
.GetPixel() ) ;
257 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
258 CGPathDrawingMode mode
= kCGPathFill
;
260 if ( fillStyle
== wxODDEVEN_RULE
)
261 mode
= kCGPathEOFill
;
263 CGContextBeginPath( m_cgContext
) ;
264 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
265 CGContextClosePath( m_cgContext
) ;
266 CGContextDrawPath( m_cgContext
, mode
) ;
268 CGContextRestoreGState( m_cgContext
) ;
271 wxGraphicPath
* wxMacCGContext::CreatePath()
273 // make sure that we now have a real cgref, before doing
274 // anything with paths
275 CGContextRef cg
= GetNativeContext() ;
278 return new wxMacCGPath() ;
281 // in case we only got a QDPort only create a cgref now
283 CGContextRef
wxMacCGContext::GetNativeContext()
285 if ( m_cgContext
== NULL
)
288 GetPortBounds( (CGrafPtr
) m_qdPort
, &bounds
) ;
289 OSStatus status
= CreateCGContextForPort((CGrafPtr
) m_qdPort
, &m_cgContext
) ;
290 CGContextSaveGState( m_cgContext
) ;
292 wxASSERT_MSG( status
== noErr
, wxT("Cannot nest wxDCs on the same window") ) ;
294 CGContextTranslateCTM( m_cgContext
, 0 , bounds
.bottom
- bounds
.top
) ;
295 CGContextScaleCTM( m_cgContext
, 1 , -1 ) ;
297 CGContextSaveGState( m_cgContext
) ;
299 SetBrush( m_brush
) ;
305 void wxMacCGContext::SetNativeContext( CGContextRef cg
)
307 // we allow either setting or clearing but not replacing
308 wxASSERT( m_cgContext
== NULL
|| cg
== NULL
) ;
311 CGContextSaveGState( cg
) ;
317 // wrapper class for a CGPattern, always allocate on heap, never call destructor
324 // is guaranteed to be called only with a non-Null CGContextRef
325 virtual void Render( CGContextRef ctxRef
) = 0 ;
327 operator CGPatternRef() const { return m_patternRef
; }
330 virtual ~wxMacCGPattern()
332 // as this is called only when our m_patternRef is been released;
333 // don't release it again
336 static void _Render( void *info
, CGContextRef ctxRef
)
338 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
339 if ( self
&& ctxRef
)
340 self
->Render( ctxRef
) ;
343 static void _Dispose( void *info
)
345 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
349 CGPatternRef m_patternRef
;
351 static const CGPatternCallbacks ms_Callbacks
;
354 const CGPatternCallbacks
wxMacCGPattern::ms_Callbacks
= { 0, &wxMacCGPattern::_Render
, &wxMacCGPattern::_Dispose
};
356 class ImagePattern
: public wxMacCGPattern
359 ImagePattern( const wxBitmap
* bmp
, CGAffineTransform transform
)
361 wxASSERT( bmp
&& bmp
->Ok() ) ;
363 Init( (CGImageRef
) bmp
->CGImageCreate() , transform
) ;
366 // ImagePattern takes ownership of CGImageRef passed in
367 ImagePattern( CGImageRef image
, CGAffineTransform transform
)
372 Init( image
, transform
) ;
375 virtual void Render( CGContextRef ctxRef
)
378 HIViewDrawCGImage( ctxRef
, &m_imageBounds
, m_image
);
382 void Init( CGImageRef image
, CGAffineTransform transform
)
387 m_imageBounds
= CGRectMake( 0.0, 0.0, (float)CGImageGetWidth( m_image
), (float)CGImageGetHeight( m_image
) ) ;
388 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
389 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
390 kCGPatternTilingNoDistortion
, true , &wxMacCGPattern::ms_Callbacks
) ;
397 CGImageRelease( m_image
) ;
401 CGRect m_imageBounds
;
404 class HatchPattern
: public wxMacCGPattern
407 HatchPattern( int hatchstyle
, CGAffineTransform transform
)
409 m_hatch
= hatchstyle
;
410 m_imageBounds
= CGRectMake( 0.0, 0.0, 8.0 , 8.0 ) ;
411 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
412 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
413 kCGPatternTilingNoDistortion
, false , &wxMacCGPattern::ms_Callbacks
) ;
416 void StrokeLineSegments( CGContextRef ctxRef
, const CGPoint pts
[] , size_t count
)
418 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
419 if ( UMAGetSystemVersion() >= 0x1040 )
421 CGContextStrokeLineSegments( ctxRef
, pts
, count
) ;
426 CGContextBeginPath (ctxRef
);
427 for (size_t i
= 0; i
< count
; i
+= 2)
429 CGContextMoveToPoint(ctxRef
, pts
[i
].x
, pts
[i
].y
);
430 CGContextAddLineToPoint(ctxRef
, pts
[i
+1].x
, pts
[i
+1].y
);
432 CGContextStrokePath(ctxRef
);
436 virtual void Render( CGContextRef ctxRef
)
440 case wxBDIAGONAL_HATCH
:
444 { 8.0 , 0.0 } , { 0.0 , 8.0 }
446 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
450 case wxCROSSDIAG_HATCH
:
454 { 0.0 , 0.0 } , { 8.0 , 8.0 } ,
455 { 8.0 , 0.0 } , { 0.0 , 8.0 }
457 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
461 case wxFDIAGONAL_HATCH
:
465 { 0.0 , 0.0 } , { 8.0 , 8.0 }
467 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
475 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
476 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
478 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
482 case wxHORIZONTAL_HATCH
:
486 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
488 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
492 case wxVERTICAL_HATCH
:
496 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
498 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
511 CGRect m_imageBounds
;
514 void wxMacCGContext::SetPen( const wxPen
&pen
)
517 if ( m_cgContext
== NULL
)
520 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
521 bool stroke
= pen
.GetStyle() != wxTRANSPARENT
;
524 // we can benchmark performance, should go into a setting later
525 CGContextSetShouldAntialias( m_cgContext
, false ) ;
531 m_mode
= kCGPathFill
; // just a default
535 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
536 CGContextSetRGBStrokeColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
538 // TODO * m_dc->m_scaleX
539 float penWidth
= pen
.GetWidth();
542 CGContextSetLineWidth( m_cgContext
, penWidth
) ;
545 switch ( pen
.GetCap() )
548 cap
= kCGLineCapRound
;
551 case wxCAP_PROJECTING
:
552 cap
= kCGLineCapSquare
;
556 cap
= kCGLineCapButt
;
560 cap
= kCGLineCapButt
;
565 switch ( pen
.GetJoin() )
568 join
= kCGLineJoinBevel
;
572 join
= kCGLineJoinMiter
;
576 join
= kCGLineJoinRound
;
580 join
= kCGLineJoinMiter
;
584 m_mode
= kCGPathStroke
;
587 const float *lengths
= NULL
;
588 float *userLengths
= NULL
;
590 const float dashUnit
= penWidth
< 1.0 ? 1.0 : penWidth
;
592 const float dotted
[] = { dashUnit
, dashUnit
+ 2.0 };
593 const float short_dashed
[] = { 9.0 , 6.0 };
594 const float dashed
[] = { 19.0 , 9.0 };
595 const float dotted_dashed
[] = { 9.0 , 6.0 , 3.0 , 3.0 };
597 switch ( pen
.GetStyle() )
604 count
= WXSIZEOF(dotted
);
609 count
= WXSIZEOF(dashed
) ;
613 lengths
= short_dashed
;
614 count
= WXSIZEOF(short_dashed
) ;
618 lengths
= dotted_dashed
;
619 count
= WXSIZEOF(dotted_dashed
);
624 count
= pen
.GetDashes( &dashes
) ;
625 if ((dashes
!= NULL
) && (count
> 0))
627 userLengths
= new float[count
] ;
628 for( int i
= 0 ; i
< count
; ++i
)
630 userLengths
[i
] = dashes
[i
] * dashUnit
;
632 if ( i
% 2 == 1 && userLengths
[i
] < dashUnit
+ 2.0 )
633 userLengths
[i
] = dashUnit
+ 2.0 ;
634 else if ( i
% 2 == 0 && userLengths
[i
] < dashUnit
)
635 userLengths
[i
] = dashUnit
;
638 lengths
= userLengths
;
643 float alphaArray
[1] = { 1.0 } ;
644 wxBitmap
* bmp
= pen
.GetStipple() ;
645 if ( bmp
&& bmp
->Ok() )
647 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
648 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
649 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
650 CGContextSetStrokePattern( m_cgContext
, pattern
, alphaArray
) ;
657 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
658 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
659 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( pen
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
661 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
662 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
664 CGContextSetStrokePattern( m_cgContext
, pattern
, colorArray
) ;
669 if ((lengths
!= NULL
) && (count
> 0))
671 CGContextSetLineDash( m_cgContext
, 0 , lengths
, count
) ;
672 // force the line cap, otherwise we get artifacts (overlaps) and just solid lines
673 cap
= kCGLineCapButt
;
677 CGContextSetLineDash( m_cgContext
, 0 , NULL
, 0 ) ;
680 CGContextSetLineCap( m_cgContext
, cap
) ;
681 CGContextSetLineJoin( m_cgContext
, join
) ;
683 delete[] userLengths
;
686 if ( fill
&& stroke
)
687 m_mode
= kCGPathFillStroke
;
691 void wxMacCGContext::SetBrush( const wxBrush
&brush
)
694 if ( m_cgContext
== NULL
)
697 bool fill
= brush
.GetStyle() != wxTRANSPARENT
;
698 bool stroke
= m_pen
.GetStyle() != wxTRANSPARENT
;
701 // we can benchmark performance, should go into a setting later
702 CGContextSetShouldAntialias( m_cgContext
, false ) ;
708 m_mode
= kCGPathFill
; // just a default
712 if ( brush
.GetStyle() == wxSOLID
)
714 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
715 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
717 else if ( brush
.IsHatch() )
719 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
720 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
721 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( brush
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
723 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
724 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
726 CGContextSetFillPattern( m_cgContext
, pattern
, colorArray
) ;
730 // now brush is a bitmap
731 float alphaArray
[1] = { 1.0 } ;
732 wxBitmap
* bmp
= brush
.GetStipple() ;
733 if ( bmp
&& bmp
->Ok() )
735 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
736 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
737 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
738 CGContextSetFillPattern( m_cgContext
, pattern
, alphaArray
) ;
742 m_mode
= kCGPathFill
;
745 if ( fill
&& stroke
)
746 m_mode
= kCGPathFillStroke
;
748 m_mode
= kCGPathStroke
;
752 void AddEllipticArcToPath(CGContextRef c
, CGPoint center
, float a
, float b
, float fromDegree
, float toDegree
)
754 CGContextSaveGState(c
);
755 CGContextTranslateCTM(c
, center
.x
, center
.y
);
756 CGContextScaleCTM(c
, a
, b
);
757 CGContextMoveToPoint(c
, 1, 0);
758 CGContextAddArc(c
, 0, 0, 1, DegToRad(fromDegree
), DegToRad(toDegree
), 0);
759 CGContextClosePath(c
);
760 CGContextRestoreGState(c
);
763 void AddRoundedRectToPath(CGContextRef c
, CGRect rect
, float ovalWidth
,
767 if (ovalWidth
== 0 || ovalHeight
== 0)
769 CGContextAddRect(c
, rect
);
773 CGContextSaveGState(c
);
774 CGContextTranslateCTM(c
, CGRectGetMinX(rect
), CGRectGetMinY(rect
));
775 CGContextScaleCTM(c
, ovalWidth
, ovalHeight
);
776 fw
= CGRectGetWidth(rect
) / ovalWidth
;
777 fh
= CGRectGetHeight(rect
) / ovalHeight
;
778 CGContextMoveToPoint(c
, fw
, fh
/2);
779 CGContextAddArcToPoint(c
, fw
, fh
, fw
/2, fh
, 1);
780 CGContextAddArcToPoint(c
, 0, fh
, 0, fh
/2, 1);
781 CGContextAddArcToPoint(c
, 0, 0, fw
/2, 0, 1);
782 CGContextAddArcToPoint(c
, fw
, 0, fw
, fh
/2, 1);
783 CGContextClosePath(c
);
784 CGContextRestoreGState(c
);
791 m_mm_to_pix_x
= mm2pt
;
792 m_mm_to_pix_y
= mm2pt
;
794 m_externalDeviceOriginX
= 0;
795 m_externalDeviceOriginY
= 0;
796 m_logicalScaleX
= 1.0;
797 m_logicalScaleY
= 1.0;
802 m_needComputeScaleX
= false;
803 m_needComputeScaleY
= false;
807 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
809 m_pen
= *wxBLACK_PEN
;
810 m_font
= *wxNORMAL_FONT
;
811 m_brush
= *wxWHITE_BRUSH
;
813 m_macATSUIStyle
= NULL
;
814 m_graphicContext
= NULL
;
819 if ( m_macATSUIStyle
)
821 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
822 m_macATSUIStyle
= NULL
;
825 delete m_graphicContext
;
828 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
830 wxCHECK_RET( Ok(), wxT("invalid window dc") );
831 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
833 wxCoord xx
= XLOG2DEVMAC(x
);
834 wxCoord yy
= YLOG2DEVMAC(y
);
835 wxCoord w
= bmp
.GetWidth();
836 wxCoord h
= bmp
.GetHeight();
837 wxCoord ww
= XLOG2DEVREL(w
);
838 wxCoord hh
= YLOG2DEVREL(h
);
840 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
841 CGImageRef image
= (CGImageRef
)( bmp
.CGImageCreate() ) ;
842 HIRect r
= CGRectMake( xx
, yy
, ww
, hh
) ;
843 HIViewDrawCGImage( cg
, &r
, image
) ;
844 CGImageRelease( image
) ;
847 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
849 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
850 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
852 wxCoord xx
= XLOG2DEVMAC(x
);
853 wxCoord yy
= YLOG2DEVMAC(y
);
854 wxCoord w
= icon
.GetWidth();
855 wxCoord h
= icon
.GetHeight();
856 wxCoord ww
= XLOG2DEVREL(w
);
857 wxCoord hh
= YLOG2DEVREL(h
);
859 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
860 CGRect r
= CGRectMake( 00 , 00 , ww
, hh
) ;
861 CGContextSaveGState(cg
);
862 CGContextTranslateCTM( cg
, xx
, yy
+ hh
);
863 CGContextScaleCTM(cg
, 1, -1);
864 PlotIconRefInContext( cg
, &r
, kAlignNone
, kTransformNone
,
865 NULL
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
866 CGContextRestoreGState( cg
) ;
869 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
871 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
873 wxCoord xx
, yy
, ww
, hh
;
876 ww
= XLOG2DEVREL(width
);
877 hh
= YLOG2DEVREL(height
);
879 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
880 CGRect clipRect
= CGRectMake( xx
,yy
, ww
, hh
) ;
881 CGContextClipToRect( cgContext
, clipRect
) ;
883 // SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ;
884 // SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
888 m_clipX1
= wxMax( m_clipX1
, xx
);
889 m_clipY1
= wxMax( m_clipY1
, yy
);
890 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
891 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
902 // TODO as soon as we don't reset the context for each operation anymore
903 // we have to update the context as well
906 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
908 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
911 DestroyClippingRegion();
916 region
.GetBox( x
, y
, w
, h
);
917 wxCoord xx
, yy
, ww
, hh
;
923 // if we have a scaling that we cannot map onto native regions
924 // we must use the box
925 if ( ww
!= w
|| hh
!= h
)
927 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
932 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
933 if ( xx
!= x
|| yy
!= y
)
934 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
935 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
940 m_clipX1
= wxMax( m_clipX1
, xx
);
941 m_clipY1
= wxMax( m_clipY1
, yy
);
942 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
943 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
956 void wxDC::DestroyClippingRegion()
958 // CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
959 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
960 CGContextRestoreGState( cgContext
);
961 CGContextSaveGState( cgContext
);
962 m_graphicContext
->SetPen( m_pen
) ;
963 m_graphicContext
->SetBrush( m_brush
) ;
967 void wxDC::DoGetSizeMM( int* width
, int* height
) const
973 *width
= long( double(w
) / (m_scaleX
* m_mm_to_pix_x
) );
975 *height
= long( double(h
) / (m_scaleY
* m_mm_to_pix_y
) );
978 void wxDC::SetTextForeground( const wxColour
&col
)
980 wxCHECK_RET(Ok(), wxT("Invalid DC"));
982 if ( col
!= m_textForegroundColour
)
984 m_textForegroundColour
= col
;
989 void wxDC::SetTextBackground( const wxColour
&col
)
991 wxCHECK_RET(Ok(), wxT("Invalid DC"));
993 m_textBackgroundColour
= col
;
996 void wxDC::SetMapMode( int mode
)
1001 SetLogicalScale( twips2mm
* m_mm_to_pix_x
, twips2mm
* m_mm_to_pix_y
);
1005 SetLogicalScale( pt2mm
* m_mm_to_pix_x
, pt2mm
* m_mm_to_pix_y
);
1009 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
1013 SetLogicalScale( m_mm_to_pix_x
/ 10.0, m_mm_to_pix_y
/ 10.0 );
1018 SetLogicalScale( 1.0, 1.0 );
1022 if (mode
!= wxMM_TEXT
)
1024 m_needComputeScaleX
=
1025 m_needComputeScaleY
= true;
1029 void wxDC::SetUserScale( double x
, double y
)
1031 // allow negative ? -> no
1034 ComputeScaleAndOrigin();
1037 void wxDC::SetLogicalScale( double x
, double y
)
1040 m_logicalScaleX
= x
;
1041 m_logicalScaleY
= y
;
1042 ComputeScaleAndOrigin();
1045 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
1047 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
1048 m_logicalOriginY
= y
* m_signY
;
1049 ComputeScaleAndOrigin();
1052 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
1054 m_externalDeviceOriginX
= x
;
1055 m_externalDeviceOriginY
= y
;
1056 ComputeScaleAndOrigin();
1059 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
1061 m_signX
= (xLeftRight
? 1 : -1);
1062 m_signY
= (yBottomUp
? -1 : 1);
1063 ComputeScaleAndOrigin();
1066 wxSize
wxDC::GetPPI() const
1068 return wxSize(72, 72);
1071 int wxDC::GetDepth() const
1076 void wxDC::ComputeScaleAndOrigin()
1078 // CMB: copy scale to see if it changes
1079 double origScaleX
= m_scaleX
;
1080 double origScaleY
= m_scaleY
;
1081 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
1082 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
1083 m_deviceOriginX
= m_externalDeviceOriginX
;
1084 m_deviceOriginY
= m_externalDeviceOriginY
;
1086 // CMB: if scale has changed call SetPen to recalulate the line width
1087 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
1089 // this is a bit artificial, but we need to force wxDC to think
1090 // the pen has changed
1091 wxPen
pen( GetPen() );
1098 void wxDC::SetPalette( const wxPalette
& palette
)
1102 void wxDC::SetBackgroundMode( int mode
)
1104 m_backgroundMode
= mode
;
1107 void wxDC::SetFont( const wxFont
&font
)
1113 void wxDC::SetPen( const wxPen
&pen
)
1119 if ( m_graphicContext
)
1121 if ( m_pen
.GetStyle() == wxSOLID
|| m_pen
.GetStyle() == wxTRANSPARENT
)
1123 m_graphicContext
->SetPen( m_pen
) ;
1127 // we have to compensate for moved device origins etc. otherwise patterned pens are standing still
1128 // eg when using a wxScrollWindow and scrolling around
1129 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1130 int origX
= XLOG2DEVMAC(0) ;
1131 int origY
= YLOG2DEVMAC(0) ;
1132 CGContextTranslateCTM (cgContext
,origX
,origY
);
1133 m_graphicContext
->SetPen( m_pen
) ;
1134 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1139 void wxDC::SetBrush( const wxBrush
&brush
)
1141 if (m_brush
== brush
)
1145 if ( m_graphicContext
)
1147 if ( brush
.GetStyle() == wxSOLID
|| brush
.GetStyle() == wxTRANSPARENT
)
1149 m_graphicContext
->SetBrush( m_brush
) ;
1153 // we have to compensate for moved device origins etc. otherwise patterned brushes are standing still
1154 // eg when using a wxScrollWindow and scrolling around
1155 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1156 int origX
= XLOG2DEVMAC(0) ;
1157 int origY
= YLOG2DEVMAC(0) ;
1158 CGContextTranslateCTM (cgContext
,origX
,origY
);
1159 m_graphicContext
->SetBrush( m_brush
) ;
1160 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1165 void wxDC::SetBackground( const wxBrush
&brush
)
1167 if (m_backgroundBrush
== brush
)
1170 m_backgroundBrush
= brush
;
1171 if (!m_backgroundBrush
.Ok())
1175 void wxDC::SetLogicalFunction( int function
)
1177 if (m_logicalFunction
== function
)
1180 m_logicalFunction
= function
;
1183 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
1184 const wxColour
& col
, int style
);
1186 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
1187 const wxColour
& col
, int style
)
1189 return wxDoFloodFill(this, x
, y
, col
, style
);
1192 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
1194 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1195 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1197 wxMacPortSaver
helper((CGrafPtr
)m_macPort
) ;
1200 // NB: GetCPixel is a deprecated QD call, and a slow one at that
1202 XLOG2DEVMAC(x
) + m_macLocalOriginInPort
.x
- m_macLocalOrigin
.x
,
1203 YLOG2DEVMAC(y
) + m_macLocalOriginInPort
.y
- m_macLocalOrigin
.y
, &colour
);
1205 // convert from Mac colour to wx
1206 col
->Set( colour
.red
>> 8, colour
.green
>> 8, colour
.blue
>> 8 );
1211 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1213 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1215 if ( m_logicalFunction
!= wxCOPY
)
1218 wxCoord xx1
= XLOG2DEVMAC(x1
) ;
1219 wxCoord yy1
= YLOG2DEVMAC(y1
) ;
1220 wxCoord xx2
= XLOG2DEVMAC(x2
) ;
1221 wxCoord yy2
= YLOG2DEVMAC(y2
) ;
1223 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1224 path
->MoveToPoint( xx1
, yy1
) ;
1225 path
->AddLineToPoint( xx2
, yy2
) ;
1226 path
->CloseSubpath() ;
1227 m_graphicContext
->StrokePath( path
) ;
1230 CalcBoundingBox(x1
, y1
);
1231 CalcBoundingBox(x2
, y2
);
1234 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
1236 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
1238 if ( m_logicalFunction
!= wxCOPY
)
1244 wxCoord xx
= XLOG2DEVMAC(x
);
1245 wxCoord yy
= YLOG2DEVMAC(y
);
1247 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1248 path
->MoveToPoint( XLOG2DEVMAC(0), yy
) ;
1249 path
->AddLineToPoint( XLOG2DEVMAC(w
), yy
) ;
1250 path
->CloseSubpath() ;
1251 path
->MoveToPoint( xx
, YLOG2DEVMAC(0) ) ;
1252 path
->AddLineToPoint( xx
, YLOG2DEVMAC(h
) ) ;
1253 path
->CloseSubpath() ;
1254 m_graphicContext
->StrokePath( path
) ;
1257 CalcBoundingBox(x
, y
);
1258 CalcBoundingBox(x
+w
, y
+h
);
1261 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
1262 wxCoord x2
, wxCoord y2
,
1263 wxCoord xc
, wxCoord yc
)
1265 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
1267 if ( m_logicalFunction
!= wxCOPY
)
1270 wxCoord xx1
= XLOG2DEVMAC(x1
);
1271 wxCoord yy1
= YLOG2DEVMAC(y1
);
1272 wxCoord xx2
= XLOG2DEVMAC(x2
);
1273 wxCoord yy2
= YLOG2DEVMAC(y2
);
1274 wxCoord xxc
= XLOG2DEVMAC(xc
);
1275 wxCoord yyc
= YLOG2DEVMAC(yc
);
1277 double dx
= xx1
- xxc
;
1278 double dy
= yy1
- yyc
;
1279 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
1280 wxCoord rad
= (wxCoord
)radius
;
1282 if (xx1
== xx2
&& yy1
== yy2
)
1287 else if (radius
== 0.0)
1293 sa
= (xx1
- xxc
== 0) ?
1294 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
1295 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
1296 ea
= (xx2
- xxc
== 0) ?
1297 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
1298 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
1301 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1302 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1303 CGContextRef ctx
= mctx
->GetNativeContext() ;
1304 CGContextSaveGState( ctx
) ;
1305 CGContextTranslateCTM( ctx
, xxc
, yyc
);
1306 CGContextScaleCTM( ctx
, 1 , -1 ) ;
1308 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1309 CGContextAddArc( ctx
, 0, 0 , rad
, DegToRad(sa
), DegToRad(ea
), 0);
1311 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1312 CGContextRestoreGState( ctx
) ;
1313 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1316 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1317 double sa
, double ea
)
1319 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
1321 if ( m_logicalFunction
!= wxCOPY
)
1324 wxCoord xx
= XLOG2DEVMAC(x
);
1325 wxCoord yy
= YLOG2DEVMAC(y
);
1326 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
1327 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
1329 // handle -ve width and/or height
1341 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1343 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1344 CGContextRef ctx
= mctx
->GetNativeContext() ;
1346 CGContextSaveGState( ctx
) ;
1347 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1348 CGContextScaleCTM( ctx
, 1 * ww
/ 2 , -1 * hh
/ 2 ) ;
1350 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1351 CGContextAddArc( ctx
, 0, 0, 1, DegToRad(sa
), DegToRad(ea
), 0);
1353 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1354 CGContextRestoreGState( ctx
) ;
1355 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1358 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
1360 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1362 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 ) ;
1365 void wxDC::DoDrawLines(int n
, wxPoint points
[],
1366 wxCoord xoffset
, wxCoord yoffset
)
1368 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1370 if ( m_logicalFunction
!= wxCOPY
)
1373 wxCoord x1
, x2
, y1
, y2
;
1374 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1375 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1376 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1377 path
->MoveToPoint( x1
, y1
) ;
1378 for (int i
= 1; i
< n
; i
++)
1380 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1381 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1383 path
->AddLineToPoint( x2
, y2
) ;
1386 m_graphicContext
->StrokePath( path
) ;
1391 void wxDC::DoDrawSpline(wxList
*points
)
1393 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1395 if ( m_logicalFunction
!= wxCOPY
)
1398 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1400 wxList::compatibility_iterator node
= points
->GetFirst();
1401 if (node
== wxList::compatibility_iterator())
1405 wxPoint
*p
= (wxPoint
*)node
->GetData();
1410 node
= node
->GetNext();
1411 p
= (wxPoint
*)node
->GetData();
1415 wxCoord cx1
= ( x1
+ x2
) / 2;
1416 wxCoord cy1
= ( y1
+ y2
) / 2;
1418 path
->MoveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ) ;
1419 path
->AddLineToPoint( XLOG2DEVMAC( cx1
) , XLOG2DEVMAC( cy1
) ) ;
1422 while ((node
= node
->GetNext()) != NULL
)
1424 while ((node
= node
->GetNext()))
1425 #endif // !wxUSE_STL
1427 p
= (wxPoint
*)node
->GetData();
1432 wxCoord cx4
= (x1
+ x2
) / 2;
1433 wxCoord cy4
= (y1
+ y2
) / 2;
1435 path
->AddQuadCurveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ,
1436 XLOG2DEVMAC( cx4
) , XLOG2DEVMAC( cy4
) ) ;
1442 path
->AddLineToPoint( XLOG2DEVMAC( x2
) , XLOG2DEVMAC( y2
) ) ;
1444 m_graphicContext
->StrokePath( path
) ;
1449 void wxDC::DoDrawPolygon( int n
, wxPoint points
[],
1450 wxCoord xoffset
, wxCoord yoffset
,
1453 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1455 if ( n
<= 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
1457 if ( m_logicalFunction
!= wxCOPY
)
1460 wxCoord x1
, x2
, y1
, y2
;
1461 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1462 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1464 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1465 path
->MoveToPoint( x1
, y1
) ;
1466 for (int i
= 1; i
< n
; i
++)
1468 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1469 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1471 path
->AddLineToPoint( x2
, y2
) ;
1474 if ( x1
!= x2
|| y1
!= y2
)
1475 path
->AddLineToPoint( x1
,y1
) ;
1477 path
->CloseSubpath() ;
1478 m_graphicContext
->DrawPath( path
, fillStyle
) ;
1483 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1485 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1487 if ( m_logicalFunction
!= wxCOPY
)
1490 wxCoord xx
= XLOG2DEVMAC(x
);
1491 wxCoord yy
= YLOG2DEVMAC(y
);
1492 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1493 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1495 // CMB: draw nothing if transformed w or h is 0
1496 if (ww
== 0 || hh
== 0)
1499 // CMB: handle -ve width and/or height
1511 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1512 path
->AddRectangle( xx
, yy
, ww
, hh
) ;
1513 m_graphicContext
->DrawPath( path
) ;
1517 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1518 wxCoord width
, wxCoord height
,
1521 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1523 if ( m_logicalFunction
!= wxCOPY
)
1527 radius
= - radius
* ((width
< height
) ? width
: height
);
1528 wxCoord xx
= XLOG2DEVMAC(x
);
1529 wxCoord yy
= YLOG2DEVMAC(y
);
1530 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1531 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1533 // CMB: draw nothing if transformed w or h is 0
1534 if (ww
== 0 || hh
== 0)
1537 // CMB: handle -ve width and/or height
1549 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1550 CGContextRef ctx
= mctx
->GetNativeContext() ;
1551 AddRoundedRectToPath( ctx
, CGRectMake( xx
, yy
, ww
, hh
) , 16 ,16 ) ;
1552 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1555 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1557 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1559 if ( m_logicalFunction
!= wxCOPY
)
1562 wxCoord xx
= XLOG2DEVMAC(x
);
1563 wxCoord yy
= YLOG2DEVMAC(y
);
1564 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1565 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1566 // CMB: draw nothing if transformed w or h is 0
1567 if (ww
== 0 || hh
== 0)
1570 // CMB: handle -ve width and/or height
1582 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1583 CGContextRef ctx
= mctx
->GetNativeContext() ;
1584 CGContextSaveGState( ctx
) ;
1585 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1586 CGContextScaleCTM( ctx
, ww
/ 2 , hh
/ 2 ) ;
1587 CGContextAddArc( ctx
, 0, 0, 1, 0 , 2*M_PI
, 0);
1588 CGContextRestoreGState( ctx
) ;
1589 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1592 bool wxDC::CanDrawBitmap(void) const
1597 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1598 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1599 wxCoord xsrcMask
, wxCoord ysrcMask
)
1601 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1602 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1604 if ( logical_func
== wxNO_OP
)
1607 if (xsrcMask
== -1 && ysrcMask
== -1)
1613 wxCoord yysrc
= source
->YLOG2DEVMAC(ysrc
) ;
1614 wxCoord xxsrc
= source
->XLOG2DEVMAC(xsrc
) ;
1615 wxCoord wwsrc
= source
->XLOG2DEVREL(width
) ;
1616 wxCoord hhsrc
= source
->YLOG2DEVREL(height
) ;
1618 wxCoord yydest
= YLOG2DEVMAC(ydest
) ;
1619 wxCoord xxdest
= XLOG2DEVMAC(xdest
) ;
1620 wxCoord wwdest
= XLOG2DEVREL(width
) ;
1621 wxCoord hhdest
= YLOG2DEVREL(height
) ;
1623 wxMemoryDC
* memdc
= dynamic_cast<wxMemoryDC
*>(source
) ;
1624 if ( memdc
&& logical_func
== wxCOPY
)
1626 wxBitmap blit
= memdc
->GetSelectedObject() ;
1627 wxASSERT_MSG( blit
.Ok() , wxT("Invalid bitmap for blitting") ) ;
1629 wxCoord bmpwidth
= blit
.GetWidth();
1630 wxCoord bmpheight
= blit
.GetHeight();
1632 if ( xxsrc
!= 0 || yysrc
!= 0 || bmpwidth
!= wwsrc
|| bmpheight
!= hhsrc
)
1634 wwsrc
= wxMin( wwsrc
, bmpwidth
- xxsrc
) ;
1635 hhsrc
= wxMin( hhsrc
, bmpheight
- yysrc
) ;
1636 if ( wwsrc
> 0 && hhsrc
> 0 )
1638 if ( xxsrc
>= 0 && yysrc
>= 0 )
1640 wxRect
subrect( xxsrc
, yysrc
, wwsrc
, hhsrc
) ;
1641 blit
= blit
.GetSubBitmap( subrect
) ;
1645 // in this case we'd probably have to adjust the different coordinates, but
1646 // we have to find out proper contract first
1647 blit
= wxNullBitmap
;
1652 blit
= wxNullBitmap
;
1658 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1659 CGImageRef image
= (CGImageRef
)( blit
.CGImageCreate() ) ;
1660 HIRect r
= CGRectMake( xxdest
, yydest
, wwdest
, hhdest
) ;
1661 HIViewDrawCGImage( cg
, &r
, image
) ;
1662 CGImageRelease( image
) ;
1668 CGContextRef cg
= (wxMacCGContext
*)(source
->GetGraphicContext())->GetNativeContext() ;
1669 void *data
= CGBitmapContextGetData( cg
) ;
1672 return false ; // wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts") ) ;
1678 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1681 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1682 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1684 if ( str
.Length() == 0 )
1686 if ( m_logicalFunction
!= wxCOPY
)
1689 OSStatus status
= noErr
;
1690 ATSUTextLayout atsuLayout
;
1691 UniCharCount chars
= str
.Length() ;
1692 UniChar
* ubuf
= NULL
;
1693 #if SIZEOF_WCHAR_T == 4
1694 wxMBConvUTF16 converter
;
1696 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1697 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1698 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1700 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1701 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1702 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1703 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1705 chars
= unicharlen
/ 2 ;
1708 ubuf
= (UniChar
*) str
.wc_str() ;
1710 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1711 chars
= wxWcslen( wchar
.data() ) ;
1712 ubuf
= (UniChar
*) wchar
.data() ;
1716 int drawX
= XLOG2DEVMAC(x
) ;
1717 int drawY
= YLOG2DEVMAC(y
) ;
1719 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1720 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1722 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1724 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1725 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1727 int iAngle
= int( angle
);
1728 if ( abs(iAngle
) > 0 )
1730 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1731 ATSUAttributeTag atsuTags
[] =
1733 kATSULineRotationTag
,
1735 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1739 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1743 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1744 atsuTags
, atsuSizes
, atsuValues
) ;
1748 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1749 ATSUAttributeTag atsuTags
[] =
1753 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1755 sizeof( CGContextRef
) ,
1757 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1761 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1762 atsuTags
, atsuSizes
, atsuValues
) ;
1765 ATSUTextMeasurement textBefore
;
1766 ATSUTextMeasurement textAfter
;
1767 ATSUTextMeasurement ascent
;
1768 ATSUTextMeasurement descent
;
1770 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1771 &textBefore
, &textAfter
, &ascent
, &descent
);
1772 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1776 if ( m_backgroundMode
== wxSOLID
)
1778 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1782 path
->AddLineToPoint(
1783 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ,
1784 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ) ;
1785 path
->AddLineToPoint(
1786 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) + cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1787 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) - sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1788 path
->AddLineToPoint(
1789 (int) (drawX
+ cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1790 (int) (drawY
- sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1792 m_graphicContext
->FillPath( path
, m_textBackgroundColour
) ;
1796 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1797 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1799 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1800 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1801 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1803 CGContextSaveGState(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext());
1804 CGContextTranslateCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), drawX
, drawY
);
1805 CGContextScaleCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), 1, -1);
1806 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1807 IntToFixed(0) , IntToFixed(0) );
1808 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1809 CGContextRestoreGState( ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ) ;
1811 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1812 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1814 ::ATSUDisposeTextLayout(atsuLayout
);
1816 #if SIZEOF_WCHAR_T == 4
1821 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1823 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1825 DoDrawRotatedText( strtext
, x
, y
, 0.0 ) ;
1828 bool wxDC::CanGetTextExtent() const
1830 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1835 void wxDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1836 wxCoord
*descent
, wxCoord
*externalLeading
,
1837 wxFont
*theFont
) const
1839 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1841 wxFont formerFont
= m_font
;
1844 // work around the constness
1845 *((wxFont
*)(&m_font
)) = *theFont
;
1849 if ( str
.Length() == 0 )
1852 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1854 OSStatus status
= noErr
;
1855 ATSUTextLayout atsuLayout
;
1856 UniCharCount chars
= str
.Length() ;
1857 UniChar
* ubuf
= NULL
;
1858 #if SIZEOF_WCHAR_T == 4
1859 wxMBConvUTF16 converter
;
1861 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1862 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1863 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1865 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1866 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1867 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1868 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1870 chars
= unicharlen
/ 2 ;
1873 ubuf
= (UniChar
*) str
.wc_str() ;
1875 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1876 chars
= wxWcslen( wchar
.data() ) ;
1877 ubuf
= (UniChar
*) wchar
.data() ;
1881 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1882 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1884 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the text") );
1886 ATSUTextMeasurement textBefore
;
1887 ATSUTextMeasurement textAfter
;
1888 ATSUTextMeasurement textAscent
;
1889 ATSUTextMeasurement textDescent
;
1891 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1892 &textBefore
, &textAfter
, &textAscent
, &textDescent
);
1895 *height
= YDEV2LOGREL( FixedToInt(textAscent
+ textDescent
) ) ;
1897 *descent
=YDEV2LOGREL( FixedToInt(textDescent
) );
1898 if ( externalLeading
)
1899 *externalLeading
= 0 ;
1901 *width
= XDEV2LOGREL( FixedToInt(textAfter
- textBefore
) ) ;
1903 ::ATSUDisposeTextLayout(atsuLayout
);
1904 #if SIZEOF_WCHAR_T == 4
1909 // work around the constness
1910 *((wxFont
*)(&m_font
)) = formerFont
;
1915 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1917 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1920 widths
.Add(0, text
.Length());
1922 if (text
.Length() == 0)
1925 ATSUTextLayout atsuLayout
;
1926 UniCharCount chars
= text
.Length() ;
1927 UniChar
* ubuf
= NULL
;
1928 #if SIZEOF_WCHAR_T == 4
1929 wxMBConvUTF16 converter
;
1931 size_t unicharlen
= converter
.WC2MB( NULL
, text
.wc_str() , 0 ) ;
1932 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1933 converter
.WC2MB( (char*) ubuf
, text
.wc_str(), unicharlen
+ 2 ) ;
1935 const wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1936 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1937 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1938 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1940 chars
= unicharlen
/ 2 ;
1943 ubuf
= (UniChar
*) text
.wc_str() ;
1945 wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1946 chars
= wxWcslen( wchar
.data() ) ;
1947 ubuf
= (UniChar
*) wchar
.data() ;
1952 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1953 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1955 for ( int pos
= 0; pos
< (int)chars
; pos
++ )
1957 unsigned long actualNumberOfBounds
= 0;
1958 ATSTrapezoid glyphBounds
;
1960 // We get a single bound, since the text should only require one. If it requires more, there is an issue
1962 result
= ATSUGetGlyphBounds( atsuLayout
, 0, 0, kATSUFromTextBeginning
, pos
+ 1,
1963 kATSUseDeviceOrigins
, 1, &glyphBounds
, &actualNumberOfBounds
);
1964 if (result
!= noErr
|| actualNumberOfBounds
!= 1 )
1967 widths
[pos
] = XDEV2LOGREL(FixedToInt( glyphBounds
.upperRight
.x
- glyphBounds
.upperLeft
.x
));
1968 //unsigned char uch = s[i];
1971 ::ATSUDisposeTextLayout(atsuLayout
);
1975 wxCoord
wxDC::GetCharWidth(void) const
1978 DoGetTextExtent(wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
) ;
1983 wxCoord
wxDC::GetCharHeight(void) const
1986 DoGetTextExtent(wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
) ;
1991 void wxDC::Clear(void)
1993 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1995 if (m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1997 HIRect rect
= CGRectMake( -10000 , -10000 , 20000 , 20000 ) ;
1998 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1999 switch( m_backgroundBrush
.MacGetBrushKind() )
2001 case kwxMacBrushTheme
:
2003 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
2004 if ( HIThemeSetFill
!= 0 )
2006 HIThemeSetFill( m_backgroundBrush
.MacGetTheme(), NULL
, cg
, kHIThemeOrientationNormal
);
2007 CGContextFillRect(cg
, rect
);
2014 GetThemeBrushAsColor( m_backgroundBrush
.MacGetTheme(), 32, true, &color
);
2015 CGContextSetRGBFillColor( cg
, (float) color
.red
/ 65536,
2016 (float) color
.green
/ 65536, (float) color
.blue
/ 65536, 1 );
2017 CGContextFillRect( cg
, rect
);
2020 // reset to normal value
2021 RGBColor col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
2022 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0, col
.green
/ 65536.0, col
.blue
/ 65536.0, 1.0 );
2026 case kwxMacBrushThemeBackground
:
2028 wxFAIL_MSG( wxT("There shouldn't be theme backgrounds under Quartz") ) ;
2030 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2031 if ( UMAGetSystemVersion() >= 0x1030 )
2033 HIThemeBackgroundDrawInfo drawInfo
;
2034 drawInfo
.version
= 0 ;
2035 drawInfo
.state
= kThemeStateActive
;
2036 drawInfo
.kind
= m_backgroundBrush
.MacGetThemeBackground(NULL
) ;
2037 if ( drawInfo
.kind
== kThemeBackgroundMetal
)
2038 HIThemeDrawBackground( &rect
, &drawInfo
, cg
,
2039 kHIThemeOrientationNormal
) ;
2040 HIThemeApplyBackground( &rect
, &drawInfo
, cg
,
2041 kHIThemeOrientationNormal
) ;
2047 case kwxMacBrushColour
:
2049 RGBColor col
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) ;
2050 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2051 CGContextFillRect(cg
, rect
);
2053 // reset to normal value
2054 col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
2055 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2060 wxFAIL_MSG( wxT("unknown brush kind") ) ;
2066 void wxDC::MacInstallFont() const
2068 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2070 if ( m_macATSUIStyle
)
2072 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
2073 m_macATSUIStyle
= NULL
;
2078 OSStatus status
= noErr
;
2079 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
2080 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
2082 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
2083 RGBColor atsuColor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel() ) ;
2084 ATSUAttributeTag atsuTags
[] =
2089 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2092 sizeof( RGBColor
) ,
2094 // Boolean kTrue = true ;
2095 // Boolean kFalse = false ;
2096 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
2097 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2102 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
2103 atsuTags
, atsuSizes
, atsuValues
);
2105 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
2109 // ---------------------------------------------------------------------------
2110 // coordinates transformations
2111 // ---------------------------------------------------------------------------
2113 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2115 return ((wxDC
*)this)->XDEV2LOG(x
);
2118 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2120 return ((wxDC
*)this)->YDEV2LOG(y
);
2123 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2125 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2128 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2130 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2133 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2135 return ((wxDC
*)this)->XLOG2DEV(x
);
2138 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2140 return ((wxDC
*)this)->YLOG2DEV(y
);
2143 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2145 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2148 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2150 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2153 #endif // wxMAC_USE_CORE_GRAPHICS