• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Customize knob image of NSScroller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: NSAmimatablePropertyContainer property animation troubles...
  • Next by Date: Why is NSWindow's setCanBeVisibleOnAllSpaces: deprecated?
  • Previous by thread: Re: SecKeychainItemCopyContent for ppc on Leopard
  • Next by thread: Why is NSWindow's setCanBeVisibleOnAllSpaces: deprecated?
  • Index(es):
    • Date
    • Thread