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) ;
113 wxMacPortSetter::~wxMacPortSetter()
115 // m_dc->MacCleanupPort(&m_ph) ;
118 //-----------------------------------------------------------------------------
120 //-----------------------------------------------------------------------------
122 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
123 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
124 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
126 //-----------------------------------------------------------------------------
127 // device context implementation
129 // more and more of the dc functionality should be implemented by calling
130 // the appropricate wxMacCGContext, but we will have to do that step by step
131 // also coordinate conversions should be moved to native matrix ops
132 //-----------------------------------------------------------------------------
134 // we always stock two context states, one at entry, to be able to preserve the
135 // state we were called with, the other one after changing to HI Graphics orientation
136 // (this one is used for getting back clippings etc)
138 wxMacCGPath::wxMacCGPath()
140 m_path
= CGPathCreateMutable() ;
143 wxMacCGPath::~wxMacCGPath()
145 CGPathRelease( m_path
) ;
148 // Starts a new subpath at
149 void wxMacCGPath::MoveToPoint( wxCoord x1
, wxCoord y1
)
151 CGPathMoveToPoint( m_path
, NULL
, x1
, y1
) ;
154 void wxMacCGPath::AddLineToPoint( wxCoord x1
, wxCoord y1
)
156 CGPathAddLineToPoint( m_path
, NULL
, x1
, y1
) ;
159 void wxMacCGPath::AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
)
161 CGPathAddQuadCurveToPoint( m_path
, NULL
, cx1
, cy1
, x1
, y1
);
164 void wxMacCGPath::AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
166 CGRect cgRect
= { { x
, y
} , { w
, h
} } ;
167 CGPathAddRect( m_path
, NULL
, cgRect
) ;
170 void wxMacCGPath::AddCircle( wxCoord x
, wxCoord y
, wxCoord r
)
172 CGPathAddArc( m_path
, NULL
, x
, y
, r
, 0.0 , 2 * M_PI
, true ) ;
175 // closes the current subpath
176 void wxMacCGPath::CloseSubpath()
178 CGPathCloseSubpath( m_path
) ;
181 CGPathRef
wxMacCGPath::GetPath() const
186 wxMacCGContext::wxMacCGContext( CGrafPtr port
)
192 wxMacCGContext::wxMacCGContext( CGContextRef cgcontext
)
195 m_cgContext
= cgcontext
;
196 CGContextSaveGState( m_cgContext
) ;
197 CGContextSaveGState( m_cgContext
) ;
200 wxMacCGContext::wxMacCGContext()
206 wxMacCGContext::~wxMacCGContext()
210 CGContextSynchronize( m_cgContext
) ;
211 CGContextRestoreGState( m_cgContext
) ;
212 CGContextRestoreGState( m_cgContext
) ;
216 CGContextRelease( m_cgContext
) ;
220 void wxMacCGContext::Clip( const wxRegion
®ion
)
222 // ClipCGContextToRegion ( m_cgContext, &bounds , (RgnHandle) dc->m_macCurrentClipRgn ) ;
225 void wxMacCGContext::StrokePath( const wxGraphicPath
*p
)
227 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
228 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
229 CGContextStrokePath( m_cgContext
) ;
232 void wxMacCGContext::DrawPath( const wxGraphicPath
*p
, int fillStyle
)
234 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
235 CGPathDrawingMode mode
= m_mode
;
237 if ( fillStyle
== wxODDEVEN_RULE
)
239 if ( mode
== kCGPathFill
)
240 mode
= kCGPathEOFill
;
241 else if ( mode
== kCGPathFillStroke
)
242 mode
= kCGPathEOFillStroke
;
245 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
246 CGContextDrawPath( m_cgContext
, mode
) ;
249 void wxMacCGContext::FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
)
251 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
252 CGContextSaveGState( m_cgContext
) ;
254 RGBColor col
= MAC_WXCOLORREF( fillColor
.GetPixel() ) ;
255 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
256 CGPathDrawingMode mode
= kCGPathFill
;
258 if ( fillStyle
== wxODDEVEN_RULE
)
259 mode
= kCGPathEOFill
;
261 CGContextBeginPath( m_cgContext
) ;
262 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
263 CGContextClosePath( m_cgContext
) ;
264 CGContextDrawPath( m_cgContext
, mode
) ;
266 CGContextRestoreGState( m_cgContext
) ;
269 wxGraphicPath
* wxMacCGContext::CreatePath()
271 // make sure that we now have a real cgref, before doing
272 // anything with paths
273 CGContextRef cg
= GetNativeContext() ;
275 return new wxMacCGPath() ;
278 // in case we only got a QDPort only create a cgref now
280 CGContextRef
wxMacCGContext::GetNativeContext()
282 if ( m_cgContext
== NULL
)
285 GetPortBounds( (CGrafPtr
) m_qdPort
, &bounds
) ;
286 OSStatus status
= CreateCGContextForPort((CGrafPtr
) m_qdPort
, &m_cgContext
) ;
287 CGContextSaveGState( m_cgContext
) ;
289 wxASSERT_MSG( status
== noErr
, wxT("Cannot nest wxDCs on the same window") ) ;
290 CGContextTranslateCTM( m_cgContext
, 0 , bounds
.bottom
- bounds
.top
) ;
291 CGContextScaleCTM( m_cgContext
, 1 , -1 ) ;
293 CGContextSaveGState( m_cgContext
) ;
295 SetBrush( m_brush
) ;
301 void wxMacCGContext::SetNativeContext( CGContextRef cg
)
303 // we allow either setting or clearing but not replacing
304 wxASSERT( m_cgContext
== NULL
|| cg
== NULL
) ;
306 CGContextSaveGState( cg
) ;
312 // wrapper class for a CGPattern, always allocate on heap, never call destructor
319 // is guaranteed to be called only with a non-Null CGContextRef
320 virtual void Render( CGContextRef ctxRef
) = 0 ;
322 operator CGPatternRef() const { return m_patternRef
; }
325 virtual ~wxMacCGPattern()
327 // as this is called only when our m_patternRef is been released;
328 // don't release it again
331 static void _Render( void *info
, CGContextRef ctxRef
)
333 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
334 if ( self
&& ctxRef
)
335 self
->Render( ctxRef
) ;
338 static void _Dispose( void *info
)
340 wxMacCGPattern
* self
= (wxMacCGPattern
*) info
;
344 CGPatternRef m_patternRef
;
346 static const CGPatternCallbacks ms_Callbacks
;
349 const CGPatternCallbacks
wxMacCGPattern::ms_Callbacks
= { 0, &wxMacCGPattern::_Render
, &wxMacCGPattern::_Dispose
};
351 class ImagePattern
: public wxMacCGPattern
354 ImagePattern( const wxBitmap
* bmp
, CGAffineTransform transform
)
356 wxASSERT( bmp
&& bmp
->Ok() ) ;
357 Init( (CGImageRef
) bmp
->CGImageCreate() , transform
) ;
360 // ImagePattern takes ownership of CGImageRef passed in
361 ImagePattern( CGImageRef image
, CGAffineTransform transform
)
366 Init( image
, transform
) ;
369 virtual void Render( CGContextRef ctxRef
)
372 HIViewDrawCGImage( ctxRef
, &m_imageBounds
, m_image
);
376 void Init( CGImageRef image
, CGAffineTransform transform
)
381 m_imageBounds
= CGRectMake( 0.0, 0.0, (float)CGImageGetWidth( m_image
), (float)CGImageGetHeight( m_image
) ) ;
382 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
383 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
384 kCGPatternTilingNoDistortion
, true , &wxMacCGPattern::ms_Callbacks
) ;
391 CGImageRelease( m_image
) ;
395 CGRect m_imageBounds
;
398 class HatchPattern
: public wxMacCGPattern
401 HatchPattern( int hatchstyle
, CGAffineTransform transform
)
403 m_hatch
= hatchstyle
;
404 m_imageBounds
= CGRectMake( 0.0, 0.0, 8.0 , 8.0 ) ;
405 m_patternRef
= CGPatternCreate( this , m_imageBounds
, transform
,
406 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
407 kCGPatternTilingNoDistortion
, false , &wxMacCGPattern::ms_Callbacks
) ;
410 void StrokeLineSegments( CGContextRef ctxRef
, const CGPoint pts
[] , size_t count
)
412 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
413 if ( UMAGetSystemVersion() >= 0x1040 )
415 CGContextStrokeLineSegments( ctxRef
, pts
, count
) ;
420 CGContextBeginPath (ctxRef
);
421 for (size_t i
= 0; i
< count
; i
+= 2) {
422 CGContextMoveToPoint(ctxRef
, pts
[i
].x
, pts
[i
].y
);
423 CGContextAddLineToPoint(ctxRef
, pts
[i
+1].x
, pts
[i
+1].y
);
425 CGContextStrokePath(ctxRef
);
429 virtual void Render( CGContextRef ctxRef
)
433 case wxBDIAGONAL_HATCH
:
436 { 8.0 , 0.0 } , { 0.0 , 8.0 }
438 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
442 case wxCROSSDIAG_HATCH
:
445 { 0.0 , 0.0 } , { 8.0 , 8.0 } ,
446 { 8.0 , 0.0 } , { 0.0 , 8.0 }
448 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
452 case wxFDIAGONAL_HATCH
:
455 { 0.0 , 0.0 } , { 8.0 , 8.0 }
457 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
464 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
465 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
467 StrokeLineSegments( ctxRef
, pts
, 4 ) ;
471 case wxHORIZONTAL_HATCH
:
474 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
476 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
480 case wxVERTICAL_HATCH
:
483 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
485 StrokeLineSegments( ctxRef
, pts
, 2 ) ;
495 CGRect m_imageBounds
;
498 void wxMacCGContext::SetPen( const wxPen
&pen
)
501 if ( m_cgContext
== NULL
)
503 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
504 bool stroke
= pen
.GetStyle() != wxTRANSPARENT
;
507 // we can benchmark performance, should go into a setting later
508 CGContextSetShouldAntialias( m_cgContext
, false ) ;
513 m_mode
= kCGPathFill
; // just a default
517 m_mode
= kCGPathFill
;
522 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
523 CGContextSetRGBStrokeColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
525 /* TODO * m_dc->m_scaleX */
526 float penWidth
= pen
.GetWidth();
529 CGContextSetLineWidth( m_cgContext
, penWidth
) ;
532 switch ( pen
.GetCap() )
535 cap
= kCGLineCapRound
;
537 case wxCAP_PROJECTING
:
538 cap
= kCGLineCapSquare
;
541 cap
= kCGLineCapButt
;
544 cap
= kCGLineCapButt
;
549 switch ( pen
.GetJoin() )
552 join
= kCGLineJoinBevel
;
555 join
= kCGLineJoinMiter
;
558 join
= kCGLineJoinRound
;
561 join
= kCGLineJoinMiter
;
564 CGContextSetLineJoin( m_cgContext
, join
) ;
566 m_mode
= kCGPathStroke
;
569 const float *lengths
= NULL
;
570 float *userLengths
= NULL
;
572 const float dashUnit
= penWidth
< 1.0 ? 1.0 : penWidth
;
574 const float dotted
[] = { dashUnit
, dashUnit
+ 2.0 };
575 const float short_dashed
[] = { 9.0 , 6.0 };
576 const float dashed
[] = { 19.0 , 9.0 };
577 const float dotted_dashed
[] = { 9.0 , 6.0 , 3.0 , 3.0 };
580 switch ( pen
.GetStyle() )
587 count
= WXSIZEOF(dotted
);
592 count
= WXSIZEOF(dashed
) ;
596 lengths
= short_dashed
;
597 count
= WXSIZEOF(short_dashed
) ;
601 lengths
= dotted_dashed
;
602 count
= WXSIZEOF(dotted_dashed
);
607 count
= pen
.GetDashes( &dashes
) ;
608 if ((dashes
!= NULL
) && (count
> 0))
610 userLengths
= new float[count
] ;
611 for( int i
= 0 ; i
< count
; ++i
)
613 userLengths
[i
] = dashes
[i
] * dashUnit
;
615 if ( i
% 2 == 1 && userLengths
[i
] < dashUnit
+ 2.0 )
616 userLengths
[i
] = dashUnit
+ 2.0 ;
617 else if ( i
% 2 == 0 && userLengths
[i
] < dashUnit
)
618 userLengths
[i
] = dashUnit
;
621 lengths
= userLengths
;
626 float alphaArray
[1] = { 1.0 } ;
627 wxBitmap
* bmp
= pen
.GetStipple() ;
628 if ( bmp
&& bmp
->Ok() )
630 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
631 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
632 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
633 CGContextSetStrokePattern( m_cgContext
, pattern
, alphaArray
) ;
640 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
641 CGContextSetStrokeColorSpace( m_cgContext
, patternSpace
) ;
642 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( pen
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
644 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
645 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
647 CGContextSetStrokePattern( m_cgContext
, pattern
, colorArray
) ;
652 if ((lengths
!= NULL
) && (count
> 0))
654 CGContextSetLineDash( m_cgContext
, 0 , lengths
, count
) ;
655 // force the line cap, otherwise we get artifacts (overlaps) and just solid lines
656 cap
= kCGLineCapButt
;
660 CGContextSetLineDash( m_cgContext
, 0 , NULL
, 0 ) ;
663 CGContextSetLineCap( m_cgContext
, cap
) ;
665 delete[] userLengths
;
668 if ( fill
&& stroke
)
670 m_mode
= kCGPathFillStroke
;
675 void wxMacCGContext::SetBrush( const wxBrush
&brush
)
678 if ( m_cgContext
== NULL
)
681 bool fill
= brush
.GetStyle() != wxTRANSPARENT
;
682 bool stroke
= m_pen
.GetStyle() != wxTRANSPARENT
;
685 // we can benchmark performance, should go into a setting later
686 CGContextSetShouldAntialias( m_cgContext
, false ) ;
692 m_mode
= kCGPathFill
; // just a default
696 if ( brush
.GetStyle() == wxSOLID
)
698 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
699 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
701 else if ( brush
.IsHatch() )
703 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) ) ;
704 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
705 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new HatchPattern( brush
.GetStyle() , CGContextGetCTM( m_cgContext
) ) ) );
707 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
708 float colorArray
[4] = { col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 } ;
710 CGContextSetFillPattern( m_cgContext
, pattern
, colorArray
) ;
714 // now brush is a bitmap
715 float alphaArray
[1] = { 1.0 } ;
716 wxBitmap
* bmp
= brush
.GetStipple() ;
717 if ( bmp
&& bmp
->Ok() )
719 wxMacCFRefHolder
<CGColorSpaceRef
> patternSpace( CGColorSpaceCreatePattern( NULL
) ) ;
720 CGContextSetFillColorSpace( m_cgContext
, patternSpace
) ;
721 wxMacCFRefHolder
<CGPatternRef
> pattern( *( new ImagePattern( bmp
, CGContextGetCTM( m_cgContext
) ) ) );
722 CGContextSetFillPattern( m_cgContext
, pattern
, alphaArray
) ;
725 m_mode
= kCGPathFill
;
729 m_mode
= kCGPathStroke
;
731 if ( fill
&& stroke
)
732 m_mode
= kCGPathFillStroke
;
736 void AddEllipticArcToPath(CGContextRef c
, CGPoint center
, float a
, float b
, float fromDegree
, float toDegree
)
738 CGContextSaveGState(c
);
739 CGContextTranslateCTM(c
, center
.x
, center
.y
);
740 CGContextScaleCTM(c
, a
, b
);
741 CGContextMoveToPoint(c
, 1, 0);
742 CGContextAddArc(c
, 0, 0, 1, DegToRad(fromDegree
), DegToRad(toDegree
), 0);
743 CGContextClosePath(c
);
744 CGContextRestoreGState(c
);
747 void AddRoundedRectToPath(CGContextRef c
, CGRect rect
, float ovalWidth
,
751 if (ovalWidth
== 0 || ovalHeight
== 0)
753 CGContextAddRect(c
, rect
);
757 CGContextSaveGState(c
);
758 CGContextTranslateCTM(c
, CGRectGetMinX(rect
), CGRectGetMinY(rect
));
759 CGContextScaleCTM(c
, ovalWidth
, ovalHeight
);
760 fw
= CGRectGetWidth(rect
) / ovalWidth
;
761 fh
= CGRectGetHeight(rect
) / ovalHeight
;
762 CGContextMoveToPoint(c
, fw
, fh
/2);
763 CGContextAddArcToPoint(c
, fw
, fh
, fw
/2, fh
, 1);
764 CGContextAddArcToPoint(c
, 0, fh
, 0, fh
/2, 1);
765 CGContextAddArcToPoint(c
, 0, 0, fw
/2, 0, 1);
766 CGContextAddArcToPoint(c
, fw
, 0, fw
, fh
/2, 1);
767 CGContextClosePath(c
);
768 CGContextRestoreGState(c
);
775 m_mm_to_pix_x
= mm2pt
;
776 m_mm_to_pix_y
= mm2pt
;
778 m_externalDeviceOriginX
= 0;
779 m_externalDeviceOriginY
= 0;
780 m_logicalScaleX
= 1.0;
781 m_logicalScaleY
= 1.0;
786 m_needComputeScaleX
= false;
787 m_needComputeScaleY
= false;
791 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
793 m_pen
= *wxBLACK_PEN
;
794 m_font
= *wxNORMAL_FONT
;
795 m_brush
= *wxWHITE_BRUSH
;
797 m_macATSUIStyle
= NULL
;
799 m_graphicContext
= NULL
;
804 if ( m_macATSUIStyle
)
806 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
807 m_macATSUIStyle
= NULL
;
810 delete m_graphicContext
;
813 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
815 wxCHECK_RET( Ok(), wxT("invalid window dc") );
816 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
817 wxCoord xx
= XLOG2DEVMAC(x
);
818 wxCoord yy
= YLOG2DEVMAC(y
);
819 wxCoord w
= bmp
.GetWidth();
820 wxCoord h
= bmp
.GetHeight();
821 wxCoord ww
= XLOG2DEVREL(w
);
822 wxCoord hh
= YLOG2DEVREL(h
);
824 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
825 CGImageRef image
= (CGImageRef
)( bmp
.CGImageCreate() ) ;
826 HIRect r
= CGRectMake( xx
, yy
, ww
, hh
) ;
827 HIViewDrawCGImage( cg
, &r
, image
) ;
828 CGImageRelease( image
) ;
831 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
833 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
834 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
836 wxCoord xx
= XLOG2DEVMAC(x
);
837 wxCoord yy
= YLOG2DEVMAC(y
);
838 wxCoord w
= icon
.GetWidth();
839 wxCoord h
= icon
.GetHeight();
840 wxCoord ww
= XLOG2DEVREL(w
);
841 wxCoord hh
= YLOG2DEVREL(h
);
843 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
844 CGRect r
= CGRectMake( 00 , 00 , ww
, hh
) ;
845 CGContextSaveGState(cg
);
846 CGContextTranslateCTM(cg
, xx
, yy
+ hh
);
847 CGContextScaleCTM(cg
, 1, -1);
848 PlotIconRefInContext( cg
, &r
, kAlignNone
, kTransformNone
,
849 NULL
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
850 CGContextRestoreGState( cg
) ;
853 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
855 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
856 wxCoord xx
, yy
, ww
, hh
;
859 ww
= XLOG2DEVREL(width
);
860 hh
= YLOG2DEVREL(height
);
862 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
863 CGRect clipRect
= CGRectMake( xx
,yy
, ww
, hh
) ;
864 CGContextClipToRect( cgContext
, clipRect
) ;
866 // SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ;
867 // SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
870 m_clipX1
= wxMax( m_clipX1
, xx
);
871 m_clipY1
= wxMax( m_clipY1
, yy
);
872 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
873 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
883 // TODO as soon as we don't reset the context for each operation anymore
884 // we have to update the context as well
887 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
889 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
892 DestroyClippingRegion();
897 region
.GetBox( x
, y
, w
, h
);
898 wxCoord xx
, yy
, ww
, hh
;
903 // if we have a scaling that we cannot map onto native regions
904 // we must use the box
905 if ( ww
!= w
|| hh
!= h
)
907 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
912 CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ;
913 if ( xx != x || yy != y )
915 OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ;
917 SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
921 m_clipX1
= wxMax( m_clipX1
, xx
);
922 m_clipY1
= wxMax( m_clipY1
, yy
);
923 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
924 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
937 void wxDC::DestroyClippingRegion()
939 // CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
940 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
941 CGContextRestoreGState( cgContext
);
942 CGContextSaveGState( cgContext
);
943 m_graphicContext
->SetPen( m_pen
) ;
944 m_graphicContext
->SetBrush( m_brush
) ;
948 void wxDC::DoGetSizeMM( int* width
, int* height
) const
953 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
954 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
957 void wxDC::SetTextForeground( const wxColour
&col
)
959 wxCHECK_RET(Ok(), wxT("Invalid DC"));
960 if ( col
!= m_textForegroundColour
)
962 m_textForegroundColour
= col
;
967 void wxDC::SetTextBackground( const wxColour
&col
)
969 wxCHECK_RET(Ok(), wxT("Invalid DC"));
970 m_textBackgroundColour
= col
;
973 void wxDC::SetMapMode( int mode
)
978 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
982 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
986 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
990 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
995 SetLogicalScale( 1.0, 1.0 );
999 if (mode
!= wxMM_TEXT
)
1001 m_needComputeScaleX
=
1002 m_needComputeScaleY
= true;
1006 void wxDC::SetUserScale( double x
, double y
)
1008 // allow negative ? -> no
1011 ComputeScaleAndOrigin();
1014 void wxDC::SetLogicalScale( double x
, double y
)
1017 m_logicalScaleX
= x
;
1018 m_logicalScaleY
= y
;
1019 ComputeScaleAndOrigin();
1022 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
1024 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
1025 m_logicalOriginY
= y
* m_signY
;
1026 ComputeScaleAndOrigin();
1029 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
1031 m_externalDeviceOriginX
= x
;
1032 m_externalDeviceOriginY
= y
;
1033 ComputeScaleAndOrigin();
1036 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
1038 m_signX
= (xLeftRight
? 1 : -1);
1039 m_signY
= (yBottomUp
? -1 : 1);
1040 ComputeScaleAndOrigin();
1043 wxSize
wxDC::GetPPI() const
1045 return wxSize(72, 72);
1048 int wxDC::GetDepth() const
1053 void wxDC::ComputeScaleAndOrigin()
1055 // CMB: copy scale to see if it changes
1056 double origScaleX
= m_scaleX
;
1057 double origScaleY
= m_scaleY
;
1058 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
1059 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
1060 m_deviceOriginX
= m_externalDeviceOriginX
;
1061 m_deviceOriginY
= m_externalDeviceOriginY
;
1063 // CMB: if scale has changed call SetPen to recalulate the line width
1064 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
1066 // this is a bit artificial, but we need to force wxDC to think
1067 // the pen has changed
1068 wxPen
pen(GetPen());
1075 void wxDC::SetPalette( const wxPalette
& palette
)
1079 void wxDC::SetBackgroundMode( int mode
)
1081 m_backgroundMode
= mode
;
1084 void wxDC::SetFont( const wxFont
&font
)
1090 void wxDC::SetPen( const wxPen
&pen
)
1096 if ( m_graphicContext
)
1098 if ( m_pen
.GetStyle() == wxSOLID
|| m_pen
.GetStyle() == wxTRANSPARENT
)
1100 m_graphicContext
->SetPen( m_pen
) ;
1104 // we have to compensate for moved device origins etc. otherwise patterned pens are standing still
1105 // eg when using a wxScrollWindow and scrolling around
1106 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1107 int origX
= XLOG2DEVMAC(0) ;
1108 int origY
= YLOG2DEVMAC(0) ;
1109 CGContextTranslateCTM (cgContext
,origX
,origY
);
1110 m_graphicContext
->SetPen( m_pen
) ;
1111 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1116 void wxDC::SetBrush( const wxBrush
&brush
)
1118 if (m_brush
== brush
)
1122 if ( m_graphicContext
)
1124 if ( brush
.GetStyle() == wxSOLID
|| brush
.GetStyle() == wxTRANSPARENT
)
1126 m_graphicContext
->SetBrush( m_brush
) ;
1130 // we have to compensate for moved device origins etc. otherwise patterned brushes are standing still
1131 // eg when using a wxScrollWindow and scrolling around
1132 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1133 int origX
= XLOG2DEVMAC(0) ;
1134 int origY
= YLOG2DEVMAC(0) ;
1135 CGContextTranslateCTM (cgContext
,origX
,origY
);
1136 m_graphicContext
->SetBrush( m_brush
) ;
1137 CGContextTranslateCTM (cgContext
,-origX
,-origY
);
1142 void wxDC::SetBackground( const wxBrush
&brush
)
1144 if (m_backgroundBrush
== brush
)
1147 m_backgroundBrush
= brush
;
1148 if (!m_backgroundBrush
.Ok())
1152 void wxDC::SetLogicalFunction( int function
)
1154 if (m_logicalFunction
== function
)
1157 m_logicalFunction
= function
;
1160 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
1161 const wxColour
& col
, int style
);
1163 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
1164 const wxColour
& col
, int style
)
1166 return wxDoFloodFill(this, x
, y
, col
, style
);
1169 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
1171 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1172 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1173 wxMacPortSaver
helper((CGrafPtr
)m_macPort
) ;
1176 XLOG2DEVMAC(x
) + m_macLocalOriginInPort
.x
- m_macLocalOrigin
.x
,
1177 YLOG2DEVMAC(y
) + m_macLocalOriginInPort
.y
- m_macLocalOrigin
.y
, &colour
);
1178 // Convert from Mac colour to wx
1179 col
->Set( colour
.red
>> 8,
1186 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1188 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1190 if ( m_logicalFunction
!= wxCOPY
)
1193 wxCoord xx1
= XLOG2DEVMAC(x1
) ;
1194 wxCoord yy1
= YLOG2DEVMAC(y1
) ;
1195 wxCoord xx2
= XLOG2DEVMAC(x2
) ;
1196 wxCoord yy2
= YLOG2DEVMAC(y2
) ;
1198 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1199 path
->MoveToPoint( xx1
, yy1
) ;
1200 path
->AddLineToPoint( xx2
, yy2
) ;
1201 path
->CloseSubpath() ;
1202 m_graphicContext
->StrokePath( path
) ;
1205 CalcBoundingBox(x1
, y1
);
1206 CalcBoundingBox(x2
, y2
);
1209 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
1211 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
1213 if ( m_logicalFunction
!= wxCOPY
)
1219 wxCoord xx
= XLOG2DEVMAC(x
);
1220 wxCoord yy
= YLOG2DEVMAC(y
);
1222 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1223 path
->MoveToPoint( XLOG2DEVMAC(0), yy
) ;
1224 path
->AddLineToPoint( XLOG2DEVMAC(w
), yy
) ;
1225 path
->CloseSubpath() ;
1226 path
->MoveToPoint( xx
, YLOG2DEVMAC(0) ) ;
1227 path
->AddLineToPoint( xx
, YLOG2DEVMAC(h
) ) ;
1228 path
->CloseSubpath() ;
1229 m_graphicContext
->StrokePath( path
) ;
1232 CalcBoundingBox(x
, y
);
1233 CalcBoundingBox(x
+w
, y
+h
);
1236 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
1237 wxCoord x2
, wxCoord y2
,
1238 wxCoord xc
, wxCoord yc
)
1240 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
1242 if ( m_logicalFunction
!= wxCOPY
)
1245 wxCoord xx1
= XLOG2DEVMAC(x1
);
1246 wxCoord yy1
= YLOG2DEVMAC(y1
);
1247 wxCoord xx2
= XLOG2DEVMAC(x2
);
1248 wxCoord yy2
= YLOG2DEVMAC(y2
);
1249 wxCoord xxc
= XLOG2DEVMAC(xc
);
1250 wxCoord yyc
= YLOG2DEVMAC(yc
);
1251 double dx
= xx1
- xxc
;
1252 double dy
= yy1
- yyc
;
1253 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
1254 wxCoord rad
= (wxCoord
)radius
;
1256 if (xx1
== xx2
&& yy1
== yy2
)
1261 else if (radius
== 0.0)
1267 sa
= (xx1
- xxc
== 0) ?
1268 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
1269 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
1270 ea
= (xx2
- xxc
== 0) ?
1271 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
1272 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
1275 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1276 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1277 CGContextRef ctx
= mctx
->GetNativeContext() ;
1278 CGContextSaveGState( ctx
) ;
1279 CGContextTranslateCTM( ctx
, xxc
, yyc
);
1280 CGContextScaleCTM( ctx
, 1 , -1 ) ;
1282 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1283 CGContextAddArc( ctx
, 0, 0 , rad
, DegToRad(sa
), DegToRad(ea
), 0);
1285 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1286 CGContextRestoreGState( ctx
) ;
1287 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1290 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1291 double sa
, double ea
)
1293 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
1295 if ( m_logicalFunction
!= wxCOPY
)
1298 wxCoord xx
= XLOG2DEVMAC(x
);
1299 wxCoord yy
= YLOG2DEVMAC(y
);
1300 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
1301 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
1302 // handle -ve width and/or height
1303 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1304 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1306 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1308 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1309 CGContextRef ctx
= mctx
->GetNativeContext() ;
1311 CGContextSaveGState( ctx
) ;
1312 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1313 CGContextScaleCTM( ctx
, 1 * ww
/ 2 , -1 * hh
/ 2 ) ;
1315 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1316 CGContextAddArc( ctx
, 0, 0, 1, DegToRad(sa
), DegToRad(ea
), 0);
1318 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1319 CGContextRestoreGState( ctx
) ;
1320 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1323 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
1325 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1326 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 ) ;
1329 void wxDC::DoDrawLines(int n
, wxPoint points
[],
1330 wxCoord xoffset
, wxCoord yoffset
)
1332 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1334 if ( m_logicalFunction
!= wxCOPY
)
1337 wxCoord x1
, x2
, y1
, y2
;
1338 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1339 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1340 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1341 path
->MoveToPoint( x1
, y1
) ;
1342 for (int i
= 1; i
< n
; i
++)
1344 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1345 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1347 path
->AddLineToPoint( x2
, y2
) ;
1350 m_graphicContext
->StrokePath( path
) ;
1355 void wxDC::DoDrawSpline(wxList
*points
)
1357 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1359 if ( m_logicalFunction
!= wxCOPY
)
1362 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1364 wxList::compatibility_iterator node
= points
->GetFirst();
1365 if (node
== wxList::compatibility_iterator())
1369 wxPoint
*p
= (wxPoint
*)node
->GetData();
1374 node
= node
->GetNext();
1375 p
= (wxPoint
*)node
->GetData();
1379 wxCoord cx1
= ( x1
+ x2
) / 2;
1380 wxCoord cy1
= ( y1
+ y2
) / 2;
1382 path
->MoveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ) ;
1383 path
->AddLineToPoint( XLOG2DEVMAC( cx1
) , XLOG2DEVMAC( cy1
) ) ;
1386 while ((node
= node
->GetNext()) != NULL
)
1388 while ((node
= node
->GetNext()))
1389 #endif // !wxUSE_STL
1391 p
= (wxPoint
*)node
->GetData();
1396 wxCoord cx4
= (x1
+ x2
) / 2;
1397 wxCoord cy4
= (y1
+ y2
) / 2;
1399 path
->AddQuadCurveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ,
1400 XLOG2DEVMAC( cx4
) , XLOG2DEVMAC( cy4
) ) ;
1406 path
->AddLineToPoint( XLOG2DEVMAC( x2
) , XLOG2DEVMAC( y2
) ) ;
1408 m_graphicContext
->StrokePath( path
) ;
1413 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
1414 wxCoord xoffset
, wxCoord yoffset
,
1417 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1418 wxCoord x1
, x2
, y1
, y2
;
1419 if ( n
== 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
1422 if ( m_logicalFunction
!= wxCOPY
)
1425 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1426 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1428 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1429 path
->MoveToPoint( x1
, y1
) ;
1430 for (int i
= 1; i
< n
; i
++)
1432 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1433 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1435 path
->AddLineToPoint( x2
, y2
) ;
1438 if ( x1
!= x2
|| y1
!= y2
)
1439 path
->AddLineToPoint( x1
,y1
) ;
1441 path
->CloseSubpath() ;
1442 m_graphicContext
->DrawPath( path
, fillStyle
) ;
1446 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1448 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1450 if ( m_logicalFunction
!= wxCOPY
)
1453 wxCoord xx
= XLOG2DEVMAC(x
);
1454 wxCoord yy
= YLOG2DEVMAC(y
);
1455 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1456 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1457 // CMB: draw nothing if transformed w or h is 0
1458 if (ww
== 0 || hh
== 0)
1461 // CMB: handle -ve width and/or height
1473 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1474 path
->AddRectangle( xx
, yy
, ww
, hh
) ;
1475 m_graphicContext
->DrawPath( path
) ;
1479 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1480 wxCoord width
, wxCoord height
,
1483 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1485 if ( m_logicalFunction
!= wxCOPY
)
1489 radius
= - radius
* ((width
< height
) ? width
: height
);
1490 wxCoord xx
= XLOG2DEVMAC(x
);
1491 wxCoord yy
= YLOG2DEVMAC(y
);
1492 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1493 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1494 // CMB: draw nothing if transformed w or h is 0
1495 if (ww
== 0 || hh
== 0)
1498 // CMB: handle -ve width and/or height
1510 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1511 CGContextRef ctx
= mctx
->GetNativeContext() ;
1512 AddRoundedRectToPath( ctx
, CGRectMake( xx
, yy
, ww
, hh
) , 16 ,16 ) ;
1513 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1516 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1518 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1520 if ( m_logicalFunction
!= wxCOPY
)
1523 wxCoord xx
= XLOG2DEVMAC(x
);
1524 wxCoord yy
= YLOG2DEVMAC(y
);
1525 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1526 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1527 // CMB: draw nothing if transformed w or h is 0
1528 if (ww
== 0 || hh
== 0)
1531 // CMB: handle -ve width and/or height
1543 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1544 CGContextRef ctx
= mctx
->GetNativeContext() ;
1545 CGContextSaveGState( ctx
) ;
1546 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1547 CGContextScaleCTM( ctx
, ww
/ 2 , hh
/ 2 ) ;
1548 CGContextAddArc( ctx
, 0, 0, 1, 0 , 2*M_PI
, 0);
1549 CGContextRestoreGState( ctx
) ;
1550 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1553 bool wxDC::CanDrawBitmap(void) const
1558 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1559 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1560 wxCoord xsrcMask
, wxCoord ysrcMask
)
1562 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1563 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1564 if ( logical_func
== wxNO_OP
)
1567 if (xsrcMask
== -1 && ysrcMask
== -1)
1573 wxCoord yysrc
= source
->YLOG2DEVMAC(ysrc
) ;
1574 wxCoord xxsrc
= source
->XLOG2DEVMAC(xsrc
) ;
1575 wxCoord wwsrc
= source
->XLOG2DEVREL(width
) ;
1576 wxCoord hhsrc
= source
->YLOG2DEVREL(height
) ;
1578 wxCoord yydest
= YLOG2DEVMAC(ydest
) ;
1579 wxCoord xxdest
= XLOG2DEVMAC(xdest
) ;
1580 wxCoord wwdest
= XLOG2DEVREL(width
) ;
1581 wxCoord hhdest
= YLOG2DEVREL(height
) ;
1583 wxMemoryDC
* memdc
= dynamic_cast<wxMemoryDC
*>(source
) ;
1584 if ( memdc
&& logical_func
== wxCOPY
)
1586 wxBitmap blit
= memdc
->GetSelectedObject() ;
1587 wxASSERT_MSG( blit
.Ok() , wxT("Invalid bitmap for blitting") ) ;
1589 wxCoord bmpwidth
= blit
.GetWidth();
1590 wxCoord bmpheight
= blit
.GetHeight();
1592 if ( xxsrc
!= 0 || yysrc
!= 0 || bmpwidth
!= wwsrc
|| bmpheight
!= hhsrc
)
1594 wwsrc
= wxMin( wwsrc
, bmpwidth
- xxsrc
) ;
1595 hhsrc
= wxMin( hhsrc
, bmpheight
- yysrc
) ;
1596 if ( wwsrc
> 0 && hhsrc
> 0 )
1598 if ( xxsrc
>= 0 && yysrc
>= 0 )
1600 wxRect
subrect( xxsrc
, yysrc
, wwsrc
, hhsrc
) ;
1601 blit
= blit
.GetSubBitmap( subrect
) ;
1605 // in this case we'd probably have to adjust the different coordinates, but
1606 // we have to find out proper contract first
1607 blit
= wxNullBitmap
;
1612 blit
= wxNullBitmap
;
1618 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1619 CGImageRef image
= (CGImageRef
)( blit
.CGImageCreate() ) ;
1620 HIRect r
= CGRectMake( xxdest
, yydest
, wwdest
, hhdest
) ;
1621 HIViewDrawCGImage( cg
, &r
, image
) ;
1622 CGImageRelease( image
) ;
1628 CGContextRef cg = (wxMacCGContext*)(source->GetGraphicContext())->GetNativeContext() ;
1629 void *data = CGBitmapContextGetData( cg ) ;
1631 return false ; // wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts") ) ;
1637 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1640 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1642 if ( str
.Length() == 0 )
1644 if ( m_logicalFunction
!= wxCOPY
)
1647 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1649 OSStatus status
= noErr
;
1650 ATSUTextLayout atsuLayout
;
1651 UniCharCount chars
= str
.Length() ;
1652 UniChar
* ubuf
= NULL
;
1653 #if SIZEOF_WCHAR_T == 4
1654 wxMBConvUTF16 converter
;
1656 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1657 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1658 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1660 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1661 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1662 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1663 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1665 chars
= unicharlen
/ 2 ;
1668 ubuf
= (UniChar
*) str
.wc_str() ;
1670 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1671 chars
= wxWcslen( wchar
.data() ) ;
1672 ubuf
= (UniChar
*) wchar
.data() ;
1676 int drawX
= XLOG2DEVMAC(x
) ;
1677 int drawY
= YLOG2DEVMAC(y
) ;
1679 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1680 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1682 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1684 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1685 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1687 int iAngle
= int( angle
);
1688 if ( abs(iAngle
) > 0 )
1690 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1691 ATSUAttributeTag atsuTags
[] =
1693 kATSULineRotationTag
,
1695 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1699 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1703 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1704 atsuTags
, atsuSizes
, atsuValues
) ;
1707 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1708 ATSUAttributeTag atsuTags
[] =
1712 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1714 sizeof( CGContextRef
) ,
1716 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1720 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1721 atsuTags
, atsuSizes
, atsuValues
) ;
1724 ATSUTextMeasurement textBefore
;
1725 ATSUTextMeasurement textAfter
;
1726 ATSUTextMeasurement ascent
;
1727 ATSUTextMeasurement descent
;
1729 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1730 &textBefore
, &textAfter
, &ascent
, &descent
);
1731 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1735 if ( m_backgroundMode
== wxSOLID
)
1737 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1741 path
->AddLineToPoint(
1742 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ,
1743 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ) ;
1744 path
->AddLineToPoint(
1745 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) + cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1746 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) - sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1747 path
->AddLineToPoint(
1748 (int) (drawX
+ cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1749 (int) (drawY
- sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1751 m_graphicContext
->FillPath( path
, m_textBackgroundColour
) ;
1755 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1756 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1758 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1759 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1760 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1762 CGContextSaveGState(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext());
1763 CGContextTranslateCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), drawX
, drawY
);
1764 CGContextScaleCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), 1, -1);
1765 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1766 IntToFixed(0) , IntToFixed(0) );
1767 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1768 CGContextRestoreGState( ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ) ;
1770 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1771 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1773 ::ATSUDisposeTextLayout(atsuLayout
);
1775 #if SIZEOF_WCHAR_T == 4
1780 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1782 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1783 DoDrawRotatedText( strtext
, x
, y
, 0.0 ) ;
1786 bool wxDC::CanGetTextExtent() const
1788 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1792 void wxDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1793 wxCoord
*descent
, wxCoord
*externalLeading
,
1794 wxFont
*theFont
) const
1796 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1797 wxFont formerFont
= m_font
;
1800 // work around the constness
1801 *((wxFont
*)(&m_font
)) = *theFont
;
1805 if ( str
.Length() == 0 )
1808 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1810 OSStatus status
= noErr
;
1811 ATSUTextLayout atsuLayout
;
1812 UniCharCount chars
= str
.Length() ;
1813 UniChar
* ubuf
= NULL
;
1814 #if SIZEOF_WCHAR_T == 4
1815 wxMBConvUTF16 converter
;
1817 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1818 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1819 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1821 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1822 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1823 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1824 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1826 chars
= unicharlen
/ 2 ;
1829 ubuf
= (UniChar
*) str
.wc_str() ;
1831 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1832 chars
= wxWcslen( wchar
.data() ) ;
1833 ubuf
= (UniChar
*) wchar
.data() ;
1837 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1838 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1840 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the text") );
1842 ATSUTextMeasurement textBefore
;
1843 ATSUTextMeasurement textAfter
;
1844 ATSUTextMeasurement textAscent
;
1845 ATSUTextMeasurement textDescent
;
1847 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1848 &textBefore
, &textAfter
, &textAscent
, &textDescent
);
1851 *height
= YDEV2LOGREL( FixedToInt(textAscent
+ textDescent
) ) ;
1853 *descent
=YDEV2LOGREL( FixedToInt(textDescent
) );
1854 if ( externalLeading
)
1855 *externalLeading
= 0 ;
1857 *width
= XDEV2LOGREL( FixedToInt(textAfter
- textBefore
) ) ;
1859 ::ATSUDisposeTextLayout(atsuLayout
);
1860 #if SIZEOF_WCHAR_T == 4
1865 // work around the constness
1866 *((wxFont
*)(&m_font
)) = formerFont
;
1871 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1873 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1876 widths
.Add(0, text
.Length());
1878 if (text
.Length() == 0)
1881 ATSUTextLayout atsuLayout
;
1882 UniCharCount chars
= text
.Length() ;
1883 UniChar
* ubuf
= NULL
;
1884 #if SIZEOF_WCHAR_T == 4
1885 wxMBConvUTF16 converter
;
1887 size_t unicharlen
= converter
.WC2MB( NULL
, text
.wc_str() , 0 ) ;
1888 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1889 converter
.WC2MB( (char*) ubuf
, text
.wc_str(), unicharlen
+ 2 ) ;
1891 const wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1892 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1893 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1894 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1896 chars
= unicharlen
/ 2 ;
1899 ubuf
= (UniChar
*) text
.wc_str() ;
1901 wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1902 chars
= wxWcslen( wchar
.data() ) ;
1903 ubuf
= (UniChar
*) wchar
.data() ;
1908 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1909 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1911 for ( int pos
= 0; pos
< (int)chars
; pos
++ )
1913 unsigned long actualNumberOfBounds
= 0;
1914 ATSTrapezoid glyphBounds
;
1916 // We get a single bound, since the text should only require one. If it requires more, there is an issue
1918 result
= ATSUGetGlyphBounds( atsuLayout
, 0, 0, kATSUFromTextBeginning
, pos
+ 1,
1919 kATSUseDeviceOrigins
, 1, &glyphBounds
, &actualNumberOfBounds
);
1920 if (result
!= noErr
|| actualNumberOfBounds
!= 1 )
1923 widths
[pos
] = XDEV2LOGREL(FixedToInt( glyphBounds
.upperRight
.x
- glyphBounds
.upperLeft
.x
));
1924 //unsigned char uch = s[i];
1927 ::ATSUDisposeTextLayout(atsuLayout
);
1931 wxCoord
wxDC::GetCharWidth(void) const
1934 DoGetTextExtent(wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
) ;
1938 wxCoord
wxDC::GetCharHeight(void) const
1941 DoGetTextExtent(wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
) ;
1945 void wxDC::Clear(void)
1947 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1949 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1951 HIRect rect
= CGRectMake( -10000 , -10000 , 20000 , 20000 ) ;
1952 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1953 switch( m_backgroundBrush
.MacGetBrushKind() )
1955 case kwxMacBrushTheme
:
1957 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1958 if ( HIThemeSetFill
!= 0 )
1960 HIThemeSetFill( m_backgroundBrush
.MacGetTheme(), NULL
, cg
, kHIThemeOrientationNormal
);
1961 CGContextFillRect(cg
, rect
);
1968 GetThemeBrushAsColor( m_backgroundBrush
.MacGetTheme(), 32, true, &color
);
1969 CGContextSetRGBFillColor( cg
, (float) color
.red
/ 65536,
1970 (float) color
.green
/ 65536, (float) color
.blue
/ 65536, 1 );
1971 CGContextFillRect( cg
, rect
);
1974 // reset to normal value
1975 RGBColor col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
1976 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0, col
.green
/ 65536.0, col
.blue
/ 65536.0, 1.0 );
1980 case kwxMacBrushThemeBackground
:
1982 wxFAIL_MSG( wxT("There shouldn't be theme backgrounds under Quartz") ) ;
1983 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1984 if ( UMAGetSystemVersion() >= 0x1030 )
1986 HIThemeBackgroundDrawInfo drawInfo
;
1987 drawInfo
.version
= 0 ;
1988 drawInfo
.state
= kThemeStateActive
;
1989 drawInfo
.kind
= m_backgroundBrush
.MacGetThemeBackground(NULL
) ;
1990 if ( drawInfo
.kind
== kThemeBackgroundMetal
)
1991 HIThemeDrawBackground( &rect
, &drawInfo
, cg
,
1992 kHIThemeOrientationNormal
) ;
1993 HIThemeApplyBackground( &rect
, &drawInfo
, cg
,
1994 kHIThemeOrientationNormal
) ;
2000 case kwxMacBrushColour
:
2002 RGBColor col
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) ;
2003 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2004 CGContextFillRect(cg
, rect
);
2006 // reset to normal value
2007 col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
2008 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2018 void wxDC::MacInstallFont() const
2020 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2022 if ( m_macATSUIStyle
)
2024 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
2025 m_macATSUIStyle
= NULL
;
2030 OSStatus status
= noErr
;
2031 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
2032 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
2034 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
2035 RGBColor atsuColor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel() ) ;
2036 ATSUAttributeTag atsuTags
[] =
2041 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2044 sizeof( RGBColor
) ,
2046 // Boolean kTrue = true ;
2047 // Boolean kFalse = false ;
2049 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
2050 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2055 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
2056 atsuTags
, atsuSizes
, atsuValues
);
2058 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
2062 // ---------------------------------------------------------------------------
2063 // coordinates transformations
2064 // ---------------------------------------------------------------------------
2066 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2068 return ((wxDC
*)this)->XDEV2LOG(x
);
2071 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2073 return ((wxDC
*)this)->YDEV2LOG(y
);
2076 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2078 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2081 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2083 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2086 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2088 return ((wxDC
*)this)->XLOG2DEV(x
);
2091 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2093 return ((wxDC
*)this)->YLOG2DEV(y
);
2096 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2098 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2101 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2103 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2106 #endif // wxMAC_USE_CORE_GRAPHICS