Draw table view gridlines precisely inside the right side of cells so that grid line positioning and spacing matches Cocoa.

Checked against Cocoa with 0, 1, 2 and 3 px intercell spacing.
This commit is contained in:
Alexander Ljungberg committed 2011-05-30 17:46:46 -04:00
1 parent 3d1638c780
commit 1c007461bd
2 files changed
+9 -12

No files matched your search

+8 -11
View File
@@ -212,7 +212,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
- (CGRect)headerRectOfColumn:(int)aColumnIndex
{
var headerRect = [self bounds],
var headerRect = CGRectMakeCopy([self bounds]),
columnRect = [_tableView rectOfColumn:aColumnIndex];
headerRect.origin.x = _CGRectGetMinX(columnRect);
@@ -592,16 +592,13 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
for (var i = 0; i < count; i++)
{
var column = [tableColumns objectAtIndex:i],
headerView = [column headerView];
var frame = [self headerRectOfColumn:i];
headerView = [column headerView],
frame = [self headerRectOfColumn:i];
// Make space for the gridline on the right.
frame.origin.x -= 0.5;
frame.size.width -= 1.0;
frame.size.height -= 0.5;
if (i > 0)
{
frame.origin.x += 0.5;
frame.size.width -= 1;
}
// Note: we're not adding in intercell spacing here. This setting only affects the regular
// table cell data views, not the header. Verified in Cocoa on March 29th, 2011.
@@ -645,8 +642,8 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
columnMaxX = _CGRectGetMaxX(columnToStroke);
CGContextMoveToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(_CGRectGetMinY(columnToStroke)));
CGContextAddLineToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(_CGRectGetMaxY(columnToStroke)));
CGContextMoveToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(_CGRectGetMinY(columnToStroke)));
CGContextAddLineToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(_CGRectGetMaxY(columnToStroke)));
}
CGContextClosePath(context);
CGContextStrokePath(context);
+1 -1
View File
@@ -3642,7 +3642,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
for (; columnArrayIndex < columnArrayCount; ++columnArrayIndex)
{
var columnRect = [self rectOfColumn:columnsArray[columnArrayIndex]],
columnX = _CGRectGetMaxX(columnRect) + 0.5;
columnX = _CGRectGetMaxX(columnRect) - 0.5;
CGContextMoveToPoint(context, columnX, minY);
CGContextAddLineToPoint(context, columnX, maxY);