Added keyed encoding for NSFont and NSColor.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21078 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2005-04-09 12:01:32 +00:00
parent daa83e855e
commit 8524adaabf
3 changed files with 109 additions and 30 deletions

View file

@ -1,3 +1,8 @@
2005-04-09 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSColor.m: Implemented most keyed encoding methods.
* Source/NSFont.m: Implemented simple keyed encoding.
2005-04-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m (-addSubview:positioned:relativeTo:): Don't

View file

@ -1579,9 +1579,18 @@ systemColorWithName(NSString *name)
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeObject: _catalog_name];
[aCoder encodeObject: _color_name];
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: 6 forKey: @"NSColorSpace"];
[aCoder encodeObject: _catalog_name forKey: @"NSCatalogName"];
[aCoder encodeObject: _color_name forKey: @"NSColorName"];
}
else
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeObject: _catalog_name];
[aCoder encodeObject: _color_name];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -1748,9 +1757,22 @@ systemColorWithName(NSString *name)
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_white_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
if ([aCoder allowsKeyedCoding])
{
NSString *str;
// FIXME: Missing handling of alpha value
str = [[NSString alloc] initWithFormat: @"%f", _white_component];
[aCoder encodeInt: 3 forKey: @"NSColorSpace"];
[aCoder encodeBytes: [str cString] length: [str cStringLength] forKey: @"NSWhite"];
RELEASE(str);
}
else
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_white_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -2032,12 +2054,19 @@ systemColorWithName(NSString *name)
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_cyan_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_magenta_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_yellow_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_black_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
if ([aCoder allowsKeyedCoding])
{
// FIXME
}
else
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_cyan_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_magenta_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_yellow_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_black_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -2269,14 +2298,28 @@ systemColorWithName(NSString *name)
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_red_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_green_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_blue_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_hue_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_saturation_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_brightness_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
if ([aCoder allowsKeyedCoding])
{
NSString *str;
// FIXME: Missing handling of alpha value
str = [[NSString alloc] initWithFormat: @"%f %f %f", _red_component,
_green_component, _blue_component];
[aCoder encodeInt: 1 forKey: @"NSColorSpace"];
[aCoder encodeBytes: [str cString] length: [str cStringLength] forKey: @"NSRGB"];
RELEASE(str);
}
else
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_red_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_green_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_blue_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_hue_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_saturation_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_brightness_component];
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -2629,8 +2672,15 @@ systemColorWithName(NSString *name)
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeObject: _pattern];
if ([aCoder allowsKeyedCoding])
{
// FIXME
}
else
{
[aCoder encodeObject: [self colorSpaceName]];
[aCoder encodeObject: _pattern];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -1083,17 +1083,41 @@ static BOOL flip_hack;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeValueOfObjCType: @encode(int) at: &role];
if (role == 0)
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: fontName];
[aCoder encodeArrayOfObjCType: @encode(float) count: 6 at: matrix];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet];
[aCoder encodeObject: fontName forKey: @"NSName"];
[aCoder encodeInt: [self pointSize] forKey: @"NSSize"];
switch (role >> 1)
{
// FIXME: Many cases still missing
case RoleControlContentFont:
[aCoder encodeInt: 16 forKey: @"NSfFlags"];
break;
case RoleLabelFont:
[aCoder encodeInt: 20 forKey: @"NSfFlags"];
break;
case RoleTitleBarFont:
[aCoder encodeInt: 22 forKey: @"NSfFlags"];
break;
default:
break;
}
}
else if (role & 1)
else
{
[aCoder encodeValueOfObjCType: @encode(float) at: &matrix[0]];
[aCoder encodeValueOfObjCType: @encode(int) at: &role];
if (role == 0)
{
[aCoder encodeObject: fontName];
[aCoder encodeArrayOfObjCType: @encode(float) count: 6 at: matrix];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet];
}
else if (role & 1)
{
[aCoder encodeValueOfObjCType: @encode(float) at: &matrix[0]];
}
}
}