subclass NSSlider and NSSliderCell
subclass NSSlider and NSSliderCell
- Subject: subclass NSSlider and NSSliderCell
- From: "Christoph Teschner" <email@hidden>
- Date: Wed, 26 Apr 2006 11:17:04 +0200
Hi,
I want to customize an NSSlider, so that the knob displays a picture.
Everything works fine except the size of the knob. Only a part of the
picture is displayed if it is bigger than the original knob. As long aus the
picture is smaller everything works fine.
I know that I have to use sizeToFit. But I have no idea if I should use it
in my sliderCell or in my slider and how this method should exactly look
like.
Any help would be great.
Thanks
Christoph
Here is what I have implemented so far:
@implementation MySliderCell
-(id)init {
self = [super init];
_knobOn = [[NSImage imageNamed:@"green.tiff" ]retain];
return self;
}
- (void)drawKnob:(NSRect)knobRect {
NSImage * knob = _knobOn;
[[self controlView] lockFocus];
[knob compositeToPoint:NSMakePoint(knobRect.origin.x,knobRect.origin.y
+knobRect.size.height) operation:NSCompositeSourceOver];
[[self controlView] unlockFocus];
}
@end
@implementation MySlider
- (void)awakeFromNib {
NSCell *oldCell = [self cell];
MySliderCell * aCell = [[[MySliderCell alloc] init] retain];
[aCell setControlSize:NSSmallControlSize];
[aCell setAction:[oldCell action]];
[aCell setTarget:[oldCell target]];
[self setCell:aCell];
[aCell release];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden