Re: NSCell with Embedded NSView
Re: NSCell with Embedded NSView
- Subject: Re: NSCell with Embedded NSView
- From: Mike Abdullah <email@hidden>
- Date: Thu, 6 Apr 2006 20:25:16 +0100
By floating, I assume you mean that you are trying to have a single
NSView instance that is used to draw each row. This is how NSCell
works, but NSViews are totally different. You must have an NSView
for each row.
Presumably you have an array of data that you are representing with
the items in your tableview. What you need to do is set it so that
each overall table data item is set as the objectValue of your cell.
Then, when your cell is asked to draw itself, it can request the view
needed from its objectValue and position it accordingly.
I can see why you're worried about the overhead present for "tens of
thousands of subviews." I'm afraid what this comes down to is that
if you are displaying that quantity of data in a tableview, you
simply cannot use an NSView as a cell. You need to seriously rethink
how this is going to work and either use a normal style of tableview,
or a custom NSCell that contains other cells and no views.
Also, bear in mind that you won't simply have one subview for each
row of the table. You will have one for each row, and one for every
single control that is contained in that view.
Mike.
On 6 Apr 2006, at 16:41PM, Mike Rossetti wrote:
Folks,
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];
}
results in recursion:
#0 0x0021d124 in -[MySpecialView display] at MySpecialView.mm:40
#1 0x0021cf10 in -[MySpecialCell drawWithFrame:inView:] at
MySpecialCell.mm:68
#2 0x9372d5ec in -[NSTableView _drawContentsAtRow:column:clipRect:]
#3 0x9372ce78 in -[NSTableView drawRow:clipRect:]
#4 0x9372cc34 in -[NSTableView drawRowIndexes:clipRect:]
#5 0x9372c2bc in -[NSTableView drawRect:]
#6 0x936c0e78 in -[NSView _drawRect:clip:]
#7 0x936c0438 in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#8 0x936bfa00 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisib
leRectForView:topView:]
#9 0x936b9674 in -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
#10 0x936ae968 in -[NSView displayIfNeeded]
-- Here we go again
#11 0x0021d17c in -[MySpecialView display] at MySpecialView.mm:43
#12 0x0021cf10 in -[MySpecialCell drawWithFrame:inView:] at
MySpecialCell.mm:68
#13 0x9372d5ec in -[NSTableView _drawContentsAtRow:column:clipRect:]
#14 0x9372ce78 in -[NSTableView drawRow:clipRect:]
#15 0x9372cc34 in -[NSTableView drawRowIndexes:clipRect:]
#16 0x9372c2bc in -[NSTableView drawRect:]
#17 0x936c0e78 in -[NSView _drawRect:clip:]
#18 0x936c0438 in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#19 0x936bfa00 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisib
leRectForView:topView:]
#20 0x936b9674 in -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
#21 0x936ae968 in -[NSView displayIfNeeded]
-- Here we go again
#22 0x0021d17c in -[MySpecialView display] at MySpecialView.mm:43
#23 0x0021cf10 in -[MySpecialCell drawWithFrame:inView:] at
MySpecialCell.mm:68
#24 0x9372d5ec in -[NSTableView _drawContentsAtRow:column:clipRect:]
#25 0x9372ce78 in -[NSTableView drawRow:clipRect:]
#26 0x9372cc34 in -[NSTableView drawRowIndexes:clipRect:]
#27 0x9372c2bc in -[NSTableView drawRect:]
#28 0x936c0e78 in -[NSView _drawRect:clip:]
#29 0x936c0438 in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
What is the recommended way to draw a floating NSView in response
to a NSCell being redrawn?
Thanks,
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
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