#ifndef WX_PRECOMP
#include "wx/dcclient.h"
+ #include "wx/dcmemory.h"
#include "wx/log.h"
#include "wx/region.h"
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
typedef float CGFloat;
#endif
+#ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 1
+#else
+ #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
+#endif
+#endif
//-----------------------------------------------------------------------------
// constants
void StrokeLineSegments( CGContextRef ctxRef , const CGPoint pts[] , size_t count )
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- if ( UMAGetSystemVersion() >= 0x1040 )
+ if ( CGContextStrokeLineSegments!=NULL )
{
CGContextStrokeLineSegments( ctxRef , pts , count );
}
}
else
{
- CGContextSetStrokeColorWithColor( cg , m_color );
+ if ( context->GetLogicalFunction() == wxINVERT || context->GetLogicalFunction() == wxXOR )
+ {
+ CGContextSetRGBStrokeColor( cg , 1.0, 1.0 , 1.0, 1.0 );
+ }
+ else
+ CGContextSetStrokeColorWithColor( cg , m_color );
}
}
if ( brush.GetStyle() == wxSOLID )
{
- float components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
+ if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ if ( HIThemeBrushCreateCGColor != 0 )
+ {
+ CGColorRef color ;
+ HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
+ m_color.Set( color ) ;
+ }
+ else
+#endif
+ {
+ // as close as we can get, unfortunately < 10.4 things get difficult
+ RGBColor color;
+ GetThemeBrushAsColor( brush.MacGetTheme(), 32, true, &color );
+ float components[4] = { (CGFloat) color.red / 65536,
+ (CGFloat) color.green / 65536, (CGFloat) color.blue / 65536, 1 } ;
+ m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
+ }
+ }
+ else
+ {
+ float components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ;
- m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
+ m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
+ }
}
else if ( brush.IsHatch() )
{
virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
wxDouble tx=0.0, wxDouble ty=0.0);
+ // gets the component valuess of the matrix
+ virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL,
+ wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const;
+
// makes this the inverse matrix
virtual void Invert();
m_matrix = CGAffineTransformMake(a,b,c,d,tx,ty);
}
+// gets the component valuess of the matrix
+void wxMacCoreGraphicsMatrixData::Get(wxDouble* a, wxDouble* b, wxDouble* c,
+ wxDouble* d, wxDouble* tx, wxDouble* ty) const
+{
+ if (a) *a = m_matrix.a;
+ if (b) *b = m_matrix.b;
+ if (c) *c = m_matrix.c;
+ if (d) *d = m_matrix.d;
+ if (tx) *tx= m_matrix.tx;
+ if (ty) *ty= m_matrix.ty;
+}
+
// makes this the inverse matrix
void wxMacCoreGraphicsMatrixData::Invert()
{
virtual void * GetNativeContext();
+ bool SetLogicalFunction( int function );
//
// transformation
//
virtual void DrawPath( const wxGraphicsPath &path, int fillStyle = wxODDEVEN_RULE );
virtual bool ShouldOffset() const
- {
+ {
int penwidth = 0 ;
if ( !m_pen.IsNull() )
{
}
}
+bool wxMacCoreGraphicsContext::SetLogicalFunction( int function )
+{
+ if (m_logicalFunction == function)
+ return true;
+
+ EnsureIsValid();
+
+ bool retval = false;
+
+ if ( function == wxCOPY )
+ {
+ retval = true;
+#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
+ if ( CGContextSetBlendMode != NULL )
+ {
+ CGContextSetBlendMode( m_cgContext, kCGBlendModeNormal );
+ CGContextSetShouldAntialias( m_cgContext, true );
+ }
+#endif
+ }
+ else if ( function == wxINVERT || function == wxXOR )
+ {
+#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
+ if ( CGContextSetBlendMode != NULL )
+ {
+ // change color to white
+ CGContextSetBlendMode( m_cgContext, kCGBlendModeExclusion );
+ CGContextSetShouldAntialias( m_cgContext, false );
+ retval = true;
+ }
+#endif
+ }
+
+ if (retval)
+ m_logicalFunction = function;
+ return retval ;
+}
void wxMacCoreGraphicsContext::Clip( const wxRegion ®ion )
{
*width = FixedToInt(textAfter - textBefore);
::ATSUDisposeTextLayout(atsuLayout);
+#if SIZEOF_WCHAR_T == 4
+ free( ubuf ) ;
+#endif
}
void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const
}
::ATSUDisposeTextLayout(atsuLayout);
+#if SIZEOF_WCHAR_T == 4
+ free( ubuf ) ;
+#endif
}
void * wxMacCoreGraphicsContext::GetNativeContext()
wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc)
{
- return new wxMacCoreGraphicsContext(this,(CGContextRef)dc.GetWindow()->MacGetCGContextRef() );
+ wxMemoryDC* mdc = wxDynamicCast(&dc, wxMemoryDC);
+ if ( mdc )
+ {
+ return new wxMacCoreGraphicsContext(this,
+ (CGContextRef)mdc->GetGraphicsContext()->GetNativeContext());
+ }
+ else
+ {
+ return new wxMacCoreGraphicsContext(this,(CGContextRef)dc.GetWindow()->MacGetCGContextRef() );
+ }
}
wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContextFromNativeContext( void * context )