Difficult NSShadow problem
Difficult NSShadow problem
- Subject: Difficult NSShadow problem
- From: Ken Tozier <email@hidden>
- Date: Sun, 15 Jul 2007 12:08:20 -0400
Hi
I wrote a page thumbnail class that consists of two parts, an actual
thumbnail pf a page and an editable page number field. I want to add
a shadow to the page thumbnail but I think I need to do something
tricky with the context or the thumbnail frame to get it to show up.
I have gotten shadows to work in the past but I think in this case, I
need to modify the draw clipping area temporarily to have the shadow
show up. Is there a way to draw a shadow outside a view's frame by
changing the clipping somehow?
TIA
Ken
Here's the relevant draw method
- (void) drawRect:(NSRect) inRect
{
NSEnumerator *enumerator = [ads objectEnumerator];
PMAdView *ad;
NSShadow *shadow = [[[NSShadow alloc] init] autorelease];
// NOTE: Only want the shadow to draw outside the view frame not for
each ad
// so bracket NSRectFillUsingOperation in it's own context and restore
// after filling
NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context saveGraphicsState];
[shadow setShadowOffset: NSMakeSize(2, -2)];
[shadow setShadowBlurRadius: 3];
[shadow set];
[[NSColor whiteColor] set];
NSRectFillUsingOperation(inRect, NSCompositeSourceOver);
[context restoreGraphicsState];
while (ad = [enumerator nextObject])
{
NSRect adFrame = [ad frame];
[ad drawRect: adFrame];
}
}
_______________________________________________
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