Implement setXXXValue methods and getters

This commit is contained in:
Gregory John Casamento 2020-04-21 23:36:11 -04:00
parent 0df7e5f7d7
commit ec3227d132

View file

@ -23,8 +23,6 @@
*/
#import "AppKit/NSSwitch.h"
#import "AppKit/NSActionCell.h"
#import "GNUstepGUI/GSTheme.h"
@implementation NSSwitch
@ -50,8 +48,6 @@
- (void) setAction: (SEL)action
{
NSString *s = NSStringFromSelector(action);
NSLog(@"Action %@",s);
_action = action;
}
@ -62,7 +58,6 @@
- (void) setTarget: (id)target
{
NSLog(@"Target %@", target);
_target = target;
}
@ -71,6 +66,63 @@
return _target;
}
- (void) setDoubleValue: (double)val
{
if (val < 1.0)
{
[self setState: NSControlStateValueOff];
}
else
{
[self setState: NSControlStateValueOn];
}
}
- (double) doubleValue
{
return (double)(([self state] == NSControlStateValueOn) ? 1.0 : 0.0);
}
- (void) setFloatValue: (float)val
{
[self setDoubleValue: (double)val];
}
- (float) floatValue
{
return (float)[self doubleValue];
}
- (void) setIntValue: (int)val
{
[self setDoubleValue: (double)val];
}
- (int) intValue
{
return (int)[self doubleValue];
}
- (void) setIntegerValue: (NSInteger)val
{
[self setDoubleValue: (double)val];
}
- (NSInteger) integerValue
{
return (NSInteger)[self doubleValue];
}
- (void) setStringValue: (NSString *)val
{
[self setDoubleValue: [val doubleValue]];
}
- (NSString *) stringValue
{
return [NSString stringWithFormat: @"%ld", [self integerValue]];
}
- (void) drawRect: (NSRect)rect
{
[[GSTheme theme] drawSwitchInRect: rect
@ -81,8 +133,6 @@
knobColor: [NSColor windowBackgroundColor]];
}
- (void) mouseDown: (NSEvent *)event
{
[super mouseDown: event];
@ -131,5 +181,9 @@
return self;
}
- (void) encodeWithCoder: (NSCoder *)acoder
{
}
@end