mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
* Headers/AppKit/NSBezierPath.h,
* Source/NSBezierPath.m * (+bezierPathWithRoundedRect:xRadius:yRadius:, -appendBezierPathWithRoundedRect:xRadius:yRadius:): New 10.5 methods. Patch by Fred Morcos <fred.morcos@gmail.com> git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28247 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
05a515f767
commit
345f77f374
3 changed files with 75 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-04-25 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSBezierPath.h,
|
||||
* Source/NSBezierPath.m (+bezierPathWithRoundedRect:xRadius:yRadius:,
|
||||
-appendBezierPathWithRoundedRect:xRadius:yRadius:):
|
||||
New 10.5 methods.
|
||||
Patch by Fred Morcos <fred.morcos@gmail.com>
|
||||
|
||||
2009-04-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSColorWell.m: Only send action if color changes ... fix
|
||||
|
|
|
@ -95,6 +95,11 @@ typedef enum {
|
|||
+ (NSBezierPath *)bezierPath;
|
||||
+ (NSBezierPath *)bezierPathWithRect:(NSRect)aRect;
|
||||
+ (NSBezierPath *)bezierPathWithOvalInRect:(NSRect)aRect;
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
+ (NSBezierPath *)bezierPathWithRoundedRect:(NSRect)aRect
|
||||
xRadius:(CGFloat)xRadius
|
||||
yRadius:(CGFloat)yRadius;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Immediate mode drawing of common paths
|
||||
|
@ -219,6 +224,11 @@ typedef enum {
|
|||
count:(int)count
|
||||
inFont:(NSFont *)font;
|
||||
- (void)appendBezierPathWithPackedGlyphs:(const char *)packedGlyphs;
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
- (void)appendBezierPathWithRoundedRect:(NSRect)aRect
|
||||
xRadius:(CGFloat)xRadius
|
||||
yRadius:(CGFloat)yRadius;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Hit detection
|
||||
|
|
|
@ -146,6 +146,20 @@ typedef struct _PathElement
|
|||
return path;
|
||||
}
|
||||
|
||||
+ (NSBezierPath *)bezierPathWithRoundedRect: (NSRect)aRect
|
||||
xRadius: (CGFloat)xRadius
|
||||
yRadius: (CGFloat)yRadius
|
||||
{
|
||||
NSBezierPath *path;
|
||||
|
||||
path = [self bezierPath];
|
||||
[path appendBezierPathWithRoundedRect: aRect
|
||||
xRadius: xRadius
|
||||
yRadius: yRadius];
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
//
|
||||
// Immediate mode drawing of common paths
|
||||
//
|
||||
|
@ -1173,6 +1187,49 @@ typedef struct _PathElement
|
|||
path: self];
|
||||
}
|
||||
|
||||
- (void) appendBezierPathWithRoundedRect: (NSRect)aRect
|
||||
xRadius: (CGFloat)xRadius
|
||||
yRadius: (CGFloat)yRadius
|
||||
{
|
||||
NSPoint startp, endp, controlp1, controlp2, topLeft, topRight, bottomRight;
|
||||
|
||||
xRadius = MIN(xRadius, aRect.size.width);
|
||||
yRadius = MIN(yRadius, aRect.size.height);
|
||||
|
||||
topLeft = NSMakePoint(NSMinX(aRect), NSMaxY(aRect));
|
||||
topRight = NSMakePoint(NSMaxX(aRect), NSMaxY(aRect));
|
||||
bottomRight = NSMakePoint(NSMaxX(aRect), NSMinY(aRect));
|
||||
|
||||
startp = NSMakePoint(aRect.origin.x, aRect.origin.y + yRadius);
|
||||
endp = NSMakePoint(aRect.origin.x + xRadius, aRect.origin.y);
|
||||
controlp1 = NSMakePoint(startp.x, startp.y - (KAPPA * yRadius));
|
||||
controlp2 = NSMakePoint(endp.x - (KAPPA * xRadius), endp.y);
|
||||
[self moveToPoint: startp];
|
||||
[self curveToPoint: endp controlPoint1: controlp1 controlPoint2: controlp2];
|
||||
|
||||
startp = NSMakePoint(bottomRight.x - xRadius, bottomRight.y);
|
||||
endp = NSMakePoint(bottomRight.x, bottomRight.y + yRadius);
|
||||
controlp1 = NSMakePoint(startp.x + (KAPPA * xRadius), startp.y);
|
||||
controlp2 = NSMakePoint(endp.x, endp.y - (KAPPA * yRadius));
|
||||
[self lineToPoint: startp];
|
||||
[self curveToPoint: endp controlPoint1: controlp1 controlPoint2: controlp2];
|
||||
|
||||
startp = NSMakePoint(topRight.x, topRight.y - yRadius);
|
||||
endp = NSMakePoint(topRight.x - xRadius, topRight.y);
|
||||
controlp1 = NSMakePoint(startp.x, startp.y + (KAPPA * yRadius));
|
||||
controlp2 = NSMakePoint(endp.x + (KAPPA * xRadius), endp.y);
|
||||
[self lineToPoint: startp];
|
||||
[self curveToPoint: endp controlPoint1: controlp1 controlPoint2: controlp2];
|
||||
|
||||
startp = NSMakePoint(topLeft.x + xRadius, topLeft.y);
|
||||
endp = NSMakePoint(topLeft.x, topLeft.y - yRadius);
|
||||
controlp1 = NSMakePoint(startp.x - (KAPPA * xRadius), startp.y);
|
||||
controlp2 = NSMakePoint(endp.x, endp.y + (KAPPA * yRadius));
|
||||
[self lineToPoint: startp];
|
||||
[self curveToPoint: endp controlPoint1: controlp1 controlPoint2: controlp2];
|
||||
|
||||
[self closePath];
|
||||
}
|
||||
|
||||
/* We use our own point structure with double elements while recursing to
|
||||
avoid losing accuracy at really fine subdivisions of curves. */
|
||||
|
|
Loading…
Reference in a new issue