git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3942 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-03-16 22:43:34 +00:00
parent ce7ebf5f45
commit 23dee081a5
2 changed files with 218 additions and 202 deletions

View file

@ -49,10 +49,17 @@ static Class cellClass;
}
}
+ (void)setCellClass:(Class)class { cellClass = class; }
+ (Class)cellClass { return cellClass; }
+ (void) setCellClass: (Class)class
{
cellClass = class;
}
- initWithFrame:(NSRect)frameRect
+ (Class) cellClass
{
return cellClass;
}
- (id) initWithFrame: (NSRect)frameRect
{
NSSliderCell* theCell = [[[isa cellClass] new] autorelease];
@ -169,16 +176,20 @@ float maxValue = [theCell maxValue];
float floatValue = 0;
float position;
if (isVertical)
{ // Adjust the point to lie inside the knob slot. We don't
// Adjust the point to lie inside the knob slot. We don't
// have to worry whether the view is flipped or not.
if (isVertical)
{
if (point.y < slotRect.origin.y + knobRect.size.height / 2)
{
position = slotRect.origin.y + knobRect.size.height / 2;
else
if (point.y > slotRect.origin.y + slotRect.size.height
}
else if (point.y > slotRect.origin.y + slotRect.size.height
- knobRect.size.height / 2)
{
position = slotRect.origin.y + slotRect.size.height
- knobRect.size.height / 2;
}
else
position = point.y;
// Compute the float value
@ -188,18 +199,21 @@ float position;
floatValue = 1 - floatValue;
}
else
{ // Adjust the point to lie inside the knob slot
{
if (point.x < slotRect.origin.x + knobRect.size.width / 2)
{
position = slotRect.origin.x + knobRect.size.width / 2;
else
if (point.x > slotRect.origin.x + slotRect.size.width
}
else if (point.x > slotRect.origin.x + slotRect.size.width
- knobRect.size.width / 2)
{
position = slotRect.origin.x + slotRect.size.width
- knobRect.size.width / 2;
}
else
position = point.x;
// Compute the float value
// given the knob size
// Compute the float value given the knob size
floatValue = (position - (slotRect.origin.x + knobRect.size.width / 2))
/ (slotRect.size.width - knobRect.size.width);
}
@ -255,8 +269,8 @@ SEL action = [theCell action];
}
}
}
// If the control is not continuous send
if (!isContinuous) // the action at the end of the drag
// If the control is not continuous send the action at the end of the drag
if (!isContinuous)
[target performSelector: action withObject: self];
[NSEvent stopPeriodicEvents];
}
@ -271,8 +285,8 @@ NSRect rect;
rect = [theCell knobRectFlipped: [self isFlipped]];
if (![self mouse: location inRect: rect])
{ // Mouse is not on the knob, move
// the knob to the mouse position
{
// Mouse is not on the knob, move the knob to the mouse position
float floatValue = [self _floatValueForMousePoint: location
knobRect: rect];

View file

@ -37,7 +37,7 @@
@implementation NSSliderCell
- init
- (id) init
{
[self initImageCell: nil];
_altIncrementValue = -1;
@ -60,6 +60,11 @@
[super dealloc];
}
- (BOOL) isFliped
{
return YES;
}
- (void) setFloatValue: (float)aFloat
{
if (aFloat < _minValue)
@ -71,12 +76,9 @@
}
- (void) drawBarInside: (NSRect)rect flipped: (BOOL)flipped
{ // not per spec FIX ME
if ([self image])
return;
[[NSColor darkGrayColor] set];
NSRectFill(rect); // draw the bar
{
[[NSColor scrollBarColor] set];
NSRectFill(rect);
}
- (NSRect) knobRectFlipped: (BOOL)flipped