Re: color row table view
Re: color row table view
- Subject: Re: color row table view
- From: jim kitchen <email@hidden>
- Date: Wed, 05 Mar 2003 19:59:53 -0700
I was given a hint a few months back by Aaron Hillegass,
to do the following:
1. Create the tableView;
2. Copy the first or second column in the new tableView;
3. Paste the new column into tableView, creating the third, fourth
and, or fifth columns, etc....;
4. Background colours worked in the new columns....
Hope this helps too.
jim k
On 3/5/03 12:17 PM, "Yojimbo" <email@hidden> wrote:
>
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.
_______________________________________________
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.