Re: NSCell with Embedded NSView
Re: NSCell with Embedded NSView
- Subject: Re: NSCell with Embedded NSView
- From: Keary Suska <email@hidden>
- Date: Thu, 06 Apr 2006 10:31:58 -0600
on 4/6/06 9:41 AM, email@hidden purportedly said:
> I'd appreciate any hints and suggestions about how to properly draw
> an NSView within an NSCell in an NSTableView. I _almost_ have it
> working. The problem I am struggling with is that only the cell in
> the very last row is being drawn properly. The crux of the matter is
> that I am trying to use a 'floating' view for rendering the contents
> of each cell in the single column in the table. (I need to use this
> view because the data being shown is complex and does not lend itself
> to composition in columns: it's a two-line presentation where both
> lines do not line up column-wise.)
>
> The floating view approach saves having to have, potentially, tens of
> thousands of subviews, one for each row. Unfortunately, trying to
> draw the view in the cell's drawWithFrame:
>
> - (void) drawWithFrame: (NSRect) cellFrame inView: (NSView*) controlView
> {
> if ([cellView superview] != controlView)
> [controlView addSubview: cellView];
>
> [cellView setFrame: cellFrame];
> [cellView display];
> }
I am not sure I follow what you mean by "floating", or why it seems
necessary, but AFAIK in some way you *have* to have a particular view for
the cell in each row. I believe that Cocoa's handling of NSTableViews are
pretty efficient, although I am not clear on their internal representation,
but I would probably be less concerned with how many views the table draws
than I would over the size of the model used to store the referenced data.
In my experience with databases and NSTableView, I haven't noticed a
significant overhead by the table view in displaying data, even up to 100k
rows. I don't know that I would bet my life on it, but it sure seems that
way. If you haven't already, just for grins, you could use your custom view
for the last cell and see if it is truly unmanageable.
That being said, you can have a delegate object implement
tableView:willDisplayCell:forTableColumn:row: and modify the contents of the
NSCell on-the-fly, or if you are using a data source you can do what you
need when the cell is called.
Hope this helps,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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