Source/Grid.m
changeset 6 af9b2b929b03
parent 1 3eb7be1dd7b6
child 7 428a194e3e59
     1.1 --- a/Source/Grid.m	Mon Mar 10 17:30:57 2008 -0700
     1.2 +++ b/Source/Grid.m	Wed Mar 12 15:51:32 2008 -0700
     1.3 @@ -67,9 +67,14 @@
     1.4  {
     1.5      CGFloat spacing = floor(MIN( (frame.size.width -2)/(CGFloat)nColumns,
     1.6                                 (frame.size.height-2)/(CGFloat)nRows) );
     1.7 +    CGSize size = CGSizeMake(nColumns*spacing+2, nRows*spacing+2);
     1.8 +    CGPoint position = frame.origin;
     1.9 +    position.x += round( (frame.size.width -size.width )/2.0 );
    1.10 +    position.y += round( (frame.size.height-size.height)/2.0 );
    1.11 +
    1.12      return [self initWithRows: nRows columns: nColumns
    1.13                        spacing: CGSizeMake(spacing,spacing)
    1.14 -                     position: frame.origin];
    1.15 +                     position: position];
    1.16  }
    1.17  
    1.18  
    1.19 @@ -187,6 +192,7 @@
    1.20  {
    1.21      // Custom CALayer drawing implementation. Delegates to the cells to draw themselves
    1.22      // in me; this is more efficient than having each cell have its own drawing.
    1.23 +    [super drawInContext: ctx];
    1.24      if( _cellColor ) {
    1.25          CGContextSetFillColorWithColor(ctx, _cellColor);
    1.26          [self drawCellsInContext: ctx fill: YES];
    1.27 @@ -409,6 +415,7 @@
    1.28  - (void) setHighlighted: (BOOL)highlighted
    1.29  {
    1.30      [super setHighlighted: highlighted];
    1.31 +    self.cornerRadius = self.bounds.size.width/2.0;
    1.32      self.borderWidth = (highlighted ?6 :0);
    1.33  }
    1.34