mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 12:00:52 +00:00
Implement setXXXValue methods and getters
This commit is contained in:
parent
0df7e5f7d7
commit
ec3227d132
1 changed files with 61 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue