IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+#ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
+#define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
+#endif
+
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
extern TECObjectRef s_TECNativeCToUnicode ;
-// TODO Update
+// TODO: update
// The textctrl implementation still needs that (needs what?) for the non-HIView implementation
//
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
if ( win->GetPeer() )
{
int x = 0 , y = 0;
- win->MacWindowToRootWindow( &x,&y ) ;
+ win->MacWindowToRootWindow( &x, &y ) ;
// get area including focus rect
CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ;
if ( !EmptyRgn( m_newClip ) )
const float dashUnit = penWidth < 1.0 ? 1.0 : penWidth;
- const float dotted[] = { dashUnit , dashUnit + 2.0 };
+ 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 };
if ((dashes != NULL) && (count > 0))
{
userLengths = new float[count] ;
- for( int i = 0 ; i < count ; ++i )
+ for ( int i = 0 ; i < count ; ++i )
{
userLengths[i] = dashes[i] * dashUnit ;
CGContextSaveGState(c);
CGContextTranslateCTM(c, CGRectGetMinX(rect), CGRectGetMinY(rect));
CGContextScaleCTM(c, ovalWidth, ovalHeight);
+
fw = CGRectGetWidth(rect) / ovalWidth;
fh = CGRectGetHeight(rect) / ovalHeight;
- CGContextMoveToPoint(c, fw, fh/2);
- CGContextAddArcToPoint(c, fw, fh, fw/2, fh, 1);
- CGContextAddArcToPoint(c, 0, fh, 0, fh/2, 1);
- CGContextAddArcToPoint(c, 0, 0, fw/2, 0, 1);
- CGContextAddArcToPoint(c, fw, 0, fw, fh/2, 1);
+
+ CGContextMoveToPoint(c, fw, fh / 2);
+ CGContextAddArcToPoint(c, fw, fh, fw / 2, fh, 1);
+ CGContextAddArcToPoint(c, 0, fh, 0, fh / 2, 1);
+ CGContextAddArcToPoint(c, 0, 0, fw / 2, 0, 1);
+ CGContextAddArcToPoint(c, fw, 0, fw, fh / 2, 1);
CGContextClosePath(c);
CGContextRestoreGState(c);
}
+#pragma mark -
+
wxDC::wxDC()
{
- m_ok = false;
+ m_ok = false ;
m_colour = true;
m_mm_to_pix_x = mm2pt;
m_mm_to_pix_y = mm2pt;
m_userScaleY = 1.0;
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_needComputeScaleX = false;
+ m_needComputeScaleX =
m_needComputeScaleY = false;
- m_ok = false ;
m_macPort = 0 ;
- m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ;
+ m_macLocalOrigin.x =
+ m_macLocalOrigin.y = 0 ;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
// we have to update the context as well
}
-void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
+void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
{
wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoSetClippingRegionAsRegion - invalid DC") );
return;
m_logicalFunction = function ;
+#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
+ CGContextRef cgContext = ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ;
+ if ( m_logicalFunction == wxCOPY )
+ CGContextSetBlendMode( cgContext, kCGBlendModeNormal ) ;
+ else if ( m_logicalFunction == wxINVERT )
+ CGContextSetBlendMode( cgContext, kCGBlendModeExclusion ) ;
+ else
+ CGContextSetBlendMode( cgContext, kCGBlendModeNormal ) ;
+#endif
}
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
{
wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoDrawLine - invalid DC") );
+#if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
if ( m_logicalFunction != wxCOPY )
return ;
+#endif
wxCoord xx1 = XLOG2DEVMAC(x1) ;
wxCoord yy1 = YLOG2DEVMAC(y1) ;
CGContextScaleCTM( ctx , 1 , -1 ) ;
if ( fill )
CGContextMoveToPoint( ctx , 0 , 0 ) ;
- CGContextAddArc( ctx, 0, 0 , rad , DegToRad(sa), DegToRad(ea), 0);
+ CGContextAddArc( ctx, 0, 0 , rad , DegToRad(sa), DegToRad(ea), 0 );
if ( fill )
CGContextAddLineToPoint( ctx , 0 , 0 ) ;
CGContextRestoreGState( ctx ) ;
CGContextRef ctx = mctx->GetNativeContext() ;
CGContextSaveGState( ctx ) ;
- CGContextTranslateCTM( ctx, xx + ww / 2, yy + hh / 2);
+ CGContextTranslateCTM( ctx, xx + ww / 2, yy + hh / 2 );
CGContextScaleCTM( ctx , 1 * ww / 2 , -1 * hh / 2 ) ;
if ( fill )
CGContextMoveToPoint( ctx , 0 , 0 ) ;
- CGContextAddArc( ctx, 0, 0, 1, DegToRad(sa), DegToRad(ea), 0);
+ CGContextAddArc( ctx, 0, 0, 1, DegToRad(sa), DegToRad(ea), 0 );
if ( fill )
CGContextAddLineToPoint( ctx , 0 , 0 ) ;
CGContextRestoreGState( ctx ) ;
{
wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoDrawLines - invalid DC") );
+#if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
if ( m_logicalFunction != wxCOPY )
return ;
+#endif
wxCoord x1, x2 , y1 , y2 ;
x1 = XLOG2DEVMAC(points[0].x + xoffset);
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 ) , 16 ,16 ) ;
CGContextDrawPath( ctx , mctx->GetDrawingMode() ) ;
}
wxMacCGContext* mctx = ((wxMacCGContext*) m_graphicContext) ;
CGContextRef ctx = mctx->GetNativeContext() ;
CGContextSaveGState( ctx ) ;
- CGContextTranslateCTM( ctx, xx + ww / 2, yy + hh / 2);
+ CGContextTranslateCTM( ctx, xx + ww / 2, yy + hh / 2 );
CGContextScaleCTM( ctx , ww / 2 , hh / 2 ) ;
- CGContextAddArc( ctx, 0, 0, 1, 0 , 2 * M_PI , 0);
+ CGContextAddArc( ctx, 0, 0, 1, 0 , 2 * M_PI , 0 );
CGContextRestoreGState( ctx ) ;
CGContextDrawPath( ctx , mctx->GetDrawingMode() ) ;
}
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask,
- wxCoord xsrcMask, wxCoord ysrcMask )
+ wxCoord xsrcMask, wxCoord ysrcMask )
{
wxCHECK_MSG( Ok(), false, wxT("wxDC(cg)::DoBlit - invalid DC") );
wxCHECK_MSG( source->Ok(), false, wxT("wxDC(cg)::DoBlit - invalid source DC") );
}
wxCoord yysrc = source->YLOG2DEVMAC(ysrc) ;
- wxCoord xxsrc = source->XLOG2DEVMAC(xsrc) ;
- wxCoord wwsrc = source->XLOG2DEVREL(width ) ;
+ wxCoord xxsrc = source->XLOG2DEVMAC(xsrc) ;
+ wxCoord wwsrc = source->XLOG2DEVREL(width) ;
wxCoord hhsrc = source->YLOG2DEVREL(height) ;
wxCoord yydest = YLOG2DEVMAC(ydest) ;
wxCoord xxdest = XLOG2DEVMAC(xdest) ;
- wxCoord wwdest = XLOG2DEVREL(width ) ;
+ wxCoord wwdest = XLOG2DEVREL(width) ;
wxCoord hhdest = YLOG2DEVREL(height) ;
wxMemoryDC* memdc = dynamic_cast<wxMemoryDC*>(source) ;
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
Rect rect ;
-
+
if ( m_backgroundMode == wxSOLID )
{
wxGraphicPath* path = m_graphicContext->CreatePath() ;
converter.WC2MB( (char*) ubuf , text.wc_str(), unicharlen + 2 ) ;
#else
const wxWCharBuffer wchar = text.wc_str( wxConvLocal ) ;
- size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ;
+ size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ;
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ;
#endif
wxCHECK_RET( Ok(), wxT("wxDC(cg)::Clear - invalid DC") );
if (m_backgroundBrush.Ok() && m_backgroundBrush.GetStyle() != wxTRANSPARENT)
- {
+ {
HIRect rect = CGRectMake( -10000 , -10000 , 20000 , 20000 ) ;
CGContextRef cg = ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ;
switch ( m_backgroundBrush.MacGetBrushKind() )
HIThemeBackgroundDrawInfo drawInfo ;
drawInfo.version = 0 ;
drawInfo.state = kThemeStateActive ;
- drawInfo.kind = m_backgroundBrush.MacGetThemeBackground(NULL) ;
+ drawInfo.kind = m_backgroundBrush.MacGetThemeBackground( NULL ) ;
if ( drawInfo.kind == kThemeBackgroundMetal )
- HIThemeDrawBackground( &rect , &drawInfo, cg ,
- kHIThemeOrientationNormal) ;
- HIThemeApplyBackground( &rect , &drawInfo, cg ,
- kHIThemeOrientationNormal) ;
+ {
+ HIThemeDrawBackground( &rect, &drawInfo, cg, kHIThemeOrientationNormal ) ;
+ HIThemeApplyBackground( &rect, &drawInfo, cg, kHIThemeOrientationNormal ) ;
+ }
}
#endif
}
case kwxMacBrushColour :
{
+ // FIXME: doesn't correctly render stippled brushes !!
+ // FIXME: should this be replaced by ::SetBrush() ??
+
RGBColor col = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ;
CGContextSetRGBFillColor( cg , col.red / 65536.0 , col.green / 65536.0 , col.blue / 65536.0 , 1.0 ) ;
CGContextFillRect(cg, rect);
if ( m_font.Ok() )
{
- OSStatus status = noErr ;
+ OSStatus status ;
+
status = ATSUCreateAndCopyStyle( (ATSUStyle) m_font.MacGetATSUStyle() , (ATSUStyle*) &m_macATSUIStyle ) ;
- wxASSERT_MSG( status == noErr, wxT("couldn't set create ATSU style") ) ;
+ wxASSERT_MSG( status == noErr, wxT("couldn't create ATSU style") ) ;
Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.MacGetFontSize()) ) ;
RGBColor atsuColor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ;
sizeof( Fixed ) ,
sizeof( RGBColor ) ,
} ;
- // Boolean kTrue = true ;
- // Boolean kFalse = false ;
- // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
{
&atsuSize ,
&atsuColor ,
} ;
- status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) ,
+ status = ::ATSUSetAttributes(
+ (ATSUStyle)m_macATSUIStyle, sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
atsuTags, atsuSizes, atsuValues);
- wxASSERT_MSG( status == noErr , wxT("couldn't Modify ATSU style") ) ;
+ wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") ) ;
}
}
+#pragma mark -
+
// ---------------------------------------------------------------------------
// coordinates transformations
// ---------------------------------------------------------------------------