Customize knob image of NSScroller
Customize knob image of NSScroller
- Subject: Customize knob image of NSScroller
- From: Lorenzo <email@hidden>
- Date: Thu, 01 Nov 2007 22:59:36 +0100
I am trying to customize the knob's image of my horizontal NSScroller.
I would like to do something similar to iTunes. It seems that the image I
have to use is just one
[knobCell setImage:[NSImage imageNamed:@"icn_knob"]];
so I thought to set an image of a circle and that Cocoa should have split
that in 3 images:
a) the half a circle at the left side
b) a vertical line to be stretched horizontally in the middle
c) the half a circle at the right side.
So I did set an image of a circle, but I have seen that it gets stretched
along the width of the knob. Too bad.
Then I tried to set a 1 x 15 vertical line image, and I got a 1 x 15 line
over a gray rectangle. Too bad. I overrode these methods
- (void)drawParts
{
if (knobCell) return;
knobCell = [NSButtonCell new];
[knobCell setButtonType:NSMomentaryChangeButton];
[knobCell setImage:[NSImage imageNamed: @"icn_scroll_knob_m"]];
[knobCell setImagePosition:NSImageOnly];
}
- (void)drawKnob
{
NSRect rect = [self rectForPart: NSScrollerKnobSlot];
[[NSColor scrollBarColor] set];
NSRectFill(rect);
rect = [self rectForPart:NSScrollerKnob];
[knobCell drawWithFrame:rect inView:self];
}
What did I forget?
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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