X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ebbb5cb2666272ef839506f101f9f914df2312c2..4913272f9cdead94a6d1470e51d6fb14946b50e0:/src/mac/carbon/dccg.cpp diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp index f90a2864dc..364809af1b 100755 --- a/src/mac/carbon/dccg.cpp +++ b/src/mac/carbon/dccg.cpp @@ -393,14 +393,24 @@ void wxMacCGContext::Scale( wxCoord xScale , wxCoord yScale ) void wxMacCGContext::DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) { CGImageRef image = (CGImageRef)( bmp.CGImageCreate() ) ; - HIRect r = CGRectMake( x , y , w , h ) ; - HIViewDrawCGImage( m_cgContext , &r , image ) ; + HIRect r = CGRectMake( 0 , 0 , w , h ); + + CGContextSaveGState( m_cgContext ); + CGContextTranslateCTM( m_cgContext, x , y + h ); + CGContextScaleCTM( m_cgContext, 1, -1 ); + + // in case image is a mask, set the foreground color + CGContextSetRGBFillColor( m_cgContext , m_textForegroundColor.Red() / 255.0 , m_textForegroundColor.Green() / 255.0 , + m_textForegroundColor.Blue() / 255.0 , m_textForegroundColor.Alpha() / 255.0 ) ; + CGContextDrawImage( m_cgContext, r, image ); + CGContextRestoreGState( m_cgContext ); + CGImageRelease( image ) ; } void wxMacCGContext::DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) { - CGRect r = CGRectMake( 00 , 00 , w , h ) ; + CGRect r = CGRectMake( 0 , 0 , w , h ) ; CGContextSaveGState( m_cgContext ); CGContextTranslateCTM( m_cgContext, x , y + h ); CGContextScaleCTM( m_cgContext, 1, -1 ); @@ -1209,7 +1219,18 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask wxCoord ww = XLOG2DEVREL(w); wxCoord hh = YLOG2DEVREL(h); - m_graphicContext->DrawBitmap( bmp, xx , yy , ww , hh ) ; + if ( bmp.GetDepth()==1 ) + { + wxGraphicPath* path = m_graphicContext->CreatePath() ; + path->AddRectangle( xx , yy , ww , hh ) ; + m_graphicContext->FillPath( path , m_textBackgroundColour, wxODDEVEN_RULE) ; + delete path; + m_graphicContext->DrawBitmap( bmp, xx , yy , ww , hh ) ; + } + else + { + m_graphicContext->DrawBitmap( bmp, xx , yy , ww , hh ) ; + } } void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) @@ -1349,7 +1370,9 @@ void wxDC::SetTextForeground( const wxColour &col ) if ( col != m_textForegroundColour ) { m_textForegroundColour = col; - m_graphicContext->SetTextColor( col ) ; + m_graphicContext->SetTextColor( col ); + // in the current implementation the font contains the text color + m_graphicContext->SetFont(m_font); } } @@ -1887,8 +1910,21 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) yy = yy - hh; } + int penwidth = m_pen.GetWidth(); + if ( penwidth == 0 ) + penwidth = 1 ; + if ( m_pen.GetStyle() == wxTRANSPARENT ) + penwidth = 0 ; + + bool offset = ( penwidth % 2 ) == 1 ; + wxGraphicPath* path = m_graphicContext->CreatePath() ; - path->AddRectangle( xx , yy , ww , hh ) ; + // if we are offsetting the entire rectangle is moved 0.5, so the border line gets off by 1 + if ( offset ) + path->AddRectangle( xx , yy , ww-1 , hh-1 ) ; + else + path->AddRectangle( xx , yy , ww , hh ) ; + m_graphicContext->DrawPath( path ) ; delete path ; } @@ -1933,19 +1969,13 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, } else { - m_graphicContext->PushState() ; - m_graphicContext->Translate( xx , yy ) ; - m_graphicContext->Scale( radius , radius ) ; - double fw = ww / radius ; - double fh = hh / radius; - path->MoveToPoint(fw, fh / 2); - path->AddArcToPoint(fw, fh, fw / 2, fh, 1); - path->AddArcToPoint(0, fh, 0, fh / 2, 1); - path->AddArcToPoint(0, 0, fw / 2, 0, 1); - path->AddArcToPoint(fw, 0, fw, fh / 2, 1); + path->MoveToPoint( xx + ww, yy + hh / 2); + path->AddArcToPoint(xx + ww, yy + hh, xx + ww / 2,yy + hh, radius); + path->AddArcToPoint(xx , yy + hh, xx , yy + hh / 2, radius); + path->AddArcToPoint(xx , yy , xx + ww / 2, yy , radius); + path->AddArcToPoint(xx + ww, yy , xx + ww, yy + hh / 2, radius); path->CloseSubpath(); m_graphicContext->DrawPath( path ) ; - m_graphicContext->PopState() ; } delete path ; }