• 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: NSTableView: computing ideal row height for arbitrary font?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView: computing ideal row height for arbitrary font?


  • Subject: Re: NSTableView: computing ideal row height for arbitrary font?
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 27 Dec 2005 17:26:30 -0800
  • Thread-topic: NSTableView: computing ideal row height for arbitrary font?

on 05/12/27 16:06, Jim Correia at email@hidden wrote:

> I have an NSTableView which I let the user pick the display font for.
> After adjusting all the cells to use the font, I want to pick the
> ideal row height for the tableview.
>
> [font defaultLineHeightForFont] + 1
>
> works in some situations, but is wildly off in others.
>
> Interface Builder gets it right. How does it determine what row
> height to use for the table?

That's a good question, and I hope someone has a good answer.

In the meantime, here is my workaround/kludge. I've found that
-boundingRectForFont works better than -defaultLineHeightForFont; at least
it is consistently about 30% too much, 3-4 pixels for most font sizes, so I
do this:

int RowHeightForFont(NSFont* font)
{
int ans = (int)([font boundingRectForFont].size.height - 4) ;
if (ans < 11)
ans++ ;
return ans ;
}


_______________________________________________
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: NSTableView: computing ideal row height for arbitrary font?
      • From: Jim Correia <email@hidden>
References: 
 >NSTableView: computing ideal row height for arbitrary font? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: how does IB draw connections outside its windows?
  • Next by Date: Re: Prevent running in Rosetta
  • Previous by thread: NSTableView: computing ideal row height for arbitrary font?
  • Next by thread: Re: NSTableView: computing ideal row height for arbitrary font?
  • Index(es):
    • Date
    • Thread