diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 4d09f62c8..396e2074b 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -316,7 +316,7 @@ var _CPKeyedUnarchiverArrayClass = Ni if ([object isKindOfClass:_CPKeyedUnarchiverDictionaryClass]) return _CPKeyedUnarchiverDecodeObjectAtIndex(self, [object objectForKey:_CPKeyedArchiverUIDKey]); - else if ([object isKindOfClass:[CPNumber class]]) + else if ([object isKindOfClass:[CPNumber class]] || [object isKindOfClass:[CPData class]]) return object; /* else alert([object className] + " " + object + " " + aKey + " " + [_plistObject description]);*/ @@ -324,6 +324,22 @@ var _CPKeyedUnarchiverArrayClass = Ni return nil; } +/* + Decodes bytes from the archive. + @param aKey the object's associated key + @return array of bytes +*/ +- (id)decodeBytesForKey:(CPString)aKey +{ + // We get the CPData wrapper, then extract the bytes array + var data = [self decodeObjectForKey:aKey]; + + if ([data isKindOfClass:[CPData class]]) + return data.bytes; + + return nil; +} + /* Notifies the delegates that decoding has finished. */ diff --git a/Objective-J/plist.js b/Objective-J/plist.js index 30f029e7e..2f9c6b087 100644 --- a/Objective-J/plist.js +++ b/Objective-J/plist.js @@ -360,7 +360,8 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData) case PLIST_BOOLEAN_FALSE: object = false; break; - case PLIST_DATA: object = FIRST_CHILD(XMLNode) ? CHILD_VALUE(XMLNode) : ""; // FIXME: temporary fix for NIBs with tags + case PLIST_DATA: object = new objj_data(); + object.bytes = FIRST_CHILD(XMLNode) ? base64_decode_to_array(CHILD_VALUE(XMLNode), true) : []; break; default: objj_exception_throw(new objj_exception(OBJJPlistParseException, "*** " + NODE_NAME(XMLNode) + " tag not recognized in Plist.")); diff --git a/Objective-J/utilities.js b/Objective-J/utilities.js index 09d499b3e..ac2e74386 100644 --- a/Objective-J/utilities.js +++ b/Objective-J/utilities.js @@ -254,7 +254,13 @@ function base64_encode_array(input) function base64_decode_to_string(input, strip) { - return String.fromCharCode.apply(null, base64_decode_to_array(input, strip)); + return bytes_to_string(base64_decode_to_array(input, strip)); +} + +function bytes_to_string(bytes) +{ + // This is relatively efficient, I think: + return String.fromCharCode.apply(null, bytes); } function base64_encode_string(input) diff --git a/Tools/NibApp/MainMenu.xib b/Tools/NibApp/MainMenu.xib index 007464c0c..cdf4bd044 100644 --- a/Tools/NibApp/MainMenu.xib +++ b/Tools/NibApp/MainMenu.xib @@ -8,7 +8,7 @@ 352.00 YES - + @@ -146,7 +146,7 @@ YES - + @@ -380,7 +380,7 @@ YES 1 - MC4wNTgxMzA0OTkgMC4wNTU1NDE4OTkgMQA + MC4zNzUyMzAzNyAwLjQ1NjE5NzE0IDEAA @@ -398,7 +398,7 @@ YES 1 - MC4wNTgxMzA0OTkgMC4wNTU1NDE4OTkgMQA + MSAwLjE3MjgzOTUyIDAuMTcyODM5NTIAA @@ -3327,7 +3327,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{199, 438}, {480, 303}} + {{438, 741}, {480, 303}} com.apple.InterfaceBuilder.CocoaPlugin {628, 654} {{257, 484}, {480, 272}} @@ -3352,7 +3352,7 @@ {{56, 843}, {299, 193}} {{115, 207}, {299, 193}} - + {299, 193} {299, 193} @@ -3373,7 +3373,7 @@ {{0, 822}, {276, 323}} {{118, 105}, {276, 323}} - + {3.40282e+38, 3.40282e+38} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/Tools/nib2cib/NSColor.j b/Tools/nib2cib/NSColor.j index 630388b12..32f78e553 100644 --- a/Tools/nib2cib/NSColor.j +++ b/Tools/nib2cib/NSColor.j @@ -2,6 +2,9 @@ * NSColor.j * nib2cib * + * Portions based on NSColor.m (12/18/2008) in Cocotron (http://www.cocotron.org/) + * Copyright (c) 2006-2007 Christopher J. W. Lloyd + * * Created by Thomas Robinson. * Copyright 2008, 280 North, Inc. * @@ -35,8 +38,86 @@ var NSUnknownColorSpaceModel = -1, - (id)NS_initWithCoder:(CPCoder)aCoder { - //var colorSpace = [aCoder decodeIntForKey:@"NSColorSpace"]; - return self = [CPColor blueColor]; + var colorSpace = [aCoder decodeIntForKey:@"NSColorSpace"], + result; + + switch (colorSpace) + { + case 1: // [NSColor colorWithCalibratedRed:values[0] green:values[1] blue:values[2] alpha:values[3]]; + case 2: // [NSColor colorWithDeviceRed:values[0] green:values[1] blue:values[2] alpha:values[3]]; + + // NSComponents data + // NSCustomColorSpace NSColorSpace + var rgb = [aCoder decodeBytesForKey:@"NSRGB"], + string = bytes_to_string(rgb), + components = [string componentsSeparatedByString:@" "], + values = [0,0,0,1]; + + for (var i = 0; i < components.length && i < 4; i++) + values[i] = [components[i] floatValue]; + + CPLog.warn("rgb="+rgb+" string=" + string + " values=" + values); + + result = [CPColor colorWithCalibratedRed:values[0] green:values[1] blue:values[2] alpha:values[3]]; + break; + + case 3: // [NSColor colorWithCalibratedWhite:values[0] alpha:values[1]]; + case 4: // [NSColor colorWithDeviceWhite:values[0] alpha:values[1]]; + + var bytes = [aCoder decodeBytesForKey:@"NSWhite"], + string = bytes_to_string(rgb), + components = [string componentsSeparatedByString:@" "], + values = [0,1]; + + for (var i = 0; i < components.length && i < 2; i++) + values[i] = [components[i] floatValue]; + + result = [CPColor colorWithCalibratedWhite:values[0] alpha:values[1]]; + break; +/* + case 5: + var cmyk = [aCoder decodeBytesForKey:@"NSCMYK"], + string = bytes_to_string(rgb), + components = [string componentsSeparatedByString:@" "], + values = [0,0,0,0,1]; + + for (var i = 0; i < components.length && i < 5; i++) + values[i] = [components[i] floatValue]; + + result = [CPColor colorWithDeviceCyan:values[0] magenta:values[1] yellow:values[2] black:values[3] alpha:values[4]]; + break; +*/ + case 6: + var catalogName = [aCoder decodeObjectForKey:@"NSCatalogName"], + colorName = [aCoder decodeObjectForKey:@"NSColorName"], + color = [aCoder decodeObjectForKey:@"NSColor"]; + + // We don't having color mappings implemented, so just use the cached NSColor + + if (catalogName === @"System") + { + var //display = [NSDisplay currentDisplay], + result = null;//[display colorWithName: colorName]; + if (!result) + { + result = color; + //[display _addSystemColor: result forName: colorName]; + } + } + else + { + result = null;//[CPColor colorWithCatalogName: catalogName colorName: colorName]; + if (!result) + result = color; + } + break; + default: + CPLog(@"-[%@ %s] unknown color space %d", isa, _cmd, colorSpace); + result = [CPColor blackColor]; + break; + } + + return result; } @end