Created
August 12, 2009 20:42
-
-
Save Me1000/166749 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)drawGridInClipRect:(CGRect)aRect | |
{ | |
[[CPColor gridColor] setStroke]; | |
if ([self gridStyleMask] | CPTableViewSolidVerticalGridLineMask) | |
{ | |
var context = [[CPGraphicsContext currentContext] graphicsPort]; | |
var exposedRows = [self rowsInRect:aRect], | |
exposedColumnIndexes = [self columnIndexesInRect:aRect], | |
columnsArray = []; | |
[exposedColumnIndexes getIndexes:columnsArray maxCount:-1 inIndexRange:nil]; //may have to set inIndexRange: to a range if nil doesn't work after compilation. | |
var columnArrayIndex = 0, | |
columnArrayCount = columnsArray.length; | |
for(; columnArrayIndex < columnArrayCount; ++columnArrayIndex) | |
{ | |
// grab each column rect and add horizontal lines | |
var columnToStroke = [self rectOfColumn:columnArrayIndex]; | |
CGContextMoveToPoint(context, columnToStroke.origin.x + columnToStroke.size.width, columnToStroke.origin.y); | |
CGContextAddLineToPoint(context, columnToStroke.origin.x + columnToStroke.size.width, columnToStroke.origin.y + columnToStroke.size.height); | |
CGContextSetLineWidth(context, 1); | |
CGContextStrokePath(context); | |
} | |
} | |
if ([self gridStyleMask] | CPTableViewSolidHorizontalGridLineMask) | |
{ | |
var context = [[CPGraphicsContext currentContext] graphicsPort]; | |
var exposedRows = [self rowsInRect:aRect]; | |
var row = exposedRows.location, | |
maxRow = CPMaxRange(exposedRows); | |
for (; row < maxRow; ++row) | |
{ | |
// grab each row rect and add the top and bottom lines | |
var rowToStroke = [self rectOfRow:row]; | |
//var points = [rowToStroke.origin.x, rowToStroke.origin.y + rowToStroke.size.height, rowToStroke.origin.x + rowToStroke.size.width, rowToStroke.origin.y + rowToStroke.size.height]; | |
//console.log(points); | |
//CGContextStrokeLineSegments(context, points, 2); | |
CGContextMoveToPoint(context, rowToStroke.origin.x, rowToStroke.origin.y + rowToStroke.size.height); | |
CGContextAddLineToPoint(context, rowToStroke.origin.x + rowToStroke.size.width, rowToStroke.origin.y + rowToStroke.size.height); | |
CGContextSetLineWidth(context, 1); | |
CGContextStrokePath(context); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment