// appends a rectangle as a new closed subpath
virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
- // appends an ellipsis as a new closed subpath fitting the passed rectangle
+ // appends a circle as a new closed subpath
virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r );
+ // appends an ellipsis as a new closed subpath fitting the passed rectangle
+ virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
+
// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r );
void wxMacCoreGraphicsPathData::AddCircle( wxDouble x, wxDouble y , wxDouble r )
{
- CGPathAddArc( m_path , NULL , (CGFloat) x , (CGFloat) y , (CGFloat) r , (CGFloat) 0.0 , (CGFloat) (2 * M_PI) , true );
+ CGPathAddEllipseInRect( m_path, NULL, CGRectMake(x-r,y-r,2*r,2*r));
+}
+
+void wxMacCoreGraphicsPathData::AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+{
+ CGPathAddEllipseInRect( m_path, NULL, CGRectMake(x,y,w,h));
}
// adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
m_cg = cg;
m_offset = offset;
if ( m_offset )
- CGContextTranslateCTM( m_cg, (CGFloat) 0.5, (CGFloat) 0.5 );
+ {
+ m_userOffset = CGContextConvertSizeToUserSpace( m_cg, CGSizeMake( 0.5 , 0.5 ) );
+ CGContextTranslateCTM( m_cg, m_userOffset.width , m_userOffset.height );
+ }
}
~wxQuartzOffsetHelper( )
{
if ( m_offset )
- CGContextTranslateCTM( m_cg, (CGFloat) -0.5, (CGFloat) -0.5 );
+ CGContextTranslateCTM( m_cg, -m_userOffset.width , -m_userOffset.height );
}
public :
+ CGSize m_userOffset;
CGContextRef m_cg;
bool m_offset;
} ;
CGContextRestoreGState( m_cgContext );
if ( m_contextSynthesized )
{
- // TODO: in case of performance problems, try issuing this not too
- // frequently (half of refresh rate)
- CGContextFlush(m_cgContext);
#if wxOSX_USE_CARBON
QDEndCGContext( GetWindowPort( m_windowRef ) , &m_cgContext);
#endif
wxCFRef<CFAttributedStringRef> attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, attributes) );
wxCFRef<CTLineRef> line( CTLineCreateWithAttributedString(attrtext) );
- double w;
+ // round the returned extent: this is probably more correct anyhow but
+ // we also need to do it to be consistent with GetPartialTextExtents()
+ // below and avoid strange situation when the last partial extent
+ // returned by it could have been greater than the full extent returned
+ // by us
CGFloat a, d, l;
-
- w = CTLineGetTypographicBounds(line, &a, &d, &l) ;
+ int w = CTLineGetTypographicBounds(line, &a, &d, &l) + 0.5;
if ( height )
*height = a+d+l;
int chars = text.length();
for ( int pos = 0; pos < (int)chars; pos ++ )
{
- widths[pos] = CTLineGetOffsetForStringIndex( line, pos+1 , NULL )+0.5;
+ widths[pos] = CTLineGetOffsetForStringIndex( line, pos+1 , NULL );
}
return;