Re: NSTableView with different color in row
Re: NSTableView with different color in row
- Subject: Re: NSTableView with different color in row
- From: Joshua Pennington <email@hidden>
- Date: Mon, 22 May 2006 22:44:30 -0500
You should check out this Pimp My Code segment by Wil Shipley:
http://wilshipley.com/blog/2005/07/pimp-my-code-part-3-gradient.html
It's about using gradient backgrounds for NSTableView.
j o a r wrote:
On 22 maj 2006, at 07.08, Angelo Chen wrote:
I'd like to display certain rows in different color based on the
related data, any way to do this?
It can of course be done, but unfortunately it's not very straight
forward. I will outline one way to do it here.
Start with a NSCell subclass that knows how to draw background color
(for example, use NSTextFieldCell, or a custom NSCell subclass).
Either set the background color dynamically in the "-willDisplayCell:"
delegate method, or provide a pre-configured cell via the
"-[NSTableColumn dataCellForRow:]" method (in which case you would
have to subclass NSTableColumn.
Note that NSTableView will draw selection highlight color outside of
the area of the table view that is covered by the table columns - so
if you override and change this color for your table cells, it can
look a bit weird (as two highlight colors would differ). One way to
avoid this problem is to use a table column resizing mode that will
ensure that the table columns always fill the entire table view.
Also note that you would typically have to use "-[NSTableView
setIntercellSpacing:] to disable inter-cell spacing in order to make
row coloring look good.
A completely different approach could be to do something based on the
table view subclass found here:
<http://developer.apple.com/samplecode/MP3_Player/MP3_Player.html>
j o a r
------------------------------------------------------------------------
_______________________________________________
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
_______________________________________________
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