X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9b26622dc12128c13790c608571d5f9bfa2d892a..3dcc2231fabc5c9ea718ae90d13fbc8dd70c3489:/src/mac/carbon/dccg.cpp diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp index 5512b97eac..9a6cd4390d 100755 --- a/src/mac/carbon/dccg.cpp +++ b/src/mac/carbon/dccg.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dc.cpp +// Name: src/mac/carbon/dccg.cpp // Purpose: wxDC class // Author: Stefan Csomor // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -15,13 +15,16 @@ #if wxMAC_USE_CORE_GRAPHICS -#include "wx/app.h" +#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" -#include "wx/log.h" #ifdef __MSL__ @@ -41,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 //----------------------------------------------------------------------------- @@ -393,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, @@ -401,7 +408,7 @@ protected : } } - ~ImagePattern() + virtual ~ImagePattern() { if ( m_image ) CGImageRelease( m_image ) ; @@ -516,7 +523,7 @@ public : } protected : - ~HatchPattern() {} + virtual ~HatchPattern() {} CGRect m_imageBounds ; int m_hatch ; @@ -545,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 ) ; @@ -597,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() ) { @@ -637,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 ; @@ -653,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() ) { @@ -671,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 ) ; } @@ -724,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() ) { @@ -733,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() ) { @@ -762,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); @@ -773,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); @@ -1450,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) @@ -1468,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 ; @@ -1720,14 +1727,14 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoDrawRotatedText - invalid DC") ); wxCHECK_RET( m_macATSUIStyle != NULL, wxT("wxDC(cg)::DoDrawRotatedText - no valid font set") ); - if ( str.Length() == 0 ) + if ( str.length() == 0 ) return ; if ( m_logicalFunction != wxCOPY ) return ; OSStatus status = noErr ; ATSUTextLayout atsuLayout ; - UniCharCount chars = str.Length() ; + UniCharCount chars = str.length() ; UniChar* ubuf = NULL ; #if SIZEOF_WCHAR_T == 4 @@ -1885,14 +1892,14 @@ void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height MacInstallFont() ; } - if ( str.Length() == 0 ) + if ( str.empty() ) return ; wxCHECK_RET( m_macATSUIStyle != NULL, wxT("wxDC(cg)::DoGetTextExtent - no valid font set") ) ; OSStatus status = noErr ; ATSUTextLayout atsuLayout ; - UniCharCount chars = str.Length() ; + UniCharCount chars = str.length() ; UniChar* ubuf = NULL ; #if SIZEOF_WCHAR_T == 4 @@ -1957,13 +1964,13 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con wxCHECK_MSG( Ok(), false, wxT("wxDC(cg)::DoGetPartialTextExtents - invalid DC") ); widths.Empty(); - widths.Add(0, text.Length()); + widths.Add(0, text.length()); - if (text.Length() == 0) + if (text.empty()) return false; ATSUTextLayout atsuLayout ; - UniCharCount chars = text.Length() ; + UniCharCount chars = text.length() ; UniChar* ubuf = NULL ; #if SIZEOF_WCHAR_T == 4 @@ -2053,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 ); } @@ -2198,4 +2205,3 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const } #endif // wxMAC_USE_CORE_GRAPHICS -