Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
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: Jens Alfke <email@hidden>
- Date: Tue, 20 Apr 2010 17:03:32 -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 wouldn't do it this way (and I speak from past experience, having
tried to do this once). You're using NSTableView for something it's
not good at — updating layout on the fly as the width changes — and
more importantly, you lose flexibility in the UI, like being able to
select text in a natural way. If you just use NSTextView instead, the
layout will work automatically, and selection of course works the way
users expect.
The only problem with NSTextView would be if you have truly enormous
amounts of text to log. In that case NSTableView wins. But then trying
to do multi-line layout in the table view will bog down for the same
reason it does in the text view. If you really need to handle millions
of lines, you probably just shouldn't attempt to wrap them.
—Jens_______________________________________________
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