mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Skeletal implementation of NSDimension
This commit is contained in:
parent
7aee0a7c6a
commit
0dd8791f2e
2 changed files with 54 additions and 3 deletions
|
@ -34,25 +34,26 @@ extern "C" {
|
|||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
|
||||
|
||||
// Unit converter
|
||||
@interface NSUnitConverter : NSObject
|
||||
- (double)baseUnitValueFromValue:(double)value;
|
||||
- (double)valueFromBaseUnitValue:(double)baseUnitValue;
|
||||
@end
|
||||
|
||||
// Linea converter... for things like C <-> F conversion...
|
||||
@interface NSUnitConverterLinear : NSUnitConverter <NSCoding>
|
||||
{
|
||||
double _coefficient;
|
||||
double _constant;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoefficient: (double)coefficient;
|
||||
- (instancetype) initWithCoefficient: (double)coefficient
|
||||
constant: (double)constant;
|
||||
|
||||
- (double) coefficient;
|
||||
- (double) constant;
|
||||
@end
|
||||
|
||||
// Units... abstract...
|
||||
@interface NSUnit : NSObject <NSCopying, NSCoding>
|
||||
{
|
||||
NSString *_symbol;
|
||||
|
@ -65,6 +66,18 @@ extern "C" {
|
|||
|
||||
@end
|
||||
|
||||
// Dimension using units....
|
||||
@interface NSDimension : NSUnit <NSCoding>
|
||||
{
|
||||
NSUInteger _reserved;
|
||||
NSUnitConverter *_converter;
|
||||
}
|
||||
|
||||
- (NSUnitConverter *) converter;
|
||||
- (instancetype) initWithSymbol: (NSString *)symbol converter: (NSUnitConverter *) converter ;
|
||||
+ (instancetype) baseUnit;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -66,11 +66,28 @@
|
|||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
return nil;
|
||||
if([coder allowsKeyedCoding])
|
||||
{
|
||||
_coefficient = [coder decodeDoubleForKey: @"coefficient"];
|
||||
_constant = [coder decodeDoubleForKey: @"constant"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder decodeValueOfObjCType: @encode(double) at: &_coefficient];
|
||||
[coder decodeValueOfObjCType: @encode(double) at: &_constant];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if([coder allowsKeyedCoding])
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
- (double) coefficient
|
||||
|
@ -148,3 +165,24 @@
|
|||
}
|
||||
@end
|
||||
|
||||
|
||||
// Dimension using units....
|
||||
@implementation NSDimension
|
||||
|
||||
- (NSUnitConverter *) converter
|
||||
{
|
||||
return _converter;
|
||||
}
|
||||
|
||||
- (instancetype) initWithSymbol: (NSString *)symbol converter: (NSUnitConverter *) converter
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype) baseUnit
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue