mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-25 20:00:42 +00:00
Merge branch 'master' of git@github.com:280north/cappuccino
This commit is contained in:
@@ -199,6 +199,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
if (!_wellView)
|
||||
{
|
||||
_wellView = [[CPView alloc] initWithFrame:aRect];
|
||||
[_wellView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
[self addSubview:_wellView];
|
||||
}
|
||||
@@ -272,7 +273,10 @@ var CPColorWellColorKey = "CPColorWellColorKey",
|
||||
_active = NO;
|
||||
_bordered = [aCoder decodeObjectForKey:CPColorWellBorderedKey];
|
||||
_color = [aCoder decodeObjectForKey:CPColorWellColorKey];
|
||||
|
||||
|
||||
[self drawBezelWithHighlight:NO];
|
||||
[self drawWellInside:CGRectInset([self bounds], 3.0, 3.0)];
|
||||
|
||||
[self _registerForNotifications];
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -430,7 +430,7 @@ function CPPointFromString(aString)
|
||||
{
|
||||
var comma = aString.indexOf(',');
|
||||
|
||||
return { x:parseFloat(aString.substr(1, comma - 1)), y:parseFloat(aString.substring(comma + 1, aString.length)) };
|
||||
return { x:parseFloat(aString.substr(1, comma - 1), 10), y:parseFloat(aString.substring(comma + 1, aString.length), 10) };
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -443,7 +443,7 @@ function CPSizeFromString(aString)
|
||||
{
|
||||
var comma = aString.indexOf(',');
|
||||
|
||||
return { width:parseFloat(aString.substr(1, comma - 1)), height:parseFloat(aString.substring(comma + 1, aString.length)) };
|
||||
return { width:parseFloat(aString.substr(1, comma - 1), 10), height:parseFloat(aString.substring(comma + 1, aString.length), 10) };
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -35,8 +35,10 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
|
||||
|
||||
if (self)
|
||||
{
|
||||
_minSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMinSizeKey];
|
||||
_maxSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMaxSizeKey];
|
||||
if ([aCoder containsValueForKey:_CPCibWindowTemplateMinSizeKey])
|
||||
_minSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMinSizeKey];
|
||||
if ([aCoder containsValueForKey:_CPCibWindowTemplateMaxSizeKey])
|
||||
_maxSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMaxSizeKey];
|
||||
|
||||
_viewClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateViewClassKey];
|
||||
|
||||
@@ -53,8 +55,10 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeSize:_minSize forKey:_CPCibWindowTemplateMinSizeKey];
|
||||
[aCoder encodeSize:_maxSize forKey:_CPCibWindowTemplateMaxSizeKey];
|
||||
if (_minSize)
|
||||
[aCoder encodeSize:_minSize forKey:_CPCibWindowTemplateMinSizeKey];
|
||||
if (_maxSize)
|
||||
[aCoder encodeSize:_maxSize forKey:_CPCibWindowTemplateMaxSizeKey];
|
||||
|
||||
[aCoder encodeObject:_viewClass forKey:_CPCibWindowTemplateViewClassKey];
|
||||
|
||||
@@ -74,12 +78,13 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
|
||||
[NSException raise:NSInvalidArgumentException format:@"Unable to locate NSWindow class %@, using NSWindow",_windowClass];
|
||||
class=[NSWindow class];*/
|
||||
|
||||
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:CPHUDBackgroundWindowMask | CPClosableWindowMask];//styleMask:_windowStyleMask];
|
||||
// alert(CPStringFromRect(_windowRect));
|
||||
// alert(CPStringFromSize(_minSize));
|
||||
// alert(CPStringFromSize(_maxSize));
|
||||
//[theWindow setMinSize:_minSize];
|
||||
//[theWindow setMaxSize:_maxSize];
|
||||
_windowStyleMask = (CPHUDBackgroundWindowMask | CPClosableWindowMask | CPResizableWindowMask);
|
||||
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
|
||||
|
||||
if (_minSize)
|
||||
[theWindow setMinSize:_minSize];
|
||||
if (_maxSize)
|
||||
[theWindow setMaxSize:_maxSize];
|
||||
[theWindow setLevel:CPFloatingWindowLevel];
|
||||
|
||||
//[result setHidesOnDeactivate:(_wtFlags&0x80000000)?YES:NO];
|
||||
|
||||
+22
-21
@@ -27,9 +27,9 @@ var CPLogDefaultTitle = "Cappuccino";
|
||||
var CPLogLevels = ["fatal", "error", "warn", "info", "debug", "trace"];
|
||||
var CPLogDefaultLevel = CPLogLevels[0];
|
||||
|
||||
var CPLogLevelsInverted = {};
|
||||
var _CPLogLevelsInverted = {};
|
||||
for (var i = 0; i < CPLogLevels.length; i++)
|
||||
CPLogLevelsInverted[CPLogLevels[i]] = i;
|
||||
_CPLogLevelsInverted[CPLogLevels[i]] = i;
|
||||
|
||||
var _CPLogRegistrations = {};
|
||||
|
||||
@@ -37,20 +37,15 @@ var _CPLogRegistrations = {};
|
||||
|
||||
var _CPFormatLogMessage = function(aString, aLevel, aTitle)
|
||||
{
|
||||
var now = new Date(),
|
||||
zero = function(number, zeros)
|
||||
{
|
||||
var digits = number.toString();
|
||||
return zeros.substring(0, zeros.length - digits.length) + digits;
|
||||
}
|
||||
var now = new Date();
|
||||
|
||||
var level = aLevel ? " ["+aLevel+"]" : "";
|
||||
var message =
|
||||
now.getFullYear() + "-" + zero(now.getMonth()+1, "00") + "-" + zero(now.getDate(), "00") + " " +
|
||||
zero(now.getHours(), "00") + ":" + zero(now.getMinutes(), "00") + ":" + zero(now.getSeconds(), "00") + "." +
|
||||
zero(now.getMilliseconds(), "000")+" " + aTitle + level + ": " + aString;
|
||||
|
||||
return message;
|
||||
if (typeof sprintf == "function")
|
||||
return sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s [%s]: %s",
|
||||
now.getFullYear(), now.getMonth(), now.getDate(),
|
||||
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
|
||||
aTitle, aLevel, aString);
|
||||
else
|
||||
return now + " " + aTitle + " [" + aLevel + "]: " + aString;
|
||||
}
|
||||
|
||||
// Register Functions:
|
||||
@@ -63,8 +58,8 @@ function CPLogRegister(aProvider, aMaxLevel)
|
||||
// Register a logger for a range of levels
|
||||
function CPLogRegisterRange(aProvider, aMinLevel, aMaxLevel)
|
||||
{
|
||||
var min = CPLogLevelsInverted[aMinLevel];
|
||||
var max = CPLogLevelsInverted[aMaxLevel];
|
||||
var min = _CPLogLevelsInverted[aMinLevel];
|
||||
var max = _CPLogLevelsInverted[aMaxLevel];
|
||||
|
||||
if (min != undefined && max != undefined)
|
||||
for (var i = 0; i <= max; i++)
|
||||
@@ -80,21 +75,27 @@ function CPLogRegisterSingle(aProvider, aLevel)
|
||||
}
|
||||
|
||||
// Main CPLog, which dispatches to individual loggers
|
||||
function CPLog(aString, aLevel, aTitle)
|
||||
function _CPLogDispatch(parameters, aLevel, aTitle)
|
||||
{
|
||||
if (aTitle == undefined)
|
||||
aTitle = CPLogDefaultTitle;
|
||||
if (aLevel == undefined)
|
||||
aLevel = CPLogDefaultLevel;
|
||||
|
||||
// to format message: use sprintf if available; otherwise do a simple join
|
||||
var message = (typeof sprintf == "function") ? sprintf.apply(null, parameters) : Array.prototype.join.call(parameters, ", ");
|
||||
|
||||
if (_CPLogRegistrations[aLevel])
|
||||
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
|
||||
_CPLogRegistrations[aLevel][i](aString, aLevel, aTitle);
|
||||
_CPLogRegistrations[aLevel][i](message, aLevel, aTitle);
|
||||
}
|
||||
|
||||
// Shortcuts for common log levels (CPLog.fatal(), CPLog.error(), etc)
|
||||
// Setup CPLog() and CPLog.xxx() aliases
|
||||
|
||||
function CPLog() { _CPLogDispatch(arguments); }
|
||||
|
||||
for (var i = 0; i < CPLogLevels.length; i++)
|
||||
CPLog[CPLogLevels[i]] = (function(level) { return function(message, title) { CPLog(message, level, title); }; })(CPLogLevels[i]);
|
||||
CPLog[CPLogLevels[i]] = (function(level) { return function() { _CPLogDispatch(arguments, level); }; })(CPLogLevels[i]);
|
||||
|
||||
// Loggers:
|
||||
|
||||
|
||||
+11
-3
@@ -645,8 +645,8 @@ String.prototype.isa = CPString;
|
||||
|
||||
// sprintf:
|
||||
|
||||
var sprintfFormatRegex = new RegExp("([^%]+|%[\\+\\-\\ \\#0]*[0-9\\*]*(.[0-9\\*]+)?[hlL]?[cdieEfgGosuxXpn%@])", "g");
|
||||
var sprintfTagRegex = new RegExp("(%)([\\+\\-\\ \\#0]*)([0-9\\*]*)((.[0-9\\*]+)?)([hlL]?)([cdieEfgGosuxXpn%@])");
|
||||
var sprintfFormatRegex = new RegExp("([^%]+|%[\\+\\-\\ \\#0]*[0-9\\*]*(.[0-9\\*]+)?[hlL]?[cbBdieEfgGosuxXpn%@])", "g");
|
||||
var sprintfTagRegex = new RegExp("(%)([\\+\\-\\ \\#0]*)([0-9\\*]*)((.[0-9\\*]+)?)([hlL]?)([cbBdieEfgGosuxXpn%@])");
|
||||
|
||||
/*!
|
||||
Creates a new string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated.
|
||||
@@ -706,7 +706,7 @@ function sprintf(format)
|
||||
|
||||
var subresult = "";
|
||||
|
||||
if (RegExp("[diufeExXo]").test(specifier))
|
||||
if (RegExp("[bBdiufeExXo]").test(specifier))
|
||||
{
|
||||
var num = Number(arguments[arg++]);
|
||||
|
||||
@@ -754,6 +754,14 @@ function sprintf(format)
|
||||
subresult = sprintf_justify(sign, prefix, number, "", width, leftJustify, padZeros);
|
||||
}
|
||||
|
||||
if (specifier == "b" || specifier == "B")
|
||||
{
|
||||
var number = String(Math.abs(num).toString(2));
|
||||
var prefix = (flags.indexOf("#") >= 0 && num != 0) ? "0b" : "";
|
||||
|
||||
subresult = sprintf_justify(sign, prefix, number, "", width, leftJustify, padZeros);
|
||||
}
|
||||
|
||||
if (specifier == "o")
|
||||
{
|
||||
var number = String(Math.abs(num).toString(8));
|
||||
|
||||
@@ -30,9 +30,12 @@
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_minSize = [aCoder decodeSizeForKey:@"NSMinSize"];
|
||||
_maxSize = [aCoder decodeSizeForKey:@"NSMaxSize"];
|
||||
{
|
||||
if ([aCoder containsValueForKey:@"NSMinSize"])
|
||||
_minSize = [aCoder decodeSizeForKey:@"NSMinSize"];
|
||||
if ([aCoder containsValueForKey:@"NSMaxSize"])
|
||||
_maxSize = [aCoder decodeSizeForKey:@"NSMaxSize"];
|
||||
|
||||
_screenRect = [aCoder decodeRectForKey:@"NSScreenRect"]; // screen created on
|
||||
_viewClass = [aCoder decodeObjectForKey:@"NSViewClass"];
|
||||
_wtFlags = [aCoder decodeIntForKey:@"NSWTFlags"];
|
||||
@@ -46,9 +49,10 @@
|
||||
_windowTitle = [aCoder decodeObjectForKey:@"NSWindowTitle"];
|
||||
_windowView = [aCoder decodeObjectForKey:@"NSWindowView"];
|
||||
|
||||
/*
|
||||
_windowRect.origin.y -= _screenRect.size.height - [[NSScreen mainScreen] frame].size.height;
|
||||
if (![_windowClass isEqualToString:@"NSPanel"])
|
||||
// Flip Y coordinate
|
||||
_windowRect.origin.y = _screenRect.size.height - _windowRect.origin.y - _windowRect.size.height;
|
||||
|
||||
/*if (![_windowClass isEqualToString:@"NSPanel"])
|
||||
_windowRect.origin.y -= [NSMainMenuView menuHeight]; // compensation for the additional menu bar
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user