mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:00:46 +00:00
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:
parent
a314803824
commit
a43992c7c0
3 changed files with 125 additions and 69 deletions
|
@ -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>
|
1999-12-29 David Lazaro <khelekir@encomix.es>
|
||||||
|
|
||||||
Changed name of function so GNUstep GUI library can be linked again.
|
Changed name of function so GNUstep GUI library can be linked again.
|
||||||
|
|
|
@ -35,52 +35,51 @@
|
||||||
|
|
||||||
@interface NSSliderCell : NSActionCell <NSCoding>
|
@interface NSSliderCell : NSActionCell <NSCoding>
|
||||||
{
|
{
|
||||||
float _minValue;
|
float _minValue;
|
||||||
float _maxValue;
|
float _maxValue;
|
||||||
float _floatValue;
|
float _altIncrementValue;
|
||||||
float _altIncrementValue;
|
id _titleCell;
|
||||||
id _titleCell;
|
id _knobCell;
|
||||||
id _knobCell;
|
NSRect _trackRect;
|
||||||
NSRect _trackRect;
|
BOOL _isVertical;
|
||||||
BOOL _isVertical;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Asking about the cell's behavior */
|
/* Asking about the cell's behavior */
|
||||||
- (double)altIncrementValue;
|
- (double) altIncrementValue;
|
||||||
+ (BOOL)prefersTrackingUntilMouseUp;
|
+ (BOOL) prefersTrackingUntilMouseUp;
|
||||||
- (NSRect)trackRect;
|
- (NSRect) trackRect;
|
||||||
|
|
||||||
/* Changing the cell's behavior */
|
/* Changing the cell's behavior */
|
||||||
- (void)setAltIncrementValue:(double)increment;
|
- (void) setAltIncrementValue: (double)increment;
|
||||||
|
|
||||||
/* Displaying the cell */
|
/* Displaying the cell */
|
||||||
- (NSRect)knobRectFlipped:(BOOL)flipped;
|
- (NSRect) knobRectFlipped: (BOOL)flipped;
|
||||||
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped;
|
- (void) drawBarInside: (NSRect)rect flipped: (BOOL)flipped;
|
||||||
- (void)drawKnob;
|
- (void) drawKnob;
|
||||||
- (void)drawKnob:(NSRect)knobRect;
|
- (void) drawKnob: (NSRect)knobRect;
|
||||||
|
|
||||||
/* Asking about the cell's appearance */
|
/* Asking about the cell's appearance */
|
||||||
- (float)knobThickness;
|
- (float) knobThickness;
|
||||||
- (int)isVertical;
|
- (int) isVertical;
|
||||||
- (NSString*)title;
|
- (NSString*) title;
|
||||||
- (id)titleCell;
|
- (id) titleCell;
|
||||||
- (NSColor*)titleColor;
|
- (NSColor*) titleColor;
|
||||||
- (NSFont*)titleFont;
|
- (NSFont*) titleFont;
|
||||||
|
|
||||||
/* Changing the cell's appearance */
|
/* Changing the cell's appearance */
|
||||||
- (void)setKnobThickness:(float)thickness;
|
- (void) setKnobThickness: (float)thickness;
|
||||||
- (void)setTitle:(NSString*)title;
|
- (void) setTitle: (NSString*)title;
|
||||||
- (void)setTitleCell:(NSCell*)aCell;
|
- (void) setTitleCell: (NSCell*)aCell;
|
||||||
- (void)setTitleColor:(NSColor*)color;
|
- (void) setTitleColor: (NSColor*)color;
|
||||||
- (void)setTitleFont:(NSFont*)font;
|
- (void) setTitleFont: (NSFont*)font;
|
||||||
|
|
||||||
/* Asking about the value limits */
|
/* Asking about the value limits */
|
||||||
- (double)minValue;
|
- (double) minValue;
|
||||||
- (double)maxValue;
|
- (double) maxValue;
|
||||||
|
|
||||||
/* Changing the value limits */
|
/* Changing the value limits */
|
||||||
- (void)setMinValue:(double)aDouble;
|
- (void) setMinValue: (double)aDouble;
|
||||||
- (void)setMaxValue:(double)aDouble;
|
- (void) setMaxValue: (double)aDouble;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
/*
|
/*
|
||||||
NSSliderCell.m
|
NSSliderCell.m
|
||||||
|
|
||||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
Copyright (C) 1996,1999 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||||
Date: September 1997
|
Date: September 1997
|
||||||
|
Rewrite: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
Date: 1999
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -44,7 +46,6 @@
|
||||||
_isVertical = -1;
|
_isVertical = -1;
|
||||||
_minValue = 0;
|
_minValue = 0;
|
||||||
_maxValue = 1;
|
_maxValue = 1;
|
||||||
_floatValue = 0;
|
|
||||||
_cell.is_bordered = YES;
|
_cell.is_bordered = YES;
|
||||||
_cell.is_bezeled = YES;
|
_cell.is_bezeled = YES;
|
||||||
|
|
||||||
|
@ -65,16 +66,6 @@
|
||||||
return YES;
|
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
|
- (void) drawBarInside: (NSRect)rect flipped: (BOOL)flipped
|
||||||
{
|
{
|
||||||
[[NSColor scrollBarColor] set];
|
[[NSColor scrollBarColor] set];
|
||||||
|
@ -86,12 +77,12 @@
|
||||||
NSImage* image = [_knobCell image];
|
NSImage* image = [_knobCell image];
|
||||||
NSSize size;
|
NSSize size;
|
||||||
NSPoint origin;
|
NSPoint origin;
|
||||||
float floatValue;
|
float floatValue = [self floatValue];
|
||||||
|
|
||||||
if (_isVertical && flipped)
|
if (_isVertical && flipped)
|
||||||
_floatValue = _maxValue + _minValue - _floatValue;
|
floatValue = _maxValue + _minValue - floatValue;
|
||||||
|
|
||||||
floatValue = (_floatValue - _minValue) / (_maxValue - _minValue);
|
floatValue = (floatValue - _minValue) / (_maxValue - _minValue);
|
||||||
|
|
||||||
size = [image size];
|
size = [image size];
|
||||||
|
|
||||||
|
@ -186,38 +177,98 @@
|
||||||
- (void) setMinValue: (double)aDouble
|
- (void) setMinValue: (double)aDouble
|
||||||
{
|
{
|
||||||
_minValue = aDouble;
|
_minValue = aDouble;
|
||||||
if (_floatValue < _minValue)
|
|
||||||
_floatValue = _minValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMaxValue: (double)aDouble
|
- (void) setMaxValue: (double)aDouble
|
||||||
{
|
{
|
||||||
_maxValue = aDouble;
|
_maxValue = aDouble;
|
||||||
if (_floatValue > _maxValue)
|
|
||||||
_floatValue = _maxValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) titleCell { return _titleCell; }
|
- (id) titleCell
|
||||||
- (NSColor*) titleColor { return [_titleCell textColor]; }
|
{
|
||||||
- (NSFont*) titleFont { return [_titleCell font]; }
|
return _titleCell;
|
||||||
- (void) setTitle: (NSString*)title { [_titleCell setStringValue: title]; }
|
}
|
||||||
- (NSString*) title { return [_titleCell stringValue]; }
|
|
||||||
- (void) setTitleCell: (NSCell*)aCell { ASSIGN(_titleCell, aCell); }
|
- (NSColor*) titleColor
|
||||||
- (void) setTitleColor: (NSColor*)color { [_titleCell setTextColor: color]; }
|
{
|
||||||
- (void) setTitleFont: (NSFont*)font { [_titleCell setFont: font]; }
|
return [_titleCell textColor];
|
||||||
- (int) isVertical { return _isVertical; }
|
}
|
||||||
- (double) altIncrementValue { return _altIncrementValue; }
|
|
||||||
+ (BOOL) prefersTrackingUntilMouseUp { return YES; }
|
- (NSFont*) titleFont
|
||||||
- (NSRect) trackRect { return _trackRect; }
|
{
|
||||||
- (double) minValue { return _minValue; }
|
return [_titleCell font];
|
||||||
- (double) maxValue { return _maxValue; }
|
}
|
||||||
- (float) floatValue { return _floatValue; }
|
|
||||||
|
- (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
|
- (id) initWithCoder: (NSCoder*)decoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: decoder];
|
self = [super initWithCoder: decoder];
|
||||||
[decoder decodeValuesOfObjCTypes: "ffffi",
|
[decoder decodeValuesOfObjCTypes: "fffi",
|
||||||
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue, &_isVertical];
|
&_minValue, &_maxValue, &_altIncrementValue, &_isVertical];
|
||||||
[decoder decodeValueOfObjCType: @encode(id) at: &_titleCell];
|
[decoder decodeValueOfObjCType: @encode(id) at: &_titleCell];
|
||||||
[decoder decodeValueOfObjCType: @encode(id) at: &_knobCell];
|
[decoder decodeValueOfObjCType: @encode(id) at: &_knobCell];
|
||||||
return self;
|
return self;
|
||||||
|
@ -226,8 +277,8 @@
|
||||||
- (void) encodeWithCoder: (NSCoder*)coder
|
- (void) encodeWithCoder: (NSCoder*)coder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: coder];
|
[super encodeWithCoder: coder];
|
||||||
[coder encodeValuesOfObjCTypes: "ffffi",
|
[coder encodeValuesOfObjCTypes: "fffi",
|
||||||
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue, &_isVertical];
|
&_minValue, &_maxValue, &_altIncrementValue, &_isVertical];
|
||||||
[coder encodeValueOfObjCType: @encode(id) at: &_titleCell];
|
[coder encodeValueOfObjCType: @encode(id) at: &_titleCell];
|
||||||
[coder encodeValueOfObjCType: @encode(id) at: &_knobCell];
|
[coder encodeValueOfObjCType: @encode(id) at: &_knobCell];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue