• 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: NSTextFieldCell multi-line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextFieldCell multi-line


  • Subject: Re: NSTextFieldCell multi-line
  • From: Ross Carter <email@hidden>
  • Date: Tue, 09 Nov 2010 15:30:04 -0500

On Nov 9, 2010, at 4:45 AM, Micha Fuhrmann wrote:

> Thanks for your respons, but I need the exacte size in points, which means drawing with the right Font etc.
>
> So here's where I am
>
> in
>
> - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
>
> I'm calling a function which calculates the height needed for the text and that's what I'm returning:
>
> -(float)heightForStringDrawing:(NSString*)theTextField withFont:(NSFont*)myFont forWidth:(float)myWidth{
> 	NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithString:theTextField] autorelease];
> 	NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize: NSMakeSize(myWidth, FLT_MAX)] autorelease];
> 	NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease];
> 	[layoutManager addTextContainer:textContainer];
> 	[textStorage addLayoutManager:layoutManager];
> 	[textStorage addAttribute:NSFontAttributeName value:myFont range:NSMakeRange(0,[textStorage length])];
> 	[textContainer setLineFragmentPadding:0.0];
> 	[layoutManager glyphRangeForTextContainer:textContainer];
> 	return [layoutManager usedRectForTextContainer:textContainer].size.height;
> }
>
> BUT, I'm getting row clippings, and the strange thing if as soon as I'm clicking on any cell, everything comes back to good order.

Are you saying that the height returned from your method differs from the actual height used by the NSTextFieldCell? If so, you might need to adjust the typesetterBehavior setting.
_______________________________________________

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

  • Follow-Ups:
    • Re: NSTextFieldCell multi-line
      • From: Jerry Krinock <email@hidden>
References: 
 >NSTextFieldCell multi-line (From: Micha Fuhrmann <email@hidden>)
 >Re: NSTextFieldCell multi-line (From: "email@hidden" <email@hidden>)
 >Re: NSTextFieldCell multi-line (From: Micha Fuhrmann <email@hidden>)

  • Prev by Date: Re: using NSURLConnection to download NSArray
  • Next by Date: Re: Apply animation curve to nswindow position?
  • Previous by thread: Re: NSTextFieldCell multi-line
  • Next by thread: Re: NSTextFieldCell multi-line
  • Index(es):
    • Date
    • Thread