Hi,

I want to display a cell like mail's message count in a table view but with a fixed size and centered on both axes. I've created a NSTextFieldCell subclass and its doing fine except that it draws in the first row only, which could mean I'm drawing at the wrong coordinates. Obviously, this is not what I want :-)

Drawing without modifying the cellFrame (commenting out the first 2 lines and changing the argument to "frame") produces the expected result: a nice oval in every row but filling the entire cell space...

Any help, pointer to doc or tutorial are welcome.

Thanks,

Andre Masse


- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
        // we want 36x20
        CGFloat y = cellFrame.size.height/2.0 - 10.0;
        NSRect frame = NSMakeRect(cellFrame.origin.x, y, 36.0, 20.0);
        
        CGFloat lineWidth = 1.5;
        
        frame = NSInsetRect(frame, lineWidth, lineWidth);
        
        //draw frame
        CGFloat radius = NSHeight(frame)*0.45;
        
NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithRoundedRect:frame xRadius:radius yRadius:radius];
        [backgroundPath setLineWidth:lineWidth];
        [frameColor set];
        [backgroundPath stroke];

        // fill it
        frame.size.height -= 2;
        frame.origin.y += 1;
        frame =  NSInsetRect(frame, 1, 0);
                
        [fillColor set];
[[NSBezierPath bezierPathWithRoundedRect:frame xRadius:radius yRadius:radius] fill];
        
        // draw text
        [super drawWithFrame:frame inView:controlView];

        
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to