Re: Preventing NSSlider bar from drawing
Re: Preventing NSSlider bar from drawing
- Subject: Re: Preventing NSSlider bar from drawing
- From: Michael Watson <email@hidden>
- Date: Wed, 17 Jan 2007 10:17:15 -0500
Overriding private methods is unsound design. Ditto accessing
private variables.
Well, it seems that the slider is not using -
drawBarInside:flipped:, since overwriting it does not work as
expected. So this is a bug and I have no problem working around it
by using "unsound design". I'll just make sure that
_usesCustomTrackImage is actually implemented before replacing it.
And should it go away in the future, I would hope that NSSlider had
been fixed ...
There's nothing broken about NSSlider. -drawBarInside:flipped: is
most certainly used, because I'm doing it in one of my control
subclasses. I'm not sure what you're doing, but as I said in a
previous e-mail, this works for me:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
// calculate knob frame
cellFrame = [self drawingRectForBounds:cellFrame];
[self drawBarInside:cellFrame isFlipped:[controlView isFlipped]];
[self drawKnob:yourKnobFrame];
}
- (void)drawKnob:(NSRect)knobRect
{
// draw your knob
}
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped
{
// draw your bar
}
Note that you may need to lock focus on your destination control view
before drawing.
--
m-s
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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