diff --git a/CommonJS/lib/cappuccino/image-utility.js b/CommonJS/lib/cappuccino/image-utility.js deleted file mode 100644 index fabd6fdf9..000000000 --- a/CommonJS/lib/cappuccino/image-utility.js +++ /dev/null @@ -1,140 +0,0 @@ - -var OS = require("os"); -var FILE = require("file"); -var ByteString = require("binary").ByteString; - -var javaImageSize = function (aFilePath) -{ - var imageStream = javax.imageio.ImageIO.createImageInputStream(new Packages.java.io.File(aFilePath).getCanonicalFile()), - readers = javax.imageio.ImageIO.getImageReaders(imageStream), - reader = null; - - if(readers.hasNext()) - reader = readers.next(); - - else - { - imageStream.close(); - //can't read image format... what do you want to do about it, - //throw an exception, return ? - } - - reader.setInput(imageStream, true, true); - - // Now we know the size (yay!) - var size = {width:reader.getWidth(0), height:reader.getHeight(0)}; - - reader.dispose(); - imageStream.close(); - - return size; -} - -var server = null; - -var serverImageSize = function (aFilePath) -{ - if (!server) - { - var cmd = "NARWHAL_ENGINE_HOME='' NARWHAL_ENGINE=rhino narwhal "+OS.enquote(module.path); - server = OS.popen(cmd, { charset : "UTF-8" }); - } - - var request = aFilePath.toByteString("UTF-8"); - sendLengthPrefixMessage(server.stdin.raw, request); - - var response = receiveLengthPrefixMessage(server.stdout.raw); - return JSON.parse(response.decodeToString("UTF-8")); -} - -if (system.engine == "rhino") - exports.sizeOfImageAtPath = javaImageSize; -else - exports.sizeOfImageAtPath = serverImageSize; - -// TODO: move these methods somewhere else? - -var bytesToNumberLE = function(bytes) { - var acc = 0; - for (var i = 0; i < bytes.length; i++) - acc += bytes.get(i) << (8*i); - return acc; -} - -var bytesToNumberBE = function(bytes) { - var acc = 0; - for (var i = 0; i < bytes.length; i++) - acc = (acc << 8) + bytes.get(i); - return acc; -} - -var numberToBytesLE = function(number, length) { - var bytes = []; - for (var i = 0; i < length; i++) - bytes[i] = (number >> (8*i)) & 0xFF; - return new ByteString(bytes); -} - -var numberToBytesBE = function(number, length) { - var bytes = []; - for (var i = 0; i < length; i++) - bytes[length-i-1] = (number >> (8*i)) & 0xFF; - return new ByteString(bytes); -} - -var lengthPrefixServer = function(stream, callback, prefixLength) { - var bytes; - do { - bytes = receiveLengthPrefixMessage(stream, prefixLength); - callback(bytes); - } while (bytes); -} - -var receiveLengthPrefixMessage = function(stream, prefixLength) { - var prefixBytes = stream.read(prefixLength || 4); - var length = bytesToNumberBE(prefixBytes); - var bytes = stream.read(length); - return bytes; -} - -var sendLengthPrefixMessage = function(stream, bytes, prefixLength) { - var lengthBytes = numberToBytesBE(bytes.length, prefixLength || 4); - stream.write(lengthBytes).write(bytes).flush(); -} - -if (module == require.main) -{ - var bytes; - while (bytes = receiveLengthPrefixMessage(require("system").stdin.raw)) - { - var fileName = bytes.decodeToString("UTF-8"); - var size = javaImageSize(fileName); - - sendLengthPrefixMessage(require("system").stdout.raw, JSON.stringify(size).toByteString("UTF-8")); - } -} - -/* - //ASYNCHRONOUS, so not useful to us - -function jscImageSize(aFilePath) -{ - var MIME_TYPES = { - ".png" : "image/png", - ".jpg" : "image/jpeg", - ".jpeg" : "image/jpeg", - ".gif" : "image/gif", - ".tif" : "image/tiff", - ".tiff" : "image/tiff" - }, - FILE = require("file"); - - var image = new Image(); - - image.src = "data:" + MIME_TYPES[FILE.extension(aFilePath)] + ";base64," + require("base64").encode(FILE.read(aFilePath, { mode : 'b'})); - - return CGSizeMake(image.width, image.height); -} - -*/ - diff --git a/CommonJS/lib/cappuccino/imagesize.j b/CommonJS/lib/cappuccino/imagesize.j new file mode 100644 index 000000000..c6e534bfa --- /dev/null +++ b/CommonJS/lib/cappuccino/imagesize.j @@ -0,0 +1,12 @@ + +var OS = require("os"); + +exports.imagesize = function(path) +{ + var p = OS.popen(["imagesize", "-n", path]); + + if (p.wait() === 0) + return JSON.parse(p.stdout.read()); + else + return null; +}; diff --git a/Tools/Jakefile b/Tools/Jakefile index a32dfbd3b..40a8a1fb9 100644 --- a/Tools/Jakefile +++ b/Tools/Jakefile @@ -1,7 +1,7 @@ require("../common.jake"); -// nib2cib uses fontinfo and capp uses nib2cib -subtasks(["fontinfo", "nib2cib", "capp", "dump_theme", "NativeHost", "XcodeCapp"], ["build"/*, "clean", "clobber"*/]); +// nib2cib uses fontinfo and imagesize and capp uses nib2cib +subtasks(["fontinfo", "imagesize", "nib2cib", "capp", "dump_theme", "NativeHost", "XcodeCapp"], ["build"/*, "clean", "clobber"*/]); -subtasks(["fontinfo"], ["clean", "clobber"]); +subtasks(["fontinfo", "imagesize"], ["clean", "clobber"]); diff --git a/Tools/fontinfo/Jakefile b/Tools/fontinfo/Jakefile index 38d02b91c..04d2a5a97 100644 --- a/Tools/fontinfo/Jakefile +++ b/Tools/fontinfo/Jakefile @@ -8,7 +8,7 @@ task ("build", function() { if (executableExists("xcodebuild")) { - var args = "-alltargets -configuration " + $CONFIGURATION; + var args = "-alltargets -configuration Release"; if (xcodebuildHasTenPointFiveSDK()) args = "-sdk macosx10.5 " + args; diff --git a/Tools/fontinfo/fontinfo.xcodeproj/project.pbxproj b/Tools/fontinfo/fontinfo.xcodeproj/project.pbxproj index 9e523b2ac..73829f007 100644 --- a/Tools/fontinfo/fontinfo.xcodeproj/project.pbxproj +++ b/Tools/fontinfo/fontinfo.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ /* Begin PBXFileReference section */ 08FB7796FE84155DC02AAC07 /* fontinfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = fontinfo.m; sourceTree = ""; }; 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 32A70AAB03705E1F00C91783 /* fontinfo_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fontinfo_Prefix.pch; sourceTree = ""; }; E11C89CC1277CECE0012609B /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; E18587D81279B93100FB6A47 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; E1C392BB133D513B0092D7CA /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; @@ -47,7 +46,6 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( - 32A70AAB03705E1F00C91783 /* fontinfo_Prefix.pch */, 08FB7796FE84155DC02AAC07 /* fontinfo.m */, ); name = Source; @@ -142,8 +140,8 @@ CONFIGURATION_TEMP_DIR = "$(CAPP_BUILD)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = fontinfo_Prefix.pch; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; OBJROOT = "$(CAPP_BUILD)"; @@ -171,6 +169,8 @@ DEPLOYMENT_POSTPROCESSING = NO; DSTROOT = "/tmp/$(PROJECT_NAME).dst"; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INSTALL_PATH = ""; diff --git a/Tools/fontinfo/fontinfo_Prefix.pch b/Tools/fontinfo/fontinfo_Prefix.pch deleted file mode 100644 index 8a571c50e..000000000 --- a/Tools/fontinfo/fontinfo_Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the 'font_info' target in the 'font_info' project. -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/Tools/imagesize/.gitignore b/Tools/imagesize/.gitignore new file mode 100644 index 000000000..567609b12 --- /dev/null +++ b/Tools/imagesize/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/Tools/imagesize/Jakefile b/Tools/imagesize/Jakefile new file mode 100644 index 000000000..e4e7d721d --- /dev/null +++ b/Tools/imagesize/Jakefile @@ -0,0 +1,40 @@ + +require ("../../common.jake"); + +var OS = require("os"), + task = require("jake").task; + +task ("build", function() +{ + if (executableExists("xcodebuild")) + { + var args = "-alltargets -configuration Release"; + + if (xcodebuildHasTenPointFiveSDK()) + args = "-sdk macosx10.5 " + args; + + else + args = "-sdk macosx " + args; + + if (OS.system("xcodebuild " + args)) + OS.exit(1); + } + else + { + print("Building imagesize requires Xcode."); + } +}); + +task ("clean", function() +{ + if (executableExists("xcodebuild") && OS.system("xcodebuild clean")) + OS.exit(1); +}); + +task ("clobber", function() +{ + if (executableExists("xcodebuild") && OS.system("xcodebuild clean")) + OS.exit(1); +}); + +task ("default", ["build"]); diff --git a/Tools/imagesize/README b/Tools/imagesize/README new file mode 100644 index 000000000..38695f664 --- /dev/null +++ b/Tools/imagesize/README @@ -0,0 +1,30 @@ +NAME + imagesize -- retrieve size information for an image + +SYNOPSIS + imagesize [-n] path + +DESCRIPTION + imagesize is a tiny utility that returns the size of an image. + The path may be either an absolute path or a path relative to the current directory. + + If the -n option is passed, the output will not be terminated with a linefeed. + +EXIT STATUS + imagesize exits with a return status of zero if there are no errors. + imagesize exits with a return status of 1 if any arguments are invalid, or a status of 2 if the image + cannot be found or the file at the given path is not a valid image. + +OUTPUT + imagesize outputs a stringified JSON object with the following structure: + + { + width:, + height: + } + + If -n is not passed, the JSON is terminated with a linefeed. The fields of the object are as follows: + +AUTHORS + Aparajita Fishman, Victory-Heart Productions + http://www.aparajita.com diff --git a/Tools/imagesize/imagesize.m b/Tools/imagesize/imagesize.m new file mode 100644 index 000000000..fed8edb9d --- /dev/null +++ b/Tools/imagesize/imagesize.m @@ -0,0 +1,71 @@ +/* + imagesize + + Copyright 2012 Aparajita Fishman +*/ + +#import +#import + + +enum { + kErrInvalidArguments = 1, + kErrInvalidPath +}; + + +int getImageSize(const char* utf8Path, BOOL appendLineFeed) +{ + NSString* path = [NSString stringWithUTF8String:utf8Path]; + NSImage* image = [[NSImage alloc] initWithContentsOfFile:path]; + + if (!image) + return kErrInvalidPath; + + NSSize size = [image size]; + + NSMutableString* result = [NSMutableString stringWithFormat:@"{\"width\":%g, \"height\":%g}", size.width, size.height]; + + if (appendLineFeed) + [result appendString:@"\n"]; + + printf("%s", [result UTF8String]); + return 0; +} + + +int main(int argc, const char* argv[]) +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int exitCode = 0; + + // usage: imagesize [-n] path + + if (argc >= 2) + { + BOOL appendLineFeed = YES; + int nextArgument = 1; + + if (argv[1][0] == '-') + { + if (argv[1][1] == 'n') + { + appendLineFeed = NO; + ++nextArgument; + } + else + exitCode = kErrInvalidArguments; + } + + if (exitCode == 0) + exitCode = getImageSize(argv[nextArgument], appendLineFeed); + } + else + { + exitCode = kErrInvalidArguments; + } + + [pool drain]; + return exitCode; +} + diff --git a/Tools/imagesize/imagesize.xcodeproj/project.pbxproj b/Tools/imagesize/imagesize.xcodeproj/project.pbxproj new file mode 100644 index 000000000..8b39c972c --- /dev/null +++ b/Tools/imagesize/imagesize.xcodeproj/project.pbxproj @@ -0,0 +1,223 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + E14061B7159D449000D99541 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E14061B6159D449000D99541 /* AppKit.framework */; }; + E1D3CFAA12AFFB7F00CBB79E /* imagesize.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* imagesize.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 08FB7796FE84155DC02AAC07 /* imagesize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = imagesize.m; sourceTree = ""; }; + 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + E14061B6159D449000D99541 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + E18587D81279B93100FB6A47 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + E1E20D0B12B09283005A6A64 /* imagesize */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = imagesize; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E1D3CF6912AFEE3800CBB79E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E14061B7159D449000D99541 /* AppKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* font_info */ = { + isa = PBXGroup; + children = ( + 08FB7795FE84155DC02AAC07 /* Source */, + E18587DD1279B93600FB6A47 /* Documentation */, + 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + ); + name = font_info; + sourceTree = ""; + }; + 08FB7795FE84155DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 08FB7796FE84155DC02AAC07 /* imagesize.m */, + ); + name = Source; + sourceTree = ""; + }; + 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 08FB779EFE84155DC02AAC07 /* Foundation.framework */, + E14061B6159D449000D99541 /* AppKit.framework */, + ); + name = "External Frameworks and Libraries"; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + E1E20D0B12B09283005A6A64 /* imagesize */, + ); + name = Products; + sourceTree = ""; + }; + E18587DD1279B93600FB6A47 /* Documentation */ = { + isa = PBXGroup; + children = ( + E18587D81279B93100FB6A47 /* README */, + ); + name = Documentation; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + E1D3CF6A12AFEE3800CBB79E /* imagesize */ = { + isa = PBXNativeTarget; + buildConfigurationList = E1D3CF6F12AFEE3B00CBB79E /* Build configuration list for PBXNativeTarget "imagesize" */; + buildPhases = ( + E1D3CF6812AFEE3800CBB79E /* Sources */, + E1D3CF6912AFEE3800CBB79E /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = imagesize; + productName = font_info; + productReference = E1E20D0B12B09283005A6A64 /* imagesize */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "imagesize" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 08FB7794FE84155DC02AAC07 /* font_info */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + E1D3CF6A12AFEE3800CBB79E /* imagesize */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + E1D3CF6812AFEE3800CBB79E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E1D3CFAA12AFFB7F00CBB79E /* imagesize.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB927908733DD40010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; + CONFIGURATION_TEMP_DIR = "$(CAPP_BUILD)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = "$(CAPP_BUILD)"; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-framework", + Foundation, + "-framework", + AppKit, + ); + PREBINDING = NO; + PRODUCT_NAME = imagesize; + SDKROOT = macosx10.5; + SYMROOT = "$(CAPP_BUILD)/Debug/CommonJS/cappuccino/bin"; + }; + name = Debug; + }; + 1DEB927A08733DD40010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; + CONFIGURATION_TEMP_DIR = "$(CAPP_BUILD)"; + DEPLOYMENT_LOCATION = NO; + DEPLOYMENT_POSTPROCESSING = NO; + DSTROOT = "/tmp/$(PROJECT_NAME).dst"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INSTALL_PATH = ""; + OBJROOT = "$(CAPP_BUILD)"; + ONLY_ACTIVE_ARCH = NO; + PREBINDING = NO; + PRODUCT_NAME = imagesize; + SDKROOT = macosx10.5; + SYMROOT = "$(CAPP_BUILD)/Release/CommonJS/cappuccino/bin"; + }; + name = Release; + }; + E1D3CF6D12AFEE3900CBB79E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = imagesize; + }; + name = Debug; + }; + E1D3CF6E12AFEE3900CBB79E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + MACOSX_DEPLOYMENT_TARGET = 10.5; + PRODUCT_NAME = imagesize; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "imagesize" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB927908733DD40010E9CD /* Debug */, + 1DEB927A08733DD40010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E1D3CF6F12AFEE3B00CBB79E /* Build configuration list for PBXNativeTarget "imagesize" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E1D3CF6D12AFEE3900CBB79E /* Debug */, + E1D3CF6E12AFEE3900CBB79E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/Tools/imagesize/imagesize.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Tools/imagesize/imagesize.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..562d5df16 --- /dev/null +++ b/Tools/imagesize/imagesize.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Tools/nib2cib/NSButton.j b/Tools/nib2cib/NSButton.j index da8fc3518..afdc6cfa5 100644 --- a/Tools/nib2cib/NSButton.j +++ b/Tools/nib2cib/NSButton.j @@ -112,6 +112,7 @@ var NSButtonIsBorderedMask = 0x00800000, } _themeClass = [[self class] defaultThemeClass]; + alternateImage = nil; } NIB_CONNECTION_EQUIVALENCY_TABLE[[cell UID]] = self; @@ -122,8 +123,7 @@ var NSButtonIsBorderedMask = 0x00800000, [self setBordered:[cell isBordered]]; _bezelStyle = [cell bezelStyle]; - - // clean up: + // Map Cocoa bezel styles to Cappuccino bezel styles and adjust frame switch (_bezelStyle) { // implemented: @@ -132,13 +132,16 @@ var NSButtonIsBorderedMask = 0x00800000, positionOffsetOriginX = 4; positionOffsetSizeWidth = -12; break; + case CPTexturedRoundedBezelStyle: positionOffsetOriginY = 2; positionOffsetOriginX = -2; positionOffsetSizeWidth = 0; break; + case CPHUDBezelStyle: break; + // approximations: case CPRoundRectBezelStyle: positionOffsetOriginY = -3; @@ -146,11 +149,13 @@ var NSButtonIsBorderedMask = 0x00800000, positionOffsetSizeWidth = 0; _bezelStyle = CPRoundedBezelStyle; break; + case CPSmallSquareBezelStyle: positionOffsetOriginX = -2; positionOffsetSizeWidth = 0; _bezelStyle = CPTexturedRoundedBezelStyle; break; + case CPThickSquareBezelStyle: case CPThickerSquareBezelStyle: case CPRegularSquareBezelStyle: @@ -159,24 +164,28 @@ var NSButtonIsBorderedMask = 0x00800000, positionOffsetSizeWidth = -4; _bezelStyle = CPTexturedRoundedBezelStyle; break; + case CPTexturedSquareBezelStyle: positionOffsetOriginY = 4; positionOffsetOriginX = -1; positionOffsetSizeWidth = -2; _bezelStyle = CPTexturedRoundedBezelStyle; break; + case CPShadowlessSquareBezelStyle: positionOffsetOriginY = 5; positionOffsetOriginX = -2; positionOffsetSizeWidth = 0; _bezelStyle = CPTexturedRoundedBezelStyle; break; + case CPRecessedBezelStyle: positionOffsetOriginY = -3; positionOffsetOriginX = -2; positionOffsetSizeWidth = 0; _bezelStyle = CPHUDBezelStyle; break; + // unsupported case CPRoundedDisclosureBezelStyle: case CPHelpButtonBezelStyle: @@ -185,6 +194,7 @@ var NSButtonIsBorderedMask = 0x00800000, CPLog.warn("NSButton [%s]: unsupported bezel style: %d", _title == null ? "" : '"' + _title + '"', _bezelStyle); _bezelStyle = CPHUDBezelStyle; break; + // error: default: CPLog.warn("NSButton [%s]: unknown bezel style: %d", _title == null ? "" : '"' + _title + '"', _bezelStyle); @@ -211,6 +221,7 @@ var NSButtonIsBorderedMask = 0x00800000, _allowsMixedState = [cell allowsMixedState]; [self setImage:[cell normalImage]]; + [self setAlternateImage:alternateImage]; [self setImagePosition:[cell imagePosition]]; [self setEnabled:[cell isEnabled]]; @@ -298,6 +309,7 @@ var NSButtonIsBorderedMask = 0x00800000, _imagePosition = CPNoImage; _highlightsBy = CPNoCellMask; + if (buttonFlags & NSHighlightsByPushInCellMask) _highlightsBy |= CPPushInCellMask; if (buttonFlags & NSHighlightsByContentsCellMask) @@ -308,6 +320,7 @@ var NSButtonIsBorderedMask = 0x00800000, _highlightsBy |= CPChangeBackgroundCellMask; _showsStateBy = CPNoCellMask; + if (buttonFlags & NSShowsStateByContentsCellMask) _showsStateBy |= CPContentsCellMask; if (buttonFlags & NSShowsStateByChangeGrayCellMask) diff --git a/Tools/nib2cib/NSCustomResource.j b/Tools/nib2cib/NSCustomResource.j index 6d716f36b..998a3a121 100644 --- a/Tools/nib2cib/NSCustomResource.j +++ b/Tools/nib2cib/NSCustomResource.j @@ -25,7 +25,8 @@ @import -var FILE = require("file"); +var FILE = require("file"), + imageSize = require("cappuccino/imagesize").imagesize; @implementation _CPCibCustomResource (NSCoding) @@ -58,11 +59,13 @@ var FILE = require("file"); if (!resourcePath) CPLog.warn("Resource \"" + _resourceName + "\" not found in the resources path: " + [aCoder resourcesPath]); else - size = imageSize(FILE.canonical(resourcePath)); + size = imageSize(FILE.canonical(resourcePath)) || CGSizeMakeZero(); // Account for the fact that an extension may have been inferred. if (resourcePath && FILE.extension(resourcePath) !== FILE.extension(_resourceName)) _resourceName += FILE.extension(resourcePath); + + CPLog.debug("Image path: %s\nImage size: %dx%d", FILE.canonical(resourcePath), size.width, size.height); } _properties = [CPDictionary dictionaryWithObject:size forKey:@"size"]; @@ -73,8 +76,6 @@ var FILE = require("file"); @end -var ImageUtility = require("cappuccino/image-utility"), - imageSize = ImageUtility.sizeOfImageAtPath; @implementation NSCustomResource : _CPCibCustomResource {