Re: Advice on using NSCell
Re: Advice on using NSCell
- Subject: Re: Advice on using NSCell
- From: Corbin Dunn <email@hidden>
- Date: Fri, 3 Mar 2006 14:49:35 -0800
- (void)tableView:(NSTableView*)tableView willDisplayCell:(id)cell
forTableColumn:(NSTableColumn*)tableColumn row:(int)rowIndex
{
#pragma unused(tableColumn)
LayerTableDataSource* dataSource = (LayerTableDataSource*)
[tableView dataSource];
// Get the row object for this cell
LayerTableRow* row = [dataSource row:rowIndex];
if (row->includesSelectedVolume)
{
[cell setFont:blackFont];
}
else
{
[cell setFont:greyFont];
}
}
@end
-------------------------
Footnote: I think I've figured out another way of doing this, but it
stills seems to be more work that I should have to do[1]. It
occurred to me that I could create a kind of "filter" NSFormatter
that reused any of the formatters I've already written to do the
object->string convertion, then turn that string into a
NSAttributedString with the desired color. I wouldn't have to mix my
data and view models, and I don't have to throw away any of the
formatters I've already written or reimplement any part of NSCell. I
just have to insert this "filter" formatter into every column of the
table, but that's not so bad as some of the alternatives.
You may simply want to build this ability into your regular formatter.
Have a flag that indicates if it should use the grey color, or not,
and use it. Then, in willDisplayCell, set that flag for the formatter
on the cell to be YES or NO, depending on how it should be...
--corbin
_______________________________________________
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