Fixes rows drawing when alternatingRowBackgroundColors > 2. TableTest showing 3 row colors

This commit is contained in:
cacaodev
2010-02-01 10:59:23 -05:00
committed by Randall Luecke
parent 050a132bd5
commit 35a7456302
2 changed files with 5 additions and 8 deletions
+4 -8
View File
@@ -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);
+1
View File
@@ -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]];