mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Initial commit before testing.
This commit is contained in:
+158
-29
@@ -26,13 +26,15 @@
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
var _CPFonts = {},
|
||||
_CPFontSystemFontFace = @"Arial, sans-serif",
|
||||
_CPWrapRegExp = new RegExp("\\s*,\\s*", "g");
|
||||
var _CPFonts = {},
|
||||
_CPFontSystemFontFace = @"Arial",
|
||||
_CPFontSystemFontSize = 12,
|
||||
_CPFontFallbackFaces = [@"Arial", @"sans-serif"],
|
||||
_CPFontStripRegExp = new RegExp("(^\\s*[\"']?|[\"']?\\s*$)", "g"),
|
||||
_CPFontStripPropertiesRegExp = new RegExp("^(italic |bold )*\\d+px ");
|
||||
|
||||
|
||||
#define _CPCreateCSSString(aName, aSize, isBold) (isBold ? @"bold " : @"") + ROUND(aSize) + @"px " + ((aName === _CPFontSystemFontFace) ? aName : (@"\"" + aName.replace(_CPWrapRegExp, '", "') + @"\", " + _CPFontSystemFontFace))
|
||||
#define _CPCachedFont(aName, aSize, isBold) _CPFonts[_CPCreateCSSString(aName, aSize, isBold)]
|
||||
#define _CPCachedFont(aName, aSize, isBold, isItalic) _CPFonts[_CPFontCreateCSSString(aName, aSize, isBold, isItalic)]
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -47,78 +49,157 @@ var _CPFonts = {},
|
||||
float _ascender;
|
||||
float _descender;
|
||||
float _lineHeight;
|
||||
BOOL _isBold;
|
||||
BOOL _isBold @accessors(readonly, getter=isBold);
|
||||
BOOL _isItalic @accessors(readonly, getter=isItalic);
|
||||
|
||||
CPString _cssString;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
var systemFont = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:"CPSystemFontFace"];
|
||||
var systemFontFace = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPSystemFontFace"];
|
||||
|
||||
if (systemFont)
|
||||
_CPFontSystemFontFace = systemFont;
|
||||
if (!systemFontFace)
|
||||
systemFontFace = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:@"CPSystemFontFace"];
|
||||
|
||||
if (systemFontFace)
|
||||
_CPFontSystemFontFace = systemFontFace;
|
||||
|
||||
var systemFontSize = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPSystemFontSize"];
|
||||
|
||||
if (!systemFontSize)
|
||||
systemFontSize = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:@"CPSystemFontSize"];
|
||||
|
||||
if (systemFontSize)
|
||||
_CPFontSystemFontSize = systemFontSize;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the default system font face, which may consist of several comma-separated family names.
|
||||
*/
|
||||
+ (CPString)systemFontFace
|
||||
{
|
||||
return _CPFontSystemFontFace;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the default system font face, which may consist of several comma-separated family names.
|
||||
*/
|
||||
+ (CPString)setSystemFontFace:(CPString)aFace
|
||||
{
|
||||
|
||||
_CPFontSystemFontFace = aFace;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the default system font size.
|
||||
*/
|
||||
+ (float)systemFontSize
|
||||
{
|
||||
return _CPFontSystemFontSize;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the default system font size.
|
||||
*/
|
||||
+ (float)setSystemFontSize:(float)size
|
||||
{
|
||||
if (size > 0)
|
||||
_CPFontSystemFontSize = size;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a font with the specified name and size.
|
||||
@param aName the name of the font
|
||||
@param aSize the size of the font (in points)
|
||||
@param aSize the size of the font (in px)
|
||||
@return the requested font
|
||||
*/
|
||||
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO];
|
||||
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO italic:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a font with the specified name, size and style.
|
||||
@param aName the name of the font
|
||||
@param aSize the size of the font (in px)
|
||||
@param italic whether the font should be italicized
|
||||
@return the requested font
|
||||
*/
|
||||
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO italic:italic];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a bold font with the specified name and size.
|
||||
@param aName the name of the font
|
||||
@param aSize the size of the font (in points)
|
||||
@param aSize the size of the font (in px)
|
||||
@return the requested bold font
|
||||
*/
|
||||
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, YES) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES];
|
||||
return _CPCachedFont(aName, aSize, YES, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES italic:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a bold font with the specified name, size and style.
|
||||
@param aName the name of the font
|
||||
@param aSize the size of the font (in px)
|
||||
@param italic whether the font should be italicized
|
||||
@return the requested font
|
||||
*/
|
||||
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES italic:italic];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the system font scaled to the specified size
|
||||
@param aSize the size of the font (in points)
|
||||
@param aSize the size of the font (in px)
|
||||
@return the requested system font
|
||||
*/
|
||||
+ (CPFont)systemFontOfSize:(CPSize)aSize
|
||||
{
|
||||
return _CPCachedFont(_CPFontSystemFontFace, aSize, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:NO];
|
||||
return _CPCachedFont(_CPFontSystemFontFace, aSize, NO, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:NO italic:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the bold system font scaled to the specified size
|
||||
@param aSize the size of the font (in points)
|
||||
@param aSize the size of the font (in px)
|
||||
@return the requested bold system font
|
||||
*/
|
||||
+ (CPFont)boldSystemFontOfSize:(CPSize)aSize
|
||||
{
|
||||
return _CPCachedFont(_CPFontSystemFontFace, aSize, YES) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:YES];
|
||||
return _CPCachedFont(_CPFontSystemFontFace, aSize, YES, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:YES italic:NO];
|
||||
}
|
||||
|
||||
/* FIXME Font Descriptor
|
||||
@ignore
|
||||
*/
|
||||
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold
|
||||
{
|
||||
return [self _initWithName:aName size:aSize bold:isBold italic:NO];
|
||||
}
|
||||
|
||||
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold italic:(BOOL)isItalic
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_name = aName;
|
||||
// Normalize all of the names
|
||||
var names = _CPFontNormalizedNames(aName);
|
||||
|
||||
_name = names[0];
|
||||
_size = aSize;
|
||||
_ascender = 0;
|
||||
_descender = 0;
|
||||
_lineHeight = 0;
|
||||
_isBold = isBold;
|
||||
_isItalic = isItalic;
|
||||
|
||||
_cssString = _CPCreateCSSString(_name, _size, _isBold);
|
||||
_cssString = _CPFontCreateCSSString(names, _size, _isBold, _isItalic);
|
||||
|
||||
_CPFonts[_cssString] = self;
|
||||
}
|
||||
@@ -139,7 +220,7 @@ var _CPFonts = {},
|
||||
|
||||
/*!
|
||||
Returns the bottom y coordinate (in CSS px), offset from the baseline, of the receiver's longest descender.
|
||||
Thus, if the longest descender extends 2 points below the baseline, descender will return –2.
|
||||
Thus, if the longest descender extends 2 px below the baseline, descender will return –2.
|
||||
*/
|
||||
- (float)descender
|
||||
{
|
||||
@@ -188,12 +269,17 @@ var _CPFonts = {},
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
return [anObject isKindOfClass:[CPFont class]] && [anObject cssString] === [self cssString];
|
||||
return [anObject isKindOfClass:[CPFont class]] && [anObject cssString] === _cssString;
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [CPString stringWithFormat:@"%@ %@ %f pt.", [super description], [self familyName], [self size]];
|
||||
return [CPString stringWithFormat:@"%@ %@", [super description], [self cssString]];
|
||||
}
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
return [[CPFont alloc] _initWithName:_name size:_size bold:_isBold italic:_isItalic];
|
||||
}
|
||||
|
||||
- (void)_getMetrics
|
||||
@@ -207,9 +293,10 @@ var _CPFonts = {},
|
||||
|
||||
@end
|
||||
|
||||
var CPFontNameKey = @"CPFontNameKey",
|
||||
CPFontSizeKey = @"CPFontSizeKey",
|
||||
CPFontIsBoldKey = @"CPFontIsBoldKey";
|
||||
var CPFontNameKey = @"CPFontNameKey",
|
||||
CPFontSizeKey = @"CPFontSizeKey",
|
||||
CPFontIsBoldKey = @"CPFontIsBoldKey",
|
||||
CPFontIsItalicKey = @"CPFontIsItalicKey";
|
||||
|
||||
@implementation CPFont (CPCoding)
|
||||
|
||||
@@ -220,9 +307,12 @@ var CPFontNameKey = @"CPFontNameKey",
|
||||
*/
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [self _initWithName:[aCoder decodeObjectForKey:CPFontNameKey]
|
||||
size:[aCoder decodeFloatForKey:CPFontSizeKey]
|
||||
bold:[aCoder decodeBoolForKey:CPFontIsBoldKey]];
|
||||
var fontName = [aCoder decodeObjectForKey:CPFontNameKey],
|
||||
size = [aCoder decodeFloatForKey:CPFontSizeKey],
|
||||
isBold = [aCoder decodeBoolForKey:CPFontIsBoldKey],
|
||||
isItalic = [aCoder decodeBoolForKey:CPFontIsItalicKey];
|
||||
|
||||
return [self _initWithName:fontName size:size bold:isBold italic:isItalic];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -231,9 +321,48 @@ var CPFontNameKey = @"CPFontNameKey",
|
||||
*/
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_name forKey:CPFontNameKey];
|
||||
var name = _cssString.replace(_CPFontStripPropertiesRegExp, "");
|
||||
|
||||
[aCoder encodeObject:name forKey:CPFontNameKey];
|
||||
[aCoder encodeFloat:_size forKey:CPFontSizeKey];
|
||||
[aCoder encodeBool:_isBold forKey:CPFontIsBoldKey];
|
||||
[aCoder encodeBool:_isItalic forKey:CPFontIsItalicKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var _CPFontCreateCSSString = function(aName, aSize, isBold, isItalic)
|
||||
{
|
||||
// aName might be a string or an array of preprocessed names
|
||||
var names = typeof(aName) === "string" ? _CPFontNormalizedNames(aName) : aName,
|
||||
properties = (isItalic ? "italic " : "") + (isBold ? "bold " : "") + aSize + "px ",
|
||||
fallbackFaces = _CPFontFallbackFaces.slice(0);
|
||||
|
||||
// Remove the standard fallback names from the names passed in
|
||||
for (var i = 0; i < fallbackFaces.length; )
|
||||
{
|
||||
for (var j = 0; j < names.length; ++j)
|
||||
{
|
||||
if (fallbackFaces[i].toLowerCase() === names[j].toLowerCase())
|
||||
{
|
||||
fallbackFaces.splice(i, 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
return properties + '"' + names.concat(fallbackFaces).join("\", \"") + '"';
|
||||
};
|
||||
|
||||
var _CPFontNormalizedNames = function(aName)
|
||||
{
|
||||
var names = aName.split(",");
|
||||
|
||||
for (var i = 0; i < names.length; ++i)
|
||||
names[i] = names[i].replace(_CPFontStripRegExp, "");
|
||||
|
||||
return names;
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
CPNumber _selectedIndex;
|
||||
|
||||
CPTabViewType _type;
|
||||
CPFont _font;
|
||||
|
||||
id _delegate;
|
||||
unsigned _delegateSelectors;
|
||||
@@ -415,6 +416,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
CPTabViewSelectedItemKey = "CPTabViewSelectedItemKey",
|
||||
CPTabViewTypeKey = "CPTabViewTypeKey",
|
||||
CPTabViewFontKey = "CPTabViewFontKey",
|
||||
CPTabViewDelegateKey = "CPTabViewDelegateKey";
|
||||
|
||||
@implementation CPTabView (CPCoding)
|
||||
@@ -425,18 +427,23 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
{
|
||||
[self _init];
|
||||
|
||||
_font = [aCoder decodeObjectForKey:CPTabViewFontKey];
|
||||
[_tabs setFont:_font];
|
||||
|
||||
_items = [aCoder decodeObjectForKey:CPTabViewItemsKey];
|
||||
|
||||
[self _updateItems];
|
||||
[self _repositionTabs];
|
||||
|
||||
var selected = [aCoder decodeObjectForKey:CPTabViewSelectedItemKey];
|
||||
|
||||
if (selected)
|
||||
[self selectTabViewItem:selected];
|
||||
|
||||
[self setDelegate:[aCoder decodeObjectForKey:CPTabViewDelegateKey]];
|
||||
|
||||
[self setTabViewType:[aCoder decodeIntForKey:CPTabViewTypeKey]];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -450,6 +457,7 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
[aCoder encodeObject:[self selectedTabViewItem] forKey:CPTabViewSelectedItemKey];
|
||||
|
||||
[aCoder encodeInt:_type forKey:CPTabViewTypeKey];
|
||||
[aCoder encodeObject:_font forKey:CPTabViewFontKey];
|
||||
|
||||
[aCoder encodeConditionalObject:_delegate forKey:CPTabViewDelegateKey];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* FontEnhancements
|
||||
*
|
||||
* Created by aparajita on March 8, 2011.
|
||||
* Copyright 2011, Victory-Heart Productions All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
// This is called when the cib is done loading.
|
||||
// You can implement this method on any object instantiated from a Cib.
|
||||
// It's a useful hook for setting up current UI values, and other things.
|
||||
|
||||
// In this case, we want the window from Cib to become our full browser window
|
||||
[theWindow setFullPlatformWindow:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Main cib file base name</key>
|
||||
<string>MainMenu.cib</string>
|
||||
<key>CPBundleName</key>
|
||||
<string>FontEnhancements</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Jakefile
|
||||
* FontEnhancements
|
||||
*
|
||||
* Created by aparajita on March 8, 2011.
|
||||
* Copyright 2011, Victory-Heart Productions All rights reserved.
|
||||
*/
|
||||
|
||||
var ENV = require("system").env,
|
||||
FILE = require("file"),
|
||||
JAKE = require("jake"),
|
||||
task = JAKE.task,
|
||||
FileList = JAKE.FileList,
|
||||
app = require("cappuccino/jake").app,
|
||||
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
|
||||
OS = require("os");
|
||||
|
||||
app ("FontEnhancements", function(task)
|
||||
{
|
||||
task.setBuildIntermediatesPath(FILE.join("Build", "FontEnhancements.build", configuration));
|
||||
task.setBuildPath(FILE.join("Build", configuration));
|
||||
|
||||
task.setProductName("FontEnhancements");
|
||||
task.setIdentifier("com.aparajitaworld.FontEnhancements");
|
||||
task.setVersion("1.0");
|
||||
task.setAuthor("Victory-Heart Productions");
|
||||
task.setEmail("feedback @nospam@ yourcompany.com");
|
||||
task.setSummary("FontEnhancements");
|
||||
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
|
||||
task.setResources(new FileList("Resources/**"));
|
||||
task.setIndexFilePath("index.html");
|
||||
task.setInfoPlistPath("Info.plist");
|
||||
task.setNib2CibFlags("-R Resources/");
|
||||
|
||||
if (configuration === "Debug")
|
||||
task.setCompilerFlags("-DDEBUG -g");
|
||||
else
|
||||
task.setCompilerFlags("-O");
|
||||
});
|
||||
|
||||
task ("default", ["FontEnhancements"], function()
|
||||
{
|
||||
printResults(configuration);
|
||||
});
|
||||
|
||||
task ("build", ["default"]);
|
||||
|
||||
task ("debug", function()
|
||||
{
|
||||
ENV["CONFIGURATION"] = "Debug";
|
||||
JAKE.subjake(["."], "build", ENV);
|
||||
});
|
||||
|
||||
task ("release", function()
|
||||
{
|
||||
ENV["CONFIGURATION"] = "Release";
|
||||
JAKE.subjake(["."], "build", ENV);
|
||||
});
|
||||
|
||||
task ("run", ["debug"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Debug", "FontEnhancements", "index.html")]);
|
||||
});
|
||||
|
||||
task ("run-release", ["release"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Release", "FontEnhancements", "index.html")]);
|
||||
});
|
||||
|
||||
task ("deploy", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Deployment", "FontEnhancements"));
|
||||
OS.system(["press", "-f", FILE.join("Build", "Release", "FontEnhancements"), FILE.join("Build", "Deployment", "FontEnhancements")]);
|
||||
printResults("Deployment")
|
||||
});
|
||||
|
||||
task ("desktop", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Desktop", "FontEnhancements"));
|
||||
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "FontEnhancements"), FILE.join("Build", "Desktop", "FontEnhancements", "FontEnhancements.app"));
|
||||
printResults("Desktop")
|
||||
});
|
||||
|
||||
task ("run-desktop", ["desktop"], function()
|
||||
{
|
||||
OS.system([FILE.join("Build", "Desktop", "FontEnhancements", "FontEnhancements.app", "Contents", "MacOS", "NativeHost"), "-i"]);
|
||||
});
|
||||
|
||||
function printResults(configuration)
|
||||
{
|
||||
print("----------------------------");
|
||||
print(configuration+" app built at path: "+FILE.join("Build", configuration, "FontEnhancements"));
|
||||
print("----------------------------");
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<!--
|
||||
index-debug.html
|
||||
FontEnhancements
|
||||
|
||||
Created by aparajita on March 8, 2011.
|
||||
Copyright 2011, Victory-Heart Productions All rights reserved.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
|
||||
<link rel="apple-touch-icon" href="Resources/icon.png" />
|
||||
<link rel="apple-touch-startup-image" href="Resources/default.png" />
|
||||
|
||||
<title>FontEnhancements</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
OBJJ_MAIN_FILE = "main.j";
|
||||
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
objj_msgSend_reset();
|
||||
|
||||
// DEBUG OPTIONS:
|
||||
|
||||
// Uncomment to enable printing of backtraces on exceptions:
|
||||
//objj_msgSend_decorate(objj_backtrace_decorator);
|
||||
|
||||
// Uncomment to supress exceptions that take place inside a message
|
||||
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
|
||||
|
||||
// Uncomment to enable runtime type checking:
|
||||
//objj_msgSend_decorate(objj_typecheck_decorator);
|
||||
|
||||
// Uncomment (along with both above) to print backtraces on type check errors:
|
||||
//objj_typecheck_prints_backtrace = true;
|
||||
|
||||
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
|
||||
//CPLogUnregister(CPLogDefault);
|
||||
|
||||
// Uncomment to enable a specific logger:
|
||||
//CPLogRegister(CPLogConsole);
|
||||
//CPLogRegister(CPLogPopup);
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
body{margin:0; padding:0;}
|
||||
#container {position: absolute; top:50%; left:50%;}
|
||||
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
|
||||
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
|
||||
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
|
||||
</style>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<STYLE type="text/css">
|
||||
#container { position: relative; top: 50%; }
|
||||
#content { position: relative;}
|
||||
</STYLE>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div id="cappuccino-body">
|
||||
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
|
||||
<script type="text/javascript">
|
||||
document.write("<div id='container'><p id='content'>" +
|
||||
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
|
||||
"Loading FontEnhancements...</p></div>");
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<div id="container">
|
||||
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
|
||||
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
|
||||
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
|
||||
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
|
||||
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
|
||||
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
|
||||
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
|
||||
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
|
||||
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
|
||||
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<!--
|
||||
index.html
|
||||
FontEnhancements
|
||||
|
||||
Created by aparajita on March 8, 2011.
|
||||
Copyright 2011, Victory-Heart Productions All rights reserved.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
|
||||
<link rel="apple-touch-icon" href="Resources/icon.png" />
|
||||
<link rel="apple-touch-startup-image" href="Resources/default.png" />
|
||||
|
||||
<title>FontEnhancements</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
OBJJ_MAIN_FILE = "main.j";
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body{margin:0; padding:0;}
|
||||
#container {position: absolute; top:50%; left:50%;}
|
||||
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
|
||||
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
|
||||
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
|
||||
</style>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<STYLE type="text/css">
|
||||
#container { position: relative; top: 50%; }
|
||||
#content { position: relative;}
|
||||
</STYLE>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div id="cappuccino-body">
|
||||
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
|
||||
<script type="text/javascript">
|
||||
document.write("<div id='container'><p id='content'>" +
|
||||
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
|
||||
"Loading FontEnhancements...</p></div>");
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<div id="container">
|
||||
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
|
||||
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
|
||||
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
|
||||
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
|
||||
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
|
||||
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
|
||||
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
|
||||
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
|
||||
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
|
||||
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* FontEnhancements
|
||||
*
|
||||
* Created by aparajita on March 8, 2011.
|
||||
* Copyright 2011, Victory-Heart Productions All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
@import "AppController.j"
|
||||
|
||||
|
||||
function main(args, namedArgs)
|
||||
{
|
||||
CPApplicationMain(args, namedArgs);
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
var unarchiver = [[Nib2CibKeyedUnarchiver alloc] initForReadingWithData:data resourcesPath:aResourcesPath],
|
||||
objectData = [unarchiver decodeObjectForKey:@"IB.objectdata"];
|
||||
|
||||
// Perform a bit of post-processing on views since all CP views are flipped.
|
||||
// Perform a bit of post-processing on fonts and views since all CP views are flipped.
|
||||
// It's better to do this here (instead of say, in NSView::initWithCoder:),
|
||||
// because at this point all the objects an mappings are stabilized.
|
||||
var objects = [unarchiver allObjects],
|
||||
@@ -42,6 +42,26 @@
|
||||
{
|
||||
var object = objects[count];
|
||||
|
||||
if ([object respondsToSelector:@selector(font)] &&
|
||||
[object respondsToSelector:@selector(setFont:)] &&
|
||||
[object font] != nil)
|
||||
{
|
||||
var nibFont = [object font],
|
||||
cibFont = nil;
|
||||
|
||||
if ([object respondsToSelector:@selector(cibFontForNibFont)])
|
||||
cibFont = [object cibFontForNibFont];
|
||||
else
|
||||
cibFont = [NSFont cibFontForNibFont:[object font]];
|
||||
|
||||
if (![cibFont isEqual:nibFont])
|
||||
{
|
||||
[object setFont:cibFont];
|
||||
|
||||
CPLog.debug("%s: substituted <%s> for <%fpx %s>", [object className], cibFont ? [cibFont cssString] : "theme default", [nibFont size], [nibFont familyName]);
|
||||
}
|
||||
}
|
||||
|
||||
if (![object isKindOfClass:[CPView class]])
|
||||
continue;
|
||||
|
||||
|
||||
+43
-19
@@ -18,35 +18,55 @@
|
||||
* 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 <Foundation/CPObject.j>
|
||||
@import <Foundation/CPData.j>
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
@import <BlendKit/BlendKit.j>
|
||||
|
||||
var FILE = require("file"),
|
||||
OS = require("os");
|
||||
OS = require("os"),
|
||||
|
||||
SharedConverter = nil;
|
||||
|
||||
NibFormatUndetermined = 0,
|
||||
NibFormatMac = 1,
|
||||
NibFormatIPhone = 2;
|
||||
NibFormatUndetermined = 0,
|
||||
NibFormatMac = 1,
|
||||
NibFormatIPhone = 2;
|
||||
|
||||
ConverterConversionException = @"ConverterConversionException";
|
||||
ConverterModeLegacy = 0;
|
||||
ConverterModeNew = 1;
|
||||
|
||||
ConverterConversionException = @"ConverterConversionException";
|
||||
|
||||
@implementation Converter : CPObject
|
||||
{
|
||||
NibFormat format @accessors;
|
||||
CPString inputPath @accessors;
|
||||
CPString outputPath @accessors;
|
||||
CPString resourcesPath @accessors;
|
||||
CPString inputPath @accessors(readonly);
|
||||
CPString outputPath @accessors;
|
||||
CPString resourcesPath @accessors;
|
||||
ConverterLayoutMode layoutMode @accessors(readonly);
|
||||
NibFormat format @accessors(readonly);
|
||||
CPTheme theme @accessors(readonly);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
+ (Converter)sharedConverter
|
||||
{
|
||||
if (!SharedConverter)
|
||||
SharedConverter = [[Converter alloc] init];
|
||||
|
||||
return SharedConverter;
|
||||
}
|
||||
|
||||
- (id)initWithInputPath:(CPString)aPath format:(NibFormat)nibFormat layoutMode:(ConverterLayoutMode)aLayoutMode theme:(CPTheme)aTheme
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
[self setFormat:NibFormatUndetermined];
|
||||
{
|
||||
inputPath = aPath;
|
||||
format = nibFormat;
|
||||
layoutMode = aLayoutMode;
|
||||
theme = aTheme;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -87,8 +107,9 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
outputPath = inputPath.substr(0, inputPath.length - FILE.extension(inputPath).length) + ".cib";
|
||||
|
||||
FILE.write(outputPath, [convertedData rawString], { charset:"UTF-8" });
|
||||
CPLog.info("Conversion successful");
|
||||
}
|
||||
catch(anException)
|
||||
catch (anException)
|
||||
{
|
||||
CPLog.fatal(anException);
|
||||
}
|
||||
@@ -96,17 +117,19 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
|
||||
- (CPData)CPCompliantNibDataAtFilePath:(CPString)aFilePath
|
||||
{
|
||||
CPLog.info("Converting Xib file to plist...");
|
||||
|
||||
// Compile xib or nib to make sure we have a non-new format nib.
|
||||
var temporaryNibFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.nib");
|
||||
|
||||
if (OS.popen(["/usr/bin/ibtool", aFilePath, "--compile", temporaryNibFilePath]).wait() === 1)
|
||||
throw "Could not compile file at " + aFilePath;
|
||||
throw "Could not compile file: " + aFilePath;
|
||||
|
||||
// Convert from binary plist to XML plist
|
||||
var temporaryPlistFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.plist");
|
||||
|
||||
if (OS.popen(["/usr/bin/plutil", "-convert", "xml1", temporaryNibFilePath, "-o", temporaryPlistFilePath]).wait() === 1)
|
||||
throw "Could not convert to xml plist for file at " + aFilePath;
|
||||
throw "Could not convert to xml plist for file: " + aFilePath;
|
||||
|
||||
if (!FILE.isReadable(temporaryPlistFilePath))
|
||||
[CPException raise:ConverterConversionException reason:@"Unable to convert nib file."];
|
||||
@@ -121,8 +144,9 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
else
|
||||
plistContents = plistContents.replace(/\<key\>\s*CF\$UID\s*\<\/key\>/g, "<key>CP$UID</key>");
|
||||
|
||||
plistContents = plistContents.replace(/<string>[\u0000-\u0008\u000B\u000C\u000E-\u001F]<\/string>/g, function(c) {
|
||||
CPLog.warn("Warning: Converting character 0x"+c.charCodeAt(8).toString(16)+" to base64 representation");
|
||||
plistContents = plistContents.replace(/<string>[\u0000-\u0008\u000B\u000C\u000E-\u001F]<\/string>/g, function(c)
|
||||
{
|
||||
CPLog.warn("Warning: converting character 0x" + c.charCodeAt(8).toString(16) + " to base64 representation");
|
||||
return "<string type=\"base64\">"+CFData.encodeBase64String(c.charAt(8))+"</string>";
|
||||
});
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ function CP_NSMapClassName(aClassName)
|
||||
|
||||
if (CPClassFromString(mappedClassName))
|
||||
{
|
||||
CPLog.info("Mapping " + aClassName + " to " + mappedClassName);
|
||||
CPLog.debug("NSAppKit: mapping " + aClassName + " to " + mappedClassName);
|
||||
|
||||
return mappedClassName;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
|
||||
var _CPButtonBezelStyleHeights = {};
|
||||
|
||||
_CPButtonBezelStyleHeights[CPRoundedBezelStyle] = 18;
|
||||
_CPButtonBezelStyleHeights[CPTexturedRoundedBezelStyle] = 20;
|
||||
_CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20;
|
||||
@@ -100,18 +101,18 @@ var NSButtonIsBorderedMask = 0x00800000,
|
||||
case CPHelpButtonBezelStyle:
|
||||
case CPCircularBezelStyle:
|
||||
case CPDisclosureBezelStyle:
|
||||
CPLog.warn("Unsupported bezel style: " + _bezelStyle);
|
||||
CPLog.warn("NSButton [%s]: unsupported bezel style: %d", _title == null ? "<no title>" : '"' + _title + '"', _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// error:
|
||||
default:
|
||||
CPLog.error("Unknown bezel style: " + _bezelStyle);
|
||||
CPLog.warn("NSButton [%s]: unknown bezel style: %d", _title == null ? "<no title>" : '"' + _title + '"', _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
}
|
||||
|
||||
if ([cell isBordered])
|
||||
{
|
||||
CPLog.info("Adjusting CPButton height from " +_frame.size.height+ " / " + _bounds.size.height+" to " + CPButtonDefaultHeight);
|
||||
CPLog.debug("NSButton [%s]: adjusting height from %d to %d", _title == null ? "<no title>" : '"' + _title + '"', _frame.size.height, CPButtonDefaultHeight);
|
||||
_frame.size.height = CPButtonDefaultHeight;
|
||||
_frame.origin.y += 4.0;
|
||||
_bounds.size.height = CPButtonDefaultHeight;
|
||||
|
||||
@@ -119,7 +119,7 @@ var NSUnknownColorSpaceModel = -1,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CPLog(@"-[%@ %s] unknown color space %d", isa, _cmd, colorSpace);
|
||||
CPLog.warn(@"-[%@ %s] unknown color space %d", isa, _cmd, colorSpace);
|
||||
result = [CPColor blackColor];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ var FILE = require("file");
|
||||
var size = CGSizeMakeZero();
|
||||
|
||||
if (![[aCoder resourcesPath] length])
|
||||
CPLog.warn("*** WARNING: Resources found in nib, but no resources path specified with -R option.");
|
||||
CPLog.warn("Resources found in nib, but no resources path specified with -R option.");
|
||||
else
|
||||
{
|
||||
var resourcePath = [aCoder resourcePathForName:_resourceName];
|
||||
|
||||
if (!resourcePath)
|
||||
CPLog.warn("*** WARNING: Resource named " + _resourceName + " not found in supplied resources path.");
|
||||
CPLog.warn("Resource named " + _resourceName + " not found in the supplied resources path.");
|
||||
else
|
||||
size = imageSize(FILE.join(FILE.cwd(), resourcePath));
|
||||
|
||||
|
||||
+35
-14
@@ -22,35 +22,56 @@
|
||||
|
||||
@import <AppKit/CPFont.j>
|
||||
|
||||
var OS = require("os"),
|
||||
fontinfo = require("fontinfo").fontinfo;
|
||||
|
||||
var IBDefaultFontFace = @"Lucida Grande",
|
||||
IBDefaultFontSize = 13.0;
|
||||
|
||||
@implementation CPFont (NSCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
var isBold = NO,
|
||||
fontName = [aCoder decodeObjectForKey:@"NSName"],
|
||||
size = [aCoder decodeDoubleForKey:@"NSSize"];
|
||||
var name = [aCoder decodeObjectForKey:@"NSName"],
|
||||
size = [aCoder decodeDoubleForKey:@"NSSize"],
|
||||
isBold = false,
|
||||
isItalic = false,
|
||||
info = fontinfo(name, size);
|
||||
|
||||
if (fontName === "LucidaGrande" && size === 13)
|
||||
if (info)
|
||||
{
|
||||
CPLog.debug("Removing default IB font: <"+fontName+", "+size+"> for theme default font.");
|
||||
return nil;
|
||||
name = info.familyName;
|
||||
isBold = info.bold;
|
||||
isItalic = info.italic;
|
||||
}
|
||||
|
||||
// FIXME: Is this alwasy true?
|
||||
if (fontName.indexOf("-Bold") === fontName.length - "-Bold".length)
|
||||
isBold = YES;
|
||||
|
||||
if (fontName === "LucidaGrande" || fontName === "LucidaGrande-Bold")
|
||||
fontName = "Arial";
|
||||
|
||||
return [self _initWithName:fontName size:size bold:isBold];
|
||||
return [self _initWithName:name size:size bold:isBold italic:isItalic];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSFont : CPFont
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
CPLog.debug("NSFont: default IB font: %s %f", IBDefaultFontFace, IBDefaultFontSize);
|
||||
}
|
||||
|
||||
+ (id)cibFontForNibFont:(CPFont)aFont
|
||||
{
|
||||
var name = [aFont familyName];
|
||||
|
||||
if (name === IBDefaultFontFace)
|
||||
{
|
||||
var size = [aFont size];
|
||||
|
||||
if (size === IBDefaultFontSize)
|
||||
return nil;
|
||||
else
|
||||
return [[CPFont alloc] _initWithName:[CPFont systemFontFace] size:size bold:[aFont isBold] italic:[aFont isItalic]];
|
||||
}
|
||||
|
||||
return [aFont copy];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
|
||||
children.forEach(function(aChild)
|
||||
{
|
||||
CPLog.info("Promoted " + aChild + " to child of " + parent);
|
||||
CPLog.debug("NSIBObjectData: promoted " + aChild + " to child of " + parent);
|
||||
_objectsKeys.push(aChild);
|
||||
_objectsValues.push(parent);
|
||||
});
|
||||
|
||||
@@ -45,6 +45,7 @@ var NSMatrixRadioModeMask = 0x40000000,
|
||||
[cellView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
[cellView setTitle:[cell title]];
|
||||
[cellView setBackgroundColor:[CPColor clearColor]]; // the IB default
|
||||
[cellView setFont:[cell font]];
|
||||
[cellView setObjectValue:[cell objectValue]];
|
||||
|
||||
[view addSubview:cellView];
|
||||
|
||||
@@ -43,17 +43,17 @@ NIB_CONNECTION_EQUIVALENCY_TABLE = {};
|
||||
|
||||
if (sourceUID in NIB_CONNECTION_EQUIVALENCY_TABLE)
|
||||
{
|
||||
CPLog.trace("Swapped object: "+_source+" for object: "+NIB_CONNECTION_EQUIVALENCY_TABLE[sourceUID]);
|
||||
CPLog.debug("NSNibConnector: swapped object: " + _source + " for object: " + NIB_CONNECTION_EQUIVALENCY_TABLE[sourceUID]);
|
||||
_source = NIB_CONNECTION_EQUIVALENCY_TABLE[sourceUID];
|
||||
}
|
||||
|
||||
if (destinationUID in NIB_CONNECTION_EQUIVALENCY_TABLE)
|
||||
{
|
||||
CPLog.trace("Swapped object: "+_destination+" for object: "+NIB_CONNECTION_EQUIVALENCY_TABLE[destinationUID]);
|
||||
CPLog.debug("NSNibConnector: swapped object: " + _destination + " for object: " + NIB_CONNECTION_EQUIVALENCY_TABLE[destinationUID]);
|
||||
_destination = NIB_CONNECTION_EQUIVALENCY_TABLE[destinationUID];
|
||||
}
|
||||
|
||||
CPLog.debug(@"Connection: " + [_source description] + " " + [_destination description] + " " + _label);
|
||||
CPLog.debug(@"NSNibConnector: connection: " + [_source description] + " " + [_destination description] + " " + _label);
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -144,7 +144,7 @@ var NSTramsformers = [CPSet setWithObjects:
|
||||
[_options setObject:NSValue forKey:CPKey];
|
||||
}
|
||||
|
||||
CPLog.debug(@"Binding Connector: " + [_binding description] + " to: " + _destination + " " + [_keyPath description] + " " + [_options description]);
|
||||
CPLog.debug(@"NSNibConnector: binding connector: " + [_binding description] + " to: " + _destination + " " + [_keyPath description] + " " + [_options description]);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
_items = [aCoder decodeObjectForKey:@"NSTabViewItems"];
|
||||
_selectedIndex = [_items indexOfObject:[aCoder decodeObjectForKey:@"NSSelectedTabViewItem"]];
|
||||
_font = [aCoder decodeObjectForKey:@"NSFont"];
|
||||
|
||||
//_delegate = [aCoder decodeObjectForKey:@""];
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
selectedFont = nil;
|
||||
|
||||
if (!font)
|
||||
font = [CPFont systemFontOfSize:12.0];
|
||||
font = [CPFont systemFontOfSize:[CPFont systemFontSize]];
|
||||
|
||||
var selectedFont = [CPFont boldFontWithName:[font familyName] size:[font size]];
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
[self setFrameSize:CGSizeMake(frame.size.width + 7.0, frame.size.height + 7.0)];
|
||||
}
|
||||
|
||||
CPLog.debug([self stringValue] + " => isBordered=" + [self isBordered] + ", isBezeled=" + [self isBezeled] + ", bezelStyle=" + [self bezelStyle] + "("+[cell stringValue]+", " + [cell placeholderString] + ")");
|
||||
CPLog.debug("NSTextField: title=\"" + [self stringValue] + "\", placeholder=" + ([cell placeholderString] == null ? "<none>" : '"' + [cell placeholderString] + '"') + ", isBordered=" + [self isBordered] + ", isBezeled=" + [self isBezeled] + ", bezelStyle=" + [self bezelStyle]);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
+11
-2
@@ -30,6 +30,17 @@ var NSViewAutoresizingMask = 0x3F,
|
||||
NSViewAutoresizesSubviewsMask = 1 << 8,
|
||||
NSViewHiddenMask = 1 << 31;
|
||||
|
||||
NSViewAlignLayoutMinValue = 1000;
|
||||
NSViewAlignLayoutBaselineLeft = 1000;
|
||||
NSViewAlignLayoutTopLeft = 2000;
|
||||
NSViewAlignLayoutTop = 3000;
|
||||
NSViewAlignLayoutTopRight = 4000;
|
||||
NSViewAlignLayoutBaselineRight = 5000;
|
||||
NSViewAlignLayoutBottomRight = 6000;
|
||||
NSViewAlignLayoutBottom = 7000;
|
||||
NSViewAlignLayoutBottomLeft = 8000;
|
||||
NSViewAlignLayoutMaxValue = 8000;
|
||||
|
||||
@implementation CPView (NSCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
@@ -84,8 +95,6 @@ var NSViewAutoresizingMask = 0x3F,
|
||||
@end
|
||||
|
||||
@implementation NSView : CPView
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
|
||||
+279
-20
@@ -18,11 +18,11 @@
|
||||
* 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 <Foundation/Foundation.j>
|
||||
|
||||
@import <AppKit/CPCib.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
@import <BlendKit/BlendKit.j>
|
||||
|
||||
@import "NSFoundation.j"
|
||||
@import "NSAppKit.j"
|
||||
@@ -30,8 +30,12 @@
|
||||
@import "Nib2CibKeyedUnarchiver.j"
|
||||
@import "Converter.j"
|
||||
|
||||
var FILE = require("file");
|
||||
var OS = require("os");
|
||||
var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
SYS = require("system"),
|
||||
|
||||
DefaultTheme = "Aristo",
|
||||
BuildTypes = ["Debug", "Release"];
|
||||
|
||||
var parser = new (require("narwhal/args").Parser)();
|
||||
|
||||
@@ -50,6 +54,19 @@ parser.option("--mac", "format")
|
||||
.def(NibFormatUndetermined)
|
||||
.help("Set format to Mac");
|
||||
|
||||
parser.option("--legacy", "conversionMode")
|
||||
.set(ConverterModeLegacy)
|
||||
.def(ConverterModeNew)
|
||||
.help("Use legacy code that does not preserve view positioning/sizing");
|
||||
|
||||
parser.option("-t", "--theme-dir", "themeDir")
|
||||
.set()
|
||||
.help("A <theme>.build directory to use for theme attribute values");
|
||||
|
||||
parser.option("--config", "configFile")
|
||||
.set()
|
||||
.help("A path to an Info.plist file from which the system font and/or size can be retrieved");
|
||||
|
||||
// parser.option("--iphone", "format")
|
||||
// .set(NibFormatIPhone)
|
||||
// .help("Set format to iPhone");
|
||||
@@ -62,6 +79,10 @@ parser.option("-q", "--quiet", "quiet")
|
||||
.set(true)
|
||||
.help("No output");
|
||||
|
||||
parser.option("--version", "showVersion")
|
||||
.set(true)
|
||||
.help("Show the version of nib2cib and quit");
|
||||
|
||||
parser.helpful();
|
||||
|
||||
function loadFrameworks(frameworkPaths, aCallback)
|
||||
@@ -83,39 +104,76 @@ function loadFrameworks(frameworkPaths, aCallback)
|
||||
aCallback();
|
||||
}
|
||||
|
||||
function logFormatter(aString, aLevel, aTitle)
|
||||
{
|
||||
return CPLogColorize(aString, aLevel);
|
||||
}
|
||||
|
||||
function main(args)
|
||||
{
|
||||
var options = parser.parse(args, null, null, true);
|
||||
|
||||
if (options.args.length < 1 || options.args.length > 2)
|
||||
if (options.args.length > 2)
|
||||
{
|
||||
parser.printUsage(options);
|
||||
OS.exit(1);
|
||||
OS.exit(0);
|
||||
}
|
||||
|
||||
if (options.quiet) {}
|
||||
else if (options.verbose === 0)
|
||||
CPLogRegister(CPLogPrint, "warn");
|
||||
CPLogRegister(CPLogPrint, "warn", logFormatter);
|
||||
else if (options.verbose === 1)
|
||||
CPLogRegister(CPLogPrint, "info");
|
||||
CPLogRegister(CPLogPrint, "info", logFormatter);
|
||||
else
|
||||
CPLogRegister(CPLogPrint);
|
||||
CPLogRegister(CPLogPrint, null, logFormatter);
|
||||
|
||||
CPLog.debug("Input: " + options.args[0]);
|
||||
CPLog.debug("Output: " + (options.args[1] || ""));
|
||||
CPLog.debug("Format: " + ["Auto","Mac","iPhone"][options.format]);
|
||||
CPLog.debug("Resources: " + (options.resources || ""));
|
||||
CPLog.debug("Frameworks: " + options.frameworks);
|
||||
printVersion();
|
||||
|
||||
var converter = [[Converter alloc] init];
|
||||
if (options.showVersion)
|
||||
OS.exit(0);
|
||||
|
||||
var inputFile = options.args[0];
|
||||
|
||||
if (!FILE.exists(inputFile))
|
||||
fail("No such file: " + FILE.canonical(inputFile));
|
||||
|
||||
if (options.layoutMode === ConverterModeNew && !haveFontInfo())
|
||||
fail("The fontinfo package is not installed, please install it.");
|
||||
|
||||
var configPath = setSystemFontAndSize(options.configFile || "", inputFile),
|
||||
themeName = "",
|
||||
themeDir = options.themeDir || "";
|
||||
|
||||
if (themeDir)
|
||||
themeName = FILE.basename(themeDir, FILE.extension(themeDir));
|
||||
|
||||
themeName = themeName || getDefaultThemeName();
|
||||
|
||||
if (!themeName)
|
||||
fail("Could not determine the theme name.");
|
||||
|
||||
var theme = loadTheme(themeName, themeDir);
|
||||
|
||||
CPLog.info("\n-------------------------------------------------------------");
|
||||
CPLog.info("Input : " + FILE.canonical(inputFile));
|
||||
CPLog.info("Output : " + (options.args[1] || ""));
|
||||
CPLog.info("Format : " + ["Auto", "Mac", "iPhone"][options.format]);
|
||||
CPLog.info("Resources : " + (options.resources || ""));
|
||||
CPLog.info("Frameworks : " + options.frameworks);
|
||||
CPLog.info("Layout Mode : " + (options.layoutMode === ConverterModeLegacy ? "legacy" : "new"));
|
||||
CPLog.info("Theme : " + themeName);
|
||||
CPLog.info("Config file : " + (configPath || ""));
|
||||
CPLog.info("System Font : " + [CPFont systemFontSize] + "px " + [CPFont systemFontFace]);
|
||||
CPLog.info("-------------------------------------------------------------\n");
|
||||
|
||||
var converter = [[Converter alloc] initWithInputPath:inputFile
|
||||
format:options.format
|
||||
layoutMode:options.layoutMode
|
||||
theme:theme];
|
||||
|
||||
if (options.resources)
|
||||
[converter setResourcesPath:options.resources];
|
||||
|
||||
[converter setFormat:options.format];
|
||||
|
||||
[converter setInputPath:options.args[0]];
|
||||
|
||||
if (options.args.length > 1)
|
||||
[converter setOutputPath:options.args[1]];
|
||||
|
||||
@@ -124,3 +182,204 @@ function main(args)
|
||||
[converter convert];
|
||||
});
|
||||
}
|
||||
|
||||
function getDefaultThemeName()
|
||||
{
|
||||
var themeName = nil,
|
||||
cappBuild = SYS.env["CAPP_BUILD"];
|
||||
|
||||
if (cappBuild)
|
||||
{
|
||||
for (var i = 0; i < BuildTypes.length; ++i)
|
||||
{
|
||||
var path = FILE.join(cappBuild, BuildTypes[i], "AppKit", "Info.plist");
|
||||
themeName = themeNameFromPropertyList(path);
|
||||
|
||||
if (themeName)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return themeName || DefaultTheme;
|
||||
}
|
||||
|
||||
function themeNameFromPropertyList(path)
|
||||
{
|
||||
if (!FILE.exists(path))
|
||||
return nil;
|
||||
|
||||
var themeName = nil,
|
||||
plist = CFPropertyList.readPropertyListFromFile(path);
|
||||
|
||||
if (plist)
|
||||
themeName = plist.valueForKey("CPDefaultTheme");
|
||||
|
||||
return themeName;
|
||||
}
|
||||
|
||||
function loadTheme(themeName, themeDir)
|
||||
{
|
||||
if (!themeDir)
|
||||
{
|
||||
cappBuild = SYS.env["CAPP_BUILD"];
|
||||
|
||||
if (!cappBuild)
|
||||
fail("Could not find $CAPP_BUILD, exiting.");
|
||||
|
||||
var baseThemeName = themeName,
|
||||
pos = themeName.indexOf("-");
|
||||
|
||||
if (pos > 0)
|
||||
baseThemeName = themeName.substr(0, pos);
|
||||
|
||||
themeDir = FILE.join(cappBuild, baseThemeName + ".build");
|
||||
}
|
||||
|
||||
if (!FILE.isDirectory(themeDir))
|
||||
fail("No such theme directory: " + themeDir);
|
||||
|
||||
var themePath = null;
|
||||
|
||||
for (var i = 0; i < BuildTypes.length; ++i)
|
||||
{
|
||||
var path = FILE.join(themeDir, BuildTypes[i], "Browser.environment/Resources", themeName + ".keyedtheme");
|
||||
|
||||
if (FILE.exists(path))
|
||||
{
|
||||
themePath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!themePath)
|
||||
fail("Could not find the keyed theme data for: " + themeName);
|
||||
|
||||
themePath = FILE.canonical(themePath);
|
||||
var plist = FILE.read(themePath);
|
||||
|
||||
if (!plist)
|
||||
fail("Could not read the keyed theme at: " + themePath);
|
||||
|
||||
// The .keyedtheme file has a header that is data I don't need. Strip it off.
|
||||
var m = plist.match(/^t;\d+;/);
|
||||
|
||||
if (!m || m.length === 0)
|
||||
fail("Invalid keyed theme data at: " + themePath);
|
||||
|
||||
plist = plist.substr(m[0].length);
|
||||
plist = CFPropertyList.propertyListFromString(plist);
|
||||
|
||||
var data = [CPData dataWithPlistObject:plist],
|
||||
theme = [CPKeyedUnarchiver unarchiveObjectWithData:data];
|
||||
|
||||
if (!theme)
|
||||
fail("Could not unarchive the theme at: " + themePath);
|
||||
|
||||
CPLog.debug("Loaded theme: " + themePath);
|
||||
return theme;
|
||||
}
|
||||
|
||||
function haveFontInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var fontinfo = require("fontinfo").fontinfo;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function setSystemFontAndSize(configFile, inputFile)
|
||||
{
|
||||
var configPath = null;
|
||||
|
||||
// First see if the user passed a config file path
|
||||
if (configFile)
|
||||
{
|
||||
var path = FILE.canonical(configFile);
|
||||
|
||||
if (!FILE.exists(path))
|
||||
fail("Cannot find the config file: " + path);
|
||||
|
||||
configPath = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
// See if we can find an Info.plist in the parent directory of the input file,
|
||||
// if the input file's directory is "Resources".
|
||||
var path = FILE.canonical(FILE.dirname(inputFile));
|
||||
|
||||
if (FILE.basename(path) === "Resources")
|
||||
{
|
||||
path = FILE.join(FILE.dirname(path), "Info.plist");
|
||||
|
||||
if (FILE.exists(path))
|
||||
configPath = path;
|
||||
}
|
||||
}
|
||||
|
||||
if (configPath)
|
||||
{
|
||||
var plist = FILE.read(configPath);
|
||||
|
||||
if (!plist)
|
||||
fail("Could not read the Info.plist at: " + configPath);
|
||||
|
||||
plist = CFPropertyList.propertyListFromString(plist);
|
||||
|
||||
if (!plist)
|
||||
fail("Could not parse the Info.plist at: " + configPath);
|
||||
|
||||
var systemFontFace = plist.valueForKey("CPSystemFontFace");
|
||||
|
||||
if (systemFontFace)
|
||||
[CPFont setSystemFontFace:systemFontFace];
|
||||
|
||||
var systemFontSize = plist.valueForKey("CPSystemFontSize");
|
||||
|
||||
if (systemFontSize)
|
||||
[CPFont setSystemFontSize:parseFloat(systemFontSize, 10)];
|
||||
}
|
||||
|
||||
return configPath;
|
||||
}
|
||||
|
||||
function printVersion()
|
||||
{
|
||||
// SYS.args[0] has the path to the nib2cib binary, from that we can get
|
||||
// to the lib/nib2cib directory which the Info.plist for nib2cib.
|
||||
var path = FILE.dirname(FILE.dirname(SYS.args[0]));
|
||||
|
||||
if (FILE.basename(path) === "narwhal")
|
||||
path = FILE.join(path, "packages", "cappuccino");
|
||||
|
||||
path = FILE.join(path, "lib", "nib2cib", "Info.plist");
|
||||
|
||||
if (FILE.exists(path))
|
||||
{
|
||||
var plist = FILE.read(path);
|
||||
|
||||
if (!plist)
|
||||
return;
|
||||
|
||||
plist = CFPropertyList.propertyListFromString(plist);
|
||||
|
||||
if (!plist)
|
||||
return;
|
||||
|
||||
var version = plist.valueForKey("CPBundleVersion");
|
||||
|
||||
if (version)
|
||||
print("nib2cib v" + version);
|
||||
}
|
||||
}
|
||||
|
||||
function fail(message)
|
||||
{
|
||||
CPLog.error(message);
|
||||
OS.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user