Fix set/tage values

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5641 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-12-29 07:14:00 +00:00
parent a95ce979e7
commit 7bb001fa02
3 changed files with 125 additions and 69 deletions

View file

@ -1,3 +1,9 @@
Wed Dec 29 7:11:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSSliderCell.m: Fix so that setting and taking values from the
cell work properly - removed unused ivar.
* Headers/AppKit/NSSliderCell.h: removed unused ivar.
1999-12-29 David Lazaro <khelekir@encomix.es>
Changed name of function so GNUstep GUI library can be linked again.

View file

@ -35,52 +35,51 @@
@interface NSSliderCell : NSActionCell <NSCoding>
{
float _minValue;
float _maxValue;
float _floatValue;
float _altIncrementValue;
id _titleCell;
id _knobCell;
NSRect _trackRect;
BOOL _isVertical;
float _minValue;
float _maxValue;
float _altIncrementValue;
id _titleCell;
id _knobCell;
NSRect _trackRect;
BOOL _isVertical;
}
/* Asking about the cell's behavior */
- (double)altIncrementValue;
+ (BOOL)prefersTrackingUntilMouseUp;
- (NSRect)trackRect;
- (double) altIncrementValue;
+ (BOOL) prefersTrackingUntilMouseUp;
- (NSRect) trackRect;
/* Changing the cell's behavior */
- (void)setAltIncrementValue:(double)increment;
- (void) setAltIncrementValue: (double)increment;
/* Displaying the cell */
- (NSRect)knobRectFlipped:(BOOL)flipped;
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped;
- (void)drawKnob;
- (void)drawKnob:(NSRect)knobRect;
- (NSRect) knobRectFlipped: (BOOL)flipped;
- (void) drawBarInside: (NSRect)rect flipped: (BOOL)flipped;
- (void) drawKnob;
- (void) drawKnob: (NSRect)knobRect;
/* Asking about the cell's appearance */
- (float)knobThickness;
- (int)isVertical;
- (NSString*)title;
- (id)titleCell;
- (NSColor*)titleColor;
- (NSFont*)titleFont;
- (float) knobThickness;
- (int) isVertical;
- (NSString*) title;
- (id) titleCell;
- (NSColor*) titleColor;
- (NSFont*) titleFont;
/* Changing the cell's appearance */
- (void)setKnobThickness:(float)thickness;
- (void)setTitle:(NSString*)title;
- (void)setTitleCell:(NSCell*)aCell;
- (void)setTitleColor:(NSColor*)color;
- (void)setTitleFont:(NSFont*)font;
- (void) setKnobThickness: (float)thickness;
- (void) setTitle: (NSString*)title;
- (void) setTitleCell: (NSCell*)aCell;
- (void) setTitleColor: (NSColor*)color;
- (void) setTitleFont: (NSFont*)font;
/* Asking about the value limits */
- (double)minValue;
- (double)maxValue;
- (double) minValue;
- (double) maxValue;
/* Changing the value limits */
- (void)setMinValue:(double)aDouble;
- (void)setMaxValue:(double)aDouble;
- (void) setMinValue: (double)aDouble;
- (void) setMaxValue: (double)aDouble;
@end

View file

