Re: Conditionally formatting cells in an NSTableView
Re: Conditionally formatting cells in an NSTableView
- Subject: Re: Conditionally formatting cells in an NSTableView
- From: Julian Barkway <email@hidden>
- Date: Tue, 26 Nov 2002 20:43:43 +0100
On Tuesday, November 26, 2002, at 03:56 pm, Tamara L. Cravit wrote:
>
What I'd like to do next is to conditionally format some cells to be in
>
bold, based on whether or not a particular data element is nil. Can I
>
do
>
this in the NSTableDataSource "aTable objectValueForTableColumn:row:"
>
method, or is there somewhere better to do this?
Short answer: Yes.
Since you don't actually have access to your table's NSCell at this
point, there is nothing useful that you can format. Instead, you need
to implement the delegate method
tableView:willDisplayCell:forTableColumn:row: in your table view's
delegate as this handily supplies you with an NSCell (by default an
NSTextFieldCell) to which formatting messages can be sent. Bear in mind
that the same cell is reused for each row and column combo that is
displayed so you will need to set or reset your attributes accordingly
each time your method is invoked. To get boldface, you will need to
first convert your font using the FontManager and then pass it to the
cell's setFont: method.
Which brings me to my number one Cocoa peeve. Unfortunately, unlike
OS9, 'bold' is no longer an attribute that can be applied to a font.
This means that if the font family you are using doesn't have a bold
variant you won't get boldface. NSFontManager's
convertFont:toHaveTrait: sounds like it will do this but all it does,
in effect, is to look for a boldface variant of the supplied font and
if it doesn't find one, it gives up. It would be nice if there was at
least the option of returning a faked bold or italic face...
--
Julian Barkway,
Zurich,
Switzerland.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.