Re: drawKnob in NSSliderCell subclass
Re: drawKnob in NSSliderCell subclass
- Subject: Re: drawKnob in NSSliderCell subclass
- From: Lon Giese <email@hidden>
- Date: Fri, 19 May 2006 19:38:21 -0700
An easier thing to do if you're not too worried about the knob being
positioned exactly correct is in:
[knobImage compositeToPoint:NSMakePoint(knobRect.origin.x
,knobRect.origin.y+knobRect.size.height)
operation:NSCompositeSourceOver];
do a bounds check, if the knob is not positioned within the frame then
move it over a bit so it is...
On May 19, 2006, at 7:26 PM, Lon Giese wrote:
The knob is getting clipped by the sliders frame... you have a
horizontal slider from the looks of things
When the knob travels to each end it is so thick it gets clipped at
each end of the slider by the frame.
making the frame wider doesn't help cause the sliding slot is made
equally longer...
it looks like this should work but I tried it and it does not... no
change. The docs say the method was deprecated but there is no
replacement method., probably cause it does not work. You can see on a
normal slider the knob stops at the ends of the frame cause the slider
takes into account the thickness of the knob...
int knobWidth = [[NSImage imageNamed:@"square.tif"] size].width;
[self setKnobThickness:knobWidth];
maybe malcolm knows why this method was deprecated and what to do in
place of it
Im not really an expert on this stuff, but you might try creating a
seperate view to draw the knob in that lays over the top of the
sliders view, make the knob's view wider than the slider's view by the
width of the knob and offset by half the width of the knob. you'll
have to play with the math a little to get the rects right, but I have
a feeling that might work... It will be pretty complicated, but you'll
figure it out...
On May 19, 2006, at 6:18 PM, Christoph Teschner wrote:
-(id)init {
self = [super init];
knobImage = [[NSImage imageNamed:@"square.tif" ]retain];
return self;
}
- (void)drawKnob:(NSRect)knobRect{
[[self controlView] lockFocus];
[knobImage compositeToPoint:NSMakePoint(knobRect.origin.x
,knobRect.origin.y+knobRect.size.height)
operation:NSCompositeSourceOver];
[[self controlView] unlockFocus];
}
- (NSRect)knobRectFlipped:(BOOL)flipped{
NSRect myRect = [super knobRectFlipped:flipped];
myRect.origin.y -= ([knobImage size].height - myRect.size.height) /
2;
myRect.origin.x -= ([knobImage size].width - myRect.size.width) / 2;
myRect.size = [knobImage size];
return myRect;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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