@ -1,10 +1,12 @@
/*
NSSliderCell.m
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996,1999 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: September 1997
Rewrite: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Date: 1999
This file is part of the GNUstep GUI Library.
@ -44,7 +46,6 @@
_isVertical = -1;
_minValue = 0;
_maxValue = 1;
_floatValue = 0;
_cell.is_bordered = YES;
_cell.is_bezeled = YES;
@ -65,16 +66,6 @@
return YES;
}
- (void) setFloatValue: (float)aFloat
{
if (aFloat < _minValue)
_floatValue = _minValue;
else if (aFloat > _maxValue)
_floatValue = _maxValue;
else
_floatValue = aFloat;
}
- (void) drawBarInside: (NSRect)rect flipped: (BOOL)flipped
{
[[NSColor scrollBarColor] set];
@ -86,12 +77,12 @@
NSImage* image = [_knobCell image];
NSSize size;
NSPoint origin;
float floatValue;
float floatValue = [self floatValue];
if (_isVertical && flipped)
_floatValue = _maxValue + _minValue - _floatValue;
floatValue = _maxValue + _minValue - floatValue;
floatValue = (_floatValue - _minValue) / (_maxValue - _minValue);
floatValue = (floatValue - _minValue) / (_maxValue - _minValue);
size = [image size];
@ -186,38 +177,98 @@
- (void) setMinValue: (double)aDouble
{
_minValue = aDouble;
if (_floatValue < _minValue)
_floatValue = _minValue;
}
- (void) setMaxValue: (double)aDouble
{
_maxValue = aDouble;
if (_floatValue > _maxValue)
_floatValue = _maxValue;
}
- (id) titleCell { return _titleCell; }
- (NSColor*) titleColor { return [_titleCell textColor]; }
- (NSFont*) titleFont { return [_titleCell font]; }
- (void) setTitle: (NSString*)title { [_titleCell setStringValue: title]; }
- (NSString*) title { return [_titleCell stringValue]; }
- (void) setTitleCell: (NSCell*)aCell { ASSIGN(_titleCell, aCell); }
- (void) setTitleColor: (NSColor*)color { [_titleCell setTextColor: color]; }
- (void) setTitleFont: (NSFont*)font { [_titleCell setFont: font]; }
- (int) isVertical { return _isVertical; }
- (double) altIncrementValue { return _altIncrementValue; }
+ (BOOL) prefersTrackingUntilMouseUp { return YES; }
- (NSRect) trackRect { return _trackRect; }
- (double) minValue { return _minValue; }
- (double) maxValue { return _maxValue; }
- (float) floatValue { return _floatValue; }
- (id) titleCell
{
return _titleCell;
}
- (NSColor*) titleColor
{
return [_titleCell textColor];
}
- (NSFont*) titleFont
{
return [_titleCell font];
}
- (void) setTitle: (NSString*)title
{
[_titleCell setStringValue: title];
}
- (NSString*) title
{
return [_titleCell stringValue];
}
- (void) setTitleCell: (NSCell*)aCell
{
ASSIGN(_titleCell, aCell);
}
- (void) setTitleColor: (NSColor*)color
{
[_titleCell setTextColor: color];
}
- (void) setTitleFont: (NSFont*)font
{
[_titleCell setFont: font];
}
- (int) isVertical
{
return _isVertical;
}
- (double) altIncrementValue
{
return _altIncrementValue;
}
+ (BOOL) prefersTrackingUntilMouseUp
{
return YES;
}
- (NSRect) trackRect
{
return _trackRect;
}
- (double) minValue
{
return _minValue;
}
- (double) maxValue
{
return _maxValue;
}
- (float) floatValue
{
float aFloat = [super floatValue];
if (aFloat < _minValue)
return _minValue;
else if (aFloat > _maxValue)
return _maxValue;
return aFloat;
}
- (id) initWithCoder: (NSCoder*)decoder
{
self = [super initWithCoder: decoder];
[decoder decodeValuesOfObjCTypes: "ffffi",
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue, &_isVertical];
[decoder decodeValuesOfObjCTypes: "fffi",
&_minValue, &_maxValue, &_altIncrementValue, &_isVertical];
[decoder decodeValueOfObjCType: @encode(id) at: &_titleCell];
[decoder decodeValueOfObjCType: @encode(id) at: &_knobCell];
return self;
@ -226,8 +277,8 @@
- (void) encodeWithCoder: (NSCoder*)coder
{
[super encodeWithCoder: coder];
[coder encodeValuesOfObjCTypes: "ffffi",
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue, &_isVertical];
[coder encodeValuesOfObjCTypes: "fffi",
&_minValue, &_maxValue, &_altIncrementValue, &_isVertical];
[coder encodeValueOfObjCType: @encode(id) at: &_titleCell];
[coder encodeValueOfObjCType: @encode(id) at: &_knobCell];
}