Re: Preventing default drawing of slider bar in custom NSSlider class
Re: Preventing default drawing of slider bar in custom NSSlider class
- Subject: Re: Preventing default drawing of slider bar in custom NSSlider class
- From: Mikael Gransell <email@hidden>
- Date: Sat, 17 Mar 2007 21:16:43 +0100
Hi Ken
Check out this link for a solution and description of your problem.
http://www.cocoabuilder.com/archive/message/cocoa/2007/1/16/177288
Cheers,
Micke
On Mar 17, 2007, at 9:01 PM, Ken Tozier wrote:
Hi
I wrote a custom NSSlider and NSSliderCell, overrode the "drawKnob:"
and "drawBarInside:flipped:" of the NSSliderCell and got the stuff I
want to draw working correctly, but I'm still getting the default
slider bar behind my slider bar. I intentionally don't call the
NSSliderCell's superclass which I thought would do the trick, but
no luck. How can I get rid of the default?
Thanks for any help
Ken
Here's the slider bar draw method
- (void) drawBarInside:(NSRect) inRect
flipped:(BOOL) inFlipped
{
NSRect adjustedRect = NSMakeRect(inRect.origin.x +
10, 0, inRect.size.width - 20, inRect.size.height);
float rectHeight = inRect.size.height,
leftWidth = [gSliderTrackLeft size].width,
rightWidth = [gSliderTrackRight size].width,
centerWidth = adjustedRect.size.width -
leftWidth - rightWidth,
adjustedRight = adjustedRect.origin.x +
adjustedRect.size.width,
yOffset = (rectHeight -
DefaultSliderBarHeight) / 2;
NSRect leftRect =
NSMakeRect(adjustedRect.origin.x, adjustedRect.origin.y + yOffset,
leftWidth, DefaultSliderBarHeight),
rightRect = NSMakeRect(adjustedRight -
rightWidth, adjustedRect.origin.y + yOffset, rightWidth,
DefaultSliderBarHeight),
centerRect = NSMakeRect(leftRect.origin.x
+ leftRect.size.width, adjustedRect.origin.y + yOffset, centerWidth,
DefaultSliderBarHeight);
minXOrigin = 10;
maxXOrigin = adjustedRight;
[gSliderTrackLeft drawInRect: leftRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
[gSliderTrackCenter drawInRect: centerRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
[gSliderTrackRight drawInRect: rightRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
}
_______________________________________________
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
_______________________________________________
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