X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82f88f03bae560f77dbdb8b5551c7b9d3729176f..a8b2285edf2eb1ef1dd1cb19abf130a871821dbf:/src/mac/carbon/graphics.cpp diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index b382c4b81b..0a22635202 100755 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -37,6 +37,13 @@ #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 @@ -161,7 +168,7 @@ public : 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 ); } @@ -457,7 +464,12 @@ void wxMacCoreGraphicsPenData::Apply( wxGraphicsContext* context ) } 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 ); } } @@ -742,6 +754,10 @@ public : 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(); @@ -813,6 +829,18 @@ void wxMacCoreGraphicsMatrixData::Set(wxDouble a, wxDouble b, wxDouble c, wxDoub 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() { @@ -1133,6 +1161,7 @@ public: virtual void * GetNativeContext(); + bool SetLogicalFunction( int function ); // // transformation // @@ -1168,7 +1197,7 @@ public: virtual void DrawPath( const wxGraphicsPath &path, int fillStyle = wxODDEVEN_RULE ); virtual bool ShouldOffset() const - { + { int penwidth = 0 ; if ( !m_pen.IsNull() ) { @@ -1310,6 +1339,43 @@ void wxMacCoreGraphicsContext::EnsureIsValid() } } +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 ) { @@ -1770,6 +1836,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid *width = FixedToInt(textAfter - textBefore); ::ATSUDisposeTextLayout(atsuLayout); +#if SIZEOF_WCHAR_T == 4 + free( ubuf ) ; +#endif } void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const @@ -1828,6 +1897,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr } ::ATSUDisposeTextLayout(atsuLayout); +#if SIZEOF_WCHAR_T == 4 + free( ubuf ) ; +#endif } void * wxMacCoreGraphicsContext::GetNativeContext()