X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/670f9935630beb2123a5ca62894ae92a3f0efa4f..2cbd98abc221cab46a54582c37a77f338b44f6b7:/src/mac/carbon/dccg.cpp diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp index 2378561aa3..9a6cd4390d 100755 --- a/src/mac/carbon/dccg.cpp +++ b/src/mac/carbon/dccg.cpp @@ -18,13 +18,13 @@ #ifndef WX_PRECOMP #include "wx/log.h" #include "wx/app.h" + #include "wx/dcmemory.h" + #include "wx/dcprint.h" + #include "wx/region.h" + #include "wx/image.h" #endif #include "wx/mac/uma.h" -#include "wx/dcmemory.h" -#include "wx/dcprint.h" -#include "wx/region.h" -#include "wx/image.h" #ifdef __MSL__ @@ -44,6 +44,10 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0 #endif +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 +typedef float CGFloat ; +#endif + //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- @@ -396,7 +400,7 @@ protected : m_image = image ; if ( m_image ) { - m_imageBounds = CGRectMake( 0.0, 0.0, (float)CGImageGetWidth( m_image ), (float)CGImageGetHeight( m_image ) ) ; + m_imageBounds = CGRectMake( 0.0, 0.0, (CGFloat)CGImageGetWidth( m_image ), (CGFloat)CGImageGetHeight( m_image ) ) ; m_patternRef = CGPatternCreate( this , m_imageBounds, transform , m_imageBounds.size.width, m_imageBounds.size.height, @@ -404,7 +408,7 @@ protected : } } - ~ImagePattern() + virtual ~ImagePattern() { if ( m_image ) CGImageRelease( m_image ) ; @@ -519,7 +523,7 @@ public : } protected : - ~HatchPattern() {} + virtual ~HatchPattern() {} CGRect m_imageBounds ; int m_hatch ; @@ -548,11 +552,11 @@ void wxMacCGContext::SetPen( const wxPen &pen ) if ( stroke ) { - RGBColor col = MAC_WXCOLORREF( pen.GetColour().GetPixel() ) ; - CGContextSetRGBStrokeColor( m_cgContext , col.red / 65536.0 , col.green / 65536.0 , col.blue / 65536.0 , 1.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 - float penWidth = pen.GetWidth(); + CGFloat penWidth = pen.GetWidth(); if (penWidth <= 0.0) penWidth = 0.1; CGContextSetLineWidth( m_cgContext , penWidth ) ; @@ -600,15 +604,15 @@ void wxMacCGContext::SetPen( const wxPen &pen ) m_mode = kCGPathStroke ; int count = 0 ; - const float *lengths = NULL ; - float *userLengths = NULL ; + const CGFloat *lengths = NULL ; + CGFloat *userLengths = NULL ; - const float dashUnit = penWidth < 1.0 ? 1.0 : penWidth; + const CGFloat dashUnit = penWidth < 1.0 ? 1.0 : penWidth; - const float dotted[] = { dashUnit , dashUnit + 2.0 }; - const float short_dashed[] = { 9.0 , 6.0 }; - const float dashed[] = { 19.0 , 9.0 }; - const float dotted_dashed[] = { 9.0 , 6.0 , 3.0 , 3.0 }; + const CGFloat dotted[] = { dashUnit , dashUnit + 2.0 }; + const CGFloat short_dashed[] = { 9.0 , 6.0 }; + const CGFloat dashed[] = { 19.0 , 9.0 }; + const CGFloat dotted_dashed[] = { 9.0 , 6.0 , 3.0 , 3.0 }; switch ( pen.GetStyle() ) { @@ -640,7 +644,7 @@ void wxMacCGContext::SetPen( const wxPen &pen ) count = pen.GetDashes( &dashes ) ; if ((dashes != NULL) && (count > 0)) { - userLengths = new float[count] ; + userLengths = new CGFloat[count] ; for ( int i = 0 ; i < count ; ++i ) { userLengths[i] = dashes[i] * dashUnit ; @@ -656,7 +660,7 @@ void wxMacCGContext::SetPen( const wxPen &pen ) case wxSTIPPLE : { - float alphaArray[1] = { 1.0 } ; + CGFloat alphaArray[1] = { 1.0 } ; wxBitmap* bmp = pen.GetStipple() ; if ( bmp && bmp->Ok() ) { @@ -674,8 +678,8 @@ void wxMacCGContext::SetPen( const wxPen &pen ) CGContextSetStrokeColorSpace( m_cgContext , patternSpace ) ; wxMacCFRefHolder pattern( *( new HatchPattern( pen.GetStyle() , CGContextGetCTM( m_cgContext ) ) ) ); - RGBColor col = MAC_WXCOLORREF( pen.GetColour().GetPixel() ) ; - float colorArray[4] = { col.red / 65536.0 , col.green / 65536.0 , col.blue / 65536.0 , 1.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 ) ; } @@ -727,8 +731,8 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) { if ( brush.GetStyle() == wxSOLID ) { - RGBColor col = MAC_WXCOLORREF( brush.GetColour().GetPixel() ) ; - CGContextSetRGBFillColor( m_cgContext , col.red / 65536.0 , col.green / 65536.0 , col.blue / 65536.0 , 1.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() ) { @@ -736,15 +740,15 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) CGContextSetFillColorSpace( m_cgContext , patternSpace ) ; wxMacCFRefHolder pattern( *( new HatchPattern( brush.GetStyle() , CGContextGetCTM( m_cgContext ) ) ) ); - RGBColor col = MAC_WXCOLORREF( brush.GetColour().GetPixel() ) ; - float colorArray[4] = { col.red / 65536.0 , col.green / 65536.0 , col.blue / 65536.0 , 1.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 ) ; } else { // now brush is a bitmap - float alphaArray[1] = { 1.0 } ; + CGFloat alphaArray[1] = { 1.0 } ; wxBitmap* bmp = brush.GetStipple() ; if ( bmp && bmp->Ok() ) { @@ -765,7 +769,7 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) } } -void AddEllipticArcToPath(CGContextRef c, CGPoint center, float a, float b, float fromDegree , float toDegree ) +void AddEllipticArcToPath(CGContextRef c, CGPoint center, CGFloat a, CGFloat b, CGFloat fromDegree , CGFloat toDegree ) { CGContextSaveGState(c); CGContextTranslateCTM(c, center.x, center.y); @@ -776,10 +780,10 @@ void AddEllipticArcToPath(CGContextRef c, CGPoint center, float a, float b, floa CGContextRestoreGState(c); } -void AddRoundedRectToPath(CGContextRef c, CGRect rect, float ovalWidth, - float ovalHeight) +void AddRoundedRectToPath(CGContextRef c, CGRect rect, CGFloat ovalWidth, + CGFloat ovalHeight) { - float fw, fh; + CGFloat fw, fh; if (ovalWidth == 0 || ovalHeight == 0) { CGContextAddRect(c, rect); @@ -1453,8 +1457,8 @@ void wxDC::DoDrawSpline(wxList *points) wxCoord cx1 = ( x1 + x2 ) / 2; wxCoord cy1 = ( y1 + y2 ) / 2; - path->MoveToPoint( XLOG2DEVMAC( x1 ) , XLOG2DEVMAC( y1 ) ) ; - path->AddLineToPoint( XLOG2DEVMAC( cx1 ) , XLOG2DEVMAC( cy1 ) ) ; + path->MoveToPoint( XLOG2DEVMAC( x1 ) , YLOG2DEVMAC( y1 ) ) ; + path->AddLineToPoint( XLOG2DEVMAC( cx1 ) , YLOG2DEVMAC( cy1 ) ) ; #if !wxUSE_STL while ((node = node->GetNext()) != NULL) @@ -1471,14 +1475,14 @@ void wxDC::DoDrawSpline(wxList *points) wxCoord cy4 = (y1 + y2) / 2; path->AddQuadCurveToPoint( - XLOG2DEVMAC( x1 ) , XLOG2DEVMAC( y1 ) , - XLOG2DEVMAC( cx4 ) , XLOG2DEVMAC( cy4 ) ) ; + XLOG2DEVMAC( x1 ) , YLOG2DEVMAC( y1 ) , + XLOG2DEVMAC( cx4 ) , YLOG2DEVMAC( cy4 ) ) ; cx1 = cx4; cy1 = cy4; } - path->AddLineToPoint( XLOG2DEVMAC( x2 ) , XLOG2DEVMAC( y2 ) ) ; + path->AddLineToPoint( XLOG2DEVMAC( x2 ) , YLOG2DEVMAC( y2 ) ) ; m_graphicContext->StrokePath( path ) ; delete path ; @@ -2056,8 +2060,8 @@ void wxDC::Clear(void) { RGBColor color; GetThemeBrushAsColor( m_backgroundBrush.MacGetTheme(), 32, true, &color ); - CGContextSetRGBFillColor( cg, (float) color.red / 65536, - (float) color.green / 65536, (float) color.blue / 65536, 1 ); + CGContextSetRGBFillColor( cg, (CGFloat) color.red / 65536, + (CGFloat) color.green / 65536, (CGFloat) color.blue / 65536, 1 ); CGContextFillRect( cg, rect ); }