Re: NSTableView/NSOutlineView variable row height
Re: NSTableView/NSOutlineView variable row height
- Subject: Re: NSTableView/NSOutlineView variable row height
- From: Graham Cox <email@hidden>
- Date: Tue, 2 Sep 2008 10:38:15 +1000
On 2 Sep 2008, at 3:58 am, Kevin Meaney wrote:
I'm new to NSTableView and more specifically NSOutlineView. I want
to have variable height rows in the outline view, and I need to keep
Tiger compatibility.
Tiger provides the informal protocol method heightOfRowByItem that
looks like it can do the job I want. However it does not seem to
provide a way of obtaining the cell for the item. I would like to
ask the cell (NSTextFieldCell) what its cell size is by calling
cellSize or cellSizeForBounds since it should know how big it needs
to be when I have set the text for the text field cell.
Since I could not find a way to make this work I've been looking for
a workaround. I have come across RowResizableViews which looks like
it might be able to do what I want, however when I ran the sample
app it looks quite buggy running in Leopard.
I feel like I am missing something that should be obvious. Pointers
would be helpful or a suggestion for something else to try.
Bear in mind that each row does not have its own cell, therefore
asking the cell for its height isn't going to help you.
The cell is moved from row to row as the table is drawn, so presumably
its height is set on the fly by asking either the delegate or the view
what its row height should be. If your delegate implements -
outlineView:heightOfRowByItem: then this is the source of this
information - it can't ask the cell for the height because that's bass-
ackwards - the cell is asking *this* method for its height. The
delegate will supply this information from some other source, which
you'll have to arrange. Other information such as the column width,
content for the row and so on can be found by asking the view or
column, and so the area bounded by a given row can be determined and
returned by the delegate. In other words, until you calculate it, the
table doesn't know how much height to reserve for each row beyond the
initial fixed height set for the table as a whole.
hth,
Graham
_______________________________________________
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