• 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
Subclassing NSLevelIndicatorCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing NSLevelIndicatorCell


  • Subject: Subclassing NSLevelIndicatorCell
  • From: Todd Freese <email@hidden>
  • Date: Thu, 28 Jun 2007 05:56:32 -0500

I am having troubles subclassing NSLevelIndicatorCell. I want to add a text percentage display in the middle of the bar graph display. This subclass is displayed in an NSTableView. My thoughts are to subclass NSLevelIndicatorCell and override the drawWithFrame method. However, my call to super does not seem to be working as my text is displayed, but bar graph is not. Here is my code:

@implementation FSLevelIndicatorCell

- (id)init
{
	self = [super init];
	return self;
}

- (void)dealloc
{
	[super dealloc];
}

- (id)copy
{
    return [super copy];
}

- (id)copyWithZone:(NSZone *)zone
{
    id newCopy = [super copyWithZone:zone];
    return newCopy;
}

- (void)drawWithFrame:(NSRect)inFrame inView:(NSView*)inView
{
// Have super draw the existing bar graph.
[super drawWithFrame:inFrame inView:inView];

// Now draw my text on top of it.
NSMutableDictionary *attrs = [NSMutableDictionary dictionaryWithDictionary:[[self attributedStringValue] attributesAtIndex:0 effectiveRange:NULL]];


NSRect centeredRect = inFrame;
centeredRect.size = [[self stringValue] sizeWithAttributes:attrs];
centeredRect.origin.x += ((inFrame.size.width - centeredRect.size.width) / 2.0);
centeredRect.origin.y = ((inFrame.size.height - centeredRect.size.height) / 2.0);

[attrs setValue:[NSColor blackColor] forKey:@"NSColor"];
[[self stringValue] drawInRect:centeredRect withAttributes:attrs];
}
_______________________________________________


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: Subclassing NSLevelIndicatorCell
      • From: "Adam R. Maxwell" <email@hidden>
  • Prev by Date: Re: CoreData predicate programming
  • Next by Date: Re: Guidance for learner
  • Previous by thread: crash in NSNavOutlineDelegate (Martin Wierschin)
  • Next by thread: Re: Subclassing NSLevelIndicatorCell
  • Index(es):
    • Date
    • Thread