Gap at top when subclassing NSScroller?
Gap at top when subclassing NSScroller?
- Subject: Gap at top when subclassing NSScroller?
- From: Keith Blount <email@hidden>
- Date: Sat, 26 Feb 2005 05:50:00 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hello,
I am attempting to subclass NSScroller for use in a
fullscreen textview/scrollview window, and I want an
old-school square look to it - just a simple black
background with a coloured rectangular knob and the
arrows, the whole thing with no more than two colours
(eg. black background with yellow knob and arrows).
On testing this out, I have achieved exactly what I
want for the most part, except that there is a gap of
a few pixels at the top of the scroller. The
rectangular scroll bar will simply not go all the way
to the top of the scroll slot - it stops a few pixels
short. This is probably to be expected, as if you look
at the defalt OS X NSScroller, there is a gap at the
top that is drawn as a silver "slot" that the blue
curved knob fits snugly into.
My question is, how do I get rid of this gap? It does
not look right when using a rectangular bar instead of
one with rounded ends... I cannot find any methods
that control this - I have tried overriding
rectForPart: to no avail.
Here is my test NSScroller subclass so far:
@implementation MyScroller
// Colour the knob slot black
- (void)drawRect:(NSRect)rect
{
[[NSColor blackColor] set];
[NSBezierPath fillRect:[self
rectForPart:NSScrollerKnobSlot]]; //rect];
[self drawKnob];
[self drawArrow:NSScrollerIncrementArrow
highlight:NO];
}
// Draws a square green knob
- (void)drawKnob
{
NSRect knobRect = [self rectForPart:NSScrollerKnob];
[[NSColor greenColor] set];
[NSBezierPath fillRect:knobRect];
}
// Draws two yellow and black boxes where the arrows
should be
- (void)drawArrow:(NSScrollerArrow)arrow
highlight:(BOOL)flag
{
NSRect arrowRect = [self
rectForPart:NSScrollerIncrementLine];
[[NSColor yellowColor] set];
[NSBezierPath fillRect:arrowRect];
arrowRect.origin.x += 1.0;
arrowRect.size.width -= 2.0;
arrowRect.origin.y += 2.0;
arrowRect.size.height -= 3.0;
[[NSColor blackColor] set];
[NSBezierPath fillRect:arrowRect];
arrowRect = [self
rectForPart:NSScrollerDecrementLine];
[[NSColor yellowColor] set];
[NSBezierPath fillRect:arrowRect];
arrowRect.origin.x += 1.0;
arrowRect.size.width -= 2.0;
arrowRect.origin.y += 1.0;
arrowRect.size.height -= 1.0;
[[NSColor blackColor] set];
[NSBezierPath fillRect:arrowRect];
}
@end
Many thanks for any help or suggestions,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
_______________________________________________
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