Re: NSSliderCell private variables
Re: NSSliderCell private variables
- Subject: Re: NSSliderCell private variables
- From: "John C. Randolph" <email@hidden>
- Date: Wed, 13 Feb 2002 00:03:48 -0800
On Tuesday, February 12, 2002, at 12:14 AM, Cyril Godefroy wrote:
John,
in the code you demonstrate, there is no cell for the knob.
Right. This is a subclass which overrides NSSliderCell's
-drawKnob: method. No extra cell required.
If I want to draw something else than a rect, for example an
image, I'd have to add a cell to my subclass.
You can draw an image without having to put it in another cell.
The code below could just as easily be:
- (void) drawKnob:(NSRect) knobRect
{
[myKnobImage drawInRect:knobRect];
}
Assuming that you've created and initialized 'myKnobImage' somewhere.
Do you mean that the knob as it is now coded in NSSliderCell is
just a NSRectFill?
No, the code to draw the knob *in this subclass* is just a rect
fill. The code in NSSliderCell draws a nice Aqua gumdrop knob,
which some talented graphic designer created at great expense
and inconvenience ;-)
I guess not (didn't look at a NSSlider recently though ;-).
I'd believe it's a NSButton or something like that.
An NSSliderCell does all its own drawing. It doesn't contain an
NSButton. Not all things that look like buttons are
NSButtonCell instances..
If you want to further customize an NSSliderCell, you can
override -drawWithFrame:inView:
-jcr
Thanks for the precision though.
Cyril
On Monday, February 11, 2002, at 09:01 PM, John C. Randolph wrote:
Cyril,
There's no ned to redo the whole class. All you need to do to
customize the knob in an NSSliderCell subclass is override
-drawKnob:, e.g:
@implementation GradientSliderCell
- (void) drawKnob:(NSRect) knobRect
{
[[[NSColor blueColor] blendedColorWithFraction:[self floatValue]
ofColor:[NSColor greenColor]] set];
NSRectFill(knobRect);
}
@end
The slider in this case has the range 0.0 to 1.0.
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.