Re: color row table view
Re: color row table view
- Subject: Re: color row table view
- From: Yojimbo <email@hidden>
- Date: Wed, 5 Mar 2003 11:17:12 -0800
If I understand you correctly this is because you added the columns in
IB and those cells automatically have drawsBackground enabled.
You can reconfigure this for each column in either your controller's
awakeFromNib or in the -tableView:willDisplayCell:forTableColumn:row
delegate method.
You will need to get the cell object and use something like:
if([aCell respondsToSelector:@selector(setDrawsBackground:)]) {
[aCell setDrawsBackground:NO];
}
Hope that helps,
Jim
On Wednesday, Mar 5, 2003, at 10:32 US/Pacific, Tony S. Wu wrote:
I did a search on the archives for color row table view, the search
comes up with some codes from Norbert:
- (void)drawRow: (int)rowIndex clipRect: (NSRect)clipRect
{
NSColor *bgColor;
if (![self isRowSelected: rowIndex])
{
if (delegateRespondsToTableViewBackgroundColorForRow)
{
bgColor = [[self delegate] tableView: self
backgroundColorForRow: rowIndex];
if (bgColor != nil)
{
NSLog(@"%@ %@ %@", NSStringFromRect([self rectOfRow:
rowIndex]), NSStringFromRect(clipRect),
NSStringFromRect(NSIntersectionRect([self rectOfRow: rowIndex],
clipRect)));
[[NSColor blackColor] set];
[[NSBezierPath bezierPathWithRect:
NSIntersectionRect([self rectOfRow: rowIndex], clipRect)] stroke];
[bgColor set];
NSRectFill(NSIntersectionRect([self rectOfRow:
rowIndex], clipRect));
NSRectFill([self rectOfRow: rowIndex]);
}
}
}
[super drawRow: rowIndex clipRect: clipRect];
}
- (void)setDelegate: (id)aDelegate
{
[super setDelegate: aDelegate];
delegateRespondsToTableViewBackgroundColorForRow =
[[self delegate] respondsToSelector:
@selector(tableView:backgroundColorForRow:)];
}
However, only the first 2 columns of my table view gets full background
color.
The others are only "stroked".
I then try to make all my table view's data cell has no background.
Now all columns get full background, but those rows that i don't want
background now gets stroked...
Can anyone tell me what i did wrong?
Tony S. Wu
email@hidden
"The world doesn't give us hope - it gives us chance."
http://homepage.mac.com/tonyswu/tonyswu - My web page.
_______________________________________________
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.
_______________________________________________
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.