X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2894667fa4e04628bcb3cae98a3dbd9cb80593ea..cda66071f17f062779a7009065e5ff7dd958440b:/src/cocoa/dc.mm?ds=sidebyside diff --git a/src/cocoa/dc.mm b/src/cocoa/dc.mm index b6c71aaca8..b527083297 100644 --- a/src/cocoa/dc.mm +++ b/src/cocoa/dc.mm @@ -65,7 +65,10 @@ wxDC::~wxDC(void) void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,width,height)]; + [m_textForegroundColour.GetNSColor() set]; [bezpath stroke]; + [m_brush.GetNSColor() set]; + [bezpath fill]; } void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) @@ -73,6 +76,8 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) NSBezierPath *bezpath = [NSBezierPath bezierPath]; [bezpath moveToPoint:NSMakePoint(x1,y1)]; [bezpath lineToPoint:NSMakePoint(x2,y2)]; + + [m_textForegroundColour.GetNSColor() set]; [bezpath stroke]; } @@ -88,9 +93,9 @@ void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer]; NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer]; if(x) - *x=usedRect.size.width; + *x=(int)usedRect.size.width; if(y) - *y=usedRect.size.height; + *y=(int)usedRect.size.height; if(descent) *descent=0; if(externalLeading) @@ -107,7 +112,11 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer]; NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer]; - + // NOTE: We'll crash trying to get the location of glyphAtIndex:0 if + // there is no length or we don't start at zero + if(!glyphRange.length) + return; + wxASSERT_MSG(glyphRange.location==0,"glyphRange must begin at zero"); NSAffineTransform *transform = [NSAffineTransform transform]; [transform translateXBy:x yBy:y]; @@ -127,6 +136,7 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) [context saveGraphicsState]; [transform concat]; [flipTransform concat]; + #if 0 // Draw+fill a rectangle so we can see where the shit is supposed to be. wxLogDebug("(%f,%f) (%fx%f)",usedRect.origin.x,usedRect.origin.y,usedRect.size.width,usedRect.size.height); NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,usedRect.size.width,usedRect.size.height)]; @@ -134,12 +144,14 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) [bezpath stroke]; [[NSColor blueColor] set]; [bezpath fill]; + #endif NSPoint layoutLocation = [sm_cocoaNSLayoutManager locationForGlyphAtIndex:0]; layoutLocation.x = 0.0; layoutLocation.y *= -1.0; layoutLocation.y += [[sm_cocoaNSLayoutManager typesetter] baselineOffsetInLayoutManager:sm_cocoaNSLayoutManager glyphIndex:0]; // NOTE: That's NSMakePoint, not NSMakePint (working on that though) + [m_textForegroundColour.GetNSColor() set]; [sm_cocoaNSLayoutManager drawGlyphsForGlyphRange:glyphRange atPoint:layoutLocation]; [context restoreGraphicsState]; @@ -246,6 +258,7 @@ void wxDC::SetPen(const wxPen& pen) void wxDC::SetBrush(const wxBrush& brush) { + m_brush = brush; } void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) @@ -324,8 +337,9 @@ void wxDC::Clear() { } -void wxDC::SetBackground(const wxBrush&) +void wxDC::SetBackground(const wxBrush& brush) { + m_backgroundBrush = brush; } void wxDC::SetPalette(const wxPalette&)