From 35a74563026c25d4d2c074e579a338daeeb048f1 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Mon, 1 Feb 2010 11:51:50 +0100 Subject: [PATCH] Fixes rows drawing when alternatingRowBackgroundColors > 2. TableTest showing 3 row colors --- AppKit/CPTableView.j | 12 ++++-------- Tests/Manual/TableTest/AppController.j | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 062ab6594..cdb0866bd 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -1954,11 +1954,6 @@ window.setTimeout(function(){ [self highlightSelectionInClipRect:exposedRect]; } -- (void)drawRect:(CGRect)aRect -{ - [_tableDrawView display]; -} - - (void)drawBackgroundInClipRect:(CGRect)aRect { if (![self usesAlternatingRowBackgroundColors]) @@ -1982,20 +1977,21 @@ window.setTimeout(function(){ // CGContextFillRect(context, CGRectIntersection(aRect, fillRect)); // console.profile("row-paint"); var exposedRows = [self rowsInRect:aRect], - firstRow = exposedRows.location -1, + firstRow = exposedRows.location, lastRow = CPMaxRange(exposedRows) - 1, colorIndex = MIN(exposedRows.length, colorCount), heightFilled = 0.0; while (colorIndex--) { - var row = firstRow % colorCount + firstRow + colorIndex, + var row = firstRow - firstRow % colorCount + colorIndex, fillRect = nil; CGContextBeginPath(context); for (; row <= lastRow; row += colorCount) - CGContextAddRect(context, CGRectIntersection(aRect, fillRect = [self rectOfRow:row])); + if (row >= firstRow) + CGContextAddRect(context, CGRectIntersection(aRect, fillRect = [self rectOfRow:row])); if (row - colorCount === lastRow) heightFilled = _CGRectGetMaxY(fillRect); diff --git a/Tests/Manual/TableTest/AppController.j b/Tests/Manual/TableTest/AppController.j index eb4b7830a..98fb0d160 100644 --- a/Tests/Manual/TableTest/AppController.j +++ b/Tests/Manual/TableTest/AppController.j @@ -39,6 +39,7 @@ CPLogRegister(CPLogConsole); [tableView setAllowsMultipleSelection:YES]; [tableView setAllowsColumnSelection:YES]; [tableView setUsesAlternatingRowBackgroundColors:YES]; + [tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]]; [tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask]; // [tableView setBackgroundColor:[CPColor blueColor]];