Re: Retrieving the current -[NSShadow set]
Re: Retrieving the current -[NSShadow set]
- Subject: Re: Retrieving the current -[NSShadow set]
- From: Keith Duncan <email@hidden>
- Date: Fri, 25 Jul 2008 15:16:15 +0100
Here's the code:
// Created by Sean Patrick O'Brien on 4/1/08.
// Copyright 2008 MolokoCacao. All rights reserved.
- (void)fillWithInnerShadow:(NSShadow *)shadow {
[NSGraphicsContext saveGraphicsState];
NSShadow *shadowCopy = [shadow copy];
NSSize offset = shadowCopy.shadowOffset;
CGFloat radius = shadowCopy.shadowBlurRadius;
NSRect bounds = NSInsetRect(self.bounds, -(ABS(offset.width) +
radius), -(ABS(offset.height) + radius));
offset.height += bounds.size.height;
shadowCopy.shadowOffset = offset;
NSAffineTransform *transform = [NSAffineTransform transform];
[transform translateXBy:0 yBy:([[NSGraphicsContext currentContext]
isFlipped] ? 1 : -1) * bounds.size.height];
NSBezierPath *drawingPath = [NSBezierPath bezierPathWithRect:bounds];
[drawingPath setWindingRule:NSEvenOddWindingRule];
[drawingPath appendBezierPath:self];
[drawingPath transformUsingAffineTransform:transform];
[self addClip];
[shadowCopy set];
[[NSColor blackColor] set];
[drawingPath fill];
[shadowCopy release];
[NSGraphicsContext restoreGraphicsState];
}
Keith Duncan
email@hidden, 33software.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden