Merge branch 'master' of git://github.com/280north/cappuccino

This commit is contained in:
Randall Luecke committed 2010-03-05 23:39:31 -05:00
commit 119c950b53
12 files changed
+297 -70

No files matched your search

+138
View File
@@ -40,6 +40,10 @@ CPApp = nil;
CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification";
CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification";
CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification";
CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification";
CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification";
CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification";
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
CPTerminateNow = YES;
CPTerminateCancel = NO;
@@ -83,6 +87,8 @@ CPRunContinuesResponse = -1002;
CPArray _windows;
CPWindow _keyWindow;
CPWindow _mainWindow;
CPWindow _previousKeyWindow;
CPWindow _previousMainWindow;
CPMenu _mainMenu;
CPDocumentController _documentController;
@@ -92,6 +98,7 @@ CPRunContinuesResponse = -1002;
//
id _delegate;
BOOL _finishedLaunching;
BOOL _isActive;
CPDictionary _namedArgs;
CPArray _args;
@@ -219,6 +226,26 @@ CPRunContinuesResponse = -1002;
removeObserver:_delegate
name:CPApplicationDidFinishLaunchingNotification
object:self];
[defaultCenter
removeObserver:_delegate
name:CPApplicationWillBecomeActiveNotification
object:self];
[defaultCenter
removeObserver:_delegate
name:CPApplicationDidBecomeActiveNotification
object:self];
[defaultCenter
removeObserver:_delegate
name:CPApplicationWillResignActiveNotification
object:self];
[defaultCenter
removeObserver:_delegate
name:CPApplicationDidResignActiveNotification
object:self];
}
_delegate = aDelegate;
@@ -236,6 +263,34 @@ CPRunContinuesResponse = -1002;
selector:@selector(applicationDidFinishLaunching:)
name:CPApplicationDidFinishLaunchingNotification
object:self];
if ([_delegate respondsToSelector:@selector(applicationWillBecomeActive:)])
[defaultCenter
addObserver:_delegate
selector:@selector(applicationWillBecomeActive:)
name:CPApplicationWillBecomeActiveNotification
object:self];
if ([_delegate respondsToSelector:@selector(applicationDidBecomeActive:)])
[defaultCenter
addObserver:_delegate
selector:@selector(applicationDidBecomeActive:)
name:CPApplicationDidBecomeActiveNotification
object:self];
if ([_delegate respondsToSelector:@selector(applicationWillResignActive:)])
[defaultCenter
addObserver:_delegate
selector:@selector(applicationWillResignActive:)
name:CPApplicationWillResignActiveNotification
object:self];
if ([_delegate respondsToSelector:@selector(applicationDidResignActive:)])
[defaultCenter
addObserver:_delegate
selector:@selector(applicationDidResignActive:)
name:CPApplicationDidResignActiveNotification
object:self];
}
/*!
@@ -419,7 +474,27 @@ CPRunContinuesResponse = -1002;
- (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
{
[self _willBecomeActive];
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
_isActive = YES;
[self _willResignActive];
}
- (void)deactivate
{
[self _willResignActive];
[CPPlatform deactivate];
_isActive = NO;
[self _didResignActive];
}
- (void)isActive
{
return _isActive;
}
- (void)hideOtherApplications:(id)aSender
@@ -624,6 +699,14 @@ CPRunContinuesResponse = -1002;
return _windows;
}
/*!
Returns an array of visible CPWindow objects, ordered by their front to back order on the screen.
*/
- (CPArray)orderedWindows
{
return CPWindowObjectList();
}
- (void)hide:(id)aSender
{
[CPPlatform hide:self];
@@ -953,10 +1036,65 @@ CPRunContinuesResponse = -1002;
return !![_documentController openDocumentWithContentsOfURL:aURL display:YES error:NULL];
}
- (void)_willBecomeActive
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillBecomeActiveNotification
object:self
userInfo:nil];
}
- (void)_didBecomeActive
{
if (![self keyWindow] && _previousKeyWindow &&
[[self windows] indexOfObjectIdenticalTo:_previousKeyWindow] !== CPNotFound)
[_previousKeyWindow makeKeyWindow];
if (![self mainWindow] && _previousMainWindow &&
[[self windows] indexOfObjectIdenticalTo:_previousMainWindow] !== CPNotFound)
[_previousMainWindow makeMainWindow];
if ([self keyWindow])
[[self keyWindow] orderFront:self];
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
[[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
_previousMainWindow = nil;
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidBecomeActiveNotification
object:self
userInfo:nil];
}
- (void)_willResignActive
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillResignActiveNotification
object:self
userInfo:nil];
}
- (void)_didResignActive
{
if (self._activeMenu)
[self._activeMenu cancelTracking];
if ([self keyWindow])
{
_previousKeyWindow = [self keyWindow];
[_previousKeyWindow resignKeyWindow];
}
if ([self mainWindow])
{
_previousMainWindow = [self mainWindow];
[_previousMainWindow resignMainWindow];
}
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidResignActiveNotification
object:self
userInfo:nil];
}
+ (CPString)defaultThemeName
-2
View File
@@ -230,8 +230,6 @@ var currentCursor = nil,
+ (void)_setCursorCSS:(CPString)aString
{
#if PLATFORM(DOM)
[CPPlatformWindow primaryPlatformWindow]._DOMBodyElement.style.cursor = aString;
var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
for (var i = 0, count = [platformWindows count]; i < count; i++)
platformWindows[i]._DOMBodyElement.style.cursor = aString;
+5 -14
View File
@@ -31,24 +31,10 @@
#include "CoreGraphics/CGGeometry.h"
/*
@global
@group CPImageScaling
*/
CPScaleProportionally = 0;
/*
@global
@group CPImageScaling
*/
CPScaleToFit = 1;
/*
@global
@group CPImageScaling
*/
CPScaleNone = 2;
var CPImageViewShadowBackgroundColor = nil;
var LEFT_SHADOW_INSET = 3.0,
@@ -225,6 +211,11 @@ var LEFT_SHADOW_INSET = 3.0,
[self setNeedsDisplay:YES];
}
- (unsigned)imageScaling
{
return [self currentValueForThemeAttribute:@"image-scaling"];
}
/*!
Toggles the display of the image view.
*/
+1 -1
View File
@@ -155,7 +155,7 @@ var SelectionColor = nil,
{
// FIXME: This should probably be even throw.
if (![_menuItem isEnabled])
return;
shouldHighlight = NO;
if (shouldHighlight)
{
+1 -2
View File
@@ -483,6 +483,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
window.setTimeout(function()
{
element.focus();
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
CPTextFieldInputOwner = self;
}, 0.0);
@@ -500,8 +501,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[[self window] platformWindow]._DOMBodyElement.ondrag = function () {};
[[self window] platformWindow]._DOMBodyElement.onselectstart = function () {};
}
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
#endif
return YES;
+1 -1
View File
@@ -22,7 +22,7 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@import <Foundation/CPKeyedUnarchiver.j>
var CPThemesByName = { },
CPThemeDefaultTheme = nil;
+111 -24
View File
@@ -175,6 +175,8 @@ CPWindowBelow = 2;
CPWindowWillCloseNotification = @"CPWindowWillCloseNotification";
CPWindowDidBecomeMainNotification = @"CPWindowDidBecomeMainNotification";
CPWindowDidResignMainNotification = @"CPWindowDidResignMainNotification";
CPWindowDidBecomeKeyNotification = @"CPWindowDidBecomeKeyNotification";
CPWindowDidResignKeyNotification = @"CPWindowDidResignKeyNotification";
CPWindowDidResizeNotification = @"CPWindowDidResizeNotification";
CPWindowDidMoveNotification = @"CPWindowDidMoveNotification";
CPWindowWillBeginSheetNotification = @"CPWindowWillBeginSheetNotification";
@@ -762,12 +764,7 @@ CPTexturedBackgroundWindowMask
[_platformWindow order:CPWindowOut window:self relativeTo:nil];
if ([CPApp keyWindow] == self)
{
[self resignKeyWindow];
CPApp._keyWindow = nil;
}
[self _updateMainAndKeyWindows];
}
/*!
@@ -1066,13 +1063,31 @@ CPTexturedBackgroundWindowMask
*/
- (void)setDelegate:(id)aDelegate
{
// FIXME: Unregister for notifications!
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter removeObserver:_delegate name:CPWindowDidResignKeyNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidBecomeKeyNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidBecomeMainNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidResignMainNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidMoveNotification object:self];
[defaultCenter removeObserver:_delegate name:CPWindowDidResizeNotification object:self];
_delegate = aDelegate;
_delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)];
var defaultCenter = [CPNotificationCenter defaultCenter];
if ([_delegate respondsToSelector:@selector(windowDidResignKey:)])
[defaultCenter
addObserver:_delegate
selector:@selector(windowDidResignKey:)
name:CPWindowDidResignKeyNotification
object:self];
if ([_delegate respondsToSelector:@selector(windowDidBecomeKey:)])
[defaultCenter
addObserver:_delegate
selector:@selector(windowDidBecomeKey:)
name:CPWindowDidBecomeKeyNotification
object:self];
if ([_delegate respondsToSelector:@selector(windowDidBecomeMain:)])
[defaultCenter
@@ -1418,8 +1433,14 @@ CPTexturedBackgroundWindowMask
*/
- (void)becomeKeyWindow
{
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
CPApp._keyWindow = self;
if (_firstResponder !== self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
[_firstResponder becomeKeyWindow];
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidBecomeKeyNotification
object:self];
}
/*!
@@ -1456,13 +1477,10 @@ CPTexturedBackgroundWindowMask
*/
- (void)makeKeyWindow
{
if (![self canBecomeKeyWindow])
if ([CPApp keyWindow] === self || ![self canBecomeKeyWindow])
return;
[CPApp._keyWindow resignKeyWindow];
CPApp._keyWindow = self;
[[CPApp keyWindow] resignKeyWindow];
[self becomeKeyWindow];
}
@@ -1473,9 +1491,12 @@ CPTexturedBackgroundWindowMask
{
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
if ([_delegate respondsToSelector:@selector(windowDidResignKey:)])
[_delegate windowDidResignKey:self];
CPApp._keyWindow = nil;
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidResignKeyNotification
object:self];
}
/*!
@@ -1664,6 +1685,8 @@ CPTexturedBackgroundWindowMask
[[self platformWindow] miniaturize:sender];
[self _updateMainAndKeyWindows];
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMiniaturizeNotification object:self];
_isMiniaturized = YES;
@@ -1799,13 +1822,10 @@ CPTexturedBackgroundWindowMask
*/
- (void)makeMainWindow
{
if (CPApp._mainWindow === self || ![self canBecomeMainWindow])
if ([CPApp mainWindow] === self || ![self canBecomeMainWindow])
return;
[CPApp._mainWindow resignMainWindow];
CPApp._mainWindow = self;
[[CPApp mainWindow] resignMainWindow];
[self becomeMainWindow];
}
@@ -1814,9 +1834,11 @@ CPTexturedBackgroundWindowMask
*/
- (void)becomeMainWindow
{
CPApp._mainWindow = self;
[self _synchronizeMenuBarTitleWithWindowTitle];
[self _synchronizeSaveMenuWithDocumentSaving];
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidBecomeMainNotification
object:self];
@@ -1830,6 +1852,71 @@ CPTexturedBackgroundWindowMask
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidResignMainNotification
object:self];
CPApp._mainWindow = nil;
}
- (void)_updateMainAndKeyWindows
{
var allWindows = [CPApp orderedWindows],
windowCount = [allWindows count];
if (!windowCount)
return;
if ([self isKeyWindow])
{
var keyWindow = [CPApp keyWindow];
[self resignKeyWindow];
if (keyWindow && keyWindow !== self && [keyWindow canBecomeKeyWindow])
[keyWindow makeKeyWindow];
else
{
var menuWindow = [CPApp mainMenu]._menuWindow;
for (var i = 0; i < windowCount; i++)
{
var currentWindow = allWindows[i];
if (currentWindow === self || currentWindow === menuWindow)
continue;
if ([currentWindow isVisible] && [currentWindow canBecomeKeyWindow])
{
[currentWindow makeKeyWindow];
break;
}
}
if (![CPApp keyWindow])
[keyWindow makeKeyWindow];
}
}
if ([self isMainWindow])
{
var mainWindow = [CPApp mainWindow];
[self resignMainWindow];
if (mainWindow && mainWindow !== self && [mainWindow canBecomeMainWindow])
[mainWindow makeMainWindow];
else
{
var menuWindow = [CPApp mainMenu]._menuWindow;
for (var i = 0; i < windowCount; i++)
{
var currentWindow = allWindows[i];
if (currentWindow === self || currentWindow === menuWindow)
continue;
if ([currentWindow isVisible] && [currentWindow canBecomeMainWindow])
{
[currentWindow makeMainWindow];
break;
}
}
}
}
}
// Managing Toolbars
+4
View File
@@ -58,6 +58,10 @@
{
}
+ (void)deactivate
{
}
+ (void)hideOtherApplications:(id)aSender
{
}
+6
View File
@@ -69,6 +69,12 @@ var screenNeedsInitialization = NO,
window.cpActivateIgnoringOtherApps(!!shouldIgnoreOtherApps);
}
+ (void)deactivate
{
if (typeof window["cpDeactivate"] === "function")
window.cpDeactivate();
}
+ (void)hideOtherApplications:(id)aSender
{
if (typeof window["cpHideOtherApplications"] === "function")
+28 -24
View File
@@ -426,7 +426,14 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
+ (CPSet)visiblePlatformWindows
{
return PlatformWindows;
if ([[CPPlatformWindow primaryPlatformWindow] isVisible])
{
var set = [CPSet setWithSet:PlatformWindows];
[set addObject:[CPPlatformWindow primaryPlatformWindow]];
return set;
}
else
return PlatformWindows;
}
- (void)orderFront:(id)aSender
@@ -1374,19 +1381,25 @@ var CPDOMEventStop = function(aDOMEvent, aPlatformWindow)
function CPWindowObjectList()
{
var platformWindow = [CPPlatformWindow primaryPlatformWindow],
levels = platformWindow._windowLevels,
layers = platformWindow._windowLayers,
levelCount = levels.length,
var platformWindows = [CPPlatformWindow visiblePlatformWindows],
platformWindowEnumerator = [platformWindows objectEnumerator],
platformWindow = nil,
windowObjects = [];
while (levelCount--)
while (platformWindow = [platformWindowEnumerator nextObject])
{
var windows = [layers objectForKey:levels[levelCount]]._windows,
windowCount = windows.length;
var levels = platformWindow._windowLevels,
layers = platformWindow._windowLayers,
levelCount = levels.length;
while (windowCount--)
windowObjects.push(windows[windowCount]);
while (levelCount--)
{
var windows = [layers objectForKey:levels[levelCount]]._windows,
windowCount = windows.length;
while (windowCount--)
windowObjects.push(windows[windowCount]);
}
}
return windowObjects;
@@ -1394,20 +1407,11 @@ function CPWindowObjectList()
function CPWindowList()
{
var platformWindow = [CPPlatformWindow primaryPlatformWindow],
levels = platformWindow._windowLevels,
layers = platformWindow._windowLayers,
levelCount = levels.length,
windowNumbers = [];
var windowObjectList = CPWindowObjectList(),
windowList = [];
while (levelCount--)
{
var windows = [layers objectForKey:levels[levelCount]]._windows,
windowCount = windows.length;
for (var i = 0, count = [windowObjectList count]; i < count; i++)
windowList.push([windowObjectList[i] windowNumber]);
while (windowCount--)
windowNumbers.push([windows[windowCount] windowNumber]);
}
return windowNumbers;
return windowList;
}
+1 -1
View File
@@ -855,7 +855,7 @@ Preprocessor.prototype.preprocess = function(tokens, /*StringBuffer*/ aStringBuf
// If we get this far and we're parsing an objj_msgSend (or array), then we have a problem.
if (tuple)
new SyntaxError(this.error_message("*** Expected ']' - Unterminated message send or array."));
throw new SyntaxError(this.error_message("*** Expected ']' - Unterminated message send or array."));
if (!aStringBuffer)
return buffer;
+1 -1
View File
@@ -33,7 +33,7 @@
{
var cell = [aCoder decodeObjectForKey:@"NSCell"];
_imageScaling = [cell imageScaling];
[self setImageScaling:[cell imageScaling]];
_isEditable = [cell isEditable];
}