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"
34 #include "wx/mac/private.h"
36 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 #if !defined( __DARWIN__ ) || defined(__MWERKS__)
44 const double M_PI
= 3.14159265358979 ;
47 const double RAD2DEG
= 180.0 / M_PI
;
48 const short kEmulatedMode
= -1 ;
49 const short kUnsupportedMode
= -2 ;
51 extern TECObjectRef s_TECNativeCToUnicode
;
54 // The text ctrl implementation still needs that for the non hiview implementation
56 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
57 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
59 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
60 m_formerClip
= NewRgn() ;
61 m_newClip
= NewRgn() ;
62 GetClip( m_formerClip
) ;
66 // guard against half constructed objects, this just leads to a empty clip
70 win
->MacWindowToRootWindow( &x
,&y
) ;
71 // get area including focus rect
72 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
73 if ( !EmptyRgn( m_newClip
) )
74 OffsetRgn( m_newClip
, x
, y
) ;
77 SetClip( m_newClip
) ;
81 wxMacWindowClipper::~wxMacWindowClipper()
83 SetPort( m_newPort
) ;
84 SetClip( m_formerClip
) ;
85 DisposeRgn( m_newClip
) ;
86 DisposeRgn( m_formerClip
) ;
89 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
90 wxMacWindowClipper( win
)
92 // the port is already set at this point
93 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
94 GetThemeDrawingState( &m_themeDrawingState
) ;
97 wxMacWindowStateSaver::~wxMacWindowStateSaver()
99 SetPort( m_newPort
) ;
100 SetThemeDrawingState( m_themeDrawingState
, true ) ;
103 // minimal implementation only used for appearance drawing < 10.3
105 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
106 m_ph( (GrafPtr
) dc
->m_macPort
)
108 wxASSERT( dc
->Ok() ) ;
110 // dc->MacSetupPort(&m_ph) ;
112 wxMacPortSetter::~wxMacPortSetter()
114 // m_dc->MacCleanupPort(&m_ph) ;
117 //-----------------------------------------------------------------------------
119 //-----------------------------------------------------------------------------
121 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
122 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
123 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
125 //-----------------------------------------------------------------------------
126 // device context implementation
128 // more and more of the dc functionality should be implemented by calling
129 // the appropricate wxMacCGContext, but we will have to do that step by step
130 // also coordinate conversions should be moved to native matrix ops
131 //-----------------------------------------------------------------------------
133 // we always stock two context states, one at entry, to be able to preserve the
134 // state we were called with, the other one after changing to HI Graphics orientation
135 // (this one is used for getting back clippings etc)
137 wxMacCGPath::wxMacCGPath()
139 m_path
= CGPathCreateMutable() ;
142 wxMacCGPath::~wxMacCGPath()
144 CGPathRelease( m_path
) ;
147 // Starts a new subpath at
148 void wxMacCGPath::MoveToPoint( wxCoord x1
, wxCoord y1
)
150 CGPathMoveToPoint( m_path
, NULL
, x1
, y1
) ;
153 void wxMacCGPath::AddLineToPoint( wxCoord x1
, wxCoord y1
)
155 CGPathAddLineToPoint( m_path
, NULL
, x1
, y1
) ;
158 void wxMacCGPath::AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
)
160 CGPathAddQuadCurveToPoint( m_path
, NULL
, cx1
, cy1
, x1
, y1
);
163 void wxMacCGPath::AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
165 CGRect cgRect
= { { x
, y
} , { w
, h
} } ;
166 CGPathAddRect( m_path
, NULL
, cgRect
) ;
169 void wxMacCGPath::AddCircle( wxCoord x
, wxCoord y
, wxCoord r
)
171 CGPathAddArc( m_path
, NULL
, x
, y
, r
, 0.0 , 2 * M_PI
, true ) ;
174 // closes the current subpath
175 void wxMacCGPath::CloseSubpath()
177 CGPathCloseSubpath( m_path
) ;
180 CGPathRef
wxMacCGPath::GetPath() const
185 wxMacCGContext::wxMacCGContext( CGrafPtr port
)
191 wxMacCGContext::wxMacCGContext( CGContextRef cgcontext
)
194 m_cgContext
= cgcontext
;
195 CGContextSaveGState( m_cgContext
) ;
196 CGContextSaveGState( m_cgContext
) ;
199 wxMacCGContext::wxMacCGContext()
205 wxMacCGContext::~wxMacCGContext()
209 CGContextSynchronize( m_cgContext
) ;
210 CGContextRestoreGState( m_cgContext
) ;
211 CGContextRestoreGState( m_cgContext
) ;
214 CGContextRelease( m_cgContext
) ;
218 void wxMacCGContext::Clip( const wxRegion
®ion
)
220 // ClipCGContextToRegion ( m_cgContext, &bounds , (RgnHandle) dc->m_macCurrentClipRgn ) ;
223 void wxMacCGContext::StrokePath( const wxGraphicPath
*p
)
225 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
226 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
227 CGContextStrokePath( m_cgContext
) ;
230 void wxMacCGContext::DrawPath( const wxGraphicPath
*p
, int fillStyle
)
232 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
233 CGPathDrawingMode mode
= m_mode
;
234 if ( fillStyle
== wxODDEVEN_RULE
)
236 if ( mode
== kCGPathFill
)
237 mode
= kCGPathEOFill
;
238 else if ( mode
== kCGPathFillStroke
)
239 mode
= kCGPathEOFillStroke
;
241 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
242 CGContextDrawPath( m_cgContext
, mode
) ;
245 void wxMacCGContext::FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
)
247 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
248 CGContextSaveGState( m_cgContext
) ;
250 RGBColor col
= MAC_WXCOLORREF( fillColor
.GetPixel() ) ;
251 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
252 CGPathDrawingMode mode
= kCGPathFill
;
254 if ( fillStyle
== wxODDEVEN_RULE
)
255 mode
= kCGPathEOFill
;
257 CGContextBeginPath( m_cgContext
) ;
258 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
259 CGContextClosePath( m_cgContext
) ;
260 CGContextDrawPath( m_cgContext
, mode
) ;
262 CGContextRestoreGState( m_cgContext
) ;
265 wxGraphicPath
* wxMacCGContext::CreatePath()
267 // make sure that we now have a real cgref, before doing
268 // anything with paths
269 CGContextRef cg
= GetNativeContext() ;
271 return new wxMacCGPath() ;
274 // in case we only got a QDPort only create a cgref now
276 CGContextRef
wxMacCGContext::GetNativeContext()
278 if( m_cgContext
== NULL
)
281 GetPortBounds( (CGrafPtr
) m_qdPort
, &bounds
) ;
282 OSStatus status
= CreateCGContextForPort((CGrafPtr
) m_qdPort
, &m_cgContext
) ;
283 CGContextSaveGState( m_cgContext
) ;
285 wxASSERT_MSG( status
== noErr
, wxT("Cannot nest wxDCs on the same window") ) ;
286 CGContextTranslateCTM( m_cgContext
, 0 , bounds
.bottom
- bounds
.top
) ;
287 CGContextScaleCTM( m_cgContext
, 1 , -1 ) ;
289 CGContextSaveGState( m_cgContext
) ;
291 SetBrush( m_brush
) ;
296 void wxMacCGContext::SetNativeContext( CGContextRef cg
)
298 // we allow either setting or clearing but not replacing
299 wxASSERT( m_cgContext
== NULL
|| cg
== NULL
) ;
301 CGContextSaveGState( cg
) ;
307 // wrapper class for a CGPattern, always allocate on heap, never call destructor
316 // is guaranteed to be called only with a non-Null CGContextRef
317 virtual void Render( CGContextRef ctxRef
) = 0 ;
319 operator CGPatternRef() const { return m_patternRef
; }
321 virtual ~wxMacCGPattern()
323 // as this is called only when our m_patternRef is been released, don't release
327 static void _Render( void *info
, CGContextRef ctxRef
)
329 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
330 if ( self
&& ctxRef
)
331 self
->Render( ctxRef
) ;
334 static void _Dispose( void *info
)
336 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
340 CGPatternRef m_patternRef
;
342 static const CGPatternCallbacks ms_Callbacks
;
345 const CGPatternCallbacks
wxMacCGPattern::ms_Callbacks
= { 0, &wxMacCGPattern::_Render
, &wxMacCGPattern::_Dispose
};
347 class ImagePattern
: public wxMacCGPattern
350 ImagePattern( const wxBitmap
* bmp
, CGAffineTransform transform
)
352 wxASSERT( bmp
&& bmp
->Ok() ) ;
353 Init( (CGImageRef
) bmp
->CGImageCreate() , transform
) ;
356 // ImagePattern takes ownership of CGImageRef passed in
357 ImagePattern( CGImageRef image
, CGAffineTransform transform
)
363 Init( image
, transform
) ;
366 virtual void Render( CGContextRef ctxRef
)
369 HIViewDrawCGImage( ctxRef
, &m_imageBounds
, m_image
);
373 void Init( CGImageRef image
, CGAffineTransform transform
)
378 m_imageBounds
= CGRectMake( 0.0, 0.0, (float)CGImageGetWidth( m_image
), (float)CGImageGetHeight( m_image
) ) ;
379 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
380 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
381 kCGPatternTilingNoDistortion
, true , &wxMacCGPattern::ms_Callbacks
) ;
388 CGImageRelease( m_image
) ;
391 CGRect m_imageBounds
;
394 class HatchPattern
: public wxMacCGPattern
397 HatchPattern( int hatchstyle
, CGAffineTransform transform
)
399 m_hatch
= hatchstyle
;
400 m_imageBounds
= CGRectMake( 0.0, 0.0, 8.0 , 8.0 ) ;
401 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
402 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
403 kCGPatternTilingNoDistortion
, false , &wxMacCGPattern::ms_Callbacks
) ;
406 void StrokeLineSegments( CGContextRef ctxRef
, const CGPoint pts
[] , size_t count
)
408 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
409 if ( UMAGetSystemVersion() >= 0x1040 )
411 CGContextStrokeLineSegments( ctxRef
, pts
, count
) ;
416 CGContextBeginPath (ctxRef
);
417 for (size_t i
= 0; i
< count
; i
+= 2) {
418 CGContextMoveToPoint(ctxRef
, pts
[i
].x
, pts
[i
].y
);
419 CGContextAddLineToPoint(ctxRef
, pts
[i
+1].x
, pts
[i
+1].y
);
421 CGContextStrokePath(ctxRef
);
425 virtual void Render( CGContextRef ctxRef
)
429 case wxBDIAGONAL_HATCH
:
432 { 8.0 , 0.0 } , { 0.0 , 8.0 }
434 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
437 case wxCROSSDIAG_HATCH
:
440 { 0.0 , 0.0 } , { 8.0 , 8.0 } ,
441 { 8.0 , 0.0 } , { 0.0 , 8.0 }
443 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
446 case wxFDIAGONAL_HATCH
:
449 { 0.0 , 0.0 } , { 8.0 , 8.0 }
451 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
457 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
458 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
460 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
463 case wxHORIZONTAL_HATCH
:
466 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
468 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
471 case wxVERTICAL_HATCH
:
474 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
476 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
487 CGRect m_imageBounds
;
490 void wxMacCGContext::SetPen( const wxPen
&pen
)
493 if ( m_cgContext
== NULL
)
495 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
496 bool stroke
= pen
.GetStyle() != wxTRANSPARENT
;
499 // we can benchmark performance, should go into a setting later
500 CGContextSetShouldAntialias( m_cgContext
, false ) ;
505 m_mode
= kCGPathFill
; // just a default
509 m_mode
= kCGPathFill
;
513 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
514 CGContextSetRGBStrokeColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
516 /* TODO * m_dc->m_scaleX */
517 float penWidth
= pen
.GetWidth();
520 CGContextSetLineWidth( m_cgContext
, penWidth
) ;
523 switch( pen
.GetCap() )
526 cap
= kCGLineCapRound
;
528 case wxCAP_PROJECTING
:
529 cap
= kCGLineCapSquare
;
532 cap
= kCGLineCapButt
;
535 cap
= kCGLineCapButt
;
540 switch( pen
.GetJoin() )
543 join
= kCGLineJoinBevel
;
546 join
= kCGLineJoinMiter
;
549 join
= kCGLineJoinRound
;
552 join
= kCGLineJoinMiter
;
555 CGContextSetLineJoin( m_cgContext
, join
) ;
557 m_mode
= kCGPathStroke
;
560 const float *lengths
= NULL
;
561 float *userLengths
= NULL
;
563 int dashUnit
= ( penWidth
< 1.0 ) ? 1.0 : penWidth
;
565 const float dotted
[] = { dashUnit
, dashUnit
+ 2.0 };
566 const float short_dashed
[] = { 9.0 , 6.0 };
567 const float dashed
[] = { 19.0 , 9.0 };
568 const float dotted_dashed
[] = { 9.0 , 6.0 , 3.0 , 3.0 };
571 switch( pen
.GetStyle() )
577 count
= WXSIZEOF(dotted
);
581 count
= WXSIZEOF(dashed
) ;
584 lengths
= short_dashed
;
585 count
= WXSIZEOF(short_dashed
) ;
588 lengths
= dotted_dashed
;
589 count
= WXSIZEOF(dotted_dashed
);
593 count
= pen
.GetDashes( &dashes
) ;
594 if ((dashes
!= NULL
) && (count
> 0))
596 userLengths
= new float[count
] ;
597 for( int i
= 0 ; i
< count
; ++i
)
599 userLengths
[i
] = (float)dashes
[i
] * dashUnit
;
601 if ( i
% 2 == 1 && userLengths
[i
] < dashUnit
+ 2.0 )
602 userLengths
[i
] = dashUnit
+ 2.0 ;
603 else if ( i
% 2 == 0 && userLengths
[i
] < dashUnit
)
604 userLengths
[i
] = dashUnit
;
607 lengths
= userLengths
;
611 float alphaArray
[1] = { 1.0 } ;
612 wxBitmap
* bmp
= pen
.GetStipple() ;
613 if ( bmp
&& bmp
->Ok() )
615 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
616 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
617 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
618 CGContextSetStrokePattern( m_cgContext
, pattern
, alphaArray
) ;
624 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
625 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
626 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( pen
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
628 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
629 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
631 CGContextSetStrokePattern( m_cgContext
, pattern
, colorArray
) ;
636 if ((lengths
!= NULL
) && (count
> 0))
638 CGContextSetLineDash( m_cgContext
, 0 , lengths
, count
) ;
639 // force the line cap, otherwise we get artifacts (overlaps) and just solid lines
640 cap
= kCGLineCapButt
;
644 CGContextSetLineDash( m_cgContext
, 0 , NULL
, 0 ) ;
646 CGContextSetLineCap( m_cgContext
, cap
) ;
648 delete[] userLengths
;
650 if ( fill
&& stroke
)
652 m_mode
= kCGPathFillStroke
;
657 void wxMacCGContext::SetBrush( const wxBrush
&brush
)
660 if ( m_cgContext
== NULL
)
663 bool fill
= brush
.GetStyle() != wxTRANSPARENT
;
664 bool stroke
= m_pen
.GetStyle() != wxTRANSPARENT
;
667 // we can benchmark performance, should go into a setting later
668 CGContextSetShouldAntialias( m_cgContext
, false ) ;
674 m_mode
= kCGPathFill
; // just a default
678 if ( brush
.GetStyle() == wxSOLID
)
680 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
681 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
683 else if ( brush
.IsHatch() )
685 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
686 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
687 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( brush
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
689 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
690 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
692 CGContextSetFillPattern( m_cgContext
, pattern
, colorArray
) ;
696 // now brush is a bitmap
697 float alphaArray
[1] = { 1.0 } ;
698 wxBitmap
* bmp
= brush
.GetStipple() ;
699 if ( bmp
&& bmp
->Ok() )
701 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
702 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
703 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
704 CGContextSetFillPattern( m_cgContext
, pattern
, alphaArray
) ;
707 m_mode
= kCGPathFill
;
711 m_mode
= kCGPathStroke
;
713 if ( fill
&& stroke
)
715 m_mode
= kCGPathFillStroke
;
720 void AddEllipticArcToPath(CGContextRef c
, CGPoint center
, float a
, float b
, float fromDegree
, float toDegree
)
722 CGContextSaveGState(c
);
723 CGContextTranslateCTM(c
, center
.x
, center
.y
);
724 CGContextScaleCTM(c
, a
, b
);
725 CGContextMoveToPoint(c
, 1, 0);
726 CGContextAddArc(c
, 0, 0, 1, DegToRad(fromDegree
), DegToRad(toDegree
), 0);
727 CGContextClosePath(c
);
728 CGContextRestoreGState(c
);
731 void AddRoundedRectToPath(CGContextRef c
, CGRect rect
, float ovalWidth
,
735 if (ovalWidth
== 0 || ovalHeight
== 0)
737 CGContextAddRect(c
, rect
);
740 CGContextSaveGState(c
);
741 CGContextTranslateCTM(c
, CGRectGetMinX(rect
), CGRectGetMinY(rect
));
742 CGContextScaleCTM(c
, ovalWidth
, ovalHeight
);
743 fw
= CGRectGetWidth(rect
) / ovalWidth
;
744 fh
= CGRectGetHeight(rect
) / ovalHeight
;
745 CGContextMoveToPoint(c
, fw
, fh
/2);
746 CGContextAddArcToPoint(c
, fw
, fh
, fw
/2, fh
, 1);
747 CGContextAddArcToPoint(c
, 0, fh
, 0, fh
/2, 1);
748 CGContextAddArcToPoint(c
, 0, 0, fw
/2, 0, 1);
749 CGContextAddArcToPoint(c
, fw
, 0, fw
, fh
/2, 1);
750 CGContextClosePath(c
);
751 CGContextRestoreGState(c
);
758 m_mm_to_pix_x
= mm2pt
;
759 m_mm_to_pix_y
= mm2pt
;
761 m_externalDeviceOriginX
= 0;
762 m_externalDeviceOriginY
= 0;
763 m_logicalScaleX
= 1.0;
764 m_logicalScaleY
= 1.0;
769 m_needComputeScaleX
= FALSE
;
770 m_needComputeScaleY
= FALSE
;
774 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
776 m_pen
= *wxBLACK_PEN
;
777 m_font
= *wxNORMAL_FONT
;
778 m_brush
= *wxWHITE_BRUSH
;
780 m_macATSUIStyle
= NULL
;
782 m_graphicContext
= NULL
;
787 if( m_macATSUIStyle
)
789 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
790 m_macATSUIStyle
= NULL
;
793 delete m_graphicContext
;
796 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
798 wxCHECK_RET( Ok(), wxT("invalid window dc") );
799 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
800 wxCoord xx
= XLOG2DEVMAC(x
);
801 wxCoord yy
= YLOG2DEVMAC(y
);
802 wxCoord w
= bmp
.GetWidth();
803 wxCoord h
= bmp
.GetHeight();
804 wxCoord ww
= XLOG2DEVREL(w
);
805 wxCoord hh
= YLOG2DEVREL(h
);
807 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
808 CGImageRef image
= (CGImageRef
)( bmp
.CGImageCreate() ) ;
809 HIRect r
= CGRectMake( xx
, yy
, ww
, hh
) ;
810 HIViewDrawCGImage( cg
, &r
, image
) ;
811 CGImageRelease( image
) ;
814 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
816 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
817 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
819 wxCoord xx
= XLOG2DEVMAC(x
);
820 wxCoord yy
= YLOG2DEVMAC(y
);
821 wxCoord w
= icon
.GetWidth();
822 wxCoord h
= icon
.GetHeight();
823 wxCoord ww
= XLOG2DEVREL(w
);
824 wxCoord hh
= YLOG2DEVREL(h
);
826 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
827 CGRect r
= CGRectMake( 00 , 00 , ww
, hh
) ;
828 CGContextSaveGState(cg
);
829 CGContextTranslateCTM(cg
, xx
, yy
+ hh
);
830 CGContextScaleCTM(cg
, 1, -1);
831 PlotIconRefInContext( cg
, &r
, kAlignNone
, kTransformNone
,
832 NULL
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
833 CGContextRestoreGState( cg
) ;
836 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
838 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
839 wxCoord xx
, yy
, ww
, hh
;
842 ww
= XLOG2DEVREL(width
);
843 hh
= YLOG2DEVREL(height
);
845 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
846 CGRect clipRect
= CGRectMake( xx
,yy
, ww
, hh
) ;
847 CGContextClipToRect( cgContext
, clipRect
) ;
849 // SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ;
850 // SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
853 m_clipX1
= wxMax( m_clipX1
, xx
);
854 m_clipY1
= wxMax( m_clipY1
, yy
);
855 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
856 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
866 // TODO as soon as we don't reset the context for each operation anymore
867 // we have to update the context as well
870 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
872 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
875 DestroyClippingRegion();
879 region
.GetBox( x
, y
, w
, h
);
880 wxCoord xx
, yy
, ww
, hh
;
885 // if we have a scaling that we cannot map onto native regions
886 // we must use the box
887 if ( ww
!= w
|| hh
!= h
)
889 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
894 CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ;
895 if ( xx != x || yy != y )
897 OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ;
899 SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
903 m_clipX1
= wxMax( m_clipX1
, xx
);
904 m_clipY1
= wxMax( m_clipY1
, yy
);
905 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
906 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
919 void wxDC::DestroyClippingRegion()
921 // CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
922 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
923 CGContextRestoreGState( cgContext
);
924 CGContextSaveGState( cgContext
);
925 m_graphicContext
->SetPen( m_pen
) ;
926 m_graphicContext
->SetBrush( m_brush
) ;
930 void wxDC::DoGetSizeMM( int* width
, int* height
) const
935 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
936 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
939 void wxDC::SetTextForeground( const wxColour
&col
)
941 wxCHECK_RET(Ok(), wxT("Invalid DC"));
942 if ( col
!= m_textForegroundColour
)
944 m_textForegroundColour
= col
;
949 void wxDC::SetTextBackground( const wxColour
&col
)
951 wxCHECK_RET(Ok(), wxT("Invalid DC"));
952 m_textBackgroundColour
= col
;
955 void wxDC::SetMapMode( int mode
)
960 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
963 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
966 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
969 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
973 SetLogicalScale( 1.0, 1.0 );
976 if (mode
!= wxMM_TEXT
)
978 m_needComputeScaleX
= TRUE
;
979 m_needComputeScaleY
= TRUE
;
983 void wxDC::SetUserScale( double x
, double y
)
985 // allow negative ? -> no
988 ComputeScaleAndOrigin();
991 void wxDC::SetLogicalScale( double x
, double y
)
996 ComputeScaleAndOrigin();
999 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
1001 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
1002 m_logicalOriginY
= y
* m_signY
;
1003 ComputeScaleAndOrigin();
1006 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
1008 m_externalDeviceOriginX
= x
;
1009 m_externalDeviceOriginY
= y
;
1010 ComputeScaleAndOrigin();
1013 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
1015 m_signX
= (xLeftRight
? 1 : -1);
1016 m_signY
= (yBottomUp
? -1 : 1);
1017 ComputeScaleAndOrigin();
1020 wxSize
wxDC::GetPPI() const
1022 return wxSize(72, 72);
1025 int wxDC::GetDepth() const
1030 void wxDC::ComputeScaleAndOrigin()
1032 // CMB: copy scale to see if it changes
1033 double origScaleX
= m_scaleX
;
1034 double origScaleY
= m_scaleY
;
1035 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
1036 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
1037 m_deviceOriginX
= m_externalDeviceOriginX
;
1038 m_deviceOriginY
= m_externalDeviceOriginY
;
1039 // CMB: if scale has changed call SetPen to recalulate the line width
1040 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
1042 // this is a bit artificial, but we need to force wxDC to think
1043 // the pen has changed
1044 wxPen
pen(GetPen());
1050 void wxDC::SetPalette( const wxPalette
& palette
)
1054 void wxDC::SetBackgroundMode( int mode
)
1056 m_backgroundMode
= mode
;
1059 void wxDC::SetFont( const wxFont
&font
)
1065 void wxDC::SetPen( const wxPen
&pen
)
1070 if ( m_graphicContext
)
1072 if ( m_pen
.GetStyle() == wxSOLID
|| m_pen
.GetStyle() == wxTRANSPARENT
)
1074 m_graphicContext
->SetPen( m_pen
) ;
1078 // we have to compensate for moved device origins etc. otherwise patterned pens are standing still
1079 // eg when using a wxScrollWindow and scrolling around
1080 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1081 int origX
= XLOG2DEVMAC(0) ;
1082 int origY
= YLOG2DEVMAC(0) ;
1083 CGContextTranslateCTM (cgContext
,origX
,origY
);
1084 m_graphicContext
->SetPen( m_pen
) ;
1085 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1090 void wxDC::SetBrush( const wxBrush
&brush
)
1092 if (m_brush
== brush
)
1095 if ( m_graphicContext
)
1097 if ( brush
.GetStyle() == wxSOLID
|| brush
.GetStyle() == wxTRANSPARENT
)
1099 m_graphicContext
->SetBrush( m_brush
) ;
1103 // we have to compensate for moved device origins etc. otherwise patterned brushes are standing still
1104 // eg when using a wxScrollWindow and scrolling around
1105 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1106 int origX
= XLOG2DEVMAC(0) ;
1107 int origY
= YLOG2DEVMAC(0) ;
1108 CGContextTranslateCTM (cgContext
,origX
,origY
);
1109 m_graphicContext
->SetBrush( m_brush
) ;
1110 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1115 void wxDC::SetBackground( const wxBrush
&brush
)
1117 if (m_backgroundBrush
== brush
)
1119 m_backgroundBrush
= brush
;
1120 if (!m_backgroundBrush
.Ok())
1124 void wxDC::SetLogicalFunction( int function
)
1126 if (m_logicalFunction
== function
)
1128 m_logicalFunction
= function
;
1131 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
1132 const wxColour
& col
, int style
);
1134 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
1135 const wxColour
& col
, int style
)
1137 return wxDoFloodFill(this, x
, y
, col
, style
);
1140 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
1142 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1143 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1144 wxMacPortSaver
helper((CGrafPtr
)m_macPort
) ;
1147 XLOG2DEVMAC(x
) + m_macLocalOriginInPort
.x
- m_macLocalOrigin
.x
,
1148 YLOG2DEVMAC(y
) + m_macLocalOriginInPort
.y
- m_macLocalOrigin
.y
, &colour
);
1149 // Convert from Mac colour to wx
1150 col
->Set( colour
.red
>> 8,
1156 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1158 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1160 if ( m_logicalFunction
!= wxCOPY
)
1163 wxCoord xx1
= XLOG2DEVMAC(x1
) ;
1164 wxCoord yy1
= YLOG2DEVMAC(y1
) ;
1165 wxCoord xx2
= XLOG2DEVMAC(x2
) ;
1166 wxCoord yy2
= YLOG2DEVMAC(y2
) ;
1168 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1169 path
->MoveToPoint( xx1
, yy1
) ;
1170 path
->AddLineToPoint( xx2
, yy2
) ;
1171 path
->CloseSubpath() ;
1172 m_graphicContext
->StrokePath( path
) ;
1175 CalcBoundingBox(x1
, y1
);
1176 CalcBoundingBox(x2
, y2
);
1179 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
1181 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
1183 if ( m_logicalFunction
!= wxCOPY
)
1189 wxCoord xx
= XLOG2DEVMAC(x
);
1190 wxCoord yy
= YLOG2DEVMAC(y
);
1192 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1193 path
->MoveToPoint( XLOG2DEVMAC(0), yy
) ;
1194 path
->AddLineToPoint( XLOG2DEVMAC(w
), yy
) ;
1195 path
->CloseSubpath() ;
1196 path
->MoveToPoint( xx
, YLOG2DEVMAC(0) ) ;
1197 path
->AddLineToPoint( xx
, YLOG2DEVMAC(h
) ) ;
1198 path
->CloseSubpath() ;
1199 m_graphicContext
->StrokePath( path
) ;
1202 CalcBoundingBox(x
, y
);
1203 CalcBoundingBox(x
+w
, y
+h
);
1206 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
1207 wxCoord x2
, wxCoord y2
,
1208 wxCoord xc
, wxCoord yc
)
1210 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
1212 if ( m_logicalFunction
!= wxCOPY
)
1215 wxCoord xx1
= XLOG2DEVMAC(x1
);
1216 wxCoord yy1
= YLOG2DEVMAC(y1
);
1217 wxCoord xx2
= XLOG2DEVMAC(x2
);
1218 wxCoord yy2
= YLOG2DEVMAC(y2
);
1219 wxCoord xxc
= XLOG2DEVMAC(xc
);
1220 wxCoord yyc
= YLOG2DEVMAC(yc
);
1221 double dx
= xx1
- xxc
;
1222 double dy
= yy1
- yyc
;
1223 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
1224 wxCoord rad
= (wxCoord
)radius
;
1226 if (xx1
== xx2
&& yy1
== yy2
)
1231 else if (radius
== 0.0)
1237 sa
= (xx1
- xxc
== 0) ?
1238 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
1239 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
1240 ea
= (xx2
- xxc
== 0) ?
1241 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
1242 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
1245 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1246 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1247 CGContextRef ctx
= mctx
->GetNativeContext() ;
1248 CGContextSaveGState( ctx
) ;
1249 CGContextTranslateCTM( ctx
, xxc
, yyc
);
1250 CGContextScaleCTM( ctx
, 1 , -1 ) ;
1252 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1253 CGContextAddArc( ctx
, 0, 0 , rad
, DegToRad(sa
), DegToRad(ea
), 0);
1255 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1256 CGContextRestoreGState( ctx
) ;
1257 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1260 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1261 double sa
, double ea
)
1263 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
1265 if ( m_logicalFunction
!= wxCOPY
)
1268 wxCoord xx
= XLOG2DEVMAC(x
);
1269 wxCoord yy
= YLOG2DEVMAC(y
);
1270 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
1271 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
1272 // handle -ve width and/or height
1273 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1274 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1276 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1278 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1279 CGContextRef ctx
= mctx
->GetNativeContext() ;
1281 CGContextSaveGState( ctx
) ;
1282 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1283 CGContextScaleCTM( ctx
, 1 * ww
/ 2 , -1 * hh
/ 2 ) ;
1285 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1286 CGContextAddArc( ctx
, 0, 0, 1, DegToRad(sa
), DegToRad(ea
), 0);
1288 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1289 CGContextRestoreGState( ctx
) ;
1290 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1293 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
1295 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1296 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 ) ;
1299 void wxDC::DoDrawLines(int n
, wxPoint points
[],
1300 wxCoord xoffset
, wxCoord yoffset
)
1302 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1304 if ( m_logicalFunction
!= wxCOPY
)
1307 wxCoord x1
, x2
, y1
, y2
;
1308 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1309 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1310 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1311 path
->MoveToPoint( x1
, y1
) ;
1312 for (int i
= 1; i
< n
; i
++)
1314 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1315 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1317 path
->AddLineToPoint( x2
, y2
) ;
1319 m_graphicContext
->StrokePath( path
) ;
1324 void wxDC::DoDrawSpline(wxList
*points
)
1326 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1328 if ( m_logicalFunction
!= wxCOPY
)
1331 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1333 wxList::compatibility_iterator node
= points
->GetFirst();
1334 if (node
== wxList::compatibility_iterator())
1338 wxPoint
*p
= (wxPoint
*)node
->GetData();
1343 node
= node
->GetNext();
1344 p
= (wxPoint
*)node
->GetData();
1348 wxCoord cx1
= ( x1
+ x2
) / 2;
1349 wxCoord cy1
= ( y1
+ y2
) / 2;
1351 path
->MoveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ) ;
1352 path
->AddLineToPoint( XLOG2DEVMAC( cx1
) , XLOG2DEVMAC( cy1
) ) ;
1355 while ((node
= node
->GetNext()) != NULL
)
1357 while ((node
= node
->GetNext()))
1358 #endif // !wxUSE_STL
1360 p
= (wxPoint
*)node
->GetData();
1365 wxCoord cx4
= (x1
+ x2
) / 2;
1366 wxCoord cy4
= (y1
+ y2
) / 2;
1368 path
->AddQuadCurveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ,
1369 XLOG2DEVMAC( cx4
) , XLOG2DEVMAC( cy4
) ) ;
1375 path
->AddLineToPoint( XLOG2DEVMAC( x2
) , XLOG2DEVMAC( y2
) ) ;
1377 m_graphicContext
->StrokePath( path
) ;
1382 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
1383 wxCoord xoffset
, wxCoord yoffset
,
1386 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1387 wxCoord x1
, x2
, y1
, y2
;
1388 if ( n
== 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
1391 if ( m_logicalFunction
!= wxCOPY
)
1394 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1395 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1397 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1398 path
->MoveToPoint( x1
, y1
) ;
1399 for (int i
= 1; i
< n
; i
++)
1401 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1402 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1404 path
->AddLineToPoint( x2
, y2
) ;
1406 if ( x1
!= x2
|| y1
!= y2
)
1408 path
->AddLineToPoint( x1
,y1
) ;
1410 path
->CloseSubpath() ;
1411 m_graphicContext
->DrawPath( path
, fillStyle
) ;
1415 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1417 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1419 if ( m_logicalFunction
!= wxCOPY
)
1422 wxCoord xx
= XLOG2DEVMAC(x
);
1423 wxCoord yy
= YLOG2DEVMAC(y
);
1424 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1425 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1426 // CMB: draw nothing if transformed w or h is 0
1427 if (ww
== 0 || hh
== 0)
1429 // CMB: handle -ve width and/or height
1440 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1441 path
->AddRectangle( xx
, yy
, ww
, hh
) ;
1442 m_graphicContext
->DrawPath( path
) ;
1446 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1447 wxCoord width
, wxCoord height
,
1450 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1452 if ( m_logicalFunction
!= wxCOPY
)
1457 radius
= - radius
* ((width
< height
) ? width
: height
);
1458 wxCoord xx
= XLOG2DEVMAC(x
);
1459 wxCoord yy
= YLOG2DEVMAC(y
);
1460 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1461 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1462 // CMB: draw nothing if transformed w or h is 0
1463 if (ww
== 0 || hh
== 0)
1465 // CMB: handle -ve width and/or height
1476 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1477 CGContextRef ctx
= mctx
->GetNativeContext() ;
1478 AddRoundedRectToPath( ctx
, CGRectMake( xx
, yy
, ww
, hh
) , 16 ,16 ) ;
1479 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1482 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1484 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1486 if ( m_logicalFunction
!= wxCOPY
)
1489 wxCoord xx
= XLOG2DEVMAC(x
);
1490 wxCoord yy
= YLOG2DEVMAC(y
);
1491 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1492 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1493 // CMB: draw nothing if transformed w or h is 0
1494 if (ww
== 0 || hh
== 0)
1496 // CMB: handle -ve width and/or height
1508 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1509 CGContextRef ctx
= mctx
->GetNativeContext() ;
1510 CGContextSaveGState( ctx
) ;
1511 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1512 CGContextScaleCTM( ctx
, ww
/ 2 , hh
/ 2 ) ;
1513 CGContextAddArc( ctx
, 0, 0, 1, 0 , 2*M_PI
, 0);
1514 CGContextRestoreGState( ctx
) ;
1515 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1518 bool wxDC::CanDrawBitmap(void) const
1523 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1524 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1525 wxCoord xsrcMask
, wxCoord ysrcMask
)
1527 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1528 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1529 if ( logical_func
== wxNO_OP
)
1531 if (xsrcMask
== -1 && ysrcMask
== -1)
1533 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1536 wxCoord yysrc
= source
->YLOG2DEVMAC(ysrc
) ;
1537 wxCoord xxsrc
= source
->XLOG2DEVMAC(xsrc
) ;
1538 wxCoord wwsrc
= source
->XLOG2DEVREL(width
) ;
1539 wxCoord hhsrc
= source
->YLOG2DEVREL(height
) ;
1541 wxCoord yydest
= YLOG2DEVMAC(ydest
) ;
1542 wxCoord xxdest
= XLOG2DEVMAC(xdest
) ;
1543 wxCoord wwdest
= XLOG2DEVREL(width
) ;
1544 wxCoord hhdest
= YLOG2DEVREL(height
) ;
1546 wxMemoryDC
* memdc
= dynamic_cast<wxMemoryDC
*>(source
) ;
1547 if ( memdc
&& logical_func
== wxCOPY
)
1549 wxBitmap blit
= memdc
->GetSelectedObject() ;
1550 wxASSERT_MSG( blit
.Ok() , wxT("Invalid bitmap for blitting") ) ;
1552 wxCoord bmpwidth
= blit
.GetWidth();
1553 wxCoord bmpheight
= blit
.GetHeight();
1555 if ( xxsrc
!= 0 || yysrc
!= 0 || bmpwidth
!= wwsrc
|| bmpheight
!= hhsrc
)
1557 wwsrc
= wxMin( wwsrc
, bmpwidth
- xxsrc
) ;
1558 hhsrc
= wxMin( hhsrc
, bmpheight
- yysrc
) ;
1559 if ( wwsrc
> 0 && hhsrc
> 0 )
1561 if ( xxsrc
>= 0 && yysrc
>= 0 )
1563 wxRect
subrect( xxsrc
, yysrc
, wwsrc
, hhsrc
) ;
1564 blit
= blit
.GetSubBitmap( subrect
) ;
1568 // in this case we'd probably have to adjust the different coordinates, but
1569 // we have to find out proper contract first
1570 blit
= wxNullBitmap
;
1575 blit
= wxNullBitmap
;
1580 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1581 CGImageRef image
= (CGImageRef
)( blit
.CGImageCreate() ) ;
1582 HIRect r
= CGRectMake( xxdest
, yydest
, wwdest
, hhdest
) ;
1583 HIViewDrawCGImage( cg
, &r
, image
) ;
1584 CGImageRelease( image
) ;
1591 CGContextRef cg = (wxMacCGContext*)(source->GetGraphicContext())->GetNativeContext() ;
1592 void *data = CGBitmapContextGetData( cg ) ;
1594 return FALSE
; // wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts") ) ;
1599 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1602 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1604 if ( str
.Length() == 0 )
1607 if ( m_logicalFunction
!= wxCOPY
)
1610 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1612 OSStatus status
= noErr
;
1613 ATSUTextLayout atsuLayout
;
1614 UniCharCount chars
= str
.Length() ;
1615 UniChar
* ubuf
= NULL
;
1616 #if SIZEOF_WCHAR_T == 4
1617 wxMBConvUTF16 converter
;
1619 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1620 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1621 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1623 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1624 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1625 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1626 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1628 chars
= unicharlen
/ 2 ;
1631 ubuf
= (UniChar
*) str
.wc_str() ;
1633 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1634 chars
= wxWcslen( wchar
.data() ) ;
1635 ubuf
= (UniChar
*) wchar
.data() ;
1639 int drawX
= XLOG2DEVMAC(x
) ;
1640 int drawY
= YLOG2DEVMAC(y
) ;
1642 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1643 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1645 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1647 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1648 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1650 int iAngle
= int( angle
);
1651 if ( abs(iAngle
) > 0 )
1653 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1654 ATSUAttributeTag atsuTags
[] =
1656 kATSULineRotationTag
,
1658 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1662 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1666 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1667 atsuTags
, atsuSizes
, atsuValues
) ;
1670 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1671 ATSUAttributeTag atsuTags
[] =
1675 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1677 sizeof( CGContextRef
) ,
1679 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1683 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1684 atsuTags
, atsuSizes
, atsuValues
) ;
1687 ATSUTextMeasurement textBefore
;
1688 ATSUTextMeasurement textAfter
;
1689 ATSUTextMeasurement ascent
;
1690 ATSUTextMeasurement descent
;
1692 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1693 &textBefore
, &textAfter
, &ascent
, &descent
);
1694 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1698 if ( m_backgroundMode
== wxSOLID
)
1700 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1704 path
->AddLineToPoint(
1705 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ,
1706 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ) ;
1707 path
->AddLineToPoint(
1708 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) + cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1709 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) - sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1710 path
->AddLineToPoint(
1711 (int) (drawX
+ cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1712 (int) (drawY
- sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1714 m_graphicContext
->FillPath( path
, m_textBackgroundColour
) ;
1718 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1719 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1721 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1722 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1723 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1725 CGContextSaveGState(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext());
1726 CGContextTranslateCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), drawX
, drawY
);
1727 CGContextScaleCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), 1, -1);
1728 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1729 IntToFixed(0) , IntToFixed(0) );
1730 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1731 CGContextRestoreGState( ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ) ;
1733 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1734 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1736 ::ATSUDisposeTextLayout(atsuLayout
);
1737 #if SIZEOF_WCHAR_T == 4
1742 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1744 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1745 DoDrawRotatedText( strtext
, x
, y
, 0.0 ) ;
1748 bool wxDC::CanGetTextExtent() const
1750 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1754 void wxDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1755 wxCoord
*descent
, wxCoord
*externalLeading
,
1756 wxFont
*theFont
) const
1758 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1759 wxFont formerFont
= m_font
;
1762 // work around the constness
1763 *((wxFont
*)(&m_font
)) = *theFont
;
1767 if ( str
.Length() == 0 )
1770 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1772 OSStatus status
= noErr
;
1773 ATSUTextLayout atsuLayout
;
1774 UniCharCount chars
= str
.Length() ;
1775 UniChar
* ubuf
= NULL
;
1776 #if SIZEOF_WCHAR_T == 4
1777 wxMBConvUTF16 converter
;
1779 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1780 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1781 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1783 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1784 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1785 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1786 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1788 chars
= unicharlen
/ 2 ;
1791 ubuf
= (UniChar
*) str
.wc_str() ;
1793 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1794 chars
= wxWcslen( wchar
.data() ) ;
1795 ubuf
= (UniChar
*) wchar
.data() ;
1800 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1801 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1803 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the text") );
1805 ATSUTextMeasurement textBefore
;
1806 ATSUTextMeasurement textAfter
;
1807 ATSUTextMeasurement textAscent
;
1808 ATSUTextMeasurement textDescent
;
1810 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1811 &textBefore
, &textAfter
, &textAscent
, &textDescent
);
1814 *height
= YDEV2LOGREL( FixedToInt(textAscent
+ textDescent
) ) ;
1816 *descent
=YDEV2LOGREL( FixedToInt(textDescent
) );
1817 if ( externalLeading
)
1818 *externalLeading
= 0 ;
1820 *width
= XDEV2LOGREL( FixedToInt(textAfter
- textBefore
) ) ;
1822 ::ATSUDisposeTextLayout(atsuLayout
);
1823 #if SIZEOF_WCHAR_T == 4
1828 // work around the constness
1829 *((wxFont
*)(&m_font
)) = formerFont
;
1835 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1837 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1840 widths
.Add(0, text
.Length());
1842 if (text
.Length() == 0)
1845 ATSUTextLayout atsuLayout
;
1846 UniCharCount chars
= text
.Length() ;
1847 UniChar
* ubuf
= NULL
;
1848 #if SIZEOF_WCHAR_T == 4
1849 wxMBConvUTF16 converter
;
1851 size_t unicharlen
= converter
.WC2MB( NULL
, text
.wc_str() , 0 ) ;
1852 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1853 converter
.WC2MB( (char*) ubuf
, text
.wc_str(), unicharlen
+ 2 ) ;
1855 const wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1856 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1857 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1858 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1860 chars
= unicharlen
/ 2 ;
1863 ubuf
= (UniChar
*) text
.wc_str() ;
1865 wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1866 chars
= wxWcslen( wchar
.data() ) ;
1867 ubuf
= (UniChar
*) wchar
.data() ;
1872 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1873 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1875 for ( int pos
= 0; pos
< (int)chars
; pos
++ ) {
1876 unsigned long actualNumberOfBounds
= 0;
1877 ATSTrapezoid glyphBounds
;
1879 // We get a single bound, since the text should only require one. If it requires more, there is an issue
1881 result
= ATSUGetGlyphBounds( atsuLayout
, 0, 0, kATSUFromTextBeginning
, pos
+ 1, kATSUseDeviceOrigins
, 1, &glyphBounds
, &actualNumberOfBounds
);
1882 if (result
!= noErr
|| actualNumberOfBounds
!= 1 )
1887 widths
[pos
] = XDEV2LOGREL(FixedToInt( glyphBounds
.upperRight
.x
- glyphBounds
.upperLeft
.x
));
1888 //unsigned char uch = s[i];
1891 ::ATSUDisposeTextLayout(atsuLayout
);
1895 wxCoord
wxDC::GetCharWidth(void) const
1898 DoGetTextExtent(wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
) ;
1902 wxCoord
wxDC::GetCharHeight(void) const
1905 DoGetTextExtent(wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
) ;
1909 void wxDC::Clear(void)
1911 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1913 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1915 HIRect rect
= CGRectMake( -10000 , -10000 , 20000 , 20000 ) ;
1916 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1917 switch( m_backgroundBrush
.MacGetBrushKind() )
1919 case kwxMacBrushTheme
:
1921 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1922 if ( HIThemeSetFill
!= 0 )
1924 HIThemeSetFill( m_backgroundBrush
.MacGetTheme(), NULL
, cg
, kHIThemeOrientationNormal
);
1925 CGContextFillRect(cg
, rect
);
1932 GetThemeBrushAsColor( m_backgroundBrush
.MacGetTheme(), 32, true, &color
);
1933 CGContextSetRGBFillColor( cg
, (float) color
.red
/ 65536,
1934 (float) color
.green
/ 65536, (float) color
.blue
/ 65536, 1 );
1935 CGContextFillRect( cg
, rect
);
1938 // reset to normal value
1939 RGBColor col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
1940 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0, col
.green
/ 65536.0, col
.blue
/ 65536.0, 1.0 );
1943 case kwxMacBrushThemeBackground
:
1945 wxFAIL_MSG( wxT("There shouldn't be theme backgrounds under Quartz") ) ;
1946 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1947 if ( UMAGetSystemVersion() >= 0x1030 )
1949 HIThemeBackgroundDrawInfo drawInfo
;
1950 drawInfo
.version
= 0 ;
1951 drawInfo
.state
= kThemeStateActive
;
1952 drawInfo
.kind
= m_backgroundBrush
.MacGetThemeBackground(NULL
) ;
1953 if ( drawInfo
.kind
== kThemeBackgroundMetal
)
1954 HIThemeDrawBackground( &rect
, &drawInfo
, cg
,
1955 kHIThemeOrientationNormal
) ;
1956 HIThemeApplyBackground( &rect
, &drawInfo
, cg
,
1957 kHIThemeOrientationNormal
) ;
1965 case kwxMacBrushColour
:
1967 RGBColor col
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) ;
1968 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
1969 CGContextFillRect(cg
, rect
);
1971 // reset to normal value
1972 col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
1973 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
1980 void wxDC::MacInstallFont() const
1982 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1984 if( m_macATSUIStyle
)
1986 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
1987 m_macATSUIStyle
= NULL
;
1992 OSStatus status
= noErr
;
1993 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1994 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1996 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1997 RGBColor atsuColor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel() ) ;
1998 ATSUAttributeTag atsuTags
[] =
2003 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2006 sizeof( RGBColor
) ,
2008 // Boolean kTrue = true ;
2009 // Boolean kFalse = false ;
2011 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
2012 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2017 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
2018 atsuTags
, atsuSizes
, atsuValues
);
2020 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
2024 // ---------------------------------------------------------------------------
2025 // coordinates transformations
2026 // ---------------------------------------------------------------------------
2028 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2030 return ((wxDC
*)this)->XDEV2LOG(x
);
2033 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2035 return ((wxDC
*)this)->YDEV2LOG(y
);
2038 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2040 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2043 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2045 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2048 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2050 return ((wxDC
*)this)->XLOG2DEV(x
);
2053 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2055 return ((wxDC
*)this)->YLOG2DEV(y
);
2058 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2060 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2063 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2065 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2068 #endif // wxMAC_USE_CORE_GRAPHICS