1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dc.h"
16 #include "wx/wxprec.h"
20 #if wxMAC_USE_CORE_GRAPHICS
23 #include "wx/mac/uma.h"
24 #include "wx/dcmemory.h"
25 #include "wx/dcprint.h"
26 #include "wx/region.h"
36 #include "wx/mac/private.h"
38 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 #if !defined( __DARWIN__ ) || defined(__MWERKS__)
46 const double M_PI
= 3.14159265358979 ;
49 const double RAD2DEG
= 180.0 / M_PI
;
50 const short kEmulatedMode
= -1 ;
51 const short kUnsupportedMode
= -2 ;
53 extern TECObjectRef s_TECNativeCToUnicode
;
56 // The text ctrl implementation still needs that for the non hiview implementation
58 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
59 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
61 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
62 m_formerClip
= NewRgn() ;
63 m_newClip
= NewRgn() ;
64 GetClip( m_formerClip
) ;
68 // guard against half constructed objects, this just leads to a empty clip
72 win
->MacWindowToRootWindow( &x
,&y
) ;
73 // get area including focus rect
74 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
75 if ( !EmptyRgn( m_newClip
) )
76 OffsetRgn( m_newClip
, x
, y
) ;
79 SetClip( m_newClip
) ;
83 wxMacWindowClipper::~wxMacWindowClipper()
85 SetPort( m_newPort
) ;
86 SetClip( m_formerClip
) ;
87 DisposeRgn( m_newClip
) ;
88 DisposeRgn( m_formerClip
) ;
91 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
92 wxMacWindowClipper( win
)
94 // the port is already set at this point
95 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
96 GetThemeDrawingState( &m_themeDrawingState
) ;
99 wxMacWindowStateSaver::~wxMacWindowStateSaver()
101 SetPort( m_newPort
) ;
102 SetThemeDrawingState( m_themeDrawingState
, true ) ;
105 // minimal implementation only used for appearance drawing < 10.3
107 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
108 m_ph( (GrafPtr
) dc
->m_macPort
)
110 wxASSERT( dc
->Ok() ) ;
112 // dc->MacSetupPort(&m_ph) ;
114 wxMacPortSetter::~wxMacPortSetter()
116 // m_dc->MacCleanupPort(&m_ph) ;
119 //-----------------------------------------------------------------------------
121 //-----------------------------------------------------------------------------
123 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
124 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
125 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
127 //-----------------------------------------------------------------------------
128 // device context implementation
130 // more and more of the dc functionality should be implemented by calling
131 // the appropricate wxMacCGContext, but we will have to do that step by step
132 // also coordinate conversions should be moved to native matrix ops
133 //-----------------------------------------------------------------------------
135 // we always stock two context states, one at entry, to be able to preserve the
136 // state we were called with, the other one after changing to HI Graphics orientation
137 // (this one is used for getting back clippings etc)
139 wxMacCGPath::wxMacCGPath()
141 m_path
= CGPathCreateMutable() ;
144 wxMacCGPath::~wxMacCGPath()
146 CGPathRelease( m_path
) ;
149 // Starts a new subpath at
150 void wxMacCGPath::MoveToPoint( wxCoord x1
, wxCoord y1
)
152 CGPathMoveToPoint( m_path
, NULL
, x1
, y1
) ;
155 void wxMacCGPath::AddLineToPoint( wxCoord x1
, wxCoord y1
)
157 CGPathAddLineToPoint( m_path
, NULL
, x1
, y1
) ;
160 void wxMacCGPath::AddQuadCurveToPoint( wxCoord cx1
, wxCoord cy1
, wxCoord x1
, wxCoord y1
)
162 CGPathAddQuadCurveToPoint( m_path
, NULL
, cx1
, cy1
, x1
, y1
);
165 void wxMacCGPath::AddRectangle( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
167 CGRect cgRect
= { { x
, y
} , { w
, h
} } ;
168 CGPathAddRect( m_path
, NULL
, cgRect
) ;
171 void wxMacCGPath::AddCircle( wxCoord x
, wxCoord y
, wxCoord r
)
173 CGPathAddArc( m_path
, NULL
, x
, y
, r
, 0.0 , 2 * M_PI
, true ) ;
176 // closes the current subpath
177 void wxMacCGPath::CloseSubpath()
179 CGPathCloseSubpath( m_path
) ;
182 CGPathRef
wxMacCGPath::GetPath() const
187 wxMacCGContext::wxMacCGContext( CGrafPtr port
)
193 wxMacCGContext::wxMacCGContext( CGContextRef cgcontext
)
196 m_cgContext
= cgcontext
;
197 CGContextSaveGState( m_cgContext
) ;
198 CGContextSaveGState( m_cgContext
) ;
201 wxMacCGContext::wxMacCGContext()
207 wxMacCGContext::~wxMacCGContext()
211 CGContextSynchronize( m_cgContext
) ;
212 CGContextRestoreGState( m_cgContext
) ;
213 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
;
236 if ( fillStyle
== wxODDEVEN_RULE
)
238 if ( mode
== kCGPathFill
)
239 mode
= kCGPathEOFill
;
240 else if ( mode
== kCGPathFillStroke
)
241 mode
= kCGPathEOFillStroke
;
243 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
244 CGContextDrawPath( m_cgContext
, mode
) ;
247 void wxMacCGContext::FillPath( const wxGraphicPath
*p
, const wxColor
&fillColor
, int fillStyle
)
249 const wxMacCGPath
* path
= dynamic_cast< const wxMacCGPath
*>( p
) ;
250 CGContextSaveGState( m_cgContext
) ;
252 RGBColor col
= MAC_WXCOLORREF( fillColor
.GetPixel() ) ;
253 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
254 CGPathDrawingMode mode
= kCGPathFill
;
256 if ( fillStyle
== wxODDEVEN_RULE
)
257 mode
= kCGPathEOFill
;
259 CGContextBeginPath( m_cgContext
) ;
260 CGContextAddPath( m_cgContext
, path
->GetPath() ) ;
261 CGContextClosePath( m_cgContext
) ;
262 CGContextDrawPath( m_cgContext
, mode
) ;
264 CGContextRestoreGState( m_cgContext
) ;
267 wxGraphicPath
* wxMacCGContext::CreatePath()
269 // make sure that we now have a real cgref, before doing
270 // anything with paths
271 CGContextRef cg
= GetNativeContext() ;
273 return new wxMacCGPath() ;
276 // in case we only got a QDPort only create a cgref now
278 CGContextRef
wxMacCGContext::GetNativeContext()
280 if( m_cgContext
== NULL
)
283 GetPortBounds( (CGrafPtr
) m_qdPort
, &bounds
) ;
284 OSStatus status
= CreateCGContextForPort((CGrafPtr
) m_qdPort
, &m_cgContext
) ;
285 CGContextSaveGState( m_cgContext
) ;
287 wxASSERT_MSG( status
== noErr
, wxT("Cannot nest wxDCs on the same window") ) ;
288 CGContextTranslateCTM( m_cgContext
, 0 , bounds
.bottom
- bounds
.top
) ;
289 CGContextScaleCTM( m_cgContext
, 1 , -1 ) ;
291 CGContextSaveGState( m_cgContext
) ;
293 SetBrush( m_brush
) ;
298 void wxMacCGContext::SetNativeContext( CGContextRef cg
)
300 // we allow either setting or clearing but not replacing
301 wxASSERT( m_cgContext
== NULL
|| cg
== NULL
) ;
303 CGContextSaveGState( cg
) ;
309 // Experimental support for dashes and patterned brushes
310 // uncomment the following lines to enable it
312 // #define _NEW_GC_DASHES_
313 // #define _NEW_GC_SUPPORT_
315 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
316 #define kCGColorSpaceGenericRGB CFSTR("kCGColorSpaceGenericRGB")
319 void EstablishPatternColorSpace(
324 CGColorSpaceRef baseSpace
, patternSpace
;
334 patternSpace
= CGColorSpaceCreatePattern( NULL
);
337 CGContextSetFillColorSpace( ctxRef
, patternSpace
);
339 CGContextSetStrokeColorSpace( ctxRef
, patternSpace
);
343 baseSpace
= CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB
);
344 patternSpace
= CGColorSpaceCreatePattern( baseSpace
);
347 CGContextSetFillColorSpace( ctxRef
, patternSpace
);
349 CGContextSetStrokeColorSpace( ctxRef
, patternSpace
);
352 // NB: the context owns these now, and this code is finished with them
353 if (patternSpace
!= NULL
)
354 CGColorSpaceRelease( patternSpace
);
355 if (baseSpace
!= NULL
)
356 CGColorSpaceRelease( baseSpace
);
359 void ImagePatternRender(
361 CGContextRef ctxRef
)
366 CGImageRef imageRef
= (CGImageRef
)info
;
367 if (imageRef
!= NULL
)
369 CGRect boundsR
= CGRectMake( 0.0, 0.0, (float)CGImageGetWidth( imageRef
), (float)CGImageGetHeight( imageRef
) );
370 CGContextDrawImage( ctxRef
, boundsR
, imageRef
);
374 void ImagePatternDispose(
377 CGImageRef imageRef
= (CGImageRef
)info
;
378 if (imageRef
!= NULL
)
379 CGImageRelease( imageRef
);
382 // specifies the struct version value and the callback functions for draw and release
383 static const CGPatternCallbacks sImagePatternCallback
= { 0, &ImagePatternRender
, &ImagePatternDispose
};
385 long CreatePatternFromBitmap(
386 CGPatternRef
*patternRef
,
387 const wxBitmap
*rasterInfo
,
392 long errorStatus
, widthV
, heightV
, depthV
;
394 if (patternRef
== NULL
)
401 if ((rasterInfo
== NULL
) || !rasterInfo
->Ok())
404 if (errorStatus
== 0)
406 // build a usable bounding CGRect from the wxBitmap's bounds wxRect
407 widthV
= rasterInfo
->GetWidth();
408 heightV
= rasterInfo
->GetHeight();
409 if ((widthV
<= 0) || (heightV
<= 0))
413 if (errorStatus
== 0)
415 depthV
= rasterInfo
->GetDepth();
416 // isColored = (depthV > 1);
418 // FIXME: this is often <= 0 - why???
420 // errorStatus = (-4);
423 if (errorStatus
== 0)
425 imageRef
= (CGImageRef
)(rasterInfo
->CGImageCreate());
426 if (imageRef
== NULL
)
430 if (errorStatus
== 0)
432 // FIXME: switch when this routine belongs to a DC class...
433 boundsR
= CGRectMake( 0.0, 0.0, (float)widthV
, (float)heightV
);
434 // boundsR = CGRectMake( 0.0, 0.0, (float)XLOG2DEVREL( widthV ), (float)XLOG2DEVREL( heightV ) );
436 *patternRef
= CGPatternCreate(
439 CGAffineTransformIdentity
,
442 kCGPatternTilingNoDistortion
,
444 &sImagePatternCallback
);
446 if (*patternRef
== (CGPatternRef
)NULL
)
453 long CreatePatternFromDashes(
454 CGPatternRef
*patternRef
,
455 const wxDash
*sourceDash
,
461 if (patternRef
== NULL
)
465 if ((sourceDash
== NULL
) || (count
<= 0))
468 wxBitmap
dashBits( (char*)sourceDash
, 8, count
, 1 );
469 errorStatus
= CreatePatternFromBitmap( patternRef
, &dashBits
, useMultibit
);
474 long CreatePatternFromBrush(
475 CGPatternRef
*patternRef
,
476 const wxBrush
&sourceBrush
,
481 if (patternRef
== NULL
)
485 errorStatus
= CreatePatternFromBitmap( patternRef
, sourceBrush
.GetStipple(), useMultibit
);
490 long CreatePatternFromPen(
491 CGPatternRef
*patternRef
,
492 const wxPen
&sourcePen
,
497 if (patternRef
== NULL
)
501 errorStatus
= CreatePatternFromBitmap( patternRef
, sourcePen
.GetStipple(), useMultibit
);
509 // FIXME: the NEW_GC_SUPPORT part this routine is unfinished and needs lots of work !!
511 void wxMacCGContext::SetPen( const wxPen
&pen
)
514 if ( m_cgContext
== NULL
)
516 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
517 bool stroke
= pen
.GetStyle() != wxTRANSPARENT
;
520 // we can benchmark performance, should go into a setting later
521 CGContextSetShouldAntialias( m_cgContext
, false ) ;
526 m_mode
= kCGPathFill
; // just a default
530 m_mode
= kCGPathFill
;
534 #if defined(_NEW_GC_SUPPORT_)
537 CGPatternRef patternRef
;
540 bool hasSetPattern
, useMultibit
;
542 hasSetPattern
= false;
544 result
= CreatePatternFromPen( &patternRef
, pen
, useMultibit
);
547 EstablishPatternColorSpace( m_cgContext
, useMultibit
, false );
550 CGContextSetStrokePattern( m_cgContext
, patternRef
, alphaArray
);
551 CGPatternRelease( patternRef
);
553 hasSetPattern
= true;
555 //wxLogDebug( wxT("CreatePatternFromPen succeeded!") );
558 // NB: the (-2) result is from wxPen instances that don't have a stipple wxBitmap
560 wxLogDebug( wxT("CreatePatternFromPen failed: result [%ld]"), result
);
567 col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() );
569 GetThemeBrushAsColor( pen
.MacGetTheme(), 32, true, &col
);
572 CGContextSetRGBStrokeColor(
573 m_cgContext
, (float) col
.red
/ 65536.0,
574 (float) col
.green
/ 65536.0, (float) col
.blue
/ 65536.0, 1.0 );
579 // original implementation
580 RGBColor col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() ) ;
581 CGContextSetRGBStrokeColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
585 switch( pen
.GetCap() )
588 cap
= kCGLineCapRound
;
590 case wxCAP_PROJECTING
:
591 cap
= kCGLineCapSquare
;
594 cap
= kCGLineCapButt
;
597 cap
= kCGLineCapButt
;
600 CGContextSetLineCap( m_cgContext
, cap
) ;
603 switch( pen
.GetJoin() )
606 join
= kCGLineJoinBevel
;
609 join
= kCGLineJoinMiter
;
612 join
= kCGLineJoinRound
;
615 join
= kCGLineJoinMiter
;
618 CGContextSetLineJoin( m_cgContext
, join
) ;
620 /* TODO * m_dc->m_scaleX */
621 float penWidth
= pen
.GetWidth();
624 CGContextSetLineWidth( m_cgContext
, penWidth
) ;
626 m_mode
= kCGPathStroke
;
629 #if defined(_NEW_GC_DASHES_)
630 const char *dashData
= NULL
;
631 char *userDashData
= NULL
;
634 const char dotted
[] = { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 };
635 const char dashed
[] = { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 };
636 const char short_dashed
[] = { 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 };
637 const char dotted_dashed
[] = { 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00 };
639 switch (pen
.GetStyle())
642 // default, undashed pen
647 count
= WXSIZEOF(dotted
);
651 count
= WXSIZEOF(dashed
);
654 dashData
= short_dashed
;
655 count
= WXSIZEOF(short_dashed
);
658 dashData
= dotted_dashed
;
659 count
= WXSIZEOF(dotted_dashed
);
662 count
= pen
.GetDashes( (wxDash
**)&userDashData
);
663 dashData
= userDashData
;
670 if ((dashData
!= NULL
) && (count
> 0))
672 CGPatternRef patternRef
;
678 result
= CreatePatternFromDashes( &patternRef
, (const wxDash
*)dashData
, count
, useMultibit
);
681 col
= MAC_WXCOLORREF( pen
.GetColour().GetPixel() );
682 CGContextSetRGBStrokeColor(
683 m_cgContext
, (float) col
.red
/ 65536.0,
684 (float) col
.green
/ 65536.0, (float) col
.blue
/ 65536.0, 1.0 );
686 EstablishPatternColorSpace( m_cgContext
, useMultibit
, false );
689 CGContextSetStrokePattern( m_cgContext
, patternRef
, alphaArray
);
690 CGPatternRelease( patternRef
);
694 wxLogDebug( wxT("CreatePatternFromDashes failed: result [%ld]"), result
);
697 const float *lengths
= NULL
;
698 float *userLengths
= NULL
;
700 const float dotted
[] = { 3 , 3 };
701 const float dashed
[] = { 19 , 9 };
702 const float short_dashed
[] = { 9 , 6 };
703 const float dotted_dashed
[] = { 9 , 6 , 3 , 3 };
705 switch( pen
.GetStyle() )
711 count
= WXSIZEOF(dotted
);
715 count
= WXSIZEOF(dashed
) ;
718 lengths
= short_dashed
;
719 count
= WXSIZEOF(short_dashed
) ;
722 lengths
= dotted_dashed
;
723 count
= WXSIZEOF(dotted_dashed
);
727 count
= pen
.GetDashes( &dashes
) ;
728 if ((dashes
!= NULL
) && (count
> 0))
730 userLengths
= new float[count
] ;
731 for( int i
= 0 ; i
< count
; ++i
)
733 userLengths
[i
] = (float)dashes
[i
] ;
734 if (userLengths
[i
] <= 0.0)
736 userLengths
[i
] = 1.0;
737 // wxLogDebug( wxT("wxMacCGContext::SetPen - bad dash length[%d] [%.2f]"), i, (float)dashes[i] );
741 lengths
= userLengths
;
747 if ((lengths
!= NULL
) && (count
> 0))
749 // we need to change the cap, otherwise everything overlaps
750 // and we get solid lines
751 CGContextSetLineDash( m_cgContext
, 0 , lengths
, count
) ;
752 CGContextSetLineCap( m_cgContext
, kCGLineCapButt
) ;
756 CGContextSetLineDash( m_cgContext
, 0 , NULL
, 0 ) ;
759 delete[] userLengths
;
762 if ( fill
&& stroke
)
764 m_mode
= kCGPathFillStroke
;
769 void wxMacCGContext::SetBrush( const wxBrush
&brush
)
772 if ( m_cgContext
== NULL
)
775 bool fill
= brush
.GetStyle() != wxTRANSPARENT
;
776 bool stroke
= m_pen
.GetStyle() != wxTRANSPARENT
;
779 // we can benchmark performance, should go into a setting later
780 CGContextSetShouldAntialias( m_cgContext
, false ) ;
786 m_mode
= kCGPathFill
; // just a default
790 #if defined(_NEW_GC_SUPPORT_)
793 CGPatternRef patternRef
;
796 bool hasSetPattern
, useMultibit
;
798 hasSetPattern
= false;
800 result
= CreatePatternFromBrush( &patternRef
, brush
, useMultibit
);
803 EstablishPatternColorSpace( m_cgContext
, useMultibit
, true );
806 CGContextSetFillPattern( m_cgContext
, patternRef
, alphaArray
);
807 CGPatternRelease( patternRef
);
809 hasSetPattern
= true;
811 //wxLogDebug( wxT("CreatePatternFromBrush succeeded!") );
814 // NB: the (-2) result is from wxBrush instances that don't have a stipple wxBitmap
816 wxLogDebug( wxT("CreatePatternFromBrush failed: result [%ld]"), result
);
823 col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() );
825 GetThemeBrushAsColor( brush
.MacGetTheme(), 32, true, &col
);
828 CGContextSetRGBFillColor(
829 m_cgContext
, (float) col
.red
/ 65536.0,
830 (float) col
.green
/ 65536.0, (float) col
.blue
/ 65536.0, 1.0 );
835 // original implementation
836 RGBColor col
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() ) ;
837 CGContextSetRGBFillColor( m_cgContext
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
840 m_mode
= kCGPathFill
;
844 m_mode
= kCGPathStroke
;
846 if ( fill
&& stroke
)
848 m_mode
= kCGPathFillStroke
;
853 void AddEllipticArcToPath(CGContextRef c
, CGPoint center
, float a
, float b
, float fromDegree
, float toDegree
)
855 CGContextSaveGState(c
);
856 CGContextTranslateCTM(c
, center
.x
, center
.y
);
857 CGContextScaleCTM(c
, a
, b
);
858 CGContextMoveToPoint(c
, 1, 0);
859 CGContextAddArc(c
, 0, 0, 1, DegToRad(fromDegree
), DegToRad(toDegree
), 0);
860 CGContextClosePath(c
);
861 CGContextRestoreGState(c
);
864 void AddRoundedRectToPath(CGContextRef c
, CGRect rect
, float ovalWidth
,
868 if (ovalWidth
== 0 || ovalHeight
== 0)
870 CGContextAddRect(c
, rect
);
873 CGContextSaveGState(c
);
874 CGContextTranslateCTM(c
, CGRectGetMinX(rect
), CGRectGetMinY(rect
));
875 CGContextScaleCTM(c
, ovalWidth
, ovalHeight
);
876 fw
= CGRectGetWidth(rect
) / ovalWidth
;
877 fh
= CGRectGetHeight(rect
) / ovalHeight
;
878 CGContextMoveToPoint(c
, fw
, fh
/2);
879 CGContextAddArcToPoint(c
, fw
, fh
, fw
/2, fh
, 1);
880 CGContextAddArcToPoint(c
, 0, fh
, 0, fh
/2, 1);
881 CGContextAddArcToPoint(c
, 0, 0, fw
/2, 0, 1);
882 CGContextAddArcToPoint(c
, fw
, 0, fw
, fh
/2, 1);
883 CGContextClosePath(c
);
884 CGContextRestoreGState(c
);
891 m_mm_to_pix_x
= mm2pt
;
892 m_mm_to_pix_y
= mm2pt
;
893 m_internalDeviceOriginX
= 0;
894 m_internalDeviceOriginY
= 0;
895 m_externalDeviceOriginX
= 0;
896 m_externalDeviceOriginY
= 0;
897 m_logicalScaleX
= 1.0;
898 m_logicalScaleY
= 1.0;
903 m_needComputeScaleX
= FALSE
;
904 m_needComputeScaleY
= FALSE
;
908 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
910 m_pen
= *wxBLACK_PEN
;
911 m_font
= *wxNORMAL_FONT
;
912 m_brush
= *wxWHITE_BRUSH
;
914 m_macATSUIStyle
= NULL
;
916 m_graphicContext
= NULL
;
921 if( m_macATSUIStyle
)
923 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
924 m_macATSUIStyle
= NULL
;
927 delete m_graphicContext
;
930 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
932 wxCHECK_RET( Ok(), wxT("invalid window dc") );
933 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
934 wxCoord xx
= XLOG2DEVMAC(x
);
935 wxCoord yy
= YLOG2DEVMAC(y
);
936 wxCoord w
= bmp
.GetWidth();
937 wxCoord h
= bmp
.GetHeight();
938 wxCoord ww
= XLOG2DEVREL(w
);
939 wxCoord hh
= YLOG2DEVREL(h
);
941 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
942 CGImageRef image
= (CGImageRef
)( bmp
.CGImageCreate() ) ;
943 HIRect r
= CGRectMake( xx
, yy
, ww
, hh
) ;
944 HIViewDrawCGImage( cg
, &r
, image
) ;
945 CGImageRelease( image
) ;
948 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
950 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
951 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
953 wxCoord xx
= XLOG2DEVMAC(x
);
954 wxCoord yy
= YLOG2DEVMAC(y
);
955 wxCoord w
= icon
.GetWidth();
956 wxCoord h
= icon
.GetHeight();
957 wxCoord ww
= XLOG2DEVREL(w
);
958 wxCoord hh
= YLOG2DEVREL(h
);
960 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
961 CGRect r
= CGRectMake( 00 , 00 , ww
, hh
) ;
962 CGContextSaveGState(cg
);
963 CGContextTranslateCTM(cg
, xx
, yy
+ hh
);
964 CGContextScaleCTM(cg
, 1, -1);
965 PlotIconRefInContext( cg
, &r
, kAlignNone
, kTransformNone
,
966 NULL
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
967 CGContextRestoreGState( cg
) ;
970 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
972 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
973 wxCoord xx
, yy
, ww
, hh
;
976 ww
= XLOG2DEVREL(width
);
977 hh
= YLOG2DEVREL(height
);
979 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
980 CGRect clipRect
= CGRectMake( xx
,yy
, ww
, hh
) ;
981 CGContextClipToRect( cgContext
, clipRect
) ;
983 // SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ;
984 // SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
987 m_clipX1
= wxMax( m_clipX1
, xx
);
988 m_clipY1
= wxMax( m_clipY1
, yy
);
989 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
990 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
1000 // TODO as soon as we don't reset the context for each operation anymore
1001 // we have to update the context as well
1004 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
1006 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
1009 DestroyClippingRegion();
1013 region
.GetBox( x
, y
, w
, h
);
1014 wxCoord xx
, yy
, ww
, hh
;
1015 xx
= XLOG2DEVMAC(x
);
1016 yy
= YLOG2DEVMAC(y
);
1017 ww
= XLOG2DEVREL(w
);
1018 hh
= YLOG2DEVREL(h
);
1019 // if we have a scaling that we cannot map onto native regions
1020 // we must use the box
1021 if ( ww
!= w
|| hh
!= h
)
1023 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
1028 CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ;
1029 if ( xx != x || yy != y )
1031 OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ;
1033 SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
1037 m_clipX1
= wxMax( m_clipX1
, xx
);
1038 m_clipY1
= wxMax( m_clipY1
, yy
);
1039 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
1040 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
1053 void wxDC::DestroyClippingRegion()
1055 // CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
1056 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1057 CGContextRestoreGState( cgContext
);
1058 CGContextSaveGState( cgContext
);
1059 m_graphicContext
->SetPen( m_pen
) ;
1060 m_graphicContext
->SetBrush( m_brush
) ;
1064 void wxDC::DoGetSizeMM( int* width
, int* height
) const
1069 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
1070 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
1073 void wxDC::SetTextForeground( const wxColour
&col
)
1075 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1076 if ( col
!= m_textForegroundColour
)
1078 m_textForegroundColour
= col
;
1083 void wxDC::SetTextBackground( const wxColour
&col
)
1085 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1086 m_textBackgroundColour
= col
;
1089 void wxDC::SetMapMode( int mode
)
1094 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
1097 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
1100 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
1103 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
1107 SetLogicalScale( 1.0, 1.0 );
1110 if (mode
!= wxMM_TEXT
)
1112 m_needComputeScaleX
= TRUE
;
1113 m_needComputeScaleY
= TRUE
;
1117 void wxDC::SetUserScale( double x
, double y
)
1119 // allow negative ? -> no
1122 ComputeScaleAndOrigin();
1125 void wxDC::SetLogicalScale( double x
, double y
)
1128 m_logicalScaleX
= x
;
1129 m_logicalScaleY
= y
;
1130 ComputeScaleAndOrigin();
1133 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
1135 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
1136 m_logicalOriginY
= y
* m_signY
;
1137 ComputeScaleAndOrigin();
1140 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
1142 m_externalDeviceOriginX
= x
;
1143 m_externalDeviceOriginY
= y
;
1144 ComputeScaleAndOrigin();
1147 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
1149 m_signX
= (xLeftRight
? 1 : -1);
1150 m_signY
= (yBottomUp
? -1 : 1);
1151 ComputeScaleAndOrigin();
1154 wxSize
wxDC::GetPPI() const
1156 return wxSize(72, 72);
1159 int wxDC::GetDepth() const
1164 void wxDC::ComputeScaleAndOrigin()
1166 // CMB: copy scale to see if it changes
1167 double origScaleX
= m_scaleX
;
1168 double origScaleY
= m_scaleY
;
1169 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
1170 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
1171 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
1172 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
1173 // CMB: if scale has changed call SetPen to recalulate the line width
1174 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
1176 // this is a bit artificial, but we need to force wxDC to think
1177 // the pen has changed
1178 wxPen
pen(GetPen());
1184 void wxDC::SetPalette( const wxPalette
& palette
)
1188 void wxDC::SetBackgroundMode( int mode
)
1190 m_backgroundMode
= mode
;
1193 void wxDC::SetFont( const wxFont
&font
)
1199 void wxDC::SetPen( const wxPen
&pen
)
1204 if ( m_graphicContext
)
1206 m_graphicContext
->SetPen( m_pen
) ;
1210 void wxDC::SetBrush( const wxBrush
&brush
)
1212 if (m_brush
== brush
)
1215 if ( m_graphicContext
)
1217 m_graphicContext
->SetBrush( m_brush
) ;
1221 void wxDC::SetBackground( const wxBrush
&brush
)
1223 if (m_backgroundBrush
== brush
)
1225 m_backgroundBrush
= brush
;
1226 if (!m_backgroundBrush
.Ok())
1230 void wxDC::SetLogicalFunction( int function
)
1232 if (m_logicalFunction
== function
)
1234 m_logicalFunction
= function
;
1237 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
1238 const wxColour
& col
, int style
);
1240 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
1241 const wxColour
& col
, int style
)
1243 return wxDoFloodFill(this, x
, y
, col
, style
);
1246 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
1248 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1249 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
1250 wxMacPortSaver
helper((CGrafPtr
)m_macPort
) ;
1253 XLOG2DEVMAC(x
) + m_macLocalOriginInPort
.x
- m_macLocalOrigin
.x
,
1254 YLOG2DEVMAC(y
) + m_macLocalOriginInPort
.y
- m_macLocalOrigin
.y
, &colour
);
1255 // Convert from Mac colour to wx
1256 col
->Set( colour
.red
>> 8,
1262 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1264 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1266 if ( m_logicalFunction
!= wxCOPY
)
1269 wxCoord xx1
= XLOG2DEVMAC(x1
) ;
1270 wxCoord yy1
= YLOG2DEVMAC(y1
) ;
1271 wxCoord xx2
= XLOG2DEVMAC(x2
) ;
1272 wxCoord yy2
= YLOG2DEVMAC(y2
) ;
1274 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1275 path
->MoveToPoint( xx1
, yy1
) ;
1276 path
->AddLineToPoint( xx2
, yy2
) ;
1277 path
->CloseSubpath() ;
1278 m_graphicContext
->StrokePath( path
) ;
1281 CalcBoundingBox(x1
, y1
);
1282 CalcBoundingBox(x2
, y2
);
1285 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
1287 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
1289 if ( m_logicalFunction
!= wxCOPY
)
1295 wxCoord xx
= XLOG2DEVMAC(x
);
1296 wxCoord yy
= YLOG2DEVMAC(y
);
1298 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1299 path
->MoveToPoint( XLOG2DEVMAC(0), yy
) ;
1300 path
->AddLineToPoint( XLOG2DEVMAC(w
), yy
) ;
1301 path
->CloseSubpath() ;
1302 path
->MoveToPoint( xx
, YLOG2DEVMAC(0) ) ;
1303 path
->AddLineToPoint( xx
, YLOG2DEVMAC(h
) ) ;
1304 path
->CloseSubpath() ;
1305 m_graphicContext
->StrokePath( path
) ;
1308 CalcBoundingBox(x
, y
);
1309 CalcBoundingBox(x
+w
, y
+h
);
1312 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
1313 wxCoord x2
, wxCoord y2
,
1314 wxCoord xc
, wxCoord yc
)
1316 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
1318 if ( m_logicalFunction
!= wxCOPY
)
1321 wxCoord xx1
= XLOG2DEVMAC(x1
);
1322 wxCoord yy1
= YLOG2DEVMAC(y1
);
1323 wxCoord xx2
= XLOG2DEVMAC(x2
);
1324 wxCoord yy2
= YLOG2DEVMAC(y2
);
1325 wxCoord xxc
= XLOG2DEVMAC(xc
);
1326 wxCoord yyc
= YLOG2DEVMAC(yc
);
1327 double dx
= xx1
- xxc
;
1328 double dy
= yy1
- yyc
;
1329 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
1330 wxCoord rad
= (wxCoord
)radius
;
1332 if (xx1
== xx2
&& yy1
== yy2
)
1337 else if (radius
== 0.0)
1343 sa
= (xx1
- xxc
== 0) ?
1344 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
1345 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
1346 ea
= (xx2
- xxc
== 0) ?
1347 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
1348 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
1351 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1352 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1353 CGContextRef ctx
= mctx
->GetNativeContext() ;
1354 CGContextSaveGState( ctx
) ;
1355 CGContextTranslateCTM( ctx
, xxc
, yyc
);
1356 CGContextScaleCTM( ctx
, 1 , -1 ) ;
1358 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1359 CGContextAddArc( ctx
, 0, 0 , rad
, DegToRad(sa
), DegToRad(ea
), 0);
1361 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1362 CGContextRestoreGState( ctx
) ;
1363 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1366 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1367 double sa
, double ea
)
1369 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
1371 if ( m_logicalFunction
!= wxCOPY
)
1374 wxCoord xx
= XLOG2DEVMAC(x
);
1375 wxCoord yy
= YLOG2DEVMAC(y
);
1376 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
1377 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
1378 // handle -ve width and/or height
1379 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
1380 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
1382 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
1384 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1385 CGContextRef ctx
= mctx
->GetNativeContext() ;
1387 CGContextSaveGState( ctx
) ;
1388 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1389 CGContextScaleCTM( ctx
, 1 * ww
/ 2 , -1 * hh
/ 2 ) ;
1391 CGContextMoveToPoint( ctx
, 0 , 0 ) ;
1392 CGContextAddArc( ctx
, 0, 0, 1, DegToRad(sa
), DegToRad(ea
), 0);
1394 CGContextAddLineToPoint( ctx
, 0 , 0 ) ;
1395 CGContextRestoreGState( ctx
) ;
1396 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1399 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
1401 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1402 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 ) ;
1405 void wxDC::DoDrawLines(int n
, wxPoint points
[],
1406 wxCoord xoffset
, wxCoord yoffset
)
1408 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1410 if ( m_logicalFunction
!= wxCOPY
)
1413 wxCoord x1
, x2
, y1
, y2
;
1414 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1415 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1416 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1417 path
->MoveToPoint( x1
, y1
) ;
1418 for (int i
= 1; i
< n
; i
++)
1420 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1421 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1423 path
->AddLineToPoint( x2
, y2
) ;
1425 m_graphicContext
->StrokePath( path
) ;
1430 void wxDC::DoDrawSpline(wxList
*points
)
1432 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1434 if ( m_logicalFunction
!= wxCOPY
)
1437 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1439 wxList::compatibility_iterator node
= points
->GetFirst();
1440 if (node
== wxList::compatibility_iterator())
1444 wxPoint
*p
= (wxPoint
*)node
->GetData();
1449 node
= node
->GetNext();
1450 p
= (wxPoint
*)node
->GetData();
1454 wxCoord cx1
= ( x1
+ x2
) / 2;
1455 wxCoord cy1
= ( y1
+ y2
) / 2;
1457 path
->MoveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ) ;
1458 path
->AddLineToPoint( XLOG2DEVMAC( cx1
) , XLOG2DEVMAC( cy1
) ) ;
1461 while ((node
= node
->GetNext()) != NULL
)
1463 while ((node
= node
->GetNext()))
1464 #endif // !wxUSE_STL
1466 p
= (wxPoint
*)node
->GetData();
1471 wxCoord cx4
= (x1
+ x2
) / 2;
1472 wxCoord cy4
= (y1
+ y2
) / 2;
1474 path
->AddQuadCurveToPoint( XLOG2DEVMAC( x1
) , XLOG2DEVMAC( y1
) ,
1475 XLOG2DEVMAC( cx4
) , XLOG2DEVMAC( cy4
) ) ;
1481 path
->AddLineToPoint( XLOG2DEVMAC( x2
) , XLOG2DEVMAC( y2
) ) ;
1483 m_graphicContext
->StrokePath( path
) ;
1488 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
1489 wxCoord xoffset
, wxCoord yoffset
,
1492 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1493 wxCoord x1
, x2
, y1
, y2
;
1494 if ( n
== 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
1497 if ( m_logicalFunction
!= wxCOPY
)
1500 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1501 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1503 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1504 path
->MoveToPoint( x1
, y1
) ;
1505 for (int i
= 1; i
< n
; i
++)
1507 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1508 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1510 path
->AddLineToPoint( x2
, y2
) ;
1512 if ( x1
!= x2
|| y1
!= y2
)
1514 path
->AddLineToPoint( x1
,y1
) ;
1516 path
->CloseSubpath() ;
1517 m_graphicContext
->DrawPath( path
, fillStyle
) ;
1521 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1523 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1525 if ( m_logicalFunction
!= wxCOPY
)
1528 wxCoord xx
= XLOG2DEVMAC(x
);
1529 wxCoord yy
= YLOG2DEVMAC(y
);
1530 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1531 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1532 // CMB: draw nothing if transformed w or h is 0
1533 if (ww
== 0 || hh
== 0)
1535 // CMB: handle -ve width and/or height
1546 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1547 path
->AddRectangle(xx
,yy
, ww
, hh
) ;
1548 m_graphicContext
->DrawPath( path
) ;
1552 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1553 wxCoord width
, wxCoord height
,
1556 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1558 if ( m_logicalFunction
!= wxCOPY
)
1563 radius
= - radius
* ((width
< height
) ? width
: height
);
1564 wxCoord xx
= XLOG2DEVMAC(x
);
1565 wxCoord yy
= YLOG2DEVMAC(y
);
1566 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1567 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1568 // CMB: draw nothing if transformed w or h is 0
1569 if (ww
== 0 || hh
== 0)
1571 // CMB: handle -ve width and/or height
1582 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1583 CGContextRef ctx
= mctx
->GetNativeContext() ;
1584 AddRoundedRectToPath( ctx
, CGRectMake( xx
, yy
, ww
, hh
) , 16 ,16 ) ;
1585 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1588 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1590 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1592 if ( m_logicalFunction
!= wxCOPY
)
1595 wxCoord xx
= XLOG2DEVMAC(x
);
1596 wxCoord yy
= YLOG2DEVMAC(y
);
1597 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1598 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1599 // CMB: draw nothing if transformed w or h is 0
1600 if (ww
== 0 || hh
== 0)
1602 // CMB: handle -ve width and/or height
1614 wxMacCGContext
* mctx
= ((wxMacCGContext
*) m_graphicContext
) ;
1615 CGContextRef ctx
= mctx
->GetNativeContext() ;
1616 CGContextSaveGState( ctx
) ;
1617 CGContextTranslateCTM( ctx
, xx
+ ww
/ 2, yy
+ hh
/ 2);
1618 CGContextScaleCTM( ctx
, ww
/ 2 , hh
/ 2 ) ;
1619 CGContextAddArc( ctx
, 0, 0, 1, 0 , 2*M_PI
, 0);
1620 CGContextRestoreGState( ctx
) ;
1621 CGContextDrawPath( ctx
, mctx
->GetDrawingMode() ) ;
1624 bool wxDC::CanDrawBitmap(void) const
1629 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1630 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1631 wxCoord xsrcMask
, wxCoord ysrcMask
)
1633 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1634 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1635 if ( logical_func
== wxNO_OP
)
1637 if (xsrcMask
== -1 && ysrcMask
== -1)
1639 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1642 wxCoord yysrc
= source
->YLOG2DEVMAC(ysrc
) ;
1643 wxCoord xxsrc
= source
->XLOG2DEVMAC(xsrc
) ;
1644 wxCoord wwsrc
= source
->XLOG2DEVREL(width
) ;
1645 wxCoord hhsrc
= source
->YLOG2DEVREL(height
) ;
1647 wxCoord yydest
= YLOG2DEVMAC(ydest
) ;
1648 wxCoord xxdest
= XLOG2DEVMAC(xdest
) ;
1649 wxCoord wwdest
= XLOG2DEVREL(width
) ;
1650 wxCoord hhdest
= YLOG2DEVREL(height
) ;
1652 wxMemoryDC
* memdc
= dynamic_cast<wxMemoryDC
*>(source
) ;
1653 if ( memdc
&& logical_func
== wxCOPY
)
1655 wxBitmap blit
= memdc
->GetSelectedObject() ;
1656 wxASSERT_MSG( blit
.Ok() , wxT("Invalid bitmap for blitting") ) ;
1658 wxCoord bmpwidth
= blit
.GetWidth();
1659 wxCoord bmpheight
= blit
.GetHeight();
1661 if ( xxsrc
!= 0 || yysrc
!= 0 || bmpwidth
!= wwsrc
|| bmpheight
!= hhsrc
)
1663 wwsrc
= wxMin( wwsrc
, bmpwidth
- xxsrc
) ;
1664 hhsrc
= wxMin( hhsrc
, bmpheight
- yysrc
) ;
1665 if ( wwsrc
> 0 && hhsrc
> 0 )
1667 if ( xxsrc
>= 0 && yysrc
>= 0 )
1669 wxRect
subrect( xxsrc
, yysrc
, wwsrc
, hhsrc
) ;
1670 blit
= blit
.GetSubBitmap( subrect
) ;
1674 // in this case we'd probably have to adjust the different coordinates, but
1675 // we have to find out proper contract first
1676 blit
= wxNullBitmap
;
1681 blit
= wxNullBitmap
;
1686 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1687 CGImageRef image
= (CGImageRef
)( blit
.CGImageCreate() ) ;
1688 HIRect r
= CGRectMake( xxdest
, yydest
, wwdest
, hhdest
) ;
1689 HIViewDrawCGImage( cg
, &r
, image
) ;
1690 CGImageRelease( image
) ;
1697 CGContextRef cg = (wxMacCGContext*)(source->GetGraphicContext())->GetNativeContext() ;
1698 void *data = CGBitmapContextGetData( cg ) ;
1700 return FALSE
; // wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts") ) ;
1705 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1708 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1710 if ( str
.Length() == 0 )
1713 if ( m_logicalFunction
!= wxCOPY
)
1716 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1718 OSStatus status
= noErr
;
1719 ATSUTextLayout atsuLayout
;
1720 UniCharCount chars
= str
.Length() ;
1721 UniChar
* ubuf
= NULL
;
1722 #if SIZEOF_WCHAR_T == 4
1723 wxMBConvUTF16 converter
;
1725 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1726 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1727 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1729 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1730 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1731 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1732 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1734 chars
= unicharlen
/ 2 ;
1737 ubuf
= (UniChar
*) str
.wc_str() ;
1739 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1740 chars
= wxWcslen( wchar
.data() ) ;
1741 ubuf
= (UniChar
*) wchar
.data() ;
1745 int drawX
= XLOG2DEVMAC(x
) ;
1746 int drawY
= YLOG2DEVMAC(y
) ;
1748 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1749 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1751 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1753 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1754 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1756 int iAngle
= int( angle
);
1757 if ( abs(iAngle
) > 0 )
1759 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1760 ATSUAttributeTag atsuTags
[] =
1762 kATSULineRotationTag
,
1764 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1768 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1772 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1773 atsuTags
, atsuSizes
, atsuValues
) ;
1776 CGContextRef cgContext
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
1777 ATSUAttributeTag atsuTags
[] =
1781 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1783 sizeof( CGContextRef
) ,
1785 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1789 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1790 atsuTags
, atsuSizes
, atsuValues
) ;
1793 ATSUTextMeasurement textBefore
;
1794 ATSUTextMeasurement textAfter
;
1795 ATSUTextMeasurement ascent
;
1796 ATSUTextMeasurement descent
;
1798 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1799 &textBefore
, &textAfter
, &ascent
, &descent
);
1800 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1804 if ( m_backgroundMode
== wxSOLID
)
1806 wxGraphicPath
* path
= m_graphicContext
->CreatePath() ;
1810 path
->AddLineToPoint(
1811 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ,
1812 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
)) ) ;
1813 path
->AddLineToPoint(
1814 (int) (drawX
+ sin(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) + cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1815 (int) (drawY
+ cos(angle
/RAD2DEG
) * FixedToInt(ascent
+ descent
) - sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1816 path
->AddLineToPoint(
1817 (int) (drawX
+ cos(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ,
1818 (int) (drawY
- sin(angle
/RAD2DEG
) * FixedToInt(textAfter
)) ) ;
1820 m_graphicContext
->FillPath( path
, m_textBackgroundColour
) ;
1824 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1825 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1827 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1828 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1829 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1831 CGContextSaveGState(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext());
1832 CGContextTranslateCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), drawX
, drawY
);
1833 CGContextScaleCTM(((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext(), 1, -1);
1834 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1835 IntToFixed(0) , IntToFixed(0) );
1836 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1837 CGContextRestoreGState( ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ) ;
1839 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1840 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1842 ::ATSUDisposeTextLayout(atsuLayout
);
1843 #if SIZEOF_WCHAR_T == 4
1848 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1850 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1851 DoDrawRotatedText( strtext
, x
, y
, 0.0 ) ;
1854 bool wxDC::CanGetTextExtent() const
1856 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1860 void wxDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
1861 wxCoord
*descent
, wxCoord
*externalLeading
,
1862 wxFont
*theFont
) const
1864 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1865 wxFont formerFont
= m_font
;
1868 // work around the constness
1869 *((wxFont
*)(&m_font
)) = *theFont
;
1873 if ( str
.Length() == 0 )
1876 wxCHECK_RET( m_macATSUIStyle
!= NULL
, wxT("No valid font set") ) ;
1878 OSStatus status
= noErr
;
1879 ATSUTextLayout atsuLayout
;
1880 UniCharCount chars
= str
.Length() ;
1881 UniChar
* ubuf
= NULL
;
1882 #if SIZEOF_WCHAR_T == 4
1883 wxMBConvUTF16 converter
;
1885 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1886 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1887 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1889 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1890 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1891 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1892 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1894 chars
= unicharlen
/ 2 ;
1897 ubuf
= (UniChar
*) str
.wc_str() ;
1899 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1900 chars
= wxWcslen( wchar
.data() ) ;
1901 ubuf
= (UniChar
*) wchar
.data() ;
1906 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1907 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1909 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the text") );
1911 ATSUTextMeasurement textBefore
;
1912 ATSUTextMeasurement textAfter
;
1913 ATSUTextMeasurement textAscent
;
1914 ATSUTextMeasurement textDescent
;
1916 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1917 &textBefore
, &textAfter
, &textAscent
, &textDescent
);
1920 *height
= YDEV2LOGREL( FixedToInt(textAscent
+ textDescent
) ) ;
1922 *descent
=YDEV2LOGREL( FixedToInt(textDescent
) );
1923 if ( externalLeading
)
1924 *externalLeading
= 0 ;
1926 *width
= XDEV2LOGREL( FixedToInt(textAfter
- textBefore
) ) ;
1928 ::ATSUDisposeTextLayout(atsuLayout
);
1929 #if SIZEOF_WCHAR_T == 4
1934 // work around the constness
1935 *((wxFont
*)(&m_font
)) = formerFont
;
1941 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1943 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1946 widths
.Add(0, text
.Length());
1948 if (text
.Length() == 0)
1951 ATSUTextLayout atsuLayout
;
1952 UniCharCount chars
= text
.Length() ;
1953 UniChar
* ubuf
= NULL
;
1954 #if SIZEOF_WCHAR_T == 4
1955 wxMBConvUTF16 converter
;
1957 size_t unicharlen
= converter
.WC2MB( NULL
, text
.wc_str() , 0 ) ;
1958 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1959 converter
.WC2MB( (char*) ubuf
, text
.wc_str(), unicharlen
+ 2 ) ;
1961 const wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1962 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1963 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1964 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1966 chars
= unicharlen
/ 2 ;
1969 ubuf
= (UniChar
*) text
.wc_str() ;
1971 wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
) ;
1972 chars
= wxWcslen( wchar
.data() ) ;
1973 ubuf
= (UniChar
*) wchar
.data() ;
1978 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1979 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1981 for ( int pos
= 0; pos
< (int)chars
; pos
++ ) {
1982 unsigned long actualNumberOfBounds
= 0;
1983 ATSTrapezoid glyphBounds
;
1985 // We get a single bound, since the text should only require one. If it requires more, there is an issue
1987 result
= ATSUGetGlyphBounds( atsuLayout
, 0, 0, kATSUFromTextBeginning
, pos
+ 1, kATSUseDeviceOrigins
, 1, &glyphBounds
, &actualNumberOfBounds
);
1988 if (result
!= noErr
|| actualNumberOfBounds
!= 1 )
1993 widths
[pos
] = XDEV2LOGREL(FixedToInt( glyphBounds
.upperRight
.x
- glyphBounds
.upperLeft
.x
));
1994 //unsigned char uch = s[i];
1997 ::ATSUDisposeTextLayout(atsuLayout
);
2001 wxCoord
wxDC::GetCharWidth(void) const
2004 DoGetTextExtent(wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
) ;
2008 wxCoord
wxDC::GetCharHeight(void) const
2011 DoGetTextExtent(wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
) ;
2015 void wxDC::Clear(void)
2017 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2019 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
2021 HIRect rect
= CGRectMake( -10000 , -10000 , 20000 , 20000 ) ;
2022 CGContextRef cg
= ((wxMacCGContext
*)(m_graphicContext
))->GetNativeContext() ;
2023 switch( m_backgroundBrush
.MacGetBrushKind() )
2025 case kwxMacBrushTheme
:
2027 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
2028 if ( HIThemeSetFill
!= 0 )
2030 HIThemeSetFill( m_backgroundBrush
.MacGetTheme(), NULL
, cg
, kHIThemeOrientationNormal
);
2031 CGContextFillRect(cg
, rect
);
2038 GetThemeBrushAsColor( m_backgroundBrush
.MacGetTheme(), 32, true, &color
);
2039 CGContextSetRGBFillColor( cg
, (float) color
.red
/ 65536,
2040 (float) color
.green
/ 65536, (float) color
.blue
/ 65536, 1 );
2041 CGContextFillRect( cg
, rect
);
2044 // reset to normal value
2045 RGBColor col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
2046 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0, col
.green
/ 65536.0, col
.blue
/ 65536.0, 1.0 );
2049 case kwxMacBrushThemeBackground
:
2051 wxFAIL_MSG( wxT("There shouldn't be theme backgrounds under Quartz") ) ;
2052 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2053 if ( UMAGetSystemVersion() >= 0x1030 )
2055 HIThemeBackgroundDrawInfo drawInfo
;
2056 drawInfo
.version
= 0 ;
2057 drawInfo
.state
= kThemeStateActive
;
2058 drawInfo
.kind
= m_backgroundBrush
.MacGetThemeBackground(NULL
) ;
2059 if ( drawInfo
.kind
== kThemeBackgroundMetal
)
2060 HIThemeDrawBackground( &rect
, &drawInfo
, cg
,
2061 kHIThemeOrientationNormal
) ;
2062 HIThemeApplyBackground( &rect
, &drawInfo
, cg
,
2063 kHIThemeOrientationNormal
) ;
2071 case kwxMacBrushColour
:
2073 RGBColor col
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) ;
2074 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2075 CGContextFillRect(cg
, rect
);
2077 // reset to normal value
2078 col
= MAC_WXCOLORREF( GetBrush().GetColour().GetPixel() ) ;
2079 CGContextSetRGBFillColor( cg
, col
.red
/ 65536.0 , col
.green
/ 65536.0 , col
.blue
/ 65536.0 , 1.0 ) ;
2086 void wxDC::MacInstallFont() const
2088 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2090 if( m_macATSUIStyle
)
2092 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
2093 m_macATSUIStyle
= NULL
;
2098 OSStatus status
= noErr
;
2099 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
2100 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
2102 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
2103 RGBColor atsuColor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel() ) ;
2104 ATSUAttributeTag atsuTags
[] =
2109 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2112 sizeof( RGBColor
) ,
2114 // Boolean kTrue = true ;
2115 // Boolean kFalse = false ;
2117 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
2118 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
2123 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
2124 atsuTags
, atsuSizes
, atsuValues
);
2126 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
2130 // ---------------------------------------------------------------------------
2131 // coordinates transformations
2132 // ---------------------------------------------------------------------------
2134 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2136 return ((wxDC
*)this)->XDEV2LOG(x
);
2139 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2141 return ((wxDC
*)this)->YDEV2LOG(y
);
2144 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2146 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2149 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2151 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2154 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2156 return ((wxDC
*)this)->XLOG2DEV(x
);
2159 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2161 return ((wxDC
*)this)->YLOG2DEV(y
);
2164 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2166 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2169 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2171 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2174 #endif // wxMAC_USE_CORE_GRAPHICS