alternating background in rows of NSCell subclass
alternating background in rows of NSCell subclass
- Subject: alternating background in rows of NSCell subclass
- From: Chuck Soper <email@hidden>
- Date: Sun, 4 Jul 2004 23:54:50 -0700
Hello,
In my Jaguar compatible application, I'm drawing a light blue
background on every other row of my NSTableView with the
willDisplayCell: delegate method shown below.
The problem is that I have a couple of NSCell subclasses. The methods
setDrawsBackground and setBackgroundColor are members of
NSTextFieldCell not NSCell. I can simply not draw the blue background
by adding the following code to the beginning of the willDisplayCell:
delegate method:
if (![cell isKindOfClass:[NSTextFieldCell class]])
return;
How can or should I draw a light blue background on every other row
in my NSCell subclass of my NSTableView in my Jaguar compatible
application? As far as I know, -
(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView in
my NSCell subclass has no way of knowing what row it's drawing. Any
ideas?
Thanks,
Chuck
- (void)tableView: (NSTableView *)tableView willDisplayCell: (id)cell
forTableColumn: (NSTableColumn *)tableColumn row: (int)rowIndex
{
if ((rowIndex % 2) == 0) {
[cell setDrawsBackground: YES];
[cell setBackgroundColor: [NSColor colorWithCalibratedRed: 0.93
green: 0.95 blue: 1.0 alpha: 1.0]];
} else {
[cell setDrawsBackground: NO];
[cell setBackgroundColor: [NSColor whiteColor]];
}
}
_______________________________________________
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.