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() ;
277 return new wxMacCGPath() ;
280 // in case we only got a QDPort only create a cgref now
282 CGContextRef
wxMacCGContext::GetNativeContext()
284 if ( m_cgContext
== NULL
)
287 GetPortBounds( (CGrafPtr
) m_qdPort
, &bounds
) ;
288 OSStatus status
= CreateCGContextForPort((CGrafPtr
) m_qdPort
, &m_cgContext
) ;
289 CGContextSaveGState( m_cgContext
) ;
291 wxASSERT_MSG( status
== noErr
, wxT("Cannot nest wxDCs on the same window") ) ;
292 CGContextTranslateCTM( m_cgContext
, 0 , bounds
.bottom
- bounds
.top
) ;
293 CGContextScaleCTM( m_cgContext
, 1 , -1 ) ;
295 CGContextSaveGState( m_cgContext
) ;
297 SetBrush( m_brush
) ;
303 void wxMacCGContext::SetNativeContext( CGContextRef cg
)
305 // we allow either setting or clearing but not replacing
306 wxASSERT( m_cgContext
== NULL
|| cg
== NULL
) ;
308 CGContextSaveGState( cg
) ;
314 // wrapper class for a CGPattern, always allocate on heap, never call destructor
321 // is guaranteed to be called only with a non-Null CGContextRef
322 virtual void Render( CGContextRef ctxRef
) = 0 ;
324 operator CGPatternRef() const { return m_patternRef
; }
327 virtual ~wxMacCGPattern()
329 // as this is called only when our m_patternRef is been released;
330 // don't release it again
333 static void _Render( void *info
, CGContextRef ctxRef
)
335 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
336 if ( self
&& ctxRef
)
337 self
->Render( ctxRef
) ;
340 static void _Dispose( void *info
)
342 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
346 CGPatternRef m_patternRef
;
348 static const CGPatternCallbacks ms_Callbacks
;
351 const CGPatternCallbacks
wxMacCGPattern::ms_Callbacks
= { 0, &wxMacCGPattern::_Render
, &wxMacCGPattern::_Dispose
};
353 class ImagePattern
: public wxMacCGPattern
356 ImagePattern( const wxBitmap
* bmp
, CGAffineTransform transform
)
358 wxASSERT( bmp
&& bmp
->Ok() ) ;
359 Init( (CGImageRef
) bmp
->CGImageCreate() , transform
) ;
362 // ImagePattern takes ownership of CGImageRef passed in
363 ImagePattern( CGImageRef image
, CGAffineTransform transform
)
368 Init( image
, transform
) ;
371 virtual void Render( CGContextRef ctxRef
)
374 HIViewDrawCGImage( ctxRef
, &m_imageBounds
, m_image
);
378 void Init( CGImageRef image
, CGAffineTransform transform
)
383 m_imageBounds
= CGRectMake( 0.0, 0.0, (float)CGImageGetWidth( m_image
), (float)CGImageGetHeight( m_image
) ) ;
384 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
385 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
386 kCGPatternTilingNoDistortion
, true , &wxMacCGPattern::ms_Callbacks
) ;
393 CGImageRelease( m_image
) ;
397 CGRect m_imageBounds
;
400 class HatchPattern
: public wxMacCGPattern
403 HatchPattern( int hatchstyle
, CGAffineTransform transform
)
405 m_hatch
= hatchstyle
;
406 m_imageBounds
= CGRectMake( 0.0, 0.0, 8.0 , 8.0 ) ;
407 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
408 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
409 kCGPatternTilingNoDistortion
, false , &wxMacCGPattern::ms_Callbacks
) ;
412 void StrokeLineSegments( CGContextRef ctxRef
, const CGPoint pts
[] , size_t count
)
414 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
415 if ( UMAGetSystemVersion() >= 0x1040 )
417 CGContextStrokeLineSegments( ctxRef
, pts
, count
) ;
422 CGContextBeginPath (ctxRef
);
423 for (size_t i
= 0; i
< count
; i
+= 2) {
424 CGContextMoveToPoint(ctxRef
, pts
[i
].x
, pts
[i
].y
);
425 CGContextAddLineToPoint(ctxRef
, pts
[i
+1].x
, pts
[i
+1].y
);
427 CGContextStrokePath(ctxRef
);
431 virtual void Render( CGContextRef ctxRef
)
435 case wxBDIAGONAL_HATCH
:
438 { 8.0 , 0.0 } , { 0.0 , 8.0 }
440 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
444 case wxCROSSDIAG_HATCH
:
447 { 0.0 , 0.0 } , { 8.0 , 8.0 } ,
448 { 8.0 , 0.0 } , { 0.0 , 8.0 }
450 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
454 case wxFDIAGONAL_HATCH
:
457 { 0.0 , 0.0 } , { 8.0 , 8.0 }
459 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
466 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
467 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
469 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
473 case wxHORIZONTAL_HATCH
:
476 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
478 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
482 case wxVERTICAL_HATCH
:
485 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
487 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
497 CGRect m_imageBounds
;
500 void wxMacCGContext::SetPen( const wxPen
&pen
)
503 if ( m_cgContext
== NULL
)
505 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
506 bool stroke
= pen
.GetStyle() != wxTRANSPARENT
;
509 // we can benchmark performance, should go into a setting later
510 CGContextSetShouldAntialias( m_cgContext
, false ) ;
515 m_mode
= kCGPathFill
; // just a default
519 m_mode
= kCGPathFill
;
524 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
525 CGContextSetRGBStrokeColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
527 /* TODO * m_dc->m_scaleX */
528 float penWidth
= pen
.GetWidth();
531 CGContextSetLineWidth( m_cgContext
, penWidth
) ;
534 switch ( pen
.GetCap() )
537 cap
= kCGLineCapRound
;
539 case wxCAP_PROJECTING
:
540 cap
= kCGLineCapSquare
;
543 cap
= kCGLineCapButt
;
546 cap
= kCGLineCapButt
;
551 switch ( pen
.GetJoin() )
554 join
= kCGLineJoinBevel
;
557 join
= kCGLineJoinMiter
;
560 join
= kCGLineJoinRound
;
563 join
= kCGLineJoinMiter
;
566 CGContextSetLineJoin( m_cgContext
, join
) ;
568 m_mode
= kCGPathStroke
;
571 const float *lengths
= NULL
;
572 float *userLengths
= NULL
;
574 const float dashUnit
= penWidth
< 1.0 ? 1.0 : penWidth
;
576 const float dotted
[] = { dashUnit
, dashUnit
+ 2.0 };
577 const float short_dashed
[] = { 9.0 , 6.0 };
578 const float dashed
[] = { 19.0 , 9.0 };
579 const float dotted_dashed
[] = { 9.0 , 6.0 , 3.0 , 3.0 };
582 switch ( pen
.GetStyle() )
589 count
= WXSIZEOF(dotted
);
594 count
= WXSIZEOF(dashed
) ;
598 lengths
= short_dashed
;
599 count
= WXSIZEOF(short_dashed
) ;
603 lengths
= dotted_dashed
;
604 count
= WXSIZEOF(dotted_dashed
);
609 count
= pen
.GetDashes( &dashes
) ;
610 if ((dashes
!= NULL
) && (count
> 0))
612 userLengths
= new float[count
] ;
613 for( int i
= 0 ; i
< count
; ++i
)
615 userLengths
[i
] = dashes
[i
] * dashUnit
;
617 if ( i
% 2 == 1 && userLengths
[i
] < dashUnit
+ 2.0 )
618 userLengths
[i
] = dashUnit
+ 2.0 ;
619 else if ( i
% 2 == 0 && userLengths
[i
] < dashUnit
)
620 userLengths
[i
] = dashUnit
;
623 lengths
= userLengths
;
628 float alphaArray
[1] = { 1.0 } ;
629 wxBitmap
* bmp
= pen
.GetStipple() ;
630 if ( bmp
&& bmp
->Ok() )
632 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
633 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
634 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
635 CGContextSetStrokePattern( m_cgContext
, pattern
, alphaArray
) ;
642 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
643 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
644 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( pen
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
646 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
647 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
649 CGContextSetStrokePattern( m_cgContext
, pattern
, colorArray
) ;
654 if ((lengths
!= NULL
) && (count
> 0))
656 CGContextSetLineDash( m_cgContext
, 0 , lengths
, count
) ;
657 // force the line cap, otherwise we get artifacts (overlaps) and just solid lines
658 cap
= kCGLineCapButt
;
662 CGContextSetLineDash( m_cgContext
, 0 , NULL
, 0 ) ;
665 CGContextSetLineCap( m_cgContext
, cap
) ;
667 delete[] userLengths
;
670 if ( fill
&& stroke
)
672 m_mode
= kCGPathFillStroke
;
677 void wxMacCGContext::SetBrush( const wxBrush
&brush
)
680 if ( m_cgContext
== NULL
)
683 bool fill
= brush
.GetStyle() != wxTRANSPARENT
;
684 bool stroke
= m_pen
.GetStyle() != wxTRANSPARENT
;
687 // we can benchmark performance, should go into a setting later
688 CGContextSetShouldAntialias( m_cgContext
, false ) ;
694 m_mode
= kCGPathFill
; // just a default
698 if ( brush
.GetStyle() == wxSOLID
)
700 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
701 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
703 else if ( brush
.IsHatch() )
705 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
706 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
707 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( brush
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
709 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
710 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
712 CGContextSetFillPattern( m_cgContext
, pattern
, colorArray
) ;
716 // now brush is a bitmap
717 float alphaArray
[1] = { 1.0 } ;
718 wxBitmap
* bmp
= brush
.GetStipple() ;
719 if ( bmp
&& bmp
->Ok() )
721 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
722 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
723 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
724 CGContextSetFillPattern( m_cgContext
, pattern
, alphaArray
) ;
727 m_mode
= kCGPathFill
;
731 m_mode
= kCGPathStroke
;
733 if ( fill
&& stroke
)
734 m_mode
= kCGPathFillStroke
;
738 void AddEllipticArcToPath(CGContextRef c
, CGPoint center
, float a
, float b
, float fromDegree
, float toDegree
)
740 CGContextSaveGState(c
);
741 CGContextTranslateCTM(c
, center
.x
, center
.y
);
742 CGContextScaleCTM(c
, a
, b
);
743 CGContextMoveToPoint(c
, 1, 0);
744 CGContextAddArc(c
, 0, 0, 1, DegToRad(fromDegree
), DegToRad(toDegree
), 0);
745 CGContextClosePath(c
);
746 CGContextRestoreGState(c
);
749 void AddRoundedRectToPath(CGContextRef c
, CGRect rect
, float ovalWidth
,
753 if (ovalWidth
== 0 || ovalHeight
== 0)
755 CGContextAddRect(c
, rect
);
759 CGContextSaveGState(c
);
760 CGContextTranslateCTM(c
, CGRectGetMinX(rect
), CGRectGetMinY(rect
));
761 CGContextScaleCTM(c
, ovalWidth
, ovalHeight
);
762 fw
= CGRectGetWidth(rect
) / ovalWidth
;
763 fh
= CGRectGetHeight(rect
) / ovalHeight
;
764 CGContextMoveToPoint(c
, fw
, fh
/2);
765 CGContextAddArcToPoint(c
, fw
, fh
, fw
/2, fh
, 1);
766 CGContextAddArcToPoint(c
, 0, fh
, 0, fh
/2, 1);
767 CGContextAddArcToPoint(c
, 0, 0, fw
/2, 0, 1);
768 CGContextAddArcToPoint(c
, fw
, 0, fw
, fh
/2, 1);
769 CGContextClosePath(c
);
770 CGContextRestoreGState(c
);
777 m_mm_to_pix_x
= mm2pt
;
778 m_mm_to_pix_y
= mm2pt
;
780 m_externalDeviceOriginX
= 0;
781 m_externalDeviceOriginY
= 0;
782 m_logicalScaleX
= 1.0;
783 m_logicalScaleY
= 1.0;
788 m_needComputeScaleX
= false;
789 m_needComputeScaleY
= false;
793 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
795 m_pen
= *wxBLACK_PEN
;
796 m_font
= *wxNORMAL_FONT
;
797 m_brush
= *wxWHITE_BRUSH
;
799 m_macATSUIStyle
= NULL
;
801 m_graphicContext
= NULL
;
806 if ( m_macATSUIStyle
)
808 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
809 m_macATSUIStyle
= NULL
;
812 delete m_graphicContext
;
815 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
817 wxCHECK_RET( Ok(), wxT("invalid window dc") );
818 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
819 wxCoord xx
= XLOG2DEVMAC(x
);
820 wxCoord yy
= YLOG2DEVMAC(y
);
821 wxCoord w
= bmp
.GetWidth();
822 wxCoord h
= bmp
.GetHeight();
823 wxCoord ww
= XLOG2DEVREL(w
);
824 wxCoord hh
= YLOG2DEVREL(h
);
826 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
827 CGImageRef image
= (CGImageRef
)( bmp
.CGImageCreate() ) ;
828 HIRect r
= CGRectMake( xx
, yy
, ww
, hh
) ;
829 HIViewDrawCGImage( cg
, &r
, image
) ;
830 CGImageRelease( image
) ;
833 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
835 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
836 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
838 wxCoord xx
= XLOG2DEVMAC(x
);
839 wxCoord yy
= YLOG2DEVMAC(y
);
840 wxCoord w
= icon
.GetWidth();
841 wxCoord h
= icon
.GetHeight();
842 wxCoord ww
= XLOG2DEVREL(w
);
843 wxCoord hh
= YLOG2DEVREL(h
);
845 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
846 CGRect r
= CGRectMake( 00 , 00 , ww
, hh
) ;
847 CGContextSaveGState(cg
);
848 CGContextTranslateCTM(cg
, xx
, yy
+ hh
);
849 CGContextScaleCTM(cg
, 1, -1);
850 PlotIconRefInContext( cg
, &r
, kAlignNone
, kTransformNone
,
851 NULL
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
852 CGContextRestoreGState( cg
) ;
855 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
857 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
858 wxCoord xx
, yy
, ww
, hh
;
861 ww
= XLOG2DEVREL(width
);
862 hh
= YLOG2DEVREL(height
);
864 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
865 CGRect clipRect
= CGRectMake( xx
,yy
, ww
, hh
) ;
866 CGContextClipToRect( cgContext
, clipRect
) ;
868 // SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ;
869 // SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
872 m_clipX1
= wxMax( m_clipX1
, xx
);
873 m_clipY1
= wxMax( m_clipY1
, yy
);
874 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
875 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
885 // TODO as soon as we don't reset the context for each operation anymore
886 // we have to update the context as well
889 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
891 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
894 DestroyClippingRegion();
899 region
.GetBox( x
, y
, w
, h
);
900 wxCoord xx
, yy
, ww
, hh
;
905 // if we have a scaling that we cannot map onto native regions
906 // we must use the box
907 if ( ww
!= w
|| hh
!= h
)
909 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
914 CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ;
915 if ( xx != x || yy != y )
917 OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ;
919 SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
923 m_clipX1
= wxMax( m_clipX1
, xx
);
924 m_clipY1
= wxMax( m_clipY1
, yy
);
925 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
926 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
939 void wxDC::DestroyClippingRegion()
941 // CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
942 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
943 CGContextRestoreGState( cgContext
);
944 CGContextSaveGState( cgContext
);
945 m_graphicContext
->SetPen( m_pen
) ;
946 m_graphicContext
->SetBrush( m_brush
) ;
950 void wxDC::DoGetSizeMM( int* width
, int* height
) const
955 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
956 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
959 void wxDC::SetTextForeground( const wxColour
&col
)
961 wxCHECK_RET(Ok(), wxT("Invalid DC"));
962 if ( col
!= m_textForegroundColour
)
964 m_textForegroundColour
= col
;
969 void wxDC::SetTextBackground( const wxColour
&col
)
971 wxCHECK_RET(Ok(), wxT("Invalid DC"));
972 m_textBackgroundColour
= col
;
975 void wxDC::SetMapMode( int mode
)
980 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
984 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
988 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
992 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
997 SetLogicalScale( 1.0, 1.0 );
1001 if (mode
!= wxMM_TEXT
)
1003 m_needComputeScaleX
=
1004 m_needComputeScaleY
= true;
1008 void wxDC::SetUserScale( double x
, double y
)
1010 // allow negative ? -> no
1013 ComputeScaleAndOrigin();
1016 void wxDC::SetLogicalScale( double x
, double y
)
1019 m_logicalScaleX
= x
;
1020 m_logicalScaleY
= y
;
1021 ComputeScaleAndOrigin();
1024 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
1026 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
1027 m_logicalOriginY
= y
* m_signY
;
1028 ComputeScaleAndOrigin();
1031 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
1033 m_externalDeviceOriginX
= x
;
1034 m_externalDeviceOriginY
= y
;
1035 ComputeScaleAndOrigin();
1038 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
1040 m_signX
= (xLeftRight
? 1 : -1);
1041 m_signY
= (yBottomUp
? -1 : 1);
1042 ComputeScaleAndOrigin();
1045 wxSize
wxDC::GetPPI() const
1047 return wxSize(72, 72);
1050 int wxDC::GetDepth() const
1055 void wxDC::ComputeScaleAndOrigin()
1057 // CMB: copy scale to see if it changes
1058 double origScaleX
= m_scaleX
;
1059 double origScaleY
= m_scaleY
;
1060 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
1061 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
1062 m_deviceOriginX
= m_externalDeviceOriginX
;
1063 m_deviceOriginY
= m_externalDeviceOriginY
;
1065 // CMB: if scale has changed call SetPen to recalulate the line width
1066 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
1068 // this is a bit artificial, but we need to force wxDC to think
1069 // the pen has changed
1070 wxPen
pen(GetPen());
1077 void wxDC::SetPalette( const wxPalette
& palette
)
1081 void wxDC::SetBackgroundMode( int mode
)
1083 m_backgroundMode
= mode
;
1086 void wxDC::SetFont( const wxFont
&font
)
1092 void wxDC::SetPen( const wxPen
&pen
)
1098 if ( m_graphicContext
)
1100 if ( m_pen
.GetStyle() == wxSOLID
|| m_pen
.GetStyle() == wxTRANSPARENT
)
1102 m_graphicContext
->SetPen( m_pen
) ;
1106 // we have to compensate for moved device origins etc. otherwise patterned pens are standing still
1107 // eg when using a wxScrollWindow and scrolling around
1108 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1109 int origX
= XLOG2DEVMAC(0) ;
1110 int origY
= YLOG2DEVMAC(0) ;
1111 CGContextTranslateCTM (cgContext
,origX
,origY
);
1112 m_graphicContext
->SetPen( m_pen
) ;
1113 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1118 void wxDC::SetBrush( const wxBrush
&brush
)
1120 if (m_brush
== brush
)
1124 if ( m_graphicContext
)
1126 if ( brush
.GetStyle() == wxSOLID
|| brush
.GetStyle() == wxTRANSPARENT
)
1128 m_graphicContext
->SetBrush( m_brush
) ;
1132 // we have to compensate for moved device origins etc. otherwise patterned brushes are standing still
1133 // eg when using a wxScrollWindow and scrolling around
1134 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1135 int origX
= XLOG2DEVMAC(0) ;
1136 int origY
= YLOG2DEVMAC(0) ;
1137 CGContextTranslateCTM (cgContext
,origX
,origY
);
1138 m_graphicContext
->SetBrush( m_brush
) ;
1139 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1144 void wxDC::SetBackground( const wxBrush
&brush
)
1146 if (m_backgroundBrush
== brush
)
1149 m_backgroundBrush
= brush
;
1150 if (!m_backgroundBrush
.Ok())
1154 void wxDC::SetLogicalFunction( int function
)
1156 if (m_logicalFunction
== function
)
1159 m_logicalFunction
= function
;
1162 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
1163 const wxColour
& col
, int style
);
1165 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
1166 const wxColour
& col
, int style
)
1168 return wxDoFloodFill(this, x
, y
, col
, style
);
1171 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
1173 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1174 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1175 wxMacPortSaver
helper((CGrafPtr
)m_macPort
) ;
1178 XLOG2DEVMAC(x
) + m_macLocalOriginInPort
.x
- m_macLocalOrigin
.x
,
1179 YLOG2DEVMAC(y
) + m_macLocalOriginInPort
.y
- m_macLocalOrigin
.y
, &colour
);
1180 // Convert from Mac colour to wx
1181 col
->Set( colour
.red
>> 8,
1188 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1190 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1192 if ( m_logicalFunction
!= wxCOPY
)
1195 wxCoord xx1
= XLOG2DEVMAC(x1
) ;
1196 wxCoord yy1
= YLOG2DEVMAC(y1
) ;
1197 wxCoord xx2
= XLOG2DEVMAC(x2
) ;
1198 wxCoord yy2
= YLOG2DEVMAC(y2
) ;
1200 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1201 path
->MoveToPoint( xx1
, yy1
) ;
1202 path
->AddLineToPoint( xx2
, yy2
) ;
1203 path
->CloseSubpath() ;
1204 m_graphicContext
->StrokePath( path
) ;
1207 CalcBoundingBox(x1
, y1
);
1208 CalcBoundingBox(x2
, y2
);
1211 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
1213 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
1215 if ( m_logicalFunction
!= wxCOPY
)
1221 wxCoord xx
= XLOG2DEVMAC(x
);
1222 wxCoord yy
= YLOG2DEVMAC(y
);
1224 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1225 path
->MoveToPoint( XLOG2DEVMAC(0), yy
) ;
1226 path
->AddLineToPoint( XLOG2DEVMAC(w
), yy
) ;
1227 path
->CloseSubpath() ;
1228 path
->MoveToPoint( xx
, YLOG2DEVMAC(0) ) ;
1229 path
->AddLineToPoint( xx
, YLOG2DEVMAC(h
) ) ;
1230 path
->CloseSubpath() ;
1231 m_graphicContext
->StrokePath( path
) ;
1234 CalcBoundingBox(x
, y
);
1235 CalcBoundingBox(x
+w
, y
+h
);
1238 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
1239 wxCoord x2
, wxCoord y2
,
1240 wxCoord xc
, wxCoord yc
)
1242 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
1244 if ( m_logicalFunction
!= wxCOPY
)
1247 wxCoord xx1
= XLOG2DEVMAC(x1
);
1248 wxCoord yy1
= YLOG2DEVMAC(y1
);
1249 wxCoord xx2
= XLOG2DEVMAC(x2
);
1250 wxCoord yy2
= YLOG2DEVMAC(y2
);
1251 wxCoord xxc
= XLOG2DEVMAC(xc
);
1252 wxCoord yyc
= YLOG2DEVMAC(yc
);
1253 double dx
= xx1
- xxc
;
1254 double dy
= yy1
- yyc
;
1255 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
1256 wxCoord rad
= (wxCoord
)radius
;
1258 if (xx1
== xx2
&& yy1
== yy2
)
1263 else if (radius
== 0.0)
1269 sa
= (xx1
- xxc
== 0) ?
1270 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
1271 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
1272 ea
= (xx2
- xxc
== 0) ?
1273 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
1274 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
1277 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1278 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1279 CGContextRef ctx
= mctx
->GetNativeContext() ;
1280 CGContextSaveGState( ctx
) ;
1281 CGContextTranslateCTM( ctx
, xxc
, yyc
);
1282 CGContextScaleCTM( ctx
, 1 , -1 ) ;
1284 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1285 CGContextAddArc( ctx
, 0, 0 , rad
, DegToRad(sa
), DegToRad(ea
), 0);
1287 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1288 CGContextRestoreGState( ctx
) ;
1289 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1292 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1293 double sa
, double ea
)
1295 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
1297 if ( m_logicalFunction
!= wxCOPY
)
1300 wxCoord xx
= XLOG2DEVMAC(x
);
1301 wxCoord yy
= YLOG2DEVMAC(y
);
1302 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
1303 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
1304 // handle -ve width and/or height
1305 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1306 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1308 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1310 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1311 CGContextRef ctx
= mctx
->GetNativeContext() ;
1313 CGContextSaveGState( ctx
) ;
1314 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1315 CGContextScaleCTM( ctx
, 1 * ww
/ 2 , -1 * hh
/ 2 ) ;
1317 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1318 CGContextAddArc( ctx
, 0, 0, 1, DegToRad(sa
), DegToRad(ea
), 0);
1320 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1321 CGContextRestoreGState( ctx
) ;
1322 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1325 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
1327 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1328 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 ) ;
1331 void wxDC::DoDrawLines(int n
, wxPoint points
[],
1332 wxCoord xoffset
, wxCoord yoffset
)
1334 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1336 if ( m_logicalFunction
!= wxCOPY
)
1339 wxCoord x1
, x2
, y1
, y2
;
1340 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1341 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1342 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1343 path
->MoveToPoint( x1
, y1
) ;
1344 for (int i
= 1; i
< n
; i
++)
1346 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1347 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1349 path
->AddLineToPoint( x2
, y2
) ;
1352 m_graphicContext
->StrokePath( path
) ;
1357 void wxDC::DoDrawSpline(wxList
*points
)
1359 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1361 if ( m_logicalFunction
!= wxCOPY
)
1364 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1366 wxList::compatibility_iterator node
= points
->GetFirst();
1367 if (node
== wxList::compatibility_iterator())
1371 wxPoint
*p
= (wxPoint
*)node
->GetData();
1376 node
= node
->GetNext();
1377 p
= (wxPoint
*)node
->GetData();
1381 wxCoord cx1
= ( x1
+ x2
) / 2;
1382 wxCoord cy1
= ( y1
+ y2
) / 2;
1384 path
->MoveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ) ;
1385 path
->AddLineToPoint( XLOG2DEVMAC( cx1
) , XLOG2DEVMAC( cy1
) ) ;
1388 while ((node
= node
->GetNext()) != NULL
)
1390 while ((node
= node
->GetNext()))
1391 #endif // !wxUSE_STL
1393 p
= (wxPoint
*)node
->GetData();
1398 wxCoord cx4
= (x1
+ x2
) / 2;
1399 wxCoord cy4
= (y1
+ y2
) / 2;
1401 path
->AddQuadCurveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ,
1402 XLOG2DEVMAC( cx4
) , XLOG2DEVMAC( cy4
) ) ;
1408 path
->AddLineToPoint( XLOG2DEVMAC( x2
) , XLOG2DEVMAC( y2
) ) ;
1410 m_graphicContext
->StrokePath( path
) ;
1415 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
1416 wxCoord xoffset
, wxCoord yoffset
,
1419 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1420 wxCoord x1
, x2
, y1
, y2
;
1421 if ( n
== 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
1424 if ( m_logicalFunction
!= wxCOPY
)
1427 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1428 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1430 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1431 path
->MoveToPoint( x1
, y1
) ;
1432 for (int i
= 1; i
< n
; i
++)
1434 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1435 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1437 path
->AddLineToPoint( x2
, y2
) ;
1440 if ( x1
!= x2
|| y1
!= y2
)
1441 path
->AddLineToPoint( x1
,y1
) ;
1443 path
->CloseSubpath() ;
1444 m_graphicContext
->DrawPath( path
, fillStyle
) ;
1448 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1450 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1452 if ( m_logicalFunction
!= wxCOPY
)
1455 wxCoord xx
= XLOG2DEVMAC(x
);
1456 wxCoord yy
= YLOG2DEVMAC(y
);
1457 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1458 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1459 // CMB: draw nothing if transformed w or h is 0
1460 if (ww
== 0 || hh
== 0)
1463 // CMB: handle -ve width and/or height
1475 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1476 path
->AddRectangle( xx
, yy
, ww
, hh
) ;
1477 m_graphicContext
->DrawPath( path
) ;
1481 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1482 wxCoord width
, wxCoord height
,
1485 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1487 if ( m_logicalFunction
!= wxCOPY
)
1491 radius
= - radius
* ((width
< height
) ? width
: height
);
1492 wxCoord xx
= XLOG2DEVMAC(x
);
1493 wxCoord yy
= YLOG2DEVMAC(y
);
1494 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1495 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1496 // CMB: draw nothing if transformed w or h is 0
1497 if (ww
== 0 || hh
== 0)
1500 // CMB: handle -ve width and/or height
1512 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1513 CGContextRef ctx
= mctx
->GetNativeContext() ;
1514 AddRoundedRectToPath( ctx
, CGRectMake( xx
, yy
, ww
, hh
) , 16 ,16 ) ;
1515 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1518 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1520 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1522 if ( m_logicalFunction
!= wxCOPY
)
1525 wxCoord xx
= XLOG2DEVMAC(x
);
1526 wxCoord yy
= YLOG2DEVMAC(y
);
1527 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1528 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1529 // CMB: draw nothing if transformed w or h is 0
1530 if (ww
== 0 || hh
== 0)
1533 // CMB: handle -ve width and/or height
1545 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1546 CGContextRef ctx
= mctx
->GetNativeContext() ;
1547 CGContextSaveGState( ctx
) ;
1548 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1549 CGContextScaleCTM( ctx
, ww
/ 2 , hh
/ 2 ) ;
1550 CGContextAddArc( ctx
, 0, 0, 1, 0 , 2*M_PI
, 0);
1551 CGContextRestoreGState( ctx
) ;
1552 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1555 bool wxDC::CanDrawBitmap(void) const
1560 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1561 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1562 wxCoord xsrcMask
, wxCoord ysrcMask
)
1564 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1565 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1566 if ( logical_func
== wxNO_OP
)
1569 if (xsrcMask
== -1 && ysrcMask
== -1)
1575 wxCoord yysrc
= source
->YLOG2DEVMAC(ysrc
) ;
1576 wxCoord xxsrc
= source
->XLOG2DEVMAC(xsrc
) ;
1577 wxCoord wwsrc
= source
->XLOG2DEVREL(width
) ;
1578 wxCoord hhsrc
= source
->YLOG2DEVREL(height
) ;
1580 wxCoord yydest
= YLOG2DEVMAC(ydest
) ;
1581 wxCoord xxdest
= XLOG2DEVMAC(xdest
) ;
1582 wxCoord wwdest
= XLOG2DEVREL(width
) ;
1583 wxCoord hhdest
= YLOG2DEVREL(height
) ;
1585 wxMemoryDC
* memdc
= dynamic_cast<wxMemoryDC
*>(source
) ;
1586 if ( memdc
&& logical_func
== wxCOPY
)
1588 wxBitmap blit
= memdc
->GetSelectedObject() ;
1589 wxASSERT_MSG( blit
.Ok() , wxT("Invalid bitmap for blitting") ) ;
1591 wxCoord bmpwidth
= blit
.GetWidth();
1592 wxCoord bmpheight
= blit
.GetHeight();
1594 if ( xxsrc
!= 0 || yysrc
!= 0 || bmpwidth
!= wwsrc
|| bmpheight
!= hhsrc
)
1596 wwsrc
= wxMin( wwsrc
, bmpwidth
- xxsrc
) ;
1597 hhsrc
= wxMin( hhsrc
, bmpheight
- yysrc
) ;
1598 if ( wwsrc
> 0 && hhsrc
> 0 )
1600 if ( xxsrc
>= 0 && yysrc
>= 0 )
1602 wxRect
subrect( xxsrc
, yysrc
, wwsrc
, hhsrc
) ;
1603 blit
= blit
.GetSubBitmap( subrect
) ;
1607 // in this case we'd probably have to adjust the different coordinates, but
1608 // we have to find out proper contract first
1609 blit
= wxNullBitmap
;
1614 blit
= wxNullBitmap
;
1620 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1621 CGImageRef image
= (CGImageRef
)( blit
.CGImageCreate() ) ;
1622 HIRect r
= CGRectMake( xxdest
, yydest
, wwdest
, hhdest
) ;
1623 HIViewDrawCGImage( cg
, &r
, image
) ;
1624 CGImageRelease( image
) ;
1630 CGContextRef cg = (wxMacCGContext*)(source->GetGraphicContext())->GetNativeContext() ;
1631 void *data = CGBitmapContextGetData( cg ) ;
1633 return false ; // wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts") ) ;
1639 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1642 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1644 if ( str
.Length() == 0 )
1646 if ( m_logicalFunction
!= wxCOPY
)
1649 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1651 OSStatus status
= noErr
;
1652 ATSUTextLayout atsuLayout
;
1653 UniCharCount chars
= str
.Length() ;
1654 UniChar
* ubuf
= NULL
;
1655 #if SIZEOF_WCHAR_T == 4
1656 wxMBConvUTF16 converter
;
1658 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1659 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1660 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1662 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1663 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1664 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1665 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1667 chars
= unicharlen
/ 2 ;
1670 ubuf
= (UniChar
*) str
.wc_str() ;
1672 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1673 chars
= wxWcslen( wchar
.data() ) ;
1674 ubuf
= (UniChar
*) wchar
.data() ;
1678 int drawX
= XLOG2DEVMAC(x
) ;
1679 int drawY
= YLOG2DEVMAC(y
) ;
1681 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1682 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1684 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1686 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1687 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1689 int iAngle
= int( angle
);
1690 if ( abs(iAngle
) > 0 )
1692 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1693 ATSUAttributeTag atsuTags
[] =
1695 kATSULineRotationTag
,
1697 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1701 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1705 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1706 atsuTags
, atsuSizes
, atsuValues
) ;
1709 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1710 ATSUAttributeTag atsuTags
[] =
1714 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1716 sizeof( CGContextRef
) ,
1718 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1722 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1723 atsuTags
, atsuSizes
, atsuValues
) ;
1726 ATSUTextMeasurement textBefore
;
1727 ATSUTextMeasurement textAfter
;
1728 ATSUTextMeasurement ascent
;
1729 ATSUTextMeasurement descent
;
1731 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1732 &textBefore
, &textAfter
, &ascent
, &descent
);
1733 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1737 if ( m_backgroundMode
== wxSOLID
)
1739 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1743 path
->AddLineToPoint(
1744 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ,
1745 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ) ;
1746 path
->AddLineToPoint(
1747 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) + cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1748 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) - sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1749 path
->AddLineToPoint(
1750 (int) (drawX
+ cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1751 (int) (drawY
- sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1753 m_graphicContext
->FillPath( path
, m_textBackgroundColour
) ;
1757 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1758 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1760 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1761 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1762 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1764 CGContextSaveGState(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext());
1765 CGContextTranslateCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), drawX
, drawY
);
1766 CGContextScaleCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), 1, -1);
1767 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1768 IntToFixed(0) , IntToFixed(0) );
1769 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1770 CGContextRestoreGState( ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ) ;
1772 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1773 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1775 ::ATSUDisposeTextLayout(atsuLayout
);
1777 #if SIZEOF_WCHAR_T == 4
1782 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1784 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1785 DoDrawRotatedText( strtext
, x
, y
, 0.0 ) ;
1788 bool wxDC::CanGetTextExtent() const
1790 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1794 void wxDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1795 wxCoord
*descent
, wxCoord
*externalLeading
,
1796 wxFont
*theFont
) const
1798 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1799 wxFont formerFont
= m_font
;
1802 // work around the constness
1803 *((wxFont
*)(&m_font
)) = *theFont
;
1807 if ( str
.Length() == 0 )
1810 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1812 OSStatus status
= noErr
;
1813 ATSUTextLayout atsuLayout
;
1814 UniCharCount chars
= str
.Length() ;
1815 UniChar
* ubuf
= NULL
;
1816 #if SIZEOF_WCHAR_T == 4
1817 wxMBConvUTF16 converter
;
1819 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1820 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1821 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1823 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1824 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1825 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1826 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1828 chars
= unicharlen
/ 2 ;
1831 ubuf
= (UniChar
*) str
.wc_str() ;
1833 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1834 chars
= wxWcslen( wchar
.data() ) ;
1835 ubuf
= (UniChar
*) wchar
.data() ;
1839 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1840 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1842 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the text") );
1844 ATSUTextMeasurement textBefore
;
1845 ATSUTextMeasurement textAfter
;
1846 ATSUTextMeasurement textAscent
;
1847 ATSUTextMeasurement textDescent
;
1849 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1850 &textBefore
, &textAfter
, &textAscent
, &textDescent
);
1853 *height
= YDEV2LOGREL( FixedToInt(textAscent
+ textDescent
) ) ;
1855 *descent
=YDEV2LOGREL( FixedToInt(textDescent
) );
1856 if ( externalLeading
)
1857 *externalLeading
= 0 ;
1859 *width
= XDEV2LOGREL( FixedToInt(textAfter
- textBefore
) ) ;
1861 ::ATSUDisposeTextLayout(atsuLayout
);
1862 #if SIZEOF_WCHAR_T == 4
1867 // work around the constness
1868 *((wxFont
*)(&m_font
)) = formerFont
;
1873 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1875 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1878 widths
.Add(0, text
.Length());
1880 if (text
.Length() == 0)
1883 ATSUTextLayout atsuLayout
;
1884 UniCharCount chars
= text
.Length() ;
1885 UniChar
* ubuf
= NULL
;
1886 #if SIZEOF_WCHAR_T == 4
1887 wxMBConvUTF16 converter
;
1889 size_t unicharlen
= converter
.WC2MB( NULL
, text
.wc_str() , 0 ) ;
1890 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1891 converter
.WC2MB( (char*) ubuf
, text
.wc_str(), unicharlen
+ 2 ) ;
1893 const wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1894 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1895 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1896 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1898 chars
= unicharlen
/ 2 ;
1901 ubuf
= (UniChar
*) text
.wc_str() ;
1903 wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1904 chars
= wxWcslen( wchar
.data() ) ;
1905 ubuf
= (UniChar
*) wchar
.data() ;
1910 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1911 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1913 for ( int pos
= 0; pos
< (int)chars
; pos
++ )
1915 unsigned long actualNumberOfBounds
= 0;
1916 ATSTrapezoid glyphBounds
;
1918 // We get a single bound, since the text should only require one. If it requires more, there is an issue
1920 result
= ATSUGetGlyphBounds( atsuLayout
, 0, 0, kATSUFromTextBeginning
, pos
+ 1,
1921 kATSUseDeviceOrigins
, 1, &glyphBounds
, &actualNumberOfBounds
);
1922 if (result
!= noErr
|| actualNumberOfBounds
!= 1 )
1925 widths
[pos
] = XDEV2LOGREL(FixedToInt( glyphBounds
.upperRight
.x
- glyphBounds
.upperLeft
.x
));
1926 //unsigned char uch = s[i];
1929 ::ATSUDisposeTextLayout(atsuLayout
);
1933 wxCoord
wxDC::GetCharWidth(void) const
1936 DoGetTextExtent(wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
) ;
1940 wxCoord
wxDC::GetCharHeight(void) const
1943 DoGetTextExtent(wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
) ;
1947 void wxDC::Clear(void)
1949 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1951 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1953 HIRect rect
= CGRectMake( -10000 , -10000 , 20000 , 20000 ) ;
1954 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1955 switch( m_backgroundBrush
.MacGetBrushKind() )
1957 case kwxMacBrushTheme
:
1959 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1960 if ( HIThemeSetFill
!= 0 )
1962 HIThemeSetFill( m_backgroundBrush
.MacGetTheme(), NULL
, cg
, kHIThemeOrientationNormal
);
1963 CGContextFillRect(cg
, rect
);
1970 GetThemeBrushAsColor( m_backgroundBrush
.MacGetTheme(), 32, true, &color
);
1971 CGContextSetRGBFillColor( cg
, (float) color
.red
/ 65536,
1972 (float) color
.green
/ 65536, (float) color
.blue
/ 65536, 1 );
1973 CGContextFillRect( cg
, rect
);
1976 // reset to normal value
1977 RGBColor col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
1978 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0, col
.green
/ 65536.0, col
.blue
/ 65536.0, 1.0 );
1982 case kwxMacBrushThemeBackground
:
1984 wxFAIL_MSG( wxT("There shouldn't be theme backgrounds under Quartz") ) ;
1985 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1986 if ( UMAGetSystemVersion() >= 0x1030 )
1988 HIThemeBackgroundDrawInfo drawInfo
;
1989 drawInfo
.version
= 0 ;
1990 drawInfo
.state
= kThemeStateActive
;
1991 drawInfo
.kind
= m_backgroundBrush
.MacGetThemeBackground(NULL
) ;
1992 if ( drawInfo
.kind
== kThemeBackgroundMetal
)
1993 HIThemeDrawBackground( &rect
, &drawInfo
, cg
,
1994 kHIThemeOrientationNormal
) ;
1995 HIThemeApplyBackground( &rect
, &drawInfo
, cg
,
1996 kHIThemeOrientationNormal
) ;
2002 case kwxMacBrushColour
:
2004 RGBColor col
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) ;
2005 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2006 CGContextFillRect(cg
, rect
);
2008 // reset to normal value
2009 col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
2010 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2020 void wxDC::MacInstallFont() const
2022 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2024 if ( m_macATSUIStyle
)
2026 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
2027 m_macATSUIStyle
= NULL
;
2032 OSStatus status
= noErr
;
2033 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
2034 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
2036 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
2037 RGBColor atsuColor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel() ) ;
2038 ATSUAttributeTag atsuTags
[] =
2043 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2046 sizeof( RGBColor
) ,
2048 // Boolean kTrue = true ;
2049 // Boolean kFalse = false ;
2051 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
2052 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2057 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
2058 atsuTags
, atsuSizes
, atsuValues
);
2060 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
2064 // ---------------------------------------------------------------------------
2065 // coordinates transformations
2066 // ---------------------------------------------------------------------------
2068 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2070 return ((wxDC
*)this)->XDEV2LOG(x
);
2073 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2075 return ((wxDC
*)this)->YDEV2LOG(y
);
2078 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2080 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2083 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2085 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2088 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2090 return ((wxDC
*)this)->XLOG2DEV(x
);
2093 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2095 return ((wxDC
*)this)->YLOG2DEV(y
);
2098 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2100 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2103 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2105 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2108 #endif // wxMAC_USE_CORE_GRAPHICS