• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Drawing NSTextFieldCell subclass in table view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing NSTextFieldCell subclass in table view


  • Subject: Drawing NSTextFieldCell subclass in table view
  • From: Andre Masse <email@hidden>
  • Date: Sat, 13 Dec 2008 17:11:52 -0500

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Drawing NSTextFieldCell subclass in table view
      • From: Patrick Mau <email@hidden>
    • Re: Drawing NSTextFieldCell subclass in table view
      • From: Iceberg-Dev <email@hidden>
  • Prev by Date: [JOB] P/T iPhone Game Developer, NYC
  • Next by Date: Re: Live updating NSPredicateEditorRowTemplate?
  • Previous by thread: [JOB] P/T iPhone Game Developer, NYC
  • Next by thread: Re: Drawing NSTextFieldCell subclass in table view
  • Index(es):
    • Date
    • Thread