Preventing default drawing of slider bar in custom NSSlider class
Preventing default drawing of slider bar in custom NSSlider class
- Subject: Preventing default drawing of slider bar in custom NSSlider class
- From: Ken Tozier <email@hidden>
- Date: Sat, 17 Mar 2007 16:01:19 -0400
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