Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Customize knob image of NSScroller



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.