From 5d2adf79144724780b85bbbcddaea04850d97e63 Mon Sep 17 00:00:00 2001 From: arobert Date: Sat, 5 Mar 2005 16:08:30 +0000 Subject: [PATCH] NSScroller: calculate buttonsWidth dyamically based on +scrollerWidth git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20851 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSScroller.m | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 99704280b..9c5ecea94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-03-05 Adrian Robert + + * Source/NSScroller.m (-checkSpaceForParts, -rectForPart:) Calculate + buttonsWidth variable dynamically based on +scrollerWidth (supports + width override by subclass). + 2005-03-05 10:53 Gregory John Casamento * Headers/AppKit/NSDataLink.h diff --git a/Source/NSScroller.m b/Source/NSScroller.m index 5719ce0b5..4228dbbe4 100644 --- a/Source/NSScroller.m +++ b/Source/NSScroller.m @@ -57,7 +57,7 @@ static NSButtonCell* rightCell = nil; static NSButtonCell* knobCell = nil; static const float scrollerWidth = 18; -static const float buttonsWidth = 16; +static const float buttonsOffset = 2; // buttonsWidth = sw - buttonsOffset static NSColor *scrollBarColor = nil; @@ -73,6 +73,10 @@ static NSColor *scrollBarColor = nil; } } +/** + * Subclasses can override this to provide different scrollbar width. But + * you may need to also override -drawParts . + */ + (float) scrollerWidth { return scrollerWidth; @@ -266,6 +270,12 @@ static NSColor *scrollBarColor = nil; return [self initWithFrame: NSZeroRect]; } +/** + * Cache images for scroll arrows and knob. If you override +scrollerWidth + * you may need to override this as well (to provide images for the new + * width). However, if you do so, you must currently also override + * -drawArrow:highlight: and -drawKnob: . + */ - (void) drawParts { /* @@ -338,6 +348,7 @@ static NSColor *scrollBarColor = nil; { NSSize frameSize = _frame.size; float size = (_isHorizontal ? frameSize.width : frameSize.height); + int buttonsWidth = [isa scrollerWidth] - buttonsOffset; if (_arrowsPosition == NSScrollerArrowsNone) { @@ -911,6 +922,7 @@ static NSColor *scrollBarColor = nil; NSRect scrollerFrame = _frame; float x = 1, y = 1; float width, height; + float buttonsWidth = ([isa scrollerWidth] - buttonsOffset); float buttonsSize = 2 * buttonsWidth + 2; NSUsableScrollerParts usableParts; /*