From 3f2607c2d0b61510064f25fc69e1a25bd6e52d4b Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 28 May 2011 18:44:32 -0400 Subject: [PATCH] CPLevelIndicator nib2cib support. --- Tools/nib2cib/NSAppKit.j | 1 + Tools/nib2cib/NSLevelIndicator.j | 103 +++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 Tools/nib2cib/NSLevelIndicator.j diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index 79ef4f13b..ad4143650 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -40,6 +40,7 @@ @import "NSFormatter.j" @import "NSIBObjectData.j" @import "NSImageView.j" +@import "NSLevelIndicator.j" @import "NSMatrix.j" @import "NSMenu.j" @import "NSMenuItem.j" diff --git a/Tools/nib2cib/NSLevelIndicator.j b/Tools/nib2cib/NSLevelIndicator.j new file mode 100644 index 000000000..8981a597b --- /dev/null +++ b/Tools/nib2cib/NSLevelIndicator.j @@ -0,0 +1,103 @@ +/* + * NSLevelIndicator.j + * nib2cib + * + * Created by Alexander Ljungberg. + * Copyright 2011, WireLoad Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import + +@implementation CPLevelIndicator (CPCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + var cell = [aCoder decodeObjectForKey:@"NSCell"]; + + _minValue = [cell minValue]; + _maxValue = [cell maxValue]; + + self = [super NS_initWithCoder:aCoder]; + + if (self) + { + _levelIndicatorStyle = [cell levelIndicatorStyle]; + _warningValue = [cell warningValue]; + _criticalValue = [cell criticalValue]; + _tickMarkPosition = [cell tickMarkPosition]; + _numberOfTickMarks = [cell numberOfTickMarks]; + _numberOfMajorTickMarks = [cell numberOfMajorTickMarks]; + } + + return self; +} + +@end + +@implementation NSLevelIndicator : CPLevelIndicator +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPLevelIndicator class]; +} + +@end + +@implementation NSLevelIndicatorCell : NSCell +{ + CPLevelIndicator _levelIndicatorStyle @accessors(readonly, getter=levelIndicatorStyle); + double _minValue @accessors(readonly, getter=minValue); + double _maxValue @accessors(readonly, getter=maxValue); + double _warningValue @accessors(readonly, getter=warningValue); + double _criticalValue @accessors(readonly, getter=criticalValue); + CPTickMarkPosition _tickMarkPosition @accessors(readonly, getter=tickMarkPosition); + int _numberOfTickMarks @accessors(readonly, getter=numberOfTickMarks); + int _numberOfMajorTickMarks @accessors(readonly, getter=numberOfMajorTickMarks); +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + self = [super initWithCoder:aCoder]; + + if (self) + { + _objectValue = [aCoder decodeDoubleForKey:@"NSValue"]; + + _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"] || 0; + _maxValue = [aCoder decodeDoubleForKey:@"NSMaxValue"]; + _warningValue = [aCoder decodeDoubleForKey:@"NSWarningValue"]; + _criticalValue = [aCoder decodeDoubleForKey:@"NSCriticalValue"]; + + _levelIndicatorStyle = [aCoder decodeIntForKey:@"NSIndicatorStyle"] || 0; + + // None of these are included in the XIB if the defaults are used. + _tickMarkPosition = [aCoder decodeIntForKey:@"NSTickMarkPosition"] || 0; + _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfTickMarks"] || 0; + _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfMajorTickMarks"] || 0; + } + + return self; +} + +@end