On 02/07/2009, at 10:09 AM, Peter Zegelin wrote:

Problem with this is there is no obvious concordance ( that I can see) between a row and its rectangle.
Wouldn't scrolling affect all this?


I wonder if the delegate method:

- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumnrow:(NSInteger)rowIndex


would be better for your needs? It gives you the row and column so you know where you are, and is called as part of the drawing loop of the table, you can just go ahead and draw. Use -rectOfRow to get the row and paint the background. I just tried the code below and it works fine:

if( rowIndex == 5 && [[aTableView tableColumns] objectAtIndex:0] == aTableColumn )
                {
                        NSRect rowRect = [aTableView rectOfRow:rowIndex];
                        [[NSColor lightGrayColor] set];
                        NSRectFill( rowRect );
                }

Note that here I paint the background of row 5 and only for the first column (though the whole row is painted - if you don't do this the additional paints on columns > 1 will erase the content of the cells in earlier columns. This shows that the table drawing is performed as you'd expect: for each row draw columns 0..n). Some variation on this ought to work for you.

Another alternative is to subclass NSTableView and override - drawRow:clipRect: which might be considered less of a hack than using the delegate method to draw.


--Graham

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to