Re: Difficult NSShadow problem
Re: Difficult NSShadow problem
- Subject: Re: Difficult NSShadow problem
- From: Ken Tozier <email@hidden>
- Date: Sun, 15 Jul 2007 12:33:46 -0400
Well I got it partiall working by temporarily locking focus on the
superview. The shadow at the bottom of the view draws OK but it's
clipped on the right. Anyone have any ideas how fix this?
- (void) drawRect:(NSRect) inRect
{
//NSRect shadowRect
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
[[self superview] lockFocus];
// is there a way to do something tricky here to have the shadow
draw outside the frame?
[shadow setShadowOffset: NSMakeSize(2, -2)];
[shadow setShadowBlurRadius: 3];
[shadow set];
[[NSColor whiteColor] set];
NSRectFillUsingOperation([self convertRect: inRect toView: [self
superview]], NSCompositeSourceOver);
[[self superview] unlockFocus];
while (ad = [enumerator nextObject])
{
NSRect adFrame = [ad frame];
[ad drawRect: adFrame];
}
}
On Jul 15, 2007, at 12:08 PM, Ken Tozier wrote:
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:
40comcast.net
This email sent to email@hidden
_______________________________________________
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