From 29d56b63f7b246fed3556bc7df0656e38faebd39 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 16 Jan 2013 11:48:23 -0800 Subject: [PATCH] Fixed bug about border in CPBox lineBorder --- AppKit/CPBox.j | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/AppKit/CPBox.j b/AppKit/CPBox.j index 5c2d906e3..60e08ed42 100644 --- a/AppKit/CPBox.j +++ b/AppKit/CPBox.j @@ -492,16 +492,22 @@ CPBelowBottom = 6; - (void)_drawLineBorderInRect:(CGRect)aRect { var context = [[CPGraphicsContext currentContext] graphicsPort], - sides = [CPMinYEdge, CPMaxXEdge, CPMaxYEdge, CPMinXEdge], - sideGray = 190.0 / 255.0, - grays = [142.0 / 255.0, sideGray, sideGray, sideGray], + cornerRadius = [self cornerRadius], borderWidth = [self borderWidth]; - while (borderWidth--) - aRect = CPDrawTiledRects(aRect, aRect, sides, grays); + aRect = CGRectInset(aRect, borderWidth / 2.0, borderWidth / 2.0); + + // clip the canvas to the actual content view in order to only display inner shadow + CGContextBeginPath(context); + CGContextAddPath(context, CGPathWithRoundedRectangleInRect(aRect, cornerRadius, cornerRadius, YES, YES, YES, YES)); + CGContextClip(context); CGContextSetFillColor(context, [self fillColor]); - CGContextFillRect(context, aRect); + CGContextSetStrokeColor(context, [self borderColor]); + + CGContextSetLineWidth(context, borderWidth); + CGContextFillRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES); + CGContextStrokeRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES); } - (void)_drawBezelBorderInRect:(CGRect)aRect