mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:50:48 +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
e42a857b66
commit
ec9518eb66
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>
|
2010-02-01 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/GSThemeDrawing.m: Preliminary support for themeing the window
|
* Source/GSThemeDrawing.m: Preliminary support for themeing the window
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
#import "AppKit/NSApplication.h"
|
#import "AppKit/NSApplication.h"
|
||||||
#import "AppKit/NSControl.h"
|
#import "AppKit/NSControl.h"
|
||||||
#import "AppKit/NSEvent.h"
|
#import "AppKit/NSEvent.h"
|
||||||
|
@ -73,8 +74,8 @@
|
||||||
[self setWraps: NO];
|
[self setWraps: NO];
|
||||||
_autorepeat = YES;
|
_autorepeat = YES;
|
||||||
_valueWraps = YES;
|
_valueWraps = YES;
|
||||||
_maxValue = 59;
|
[self setMaxValue: 59];
|
||||||
_minValue = 0;
|
[self setMinValue: 0];
|
||||||
_increment = 1;
|
_increment = 1;
|
||||||
|
|
||||||
highlightUp = NO;
|
highlightUp = NO;
|
||||||
|
@ -91,6 +92,8 @@
|
||||||
- (void) setMaxValue: (double)maxValue
|
- (void) setMaxValue: (double)maxValue
|
||||||
{
|
{
|
||||||
_maxValue = maxValue;
|
_maxValue = maxValue;
|
||||||
|
if ([self doubleValue] > _maxValue)
|
||||||
|
[self setDoubleValue: _maxValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (double) minValue
|
- (double) minValue
|
||||||
|
@ -101,6 +104,31 @@
|
||||||
- (void) setMinValue: (double)minValue
|
- (void) setMinValue: (double)minValue
|
||||||
{
|
{
|
||||||
_minValue = 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
|
- (double) increment
|
||||||
|
@ -391,13 +419,6 @@
|
||||||
else if (newValue < minValue)
|
else if (newValue < minValue)
|
||||||
newValue = newValue + maxValue - minValue + 1;
|
newValue = newValue + maxValue - minValue + 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (newValue > maxValue)
|
|
||||||
newValue = maxValue;
|
|
||||||
else if (newValue < minValue)
|
|
||||||
newValue = minValue;
|
|
||||||
}
|
|
||||||
[self setDoubleValue: newValue];
|
[self setDoubleValue: newValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,13 +437,6 @@
|
||||||
else if (newValue < minValue)
|
else if (newValue < minValue)
|
||||||
newValue = newValue + maxValue - minValue + 1;
|
newValue = newValue + maxValue - minValue + 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (newValue > maxValue)
|
|
||||||
newValue = maxValue;
|
|
||||||
else if (newValue < minValue)
|
|
||||||
newValue = minValue;
|
|
||||||
}
|
|
||||||
[self setDoubleValue: newValue];
|
[self setDoubleValue: newValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue