/////////////////////////////////////////////////////////////////////////////
-// 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"
#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__
#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
//-----------------------------------------------------------------------------
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,
}
}
- ~ImagePattern()
+ virtual ~ImagePattern()
{
if ( m_image )
CGImageRelease( m_image ) ;
}
protected :
- ~HatchPattern() {}
+ virtual ~HatchPattern() {}
CGRect m_imageBounds ;
int m_hatch ;
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 ) ;
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() )
{
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 ;
case wxSTIPPLE :
{
- float alphaArray[1] = { 1.0 } ;
+ CGFloat alphaArray[1] = { 1.0 } ;
wxBitmap* bmp = pen.GetStipple() ;
if ( bmp && bmp->Ok() )
{
CGContextSetStrokeColorSpace( m_cgContext , patternSpace ) ;
wxMacCFRefHolder<CGPatternRef> 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 ) ;
}
{
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() )
{
CGContextSetFillColorSpace( m_cgContext , patternSpace ) ;
wxMacCFRefHolder<CGPatternRef> 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() )
{
}
}
-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);
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);
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)
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 ;
wxMacCGContext* mctx = ((wxMacCGContext*) m_graphicContext) ;
CGContextRef ctx = mctx->GetNativeContext() ;
- AddRoundedRectToPath( ctx , CGRectMake( xx , yy , ww , hh ) , 16 ,16 ) ;
+ AddRoundedRectToPath( ctx , CGRectMake( xx , yy , ww , hh ) , radius , radius ) ;
CGContextDrawPath( ctx , mctx->GetDrawingMode() ) ;
}
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
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
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
{
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 );
}
}
#endif // wxMAC_USE_CORE_GRAPHICS
-