Re: NSTableView - Alternating blue and white background
Re: NSTableView - Alternating blue and white background
- Subject: Re: NSTableView - Alternating blue and white background
- From: Stéphane Sudre <email@hidden>
- Date: Tue, 17 Dec 2002 11:38:43 +0100
On mardi, dic 17, 2002, at 11:05 Europe/Paris, Cristi Savu wrote:
Easy,
subclass you NSTableView and use something like this :
[...]
- (void) drawRow:(int) rowIndex clipRect:(NSRect) clipRect
{
if ((rowIndex % 2 == 0) && ([self selectedRow] != rowIndex))
{
NSColor* bgColor =[NSColor colorWithCalibratedRed:0.97 green: 0.97
blue: 0.97 alpha: 0.97];
NSRect rect= [self rectOfRow: rowIndex];
[bgColor set];
NSRectFill(rect);
}
[super drawRow: rowIndex clipRect: clipRect];
}
This is not working for the full table view
and
On mardi, dic 17, 2002, at 11:03 Europe/Paris, email@hidden
wrote:
You need to implement the tableviews delegate method -
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
you change the properties of the cell that is about to be drawn there
.
Search the archives on this topic, theres quite a few snazzy code
snippets for doing stuff like this.
This not working either.
-------
These 2 solutions are only displaying the stripped background when
there is a record for the row.
If you want to display a stripped background on the whole tableview
(even when there is not enough lines to fill it), you need to use other
solutions.
One solution is described in some Mac Tech articles written by Dan
Wood. The code is available on his web site and IIRC, if you search the
archive you should find a post indicating the URL of the source codes.
_______________________________________________
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.