From 84f6564cd20d1c429a9f42bcd395e360f96ae500 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Wed, 7 Jan 2009 00:05:54 -0800 Subject: [PATCH] Added CGContextStrokeRoundedRect. Reviewed by me. --- AppKit/CoreGraphics/CGContext.j | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/AppKit/CoreGraphics/CGContext.j b/AppKit/CoreGraphics/CGContext.j index 8a2e0bc36..763899fbb 100644 --- a/AppKit/CoreGraphics/CGContext.j +++ b/AppKit/CoreGraphics/CGContext.j @@ -633,6 +633,52 @@ function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, s CGContextFillPath(aContext); } +function CGContextStrokeRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw) +{ + var xMin = _CGRectGetMinX(aRect), + xMax = _CGRectGetMaxX(aRect), + yMin = _CGRectGetMinY(aRect), + yMax = _CGRectGetMaxY(aRect); + + CGContextBeginPath(aContext); + CGContextMoveToPoint(aContext, xMin + aRadius, yMin); + + if (ne) + { + CGContextAddLineToPoint(aContext, xMax - aRadius, yMin); + CGContextAddCurveToPoint(aContext, xMax - aRadius, yMin, xMax, yMin, xMax, yMin + aRadius); + } + else + CGContextAddLineToPoint(aContext, xMax, yMin); + + if (se) + { + CGContextAddLineToPoint(aContext, xMax, yMax - aRadius); + CGContextAddCurveToPoint(aContext, xMax, yMax - aRadius, xMax, yMax, xMax - aRadius, yMax); + } + else + CGContextAddLineToPoint(aContext, xMax, yMax); + + if (sw) + { + CGContextAddLineToPoint(aContext, xMin + aRadius, yMax); + CGContextAddCurveToPoint(aContext, xMin + aRadius, yMax, xMin, yMax, xMin, yMax - aRadius); + } + else + CGContextAddLineToPoint(aContext, xMin, yMax); + + if (nw) + { + CGContextAddLineToPoint(aContext, xMin, yMin + aRadius); + CGContextAddCurveToPoint(aContext, xMin, yMin + aRadius, xMin, yMin, xMin + aRadius, yMin); + } else + CGContextAddLineToPoint(aContext, xMin, yMin); + + CGContextClosePath(aContext); + + CGContextStrokePath(aContext); +} + if (CPFeatureIsCompatible(CPHTMLCanvasFeature)) { #include "CGContextCanvas.j"