• 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: Drawing glitches in NSTableView with variable row hight (just like Console.app)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)


  • Subject: Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 20 Apr 2010 16:13:07 -0700

On 2010 Apr 19, at 08:56, Marco Masser wrote:

> I'm trying to implement a logging facility for an app ..., i.e. an NSTableView with varying row heights.

> I found three different approaches to calculating the height for a given width, but they all seem to be very performance-hungry:
> 1) (my favorite) I set the message string on my message column's NSTextFieldCell directly and call -cellSizeForBounds:
> 2) Creating an NSAttributedString with the attributes of my cell, calculating its size and then using the string's total width and my column's width.
> 3) Using some code from the docs involving an NSTextStorage, NSLayoutManager, and an NSTextContainer.

I have written an app which has a log window with variable row heights, in the sense that some rows have one line of text, some have two and some have more.  I have not noticed any drawing or resizing uglies.  I suppose I'm using what you call approach number 2.  It works by implementing the NSTableView delegate method -tableView:heightOfRow: in the table's array controller.

> calculate the number of rows (seems to be off some times).

This is a problem.  In my case, I don't need to calculate the height because my strings have a known number of hard line breaks.  However, assuming that the table's cell is an NSTextFieldCell, indeed you do have a problem.  Although you can get pretty close by changing the typesetter behavior in the layout manager you use to simulate the layout from the default NSTypesetterLatestBehavior to NSTypesetterBehavior_10_2_WithCompatibility, I've never found a way to measure the size of text rendered in an NSTextFieldCell with 100% reliability.

_______________________________________________

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: Drawing glitches in NSTableView with variable row hight (just like Console.app)
      • From: Jens Alfke <email@hidden>
References: 
 >Drawing glitches in NSTableView with variable row hight (just like Console.app) (From: Marco Masser <email@hidden>)

  • Prev by Date: Re: Baffling Button Behavior [SOLVED]
  • Next by Date: Re: CoreData: updating property of fetched object and refetching
  • Previous by thread: Drawing glitches in NSTableView with variable row hight (just like Console.app)
  • Next by thread: Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
  • Index(es):
    • Date
    • Thread