• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Shadowed text view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shadowed text view


  • Subject: Re: Shadowed text view
  • From: Todd Ransom <email@hidden>
  • Date: Tue, 13 Dec 2005 15:34:02 -0700

There is a sample app called RaisedEditor that demonstrates exactly how to do this. It is in the WWDC 2003 sample code which i think you can download from developer.apple.com.

Todd Ransom
Return Self Software
http://returnself.com



On Dec 12, 2005, at 4:50 PM, Eamon Ford wrote:

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

_______________________________________________
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
  • Follow-Ups:
    • Re: Shadowed text view
      • From: Tim Buchheim <email@hidden>
    • Re: Shadowed text view
      • From: Eamon Ford <email@hidden>
References: 
 >Shadowed text view (From: Eamon Ford <email@hidden>)

  • Prev by Date: Re: Getting the arguments of methods in other frameworks (from GDB)
  • Next by Date: Re: Setting initial filename for Save As
  • Previous by thread: Shadowed text view
  • Next by thread: Re: Shadowed text view
  • Index(es):
    • Date
    • Thread