mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:11:18 +00:00
Add gradient methods on graphics context.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28872 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bf24d5d246
commit
054405e8f3
5 changed files with 59 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-10-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSGraphicsContext.h,
|
||||
* Source/NSGraphicsContext.m: Define empty gradient methods.
|
||||
* Source/NSGradient.m: Use these methods.
|
||||
* Source/NSColor.m (-colorUsingColorSpace): Don't use isEqual: on
|
||||
color space.
|
||||
|
||||
2009-10-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSGradient.m: Add context savig/restore and first attempt
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
@class NSFont;
|
||||
@class NSSet;
|
||||
@class NSBitmapImageRep;
|
||||
@class NSGradient;
|
||||
|
||||
/*
|
||||
* Backing Store Types
|
||||
|
@ -505,6 +506,21 @@ transform between current user space and image space for this image.</desc>
|
|||
|
||||
@end
|
||||
|
||||
@interface NSGraphicsContext (NSGradient)
|
||||
- (void) drawGradient: (NSGradient*)gradient
|
||||
fromCenter: (NSPoint)startCenter
|
||||
radius: (CGFloat)startRadius
|
||||
toCenter: (NSPoint)endCenter
|
||||
radius: (CGFloat)endRadius
|
||||
options: (NSUInteger)options;
|
||||
|
||||
- (void) drawGradient: (NSGradient*)gradient
|
||||
fromPoint: (NSPoint)startPoint
|
||||
toPoint: (NSPoint)endPoint
|
||||
options: (NSUInteger)options;
|
||||
|
||||
@end
|
||||
|
||||
/* NSGraphicContext constants */
|
||||
APPKIT_EXPORT NSString *NSGraphicsContextDestinationAttributeName;
|
||||
APPKIT_EXPORT NSString *NSGraphicsContextPDFFormat;
|
||||
|
|
|
@ -1218,7 +1218,7 @@ systemColorWithName(NSString *name)
|
|||
// FIXME
|
||||
NSString *colorSpaceName;
|
||||
|
||||
if ([space isEqualTo: [self colorSpace]])
|
||||
if (space == [self colorSpace])
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -55,14 +55,22 @@
|
|||
radius: (CGFloat)endRadius
|
||||
options: (NSGradientDrawingOptions)options
|
||||
{
|
||||
// FIXME: New backend call
|
||||
[[NSGraphicsContext currentContext] drawGradient: self
|
||||
fromCenter: startCenter
|
||||
radius: startRadius
|
||||
toCenter: endCenter
|
||||
radius: endRadius
|
||||
options: options];
|
||||
}
|
||||
|
||||
- (void) drawFromPoint: (NSPoint)startPoint
|
||||
toPoint: (NSPoint)endPoint
|
||||
options: (NSGradientDrawingOptions)options
|
||||
{
|
||||
// FIXME: New backend call
|
||||
[[NSGraphicsContext currentContext] drawGradient: self
|
||||
fromPoint: startPoint
|
||||
toPoint: endPoint
|
||||
options: options];
|
||||
}
|
||||
|
||||
- (void) drawInBezierPath: (NSBezierPath *)path angle: (CGFloat)angle
|
||||
|
@ -197,7 +205,7 @@ relativeCenterPosition: (NSPoint)relativeCenterPoint
|
|||
{
|
||||
return [self initWithColors: colorArray
|
||||
atLocations: NULL
|
||||
colorSpace: null];
|
||||
colorSpace: nil];
|
||||
}
|
||||
|
||||
- (id) initWithColors: (NSArray *)colorArray
|
||||
|
@ -208,7 +216,7 @@ relativeCenterPosition: (NSPoint)relativeCenterPoint
|
|||
{
|
||||
_numberOfColorStops = [colorArray count];
|
||||
NSAssert(_numberOfColorStops >= 2, @"NSGradient needs at least 2 locations");
|
||||
if (colorSpace == null)
|
||||
if (colorSpace == nil)
|
||||
{
|
||||
colorSpace = [[colorArray objectAtIndex: 0] colorSpace];
|
||||
}
|
||||
|
@ -261,7 +269,7 @@ relativeCenterPosition: (NSPoint)relativeCenterPoint
|
|||
|
||||
self = [self initWithColors: colorArray
|
||||
atLocations: locations
|
||||
colorSpace: null];
|
||||
colorSpace: nil];
|
||||
|
||||
RELEASE(colorArray);
|
||||
objc_free(locations);
|
||||
|
|
|
@ -1780,3 +1780,24 @@ NSGraphicsContext *GSCurrentContext(void)
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSGraphicsContext (NSGradient)
|
||||
- (void) drawGradient: (NSGradient*)gradient
|
||||
fromCenter: (NSPoint)startCenter
|
||||
radius: (CGFloat)startRadius
|
||||
toCenter: (NSPoint)endCenter
|
||||
radius: (CGFloat)endRadius
|
||||
options: (NSUInteger)options
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) drawGradient: (NSGradient*)gradient
|
||||
fromPoint: (NSPoint)startPoint
|
||||
toPoint: (NSPoint)endPoint
|
||||
options: (NSUInteger)options
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue