Skip to content

Instantly share code, notes, and snippets.

@Me1000
Created August 12, 2009 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Me1000/166749 to your computer and use it in GitHub Desktop.
Save Me1000/166749 to your computer and use it in GitHub Desktop.
-(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