Shadowed text view
Shadowed text view
- Subject: Shadowed text view
- From: Eamon Ford <email@hidden>
- Date: Mon, 12 Dec 2005 15:50:28 -0800
Hey all,
I'm trying to make a shadowed text view like in Address Book and
iCal, and I've succeeded in making the shadow and gray outline, but
what would be the best way to draw the text in the right place and
highlight it when it's selected?
Here's my drawRect: method (most of this code is from Jeremy Dronfield):
- (void)drawRect:(NSRect)aRect
{
NSTextView * textView = [controller textView];
NSRange charRange = NSMakeRange(0, [[[textView textStorage]
characters] count]);
NSRange glyphRange = [[textView layoutManager]
glyphRangeForCharacterRange:charRange actualCharacterRange:nil];
NSRect rect = [[textView layoutManager]
boundingRectForGlyphRange:glyphRange inTextContainer:[textView
textContainer]];
NSColor *backgroundColor = [NSColor whiteColor];
[backgroundColor set];
NSRectFill([self bounds]);
NSColor *fillColor = [NSColor whiteColor];
NSColor *outlineColor = [NSColor grayColor];
NSShadow *viewShadow = [[NSShadow alloc] init];
[viewShadow setShadowOffset:NSMakeSize(3.5, -3.5)];
[viewShadow setShadowBlurRadius:6.5];
[fillColor setFill];
[outlineColor setStroke];
NSBezierPath *outline = [NSBezierPath bezierPathWithRect:rect];
[outline setLineWidth:1.0];
[outline setLineJoinStyle:NSMiterLineJoinStyle];
[outline stroke];
[viewShadow set];
[outline fill]; // <- important to put the shadow on the fill, not
the stroke
[viewShadow release];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden