return m_path ;
}
-void wxMacCGPath::AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r )
+void wxMacCGPath::AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r )
{
- CGPathAddArcToPoint( m_path, NULL , x1, y1, x2, y2, r);
+ CGPathAddArcToPoint( m_path, NULL , x1, y1, x2, y2, r);
}
-void wxMacCGPath::AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise )
+void wxMacCGPath::AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise )
{
- CGPathAddArc( m_path, NULL , x, y, r, startAngle, endAngle, clockwise);
+ CGPathAddArc( m_path, NULL , x, y, r, startAngle, endAngle, clockwise);
}
//-----------------------------------------------------------------------------
width = 1 ;
if ( m_pen.GetStyle() == wxTRANSPARENT )
width = 0 ;
-
- bool offset = ( width % 2 ) == 1 ;
+
+ bool offset = ( width % 2 ) == 1 ;
if ( offset )
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
width = 1 ;
if ( m_pen.GetStyle() == wxTRANSPARENT )
width = 0 ;
-
- bool offset = ( width % 2 ) == 1 ;
+
+ bool offset = ( width % 2 ) == 1 ;
if ( offset )
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
m_cgContext = cg ;
}
-void wxMacCGContext::Translate( wxCoord dx , wxCoord dy )
+void wxMacCGContext::Translate( wxCoord dx , wxCoord dy )
{
CGContextTranslateCTM( m_cgContext, dx, dy );
}
CGContextScaleCTM( m_cgContext , xScale , yScale ) ;
}
-void wxMacCGContext::DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h )
+void wxMacCGContext::DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h )
{
CGImageRef image = (CGImageRef)( bmp.CGImageCreate() ) ;
- HIRect r = CGRectMake( 0 , 0 , w , h );
+ HIRect r = CGRectMake( 0 , 0 , w , h );
CGContextSaveGState( m_cgContext );
CGContextTranslateCTM( m_cgContext, x , y + h );
CGContextScaleCTM( m_cgContext, 1, -1 );
-
+
// in case image is a mask, set the foreground color
- CGContextSetRGBFillColor( m_cgContext , m_textForegroundColor.Red() / 255.0 , m_textForegroundColor.Green() / 255.0 ,
+ CGContextSetRGBFillColor( m_cgContext , m_textForegroundColor.Red() / 255.0 , m_textForegroundColor.Green() / 255.0 ,
m_textForegroundColor.Blue() / 255.0 , m_textForegroundColor.Alpha() / 255.0 ) ;
CGContextDrawImage( m_cgContext, r, image );
CGContextRestoreGState( m_cgContext );
CGImageRelease( image ) ;
}
-void wxMacCGContext::DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h )
+void wxMacCGContext::DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h )
{
CGRect r = CGRectMake( 0 , 0 , w , h ) ;
CGContextSaveGState( m_cgContext );
CGContextSaveGState( m_cgContext );
}
-void wxMacCGContext::PopState()
+void wxMacCGContext::PopState()
{
CGContextRestoreGState( m_cgContext );
}
-void wxMacCGContext::SetTextColor( const wxColour &col )
+void wxMacCGContext::SetTextColor( const wxColour &col )
{
m_textForegroundColor = col ;
}
if ( stroke )
{
- CGContextSetRGBStrokeColor( m_cgContext , pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 ,
+ CGContextSetRGBStrokeColor( m_cgContext , pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 ,
pen.GetColour().Blue() / 255.0 , pen.GetColour().Alpha() / 255.0 ) ;
// TODO: * m_dc->m_scaleX
CGContextSetStrokeColorSpace( m_cgContext , patternSpace ) ;
wxMacCFRefHolder<CGPatternRef> pattern( *( new HatchPattern( pen.GetStyle() , CGContextGetCTM( m_cgContext ) ) ) );
- CGFloat colorArray[4] = { pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 ,
+ CGFloat colorArray[4] = { pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 ,
pen.GetColour().Blue() / 255.0 , pen.GetColour().Alpha() / 255.0 } ;
CGContextSetStrokePattern( m_cgContext, pattern , colorArray ) ;
{
if ( brush.GetStyle() == wxSOLID )
{
- CGContextSetRGBFillColor( m_cgContext , brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
+ CGContextSetRGBFillColor( m_cgContext , brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 ) ;
}
else if ( brush.IsHatch() )
CGContextSetFillColorSpace( m_cgContext , patternSpace ) ;
wxMacCFRefHolder<CGPatternRef> pattern( *( new HatchPattern( brush.GetStyle() , CGContextGetCTM( m_cgContext ) ) ) );
- CGFloat colorArray[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
+ CGFloat colorArray[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ;
CGContextSetFillPattern( m_cgContext, pattern , colorArray ) ;
}
}
-void wxMacCGContext::DrawText( const wxString &str, wxCoord x, wxCoord y, double angle )
+void wxMacCGContext::DrawText( const wxString &str, wxCoord x, wxCoord y, double angle )
{
OSStatus status = noErr ;
ATSUTextLayout atsuLayout ;
free( ubuf ) ;
#endif
}
-
+
void wxMacCGContext::GetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
wxCoord *descent, wxCoord *externalLeading ) const
{
wxCHECK_RET( m_macATSUIStyle != NULL, wxT("wxDC(cg)::DoGetTextExtent - no valid font set") ) ;
OSStatus status = noErr ;
-
+
ATSUTextLayout atsuLayout ;
UniCharCount chars = str.length() ;
UniChar* ubuf = NULL ;
::ATSUDisposeTextLayout(atsuLayout);
}
-void wxMacCGContext::GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
+void wxMacCGContext::GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
{
widths.Empty();
widths.Add(0, text.length());
::ATSUDisposeTextLayout(atsuLayout);
}
-void wxMacCGContext::SetFont( const wxFont &font )
+void wxMacCGContext::SetFont( const wxFont &font )
{
if ( m_macATSUIStyle )
{
{
if ( m_pen == pen )
return ;
-
+
m_pen = pen;
if ( m_graphicContext )
{
}
bool fill = m_brush.GetStyle() != wxTRANSPARENT ;
-
+
wxGraphicPath* path = m_graphicContext->CreatePath() ;
m_graphicContext->PushState() ;
m_graphicContext->Translate( xxc, yyc ) ;
penwidth = 1 ;
if ( m_pen.GetStyle() == wxTRANSPARENT )
penwidth = 0 ;
-
- bool offset = ( penwidth % 2 ) == 1 ;
+
+ bool offset = ( penwidth % 2 ) == 1 ;
wxGraphicPath* path = m_graphicContext->CreatePath() ;
// if we are offsetting the entire rectangle is moved 0.5, so the border line gets off by 1
path->AddRectangle( xx , yy , ww-1 , hh-1 ) ;
else
path->AddRectangle( xx , yy , ww , hh ) ;
-
+
m_graphicContext->DrawPath( path ) ;
delete path ;
}
hh = -hh;
yy = yy - hh;
}
-
+
wxGraphicPath* path = m_graphicContext->CreatePath() ;
m_graphicContext->PushState() ;
m_graphicContext->Translate(xx + ww / 2, yy + hh / 2);
else
{
wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts, and only with wxCOPY logical operation.") ) ;
- return false ;
+ return false ;
}
return true;
}
wxCoord h , d , e , w ;
-
+
m_graphicContext->GetTextExtent( str, &w, &h, &d, &e ) ;
if ( height )
*/ // TODO
wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
{
- long new_x = x - m_deviceOriginX;
- if (new_x > 0)
- return (wxCoord)((double)new_x / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
- else
- return (wxCoord)((double)new_x / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
+ return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
{
- long new_y = y - m_deviceOriginY;
- if (new_y > 0)
- return (wxCoord)((double)new_y / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
- else
- return (wxCoord)((double)new_y / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
+ return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
{
- if (x > 0)
- return (wxCoord)((double)x / m_scaleX + 0.5);
- else
- return (wxCoord)((double)x / m_scaleX - 0.5);
+ return wxRound((double)(x) / m_scaleX);
}
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
{
- if (y > 0)
- return (wxCoord)((double)y / m_scaleY + 0.5);
- else
- return (wxCoord)((double)y / m_scaleY - 0.5);
+ return wxRound((double)(y) / m_scaleY);
}
wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
{
- long new_x = x - m_logicalOriginX;
- if (new_x > 0)
- return (wxCoord)((double)new_x * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
- else
- return (wxCoord)((double)new_x * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
+ return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
{
- long new_y = y - m_logicalOriginY;
- if (new_y > 0)
- return (wxCoord)((double)new_y * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
- else
- return (wxCoord)((double)new_y * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
+ return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
{
- if (x > 0)
- return (wxCoord)((double)x * m_scaleX + 0.5);
- else
- return (wxCoord)((double)x * m_scaleX - 0.5);
+ return wxRound((double)(x) * m_scaleX);
}
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
{
- if (y > 0)
- return (wxCoord)((double)y * m_scaleY + 0.5);
- else
- return (wxCoord)((double)y * m_scaleY - 0.5);
+ return wxRound((double)(y) * m_scaleY);
}
#endif // wxMAC_USE_CORE_GRAPHICS