Re: NSTableView and NSView
Re: NSTableView and NSView
- Subject: Re: NSTableView and NSView
- From: j o a r <email@hidden>
- Date: Tue, 21 Nov 2006 19:13:30 +0100
On 21 nov 2006, at 18.31, Michael Watson wrote:
Right, that's where I found the example project. But there isn't
really any documentation there that explains how this accomplishes
the task.
Quick background: It would be great to have a control like
NSTableView that could "serve up" views and not cells. As creating a
replacement for NSTableView from scratch would be quite a task - both
initially, and in maintenance - I created this proof-of-concept of
how it can be done using a slim wrapper for the standard NSTableView.
Now on to a quick and simplified overview of how the SubviewTableView
(SVTV) works:
In a regular table view you have this configuration:
NSTableView -> NSTableDataSource
My hack introduces a middle man and a new protocol, like this:
NSTableView -> SVTVController -> SVTVControllerDataSource
The NSTableDataSource protocol provides object values for rows. In
much the same way, the SVTVControllerDataSource protocol provides
NSView instances for rows.
When the NSTableView asks the SVTVController for an object value for
a cell, it turns around to the SVTVControllerDataSource to get the
appropriate NSView and returns that.
The cell is a custom subclass that doesn't draw anything. Instead,
when asked to draw, it takes the view it received earlier, and
inserts it as a subclass to the table view, in the position where it
was asked to draw.
And that's basically it. It works pretty OK for simple things, but
standard disclaimers apply... ;-)
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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