mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Fix NSStepperCell min/max clamping behaviour (same fix as the one to NSSliderCell I made a while ago)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29457 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
539223a674
commit
96fe347c5a
2 changed files with 35 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-02-01 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSStepperCell.m: Correct clamping behaviour as I did to
|
||||
NSSliderCell earlier.
|
||||
|
||||
2010-02-01 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m: Preliminary support for themeing the window
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import <Foundation/NSValue.h>
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSControl.h"
|
||||
#import "AppKit/NSEvent.h"
|
||||
|
@ -73,8 +74,8 @@
|
|||
[self setWraps: NO];
|
||||
_autorepeat = YES;
|
||||
_valueWraps = YES;
|
||||
_maxValue = 59;
|
||||
_minValue = 0;
|
||||
[self setMaxValue: 59];
|
||||
[self setMinValue: 0];
|
||||
_increment = 1;
|
||||
|
||||
highlightUp = NO;
|
||||
|
@ -91,6 +92,8 @@
|
|||
- (void) setMaxValue: (double)maxValue
|
||||
{
|
||||
_maxValue = maxValue;
|
||||
if ([self doubleValue] > _maxValue)
|
||||
[self setDoubleValue: _maxValue];
|
||||
}
|
||||
|
||||
- (double) minValue
|
||||
|
@ -101,6 +104,31 @@
|
|||
- (void) setMinValue: (double)minValue
|
||||
{
|
||||
_minValue = minValue;
|
||||
if ([self doubleValue] < _minValue)
|
||||
[self setDoubleValue: _minValue];
|
||||
}
|
||||
|
||||
- (void) setObjectValue: (id)anObject
|
||||
{
|
||||
// NOTE: valueWraps has no effect on setObjectValue:
|
||||
// FIXME: Copied from NSSliderCell.. can we share the code somehow?
|
||||
|
||||
// If the provided object doesn't respond to doubeValue, or our minValue
|
||||
// is greater than our maxValue, we set our value to our minValue
|
||||
// (this arbitrary choice matches OS X)
|
||||
if ([anObject respondsToSelector: @selector(doubleValue)] == NO ||
|
||||
_minValue > _maxValue)
|
||||
[super setObjectValue: [NSNumber numberWithDouble: _minValue]];
|
||||
else
|
||||
{
|
||||
double aDouble = [anObject doubleValue];
|
||||
if (aDouble < _minValue)
|
||||
[super setObjectValue: [NSNumber numberWithDouble: _minValue]];
|
||||
else if (aDouble > _maxValue)
|
||||
[super setObjectValue: [NSNumber numberWithDouble: _maxValue]];
|
||||
else
|
||||
[super setObjectValue: anObject];
|
||||
}
|
||||
}
|
||||
|
||||
- (double) increment
|
||||
|
@ -391,13 +419,6 @@
|
|||
else if (newValue < minValue)
|
||||
newValue = newValue + maxValue - minValue + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newValue > maxValue)
|
||||
newValue = maxValue;
|
||||
else if (newValue < minValue)
|
||||
newValue = minValue;
|
||||
}
|
||||
[self setDoubleValue: newValue];
|
||||
}
|
||||
|
||||
|
@ -416,13 +437,6 @@
|
|||
else if (newValue < minValue)
|
||||
newValue = newValue + maxValue - minValue + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newValue > maxValue)
|
||||
newValue = maxValue;
|
||||
else if (newValue < minValue)
|
||||
newValue = minValue;
|
||||
}
|
||||
[self setDoubleValue: newValue];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue