mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-10 12:47:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6678bba94f |
@@ -96,12 +96,12 @@
|
|||||||
return _items;
|
return _items;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addItem:(CPAccordionViewItem)anItem
|
- (void)addItem:(CPAccordionItem)anItem
|
||||||
{
|
{
|
||||||
[self insertItem:anItem atIndex:_items.length];
|
[self insertItem:anItem atIndex:_items.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertItem:(CPAccordionViewItem)anItem atIndex:(CPInteger)anIndex
|
- (void)insertItem:(CPAccordionItem)anItem atIndex:(CPInteger)anIndex
|
||||||
{
|
{
|
||||||
// FIXME: SHIFT ITEMS RIGHT
|
// FIXME: SHIFT ITEMS RIGHT
|
||||||
[_expandedItemIndexes addIndex:anIndex];
|
[_expandedItemIndexes addIndex:anIndex];
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
[self setNeedsLayout];
|
[self setNeedsLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeItem:(CPAccordionViewItem)anItem
|
- (void)removeItem:(CPAccordionItem)anItem
|
||||||
{
|
{
|
||||||
[self removeItemAtIndex:[_items indexOfObjectIdenticalTo:anItem]];
|
[self removeItemAtIndex:[_items indexOfObjectIdenticalTo:anItem]];
|
||||||
}
|
}
|
||||||
|
|||||||
+202
-183
@@ -31,7 +31,6 @@
|
|||||||
@import "CPCibLoading.j"
|
@import "CPCibLoading.j"
|
||||||
@import "CPPlatform.j"
|
@import "CPPlatform.j"
|
||||||
|
|
||||||
#include "Platform/Platform.h"
|
|
||||||
|
|
||||||
var CPMainCibFile = @"CPMainCibFile",
|
var CPMainCibFile = @"CPMainCibFile",
|
||||||
CPMainCibFileHumanFriendly = @"Main cib file base name";
|
CPMainCibFileHumanFriendly = @"Main cib file base name";
|
||||||
@@ -54,7 +53,7 @@ CPRunStoppedResponse = -1000;
|
|||||||
CPRunAbortedResponse = -1001;
|
CPRunAbortedResponse = -1001;
|
||||||
CPRunContinuesResponse = -1002;
|
CPRunContinuesResponse = -1002;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ingroup appkit
|
@ingroup appkit
|
||||||
@class CPApplication
|
@class CPApplication
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ CPRunContinuesResponse = -1002;
|
|||||||
Every GUI application has exactly one instance of CPApplication (or of a custom subclass of
|
Every GUI application has exactly one instance of CPApplication (or of a custom subclass of
|
||||||
CPApplication). Your program's main() function can create that instance by calling the
|
CPApplication). Your program's main() function can create that instance by calling the
|
||||||
\c CPApplicationMain function. A simple example looks like this:
|
\c CPApplicationMain function. A simple example looks like this:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
function main(args, namedArgs)
|
function main(args, namedArgs)
|
||||||
{
|
{
|
||||||
@@ -82,25 +81,25 @@ CPRunContinuesResponse = -1002;
|
|||||||
@implementation CPApplication : CPResponder
|
@implementation CPApplication : CPResponder
|
||||||
{
|
{
|
||||||
CPArray _eventListeners;
|
CPArray _eventListeners;
|
||||||
|
|
||||||
CPEvent _currentEvent;
|
CPEvent _currentEvent;
|
||||||
|
|
||||||
CPArray _windows;
|
CPArray _windows;
|
||||||
CPWindow _keyWindow;
|
CPWindow _keyWindow;
|
||||||
CPWindow _mainWindow;
|
CPWindow _mainWindow;
|
||||||
CPWindow _previousKeyWindow;
|
CPWindow _previousKeyWindow;
|
||||||
CPWindow _previousMainWindow;
|
CPWindow _previousMainWindow;
|
||||||
|
|
||||||
CPMenu _mainMenu;
|
CPMenu _mainMenu;
|
||||||
CPDocumentController _documentController;
|
CPDocumentController _documentController;
|
||||||
|
|
||||||
CPModalSession _currentSession;
|
CPModalSession _currentSession;
|
||||||
|
|
||||||
//
|
//
|
||||||
id _delegate;
|
id _delegate;
|
||||||
BOOL _finishedLaunching;
|
BOOL _finishedLaunching;
|
||||||
BOOL _isActive;
|
BOOL _isActive;
|
||||||
|
|
||||||
CPDictionary _namedArgs;
|
CPDictionary _namedArgs;
|
||||||
CPArray _args;
|
CPArray _args;
|
||||||
CPString _fullArgsString;
|
CPString _fullArgsString;
|
||||||
@@ -119,7 +118,7 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if (!CPApp)
|
if (!CPApp)
|
||||||
CPApp = [[CPApplication alloc] init];
|
CPApp = [[CPApplication alloc] init];
|
||||||
|
|
||||||
return CPApp;
|
return CPApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,18 +130,73 @@ CPRunContinuesResponse = -1002;
|
|||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
CPApp = self;
|
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
_eventListeners = [];
|
_eventListeners = [];
|
||||||
|
|
||||||
_windows = [];
|
_windows = [];
|
||||||
|
|
||||||
[_windows addObject:nil];
|
[_windows addObject:nil];
|
||||||
}
|
|
||||||
|
// FIXME: This should be read from the cib.
|
||||||
|
_mainMenu = [[CPMenu alloc] initWithTitle:@"MainMenu"];
|
||||||
|
|
||||||
|
// FIXME: We should implement autoenabling.
|
||||||
|
[_mainMenu setAutoenablesItems:NO];
|
||||||
|
|
||||||
|
var bundle = [CPBundle bundleForClass:[CPApplication class]],
|
||||||
|
newMenuItem = [[CPMenuItem alloc] initWithTitle:@"New" action:@selector(newDocument:) keyEquivalent:@"n"];
|
||||||
|
|
||||||
|
[newMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/New.png"] size:CGSizeMake(16.0, 16.0)]];
|
||||||
|
[newMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/NewHighlighted.png"] size:CGSizeMake(16.0, 16.0)]];
|
||||||
|
|
||||||
|
[_mainMenu addItem:newMenuItem];
|
||||||
|
|
||||||
|
var openMenuItem = [[CPMenuItem alloc] initWithTitle:@"Open" action:@selector(openDocument:) keyEquivalent:@"o"];
|
||||||
|
|
||||||
|
[openMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/Open.png"] size:CGSizeMake(16.0, 16.0)]];
|
||||||
|
[openMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/OpenHighlighted.png"] size:CGSizeMake(16.0, 16.0)]];
|
||||||
|
|
||||||
|
[_mainMenu addItem:openMenuItem];
|
||||||
|
|
||||||
|
var saveMenu = [[CPMenu alloc] initWithTitle:@"Save"],
|
||||||
|
saveMenuItem = [[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:nil];
|
||||||
|
|
||||||
|
[saveMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/Save.png"] size:CGSizeMake(16.0, 16.0)]];
|
||||||
|
[saveMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/SaveHighlighted.png"] size:CGSizeMake(16.0, 16.0)]];
|
||||||
|
|
||||||
|
[saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:@"s"]];
|
||||||
|
[saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save As" action:@selector(saveDocumentAs:) keyEquivalent:nil]];
|
||||||
|
|
||||||
|
[saveMenuItem setSubmenu:saveMenu];
|
||||||
|
|
||||||
|
[_mainMenu addItem:saveMenuItem];
|
||||||
|
|
||||||
|
var editMenuItem = [[CPMenuItem alloc] initWithTitle:@"Edit" action:nil keyEquivalent:nil],
|
||||||
|
editMenu = [[CPMenu alloc] initWithTitle:@"Edit"],
|
||||||
|
|
||||||
|
undoMenuItem = [[CPMenuItem alloc] initWithTitle:@"Undo" action:@selector(undo:) keyEquivalent:CPUndoKeyEquivalent],
|
||||||
|
redoMenuItem = [[CPMenuItem alloc] initWithTitle:@"Redo" action:@selector(redo:) keyEquivalent:CPRedoKeyEquivalent];
|
||||||
|
|
||||||
|
[undoMenuItem setKeyEquivalentModifierMask:CPUndoKeyEquivalentModifierMask];
|
||||||
|
[redoMenuItem setKeyEquivalentModifierMask:CPRedoKeyEquivalentModifierMask];
|
||||||
|
|
||||||
|
[editMenu addItem:undoMenuItem];
|
||||||
|
[editMenu addItem:redoMenuItem];
|
||||||
|
|
||||||
|
[editMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"]],
|
||||||
|
[editMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"]],
|
||||||
|
[editMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"]];
|
||||||
|
|
||||||
|
[editMenuItem setSubmenu:editMenu];
|
||||||
|
[editMenuItem setHidden:YES];
|
||||||
|
|
||||||
|
[_mainMenu addItem:editMenuItem];
|
||||||
|
|
||||||
|
[_mainMenu addItem:[CPMenuItem separatorItem]];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,46 +212,85 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if (_delegate == aDelegate)
|
if (_delegate == aDelegate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var defaultCenter = [CPNotificationCenter defaultCenter],
|
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||||
delegateNotifications =
|
|
||||||
[
|
|
||||||
CPApplicationWillFinishLaunchingNotification, @selector(applicationWillFinishLaunching:),
|
|
||||||
CPApplicationDidFinishLaunchingNotification, @selector(applicationDidFinishLaunching:),
|
|
||||||
CPApplicationWillBecomeActiveNotification, @selector(applicationWillBecomeActive:),
|
|
||||||
CPApplicationDidBecomeActiveNotification, @selector(applicationDidBecomeActive:),
|
|
||||||
CPApplicationWillResignActiveNotification, @selector(applicationWillResignActive:),
|
|
||||||
CPApplicationDidResignActiveNotification, @selector(applicationDidResignActive:),
|
|
||||||
CPApplicationWillTerminateNotification, @selector(applicationWillTerminate:)
|
|
||||||
],
|
|
||||||
count = [delegateNotifications count];
|
|
||||||
|
|
||||||
if (_delegate)
|
if (_delegate)
|
||||||
{
|
{
|
||||||
var index = 0;
|
[defaultCenter
|
||||||
|
removeObserver:_delegate
|
||||||
|
name:CPApplicationWillFinishLaunchingNotification
|
||||||
|
object:self];
|
||||||
|
|
||||||
for (; index < count; index += 2)
|
[defaultCenter
|
||||||
{
|
removeObserver:_delegate
|
||||||
var notificationName = delegateNotifications[index],
|
name:CPApplicationDidFinishLaunchingNotification
|
||||||
selector = delegateNotifications[index + 1];
|
object:self];
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:selector])
|
[defaultCenter
|
||||||
[defaultCenter removeObserver:_delegate name:notificationName object:self];
|
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;
|
_delegate = aDelegate;
|
||||||
|
|
||||||
|
if ([_delegate respondsToSelector:@selector(applicationWillFinishLaunching:)])
|
||||||
|
[defaultCenter
|
||||||
|
addObserver:_delegate
|
||||||
|
selector:@selector(applicationWillFinishLaunching:)
|
||||||
|
name:CPApplicationWillFinishLaunchingNotification
|
||||||
|
object:self];
|
||||||
|
|
||||||
|
if ([_delegate respondsToSelector:@selector(applicationDidFinishLaunching:)])
|
||||||
|
[defaultCenter
|
||||||
|
addObserver:_delegate
|
||||||
|
selector:@selector(applicationDidFinishLaunching:)
|
||||||
|
name:CPApplicationDidFinishLaunchingNotification
|
||||||
|
object:self];
|
||||||
|
|
||||||
var index = 0;
|
if ([_delegate respondsToSelector:@selector(applicationWillBecomeActive:)])
|
||||||
|
[defaultCenter
|
||||||
|
addObserver:_delegate
|
||||||
|
selector:@selector(applicationWillBecomeActive:)
|
||||||
|
name:CPApplicationWillBecomeActiveNotification
|
||||||
|
object:self];
|
||||||
|
|
||||||
for (; index < count; index += 2)
|
if ([_delegate respondsToSelector:@selector(applicationDidBecomeActive:)])
|
||||||
{
|
[defaultCenter
|
||||||
var notificationName = delegateNotifications[index],
|
addObserver:_delegate
|
||||||
selector = delegateNotifications[index + 1];
|
selector:@selector(applicationDidBecomeActive:)
|
||||||
|
name:CPApplicationDidBecomeActiveNotification
|
||||||
|
object:self];
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:selector])
|
if ([_delegate respondsToSelector:@selector(applicationWillResignActive:)])
|
||||||
[defaultCenter addObserver:_delegate selector:selector name:notificationName object:self];
|
[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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -223,28 +316,28 @@ CPRunContinuesResponse = -1002;
|
|||||||
|
|
||||||
// We also want to set the default cursor on the body, so that buttons and things don't have an iBeam
|
// We also want to set the default cursor on the body, so that buttons and things don't have an iBeam
|
||||||
[[CPCursor arrowCursor] set];
|
[[CPCursor arrowCursor] set];
|
||||||
|
|
||||||
var bundle = [CPBundle mainBundle],
|
var bundle = [CPBundle mainBundle],
|
||||||
types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];
|
types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];
|
||||||
|
|
||||||
if ([types count] > 0)
|
if ([types count] > 0)
|
||||||
_documentController = [CPDocumentController sharedDocumentController];
|
_documentController = [CPDocumentController sharedDocumentController];
|
||||||
|
|
||||||
var delegateClassName = [bundle objectForInfoDictionaryKey:@"CPApplicationDelegateClass"];
|
var delegateClassName = [bundle objectForInfoDictionaryKey:@"CPApplicationDelegateClass"];
|
||||||
|
|
||||||
if (delegateClassName)
|
if (delegateClassName)
|
||||||
{
|
{
|
||||||
var delegateClass = objj_getClass(delegateClassName);
|
var delegateClass = objj_getClass(delegateClassName);
|
||||||
|
|
||||||
if (delegateClass)
|
if (delegateClass)
|
||||||
if ([_documentController class] == delegateClass)
|
if ([_documentController class] == delegateClass)
|
||||||
[self setDelegate:_documentController];
|
[self setDelegate:_documentController];
|
||||||
else
|
else
|
||||||
[self setDelegate:[[delegateClass alloc] init]];
|
[self setDelegate:[[delegateClass alloc] init]];
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||||
|
|
||||||
[defaultCenter
|
[defaultCenter
|
||||||
postNotificationName:CPApplicationWillFinishLaunchingNotification
|
postNotificationName:CPApplicationWillFinishLaunchingNotification
|
||||||
object:self];
|
object:self];
|
||||||
@@ -276,10 +369,6 @@ CPRunContinuesResponse = -1002;
|
|||||||
|
|
||||||
- (void)terminate:(id)aSender
|
- (void)terminate:(id)aSender
|
||||||
{
|
{
|
||||||
[[CPNotificationCenter defaultCenter]
|
|
||||||
postNotificationName:CPApplicationWillTerminateNotification
|
|
||||||
object:self];
|
|
||||||
|
|
||||||
if (![CPPlatform isBrowser])
|
if (![CPPlatform isBrowser])
|
||||||
{
|
{
|
||||||
[[CPDocumentController sharedDocumentController] closeAllDocumentsWithDelegate:self
|
[[CPDocumentController sharedDocumentController] closeAllDocumentsWithDelegate:self
|
||||||
@@ -333,14 +422,14 @@ CPRunContinuesResponse = -1002;
|
|||||||
versionLabel = [contentView viewWithTag:3],
|
versionLabel = [contentView viewWithTag:3],
|
||||||
copyrightLabel = [contentView viewWithTag:4],
|
copyrightLabel = [contentView viewWithTag:4],
|
||||||
standardPath = [[CPBundle bundleForClass:[self class]] pathForResource:@"standardApplicationIcon.png"];
|
standardPath = [[CPBundle bundleForClass:[self class]] pathForResource:@"standardApplicationIcon.png"];
|
||||||
|
|
||||||
// FIXME move this into the CIB eventually
|
// FIXME move this into the CIB eventually
|
||||||
[applicationLabel setFont:[CPFont boldSystemFontOfSize:14.0]];
|
[applicationLabel setFont:[CPFont boldSystemFontOfSize:14.0]];
|
||||||
[applicationLabel setAlignment:CPCenterTextAlignment];
|
[applicationLabel setAlignment:CPCenterTextAlignment];
|
||||||
[versionLabel setAlignment:CPCenterTextAlignment];
|
[versionLabel setAlignment:CPCenterTextAlignment];
|
||||||
[copyrightLabel setAlignment:CPCenterTextAlignment];
|
[copyrightLabel setAlignment:CPCenterTextAlignment];
|
||||||
|
|
||||||
[imageView setImage:applicationIcon || [[CPImage alloc] initWithContentsOfFile:standardPath
|
[imageView setImage:applicationIcon || [[CPImage alloc] initWithContentsOfFile:standardPath
|
||||||
size:CGSizeMake(256, 256)]];
|
size:CGSizeMake(256, 256)]];
|
||||||
|
|
||||||
[applicationLabel setStringValue:applicationTitle || ""];
|
[applicationLabel setStringValue:applicationTitle || ""];
|
||||||
@@ -444,10 +533,10 @@ CPRunContinuesResponse = -1002;
|
|||||||
return;
|
return;
|
||||||
// raise exception;
|
// raise exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentSession._state = aCode;
|
_currentSession._state = aCode;
|
||||||
_currentSession = _currentSession._previous;
|
_currentSession = _currentSession._previous;
|
||||||
|
|
||||||
// if (aCode == CPRunAbortedResponse)
|
// if (aCode == CPRunAbortedResponse)
|
||||||
[self _removeRunModalLoop];
|
[self _removeRunModalLoop];
|
||||||
}
|
}
|
||||||
@@ -456,12 +545,12 @@ CPRunContinuesResponse = -1002;
|
|||||||
- (void)_removeRunModalLoop
|
- (void)_removeRunModalLoop
|
||||||
{
|
{
|
||||||
var count = _eventListeners.length;
|
var count = _eventListeners.length;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
if (_eventListeners[count]._callback === _CPRunModalLoop)
|
if (_eventListeners[count]._callback === _CPRunModalLoop)
|
||||||
{
|
{
|
||||||
_eventListeners.splice(count, 1);
|
_eventListeners.splice(count, 1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,12 +588,12 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
aModalSession._previous = _currentSession;
|
aModalSession._previous = _currentSession;
|
||||||
_currentSession = aModalSession;
|
_currentSession = aModalSession;
|
||||||
|
|
||||||
var theWindow = aModalSession._window;
|
var theWindow = aModalSession._window;
|
||||||
|
|
||||||
[theWindow center];
|
[theWindow center];
|
||||||
[theWindow makeKeyAndOrderFront:self];
|
[theWindow makeKeyAndOrderFront:self];
|
||||||
|
|
||||||
// [theWindow._bridge _obscureWindowsBelowModalWindow];
|
// [theWindow._bridge _obscureWindowsBelowModalWindow];
|
||||||
|
|
||||||
[CPApp setCallback:_CPRunModalLoop forNextEventMatchingMask:CPAnyEventMask untilDate:nil inMode:0 dequeue:NO];
|
[CPApp setCallback:_CPRunModalLoop forNextEventMatchingMask:CPAnyEventMask untilDate:nil inMode:0 dequeue:NO];
|
||||||
@@ -518,7 +607,7 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if (!_currentSession)
|
if (!_currentSession)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
return _currentSession._window;
|
return _currentSession._window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,7 +652,7 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if (_eventListeners[_eventListeners.length - 1]._mask & (1 << [anEvent type]))
|
if (_eventListeners[_eventListeners.length - 1]._mask & (1 << [anEvent type]))
|
||||||
_eventListeners.pop()._callback(anEvent);
|
_eventListeners.pop()._callback(anEvent);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,11 +763,11 @@ CPRunContinuesResponse = -1002;
|
|||||||
|
|
||||||
if ([super tryToPerform:anAction with:anObject])
|
if ([super tryToPerform:anAction with:anObject])
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
if([_delegate respondsToSelector:anAction])
|
if([_delegate respondsToSelector:anAction])
|
||||||
{
|
{
|
||||||
[_delegate performSelector:anAction withObject:anObject];
|
[_delegate performSelector:anAction withObject:anObject];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,9 +787,9 @@ CPRunContinuesResponse = -1002;
|
|||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
[target performSelector:anAction withObject:aSender];
|
[target performSelector:anAction withObject:aSender];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,10 +808,10 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if (!anAction)
|
if (!anAction)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
if (aTarget)
|
if (aTarget)
|
||||||
return aTarget;
|
return aTarget;
|
||||||
|
|
||||||
return [self targetForAction:anAction];
|
return [self targetForAction:anAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -747,28 +836,28 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
var responder = [aWindow firstResponder],
|
var responder = [aWindow firstResponder],
|
||||||
checkWindow = YES;
|
checkWindow = YES;
|
||||||
|
|
||||||
while (responder)
|
while (responder)
|
||||||
{
|
{
|
||||||
if ([responder respondsToSelector:anAction])
|
if ([responder respondsToSelector:anAction])
|
||||||
return responder;
|
return responder;
|
||||||
|
|
||||||
if (responder == aWindow)
|
if (responder == aWindow)
|
||||||
checkWindow = NO;
|
checkWindow = NO;
|
||||||
|
|
||||||
responder = [responder nextResponder];
|
responder = [responder nextResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkWindow && [aWindow respondsToSelector:anAction])
|
if (checkWindow && [aWindow respondsToSelector:anAction])
|
||||||
return aWindow;
|
return aWindow;
|
||||||
|
|
||||||
var delegate = [aWindow delegate];
|
var delegate = [aWindow delegate];
|
||||||
|
|
||||||
if ([delegate respondsToSelector:anAction])
|
if ([delegate respondsToSelector:anAction])
|
||||||
return delegate;
|
return delegate;
|
||||||
|
|
||||||
var windowController = [aWindow windowController];
|
var windowController = [aWindow windowController];
|
||||||
|
|
||||||
if ([windowController respondsToSelector:anAction])
|
if ([windowController respondsToSelector:anAction])
|
||||||
return windowController;
|
return windowController;
|
||||||
|
|
||||||
@@ -797,26 +886,26 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if (!anAction)
|
if (!anAction)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
var target = [self _targetForWindow:[self keyWindow] action:anAction];
|
var target = [self _targetForWindow:[self keyWindow] action:anAction];
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
target = [self _targetForWindow:[self mainWindow] action:anAction];
|
target = [self _targetForWindow:[self mainWindow] action:anAction];
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
if ([self respondsToSelector:anAction])
|
if ([self respondsToSelector:anAction])
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:anAction])
|
if ([_delegate respondsToSelector:anAction])
|
||||||
return _delegate;
|
return _delegate;
|
||||||
|
|
||||||
if ([_documentController respondsToSelector:anAction])
|
if ([_documentController respondsToSelector:anAction])
|
||||||
return _documentController;
|
return _documentController;
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -846,14 +935,14 @@ CPRunContinuesResponse = -1002;
|
|||||||
@param aContextInfo
|
@param aContextInfo
|
||||||
*/
|
*/
|
||||||
- (void)beginSheet:(CPWindow)aSheet modalForWindow:(CPWindow)aWindow modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
|
- (void)beginSheet:(CPWindow)aSheet modalForWindow:(CPWindow)aWindow modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
|
||||||
{
|
{
|
||||||
var styleMask = [aSheet styleMask];
|
var styleMask = [aSheet styleMask];
|
||||||
if (!(styleMask & CPDocModalWindowMask))
|
if (!(styleMask & CPDocModalWindowMask))
|
||||||
{
|
{
|
||||||
[CPException raise:CPInternalInconsistencyException reason:@"Currently only CPDocModalWindowMask style mask is supported for attached sheets"];
|
[CPException raise:CPInternalInconsistencyException reason:@"Currently only CPDocModalWindowMask style mask is supported for attached sheets"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[aWindow orderFront:self];
|
[aWindow orderFront:self];
|
||||||
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
|
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
|
||||||
}
|
}
|
||||||
@@ -861,15 +950,15 @@ CPRunContinuesResponse = -1002;
|
|||||||
- (void)endSheet:(CPWindow)sheet returnCode:(int)returnCode
|
- (void)endSheet:(CPWindow)sheet returnCode:(int)returnCode
|
||||||
{
|
{
|
||||||
var count = [_windows count];
|
var count = [_windows count];
|
||||||
|
|
||||||
while (--count >= 0)
|
while (--count >= 0)
|
||||||
{
|
{
|
||||||
var aWindow = [_windows objectAtIndex:count];
|
var aWindow = [_windows objectAtIndex:count];
|
||||||
var context = aWindow._sheetContext;
|
var context = aWindow._sheetContext;
|
||||||
|
|
||||||
if (context != nil && context["sheet"] === sheet)
|
if (context != nil && context["sheet"] === sheet)
|
||||||
{
|
{
|
||||||
context["returnCode"] = returnCode;
|
context["returnCode"] = returnCode;
|
||||||
[aWindow _detachSheetWindow];
|
[aWindow _detachSheetWindow];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -885,7 +974,7 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
if(_fullArgsString !== window.location.hash)
|
if(_fullArgsString !== window.location.hash)
|
||||||
[self _reloadArguments];
|
[self _reloadArguments];
|
||||||
|
|
||||||
return _args;
|
return _args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -895,28 +984,28 @@ CPRunContinuesResponse = -1002;
|
|||||||
{
|
{
|
||||||
_args = [];
|
_args = [];
|
||||||
window.location.hash = @"#";
|
window.location.hash = @"#";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if([args class] != CPArray)
|
if([args class] != CPArray)
|
||||||
args = [CPArray arrayWithObject:args];
|
args = [CPArray arrayWithObject:args];
|
||||||
|
|
||||||
_args = args;
|
_args = args;
|
||||||
|
|
||||||
var toEncode = [_args copy];
|
var toEncode = [_args copy];
|
||||||
for(var i=0, count = toEncode.length; i<count; i++)
|
for(var i=0, count = toEncode.length; i<count; i++)
|
||||||
toEncode[i] = encodeURIComponent(toEncode[i]);
|
toEncode[i] = encodeURIComponent(toEncode[i]);
|
||||||
|
|
||||||
var hash = [toEncode componentsJoinedByString:@"/"];
|
var hash = [toEncode componentsJoinedByString:@"/"];
|
||||||
|
|
||||||
window.location.hash = @"#" + hash;
|
window.location.hash = @"#" + hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_reloadArguments
|
- (void)_reloadArguments
|
||||||
{
|
{
|
||||||
_fullArgsString = window.location.hash;
|
_fullArgsString = window.location.hash;
|
||||||
|
|
||||||
if (_fullArgsString.length)
|
if (_fullArgsString.length)
|
||||||
{
|
{
|
||||||
var args = _fullArgsString.substring(1).split("/");
|
var args = _fullArgsString.substring(1).split("/");
|
||||||
@@ -951,18 +1040,18 @@ CPRunContinuesResponse = -1002;
|
|||||||
|
|
||||||
- (void)_willBecomeActive
|
- (void)_willBecomeActive
|
||||||
{
|
{
|
||||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillBecomeActiveNotification
|
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillBecomeActiveNotification
|
||||||
object:self
|
object:self
|
||||||
userInfo:nil];
|
userInfo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_didBecomeActive
|
- (void)_didBecomeActive
|
||||||
{
|
{
|
||||||
if (![self keyWindow] && _previousKeyWindow &&
|
if (![self keyWindow] && _previousKeyWindow &&
|
||||||
[[self windows] indexOfObjectIdenticalTo:_previousKeyWindow] !== CPNotFound)
|
[[self windows] indexOfObjectIdenticalTo:_previousKeyWindow] !== CPNotFound)
|
||||||
[_previousKeyWindow makeKeyWindow];
|
[_previousKeyWindow makeKeyWindow];
|
||||||
|
|
||||||
if (![self mainWindow] && _previousMainWindow &&
|
if (![self mainWindow] && _previousMainWindow &&
|
||||||
[[self windows] indexOfObjectIdenticalTo:_previousMainWindow] !== CPNotFound)
|
[[self windows] indexOfObjectIdenticalTo:_previousMainWindow] !== CPNotFound)
|
||||||
[_previousMainWindow makeMainWindow];
|
[_previousMainWindow makeMainWindow];
|
||||||
|
|
||||||
@@ -976,15 +1065,15 @@ CPRunContinuesResponse = -1002;
|
|||||||
_previousKeyWindow = nil;
|
_previousKeyWindow = nil;
|
||||||
_previousMainWindow = nil;
|
_previousMainWindow = nil;
|
||||||
|
|
||||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidBecomeActiveNotification
|
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidBecomeActiveNotification
|
||||||
object:self
|
object:self
|
||||||
userInfo:nil];
|
userInfo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_willResignActive
|
- (void)_willResignActive
|
||||||
{
|
{
|
||||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillResignActiveNotification
|
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillResignActiveNotification
|
||||||
object:self
|
object:self
|
||||||
userInfo:nil];
|
userInfo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,8 +1094,8 @@ CPRunContinuesResponse = -1002;
|
|||||||
[_previousMainWindow resignMainWindow];
|
[_previousMainWindow resignMainWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidResignActiveNotification
|
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidResignActiveNotification
|
||||||
object:self
|
object:self
|
||||||
userInfo:nil];
|
userInfo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,7 +1123,7 @@ var _CPRunModalLoop = function(anEvent)
|
|||||||
|
|
||||||
var theWindow = [anEvent window],
|
var theWindow = [anEvent window],
|
||||||
modalSession = CPApp._currentSession;
|
modalSession = CPApp._currentSession;
|
||||||
|
|
||||||
if (theWindow == modalSession._window || [theWindow worksWhenModal])
|
if (theWindow == modalSession._window || [theWindow worksWhenModal])
|
||||||
[theWindow sendEvent:anEvent];
|
[theWindow sendEvent:anEvent];
|
||||||
}
|
}
|
||||||
@@ -1048,13 +1137,6 @@ var _CPRunModalLoop = function(anEvent)
|
|||||||
|
|
||||||
function CPApplicationMain(args, namedArgs)
|
function CPApplicationMain(args, namedArgs)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if PLATFORM(DOM)
|
|
||||||
// hook to allow recorder, etc to manipulate things before starting AppKit
|
|
||||||
if (window.parent !== window && typeof window.parent._childAppIsStarting === "function")
|
|
||||||
window.parent._childAppIsStarting(window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
var mainBundle = [CPBundle mainBundle],
|
var mainBundle = [CPBundle mainBundle],
|
||||||
principalClass = [mainBundle principalClass];
|
principalClass = [mainBundle principalClass];
|
||||||
|
|
||||||
@@ -1133,73 +1215,10 @@ var _CPAppBootstrapperActions = nil;
|
|||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
[self loadCiblessBrowserMainMenu];
|
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)loadCiblessBrowserMainMenu
|
|
||||||
{
|
|
||||||
var mainMenu = [[CPMenu alloc] initWithTitle:@"MainMenu"];
|
|
||||||
|
|
||||||
// FIXME: We should implement autoenabling.
|
|
||||||
[mainMenu setAutoenablesItems:NO];
|
|
||||||
|
|
||||||
var bundle = [CPBundle bundleForClass:[CPApplication class]],
|
|
||||||
newMenuItem = [[CPMenuItem alloc] initWithTitle:@"New" action:@selector(newDocument:) keyEquivalent:@"n"];
|
|
||||||
|
|
||||||
[newMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/New.png"] size:CGSizeMake(16.0, 16.0)]];
|
|
||||||
[newMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/NewHighlighted.png"] size:CGSizeMake(16.0, 16.0)]];
|
|
||||||
|
|
||||||
[mainMenu addItem:newMenuItem];
|
|
||||||
|
|
||||||
var openMenuItem = [[CPMenuItem alloc] initWithTitle:@"Open" action:@selector(openDocument:) keyEquivalent:@"o"];
|
|
||||||
|
|
||||||
[openMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/Open.png"] size:CGSizeMake(16.0, 16.0)]];
|
|
||||||
[openMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/OpenHighlighted.png"] size:CGSizeMake(16.0, 16.0)]];
|
|
||||||
|
|
||||||
[mainMenu addItem:openMenuItem];
|
|
||||||
|
|
||||||
var saveMenu = [[CPMenu alloc] initWithTitle:@"Save"],
|
|
||||||
saveMenuItem = [[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:nil];
|
|
||||||
|
|
||||||
[saveMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/Save.png"] size:CGSizeMake(16.0, 16.0)]];
|
|
||||||
[saveMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/SaveHighlighted.png"] size:CGSizeMake(16.0, 16.0)]];
|
|
||||||
|
|
||||||
[saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:@"s"]];
|
|
||||||
[saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save As" action:@selector(saveDocumentAs:) keyEquivalent:nil]];
|
|
||||||
|
|
||||||
[saveMenuItem setSubmenu:saveMenu];
|
|
||||||
|
|
||||||
[mainMenu addItem:saveMenuItem];
|
|
||||||
|
|
||||||
var editMenuItem = [[CPMenuItem alloc] initWithTitle:@"Edit" action:nil keyEquivalent:nil],
|
|
||||||
editMenu = [[CPMenu alloc] initWithTitle:@"Edit"],
|
|
||||||
|
|
||||||
undoMenuItem = [[CPMenuItem alloc] initWithTitle:@"Undo" action:@selector(undo:) keyEquivalent:CPUndoKeyEquivalent],
|
|
||||||
redoMenuItem = [[CPMenuItem alloc] initWithTitle:@"Redo" action:@selector(redo:) keyEquivalent:CPRedoKeyEquivalent];
|
|
||||||
|
|
||||||
[undoMenuItem setKeyEquivalentModifierMask:CPUndoKeyEquivalentModifierMask];
|
|
||||||
[redoMenuItem setKeyEquivalentModifierMask:CPRedoKeyEquivalentModifierMask];
|
|
||||||
|
|
||||||
[editMenu addItem:undoMenuItem];
|
|
||||||
[editMenu addItem:redoMenuItem];
|
|
||||||
|
|
||||||
[editMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"]],
|
|
||||||
[editMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"]],
|
|
||||||
[editMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"]];
|
|
||||||
|
|
||||||
[editMenuItem setSubmenu:editMenu];
|
|
||||||
[editMenuItem setHidden:YES];
|
|
||||||
|
|
||||||
[mainMenu addItem:editMenuItem];
|
|
||||||
|
|
||||||
[mainMenu addItem:[CPMenuItem separatorItem]];
|
|
||||||
|
|
||||||
[CPApp setMainMenu:mainMenu];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (void)cibDidFinishLoading:(CPCib)aCib
|
+ (void)cibDidFinishLoading:(CPCib)aCib
|
||||||
{
|
{
|
||||||
[self performActions];
|
[self performActions];
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ CPGrooveBorder = 3;
|
|||||||
|
|
||||||
[aView setFrame:CGRectInset([self bounds], _contentMargin.width + _borderWidth, _contentMargin.height + _borderWidth)];
|
[aView setFrame:CGRectInset([self bounds], _contentMargin.width + _borderWidth, _contentMargin.height + _borderWidth)];
|
||||||
[self replaceSubview:_contentView with:aView];
|
[self replaceSubview:_contentView with:aView];
|
||||||
|
[aView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||||
|
|
||||||
_contentView = aView;
|
_contentView = aView;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-77
@@ -64,14 +64,14 @@
|
|||||||
|
|
||||||
+ (CPImage)branchImage
|
+ (CPImage)branchImage
|
||||||
{
|
{
|
||||||
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPBrowser class]]
|
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[self class]]
|
||||||
pathForResource:"browser-leaf.png"]
|
pathForResource:"browser-leaf.png"]
|
||||||
size:CGSizeMake(9,9)];
|
size:CGSizeMake(9,9)];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPImage)highlightedBranchImage
|
+ (CPImage)highlightedBranchImage
|
||||||
{
|
{
|
||||||
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPBrowser class]]
|
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[self class]]
|
||||||
pathForResource:"browser-leaf-highlighted.png"]
|
pathForResource:"browser-leaf-highlighted.png"]
|
||||||
size:CGSizeMake(9,9)];
|
size:CGSizeMake(9,9)];
|
||||||
}
|
}
|
||||||
@@ -213,6 +213,8 @@
|
|||||||
[table setAllowsEmptySelection:_allowsEmptySelection];
|
[table setAllowsEmptySelection:_allowsEmptySelection];
|
||||||
[table registerForDraggedTypes:[self registeredDraggedTypes]];
|
[table registerForDraggedTypes:[self registeredDraggedTypes]];
|
||||||
|
|
||||||
|
[self setNextResponder:table];
|
||||||
|
|
||||||
[self _addTableColumnsToTableView:table forColumnIndex:index];
|
[self _addTableColumnsToTableView:table forColumnIndex:index];
|
||||||
|
|
||||||
var delegate = [[_CPBrowserTableDelegate alloc] init];
|
var delegate = [[_CPBrowserTableDelegate alloc] init];
|
||||||
@@ -312,39 +314,6 @@
|
|||||||
[_contentView setFrameSize:CGSizeMake(xOrigin, height)];
|
[_contentView setFrameSize:CGSizeMake(xOrigin, height)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned)rowAtPoint:(CGPoint)aPoint
|
|
||||||
{
|
|
||||||
var column = [self columnAtPoint:aPoint];
|
|
||||||
if (column === -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
var tableView = _tableViews[column];
|
|
||||||
return [tableView rowAtPoint:[tableView convertPoint:aPoint fromView:self]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (unsigned)columnAtPoint:(CGPoint)aPoint
|
|
||||||
{
|
|
||||||
var adjustedPoint = [_contentView convertPoint:aPoint fromView:self];
|
|
||||||
|
|
||||||
for (var i = 0, count = _tableViews.length; i < count; i++)
|
|
||||||
{
|
|
||||||
var frame = [[_tableViews[i] enclosingScrollView] frame];
|
|
||||||
if (CGRectContainsPoint(frame, adjustedPoint))
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (CGRect)rectOfRow:(unsigned)aRow inColumn:(unsigned)aColumn
|
|
||||||
{
|
|
||||||
var tableView = _tableViews[aColumn],
|
|
||||||
rect = [tableView rectOfRow:aRow];
|
|
||||||
|
|
||||||
rect.origin = [self convertPoint:rect.origin fromView:tableView];
|
|
||||||
return rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ITEMS
|
// ITEMS
|
||||||
|
|
||||||
- (id)itemAtRow:(int)row inColumn:(int)column
|
- (id)itemAtRow:(int)row inColumn:(int)column
|
||||||
@@ -388,10 +357,6 @@
|
|||||||
|
|
||||||
// CLICK EVENTS
|
// CLICK EVENTS
|
||||||
|
|
||||||
- (void)trackMouse:(CPEvent)anEvent
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_column:(unsigned)columnIndex clickedRow:(unsigned)rowIndex
|
- (void)_column:(unsigned)columnIndex clickedRow:(unsigned)rowIndex
|
||||||
{
|
{
|
||||||
[self setLastColumn:columnIndex];
|
[self setLastColumn:columnIndex];
|
||||||
@@ -417,15 +382,6 @@
|
|||||||
[self sendAction:_doubleAction to:_target];
|
[self sendAction:_doubleAction to:_target];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyDown:(CPEvent)anEvent
|
|
||||||
{
|
|
||||||
var column = [self selectedColumn];
|
|
||||||
if (column === -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
[_tableViews[column] keyDown:anEvent];
|
|
||||||
}
|
|
||||||
|
|
||||||
// SIZING
|
// SIZING
|
||||||
|
|
||||||
- (float)columnContentWidthForColumnWidth:(float)aWidth
|
- (float)columnContentWidthForColumnWidth:(float)aWidth
|
||||||
@@ -570,9 +526,6 @@
|
|||||||
|
|
||||||
- (CPIndexSet)selectedRowIndexesInColumn:(unsigned)column
|
- (CPIndexSet)selectedRowIndexesInColumn:(unsigned)column
|
||||||
{
|
{
|
||||||
if (column < 0 || column > [self lastColumn] +1)
|
|
||||||
return [CPIndexSet indexSet];
|
|
||||||
|
|
||||||
return [[self tableViewInColumn:column] selectedRowIndexes];
|
return [[self tableViewInColumn:column] selectedRowIndexes];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,6 +551,8 @@
|
|||||||
|
|
||||||
[[self tableViewInColumn:column] selectRowIndexes:indexSet byExtendingSelection:NO];
|
[[self tableViewInColumn:column] selectRowIndexes:indexSet byExtendingSelection:NO];
|
||||||
|
|
||||||
|
[self setNextResponder:[self tableViewInColumn:[self lastColumn]]];
|
||||||
|
|
||||||
[self scrollColumnToVisible:column];
|
[self scrollColumnToVisible:column];
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)])
|
if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)])
|
||||||
@@ -649,8 +604,6 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
var _CPBrowserResizeControlBackgroundImage = nil;
|
|
||||||
|
|
||||||
@implementation _CPBrowserResizeControl : CPView
|
@implementation _CPBrowserResizeControl : CPView
|
||||||
{
|
{
|
||||||
CGPoint _mouseDownX;
|
CGPoint _mouseDownX;
|
||||||
@@ -659,26 +612,6 @@ var _CPBrowserResizeControlBackgroundImage = nil;
|
|||||||
unsigned _width;
|
unsigned _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPImage)backgroundImage
|
|
||||||
{
|
|
||||||
if (!_CPBrowserResizeControlBackgroundImage)
|
|
||||||
{
|
|
||||||
var path = [[CPBundle bundleForClass:[self class]] pathForResource:"browser-resize-control.png"];
|
|
||||||
_CPBrowserResizeControlBackgroundImage = [[CPImage alloc] initWithContentsOfFile:path
|
|
||||||
size:CGSizeMake(15, 14)];
|
|
||||||
}
|
|
||||||
|
|
||||||
return _CPBrowserResizeControlBackgroundImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id)initWithFrame:(CGRect)aFrame
|
|
||||||
{
|
|
||||||
if (self = [super initWithFrame:aFrame])
|
|
||||||
[self setBackgroundColor:[CPColor colorWithPatternImage:[[self class] backgroundImage]]];
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)mouseDown:(CPEvent)anEvent
|
- (void)mouseDown:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
_mouseDownX = [anEvent locationInWindow].x;
|
_mouseDownX = [anEvent locationInWindow].x;
|
||||||
@@ -693,23 +626,34 @@ var _CPBrowserResizeControlBackgroundImage = nil;
|
|||||||
[_browser setWidth:_width + deltaX ofColumn:_index];
|
[_browser setWidth:_width + deltaX ofColumn:_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseUp:(CPEvent)anEvent
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
var _CPBrowserResizeControlBackgroundImage = nil;
|
||||||
|
|
||||||
@implementation _CPBrowserScrollView : CPScrollView
|
@implementation _CPBrowserScrollView : CPScrollView
|
||||||
{
|
{
|
||||||
_CPBrowserResizeControl _resizeControl;
|
_CPBrowserResizeControl _resizeControl;
|
||||||
CPBrowser _browser @accessors;
|
CPBrowser _browser @accessors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (CPImage)backgroundImage
|
||||||
|
{
|
||||||
|
if (!_CPBrowserResizeControlBackgroundImage)
|
||||||
|
{
|
||||||
|
var path = [[CPBundle bundleForClass:[self class]] pathForResource:"browser-resize-control.png"];
|
||||||
|
_CPBrowserResizeControlBackgroundImage = [[CPImage alloc] initWithContentsOfFile:path
|
||||||
|
size:CGSizeMake(15, 14)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _CPBrowserResizeControlBackgroundImage;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)initWithFrame:(CGRect)aFrame
|
- (void)initWithFrame:(CGRect)aFrame
|
||||||
{
|
{
|
||||||
if (self = [super initWithFrame:aFrame])
|
if (self = [super initWithFrame:aFrame])
|
||||||
{
|
{
|
||||||
_resizeControl = [[_CPBrowserResizeControl alloc] initWithFrame:CGRectMakeZero()];
|
_resizeControl = [[_CPBrowserResizeControl alloc] initWithFrame:CGRectMakeZero()];
|
||||||
|
[_resizeControl setBackgroundColor:[CPColor colorWithPatternImage:[[self class] backgroundImage]]];
|
||||||
[self addSubview:_resizeControl];
|
[self addSubview:_resizeControl];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -530,7 +530,6 @@ CPButtonStateMixed = CPThemeState("mixed");
|
|||||||
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
|
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
|
||||||
[contentView setImagePosition:[self currentValueForThemeAttribute:@"image-position"]];
|
[contentView setImagePosition:[self currentValueForThemeAttribute:@"image-position"]];
|
||||||
[contentView setImageScaling:[self currentValueForThemeAttribute:@"image-scaling"]];
|
[contentView setImageScaling:[self currentValueForThemeAttribute:@"image-scaling"]];
|
||||||
[contentView setDimsImage:[self hasThemeState:CPThemeStateDisabled] && _imageDimsWhenDisabled];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-54
@@ -14,9 +14,8 @@
|
|||||||
+ (id)plusButton
|
+ (id)plusButton
|
||||||
{
|
{
|
||||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)],
|
var button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)],
|
||||||
image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPButtonBar class]] pathForResource:@"plus_button.png"] size:CGSizeMake(11, 12)];
|
image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:self] pathForResource:@"plus_button.png"] size:CGSizeMake(11, 12)];
|
||||||
|
|
||||||
[button setBordered:NO];
|
|
||||||
[button setImage:image];
|
[button setImage:image];
|
||||||
[button setImagePosition:CPImageOnly];
|
[button setImagePosition:CPImageOnly];
|
||||||
|
|
||||||
@@ -26,30 +25,14 @@
|
|||||||
+ (id)minusButton
|
+ (id)minusButton
|
||||||
{
|
{
|
||||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)],
|
var button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)],
|
||||||
image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPButtonBar class]] pathForResource:@"minus_button.png"] size:CGSizeMake(11, 4)];
|
image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:self] pathForResource:@"minus_button.png"] size:CGSizeMake(11, 4)];
|
||||||
|
|
||||||
[button setBordered:NO];
|
|
||||||
[button setImage:image];
|
[button setImage:image];
|
||||||
[button setImagePosition:CPImageOnly];
|
[button setImagePosition:CPImageOnly];
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)actionPopupButton
|
|
||||||
{
|
|
||||||
var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)],
|
|
||||||
image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPButtonBar class]] pathForResource:@"action_button.png"] size:CGSizeMake(22, 14)];
|
|
||||||
|
|
||||||
[button addItemWithTitle:nil];
|
|
||||||
[[button lastItem] setImage:image];
|
|
||||||
[button setImagePosition:CPImageOnly];
|
|
||||||
[button setValue:CGInsetMake(0, 0, 0, 0) forThemeAttribute:"content-inset"];
|
|
||||||
|
|
||||||
[button setPullsDown:YES];
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (CPString)themeClass
|
+ (CPString)themeClass
|
||||||
{
|
{
|
||||||
return @"button-bar";
|
return @"button-bar";
|
||||||
@@ -57,8 +40,8 @@
|
|||||||
|
|
||||||
+ (id)themeAttributes
|
+ (id)themeAttributes
|
||||||
{
|
{
|
||||||
return [CPDictionary dictionaryWithObjects:[CGInsetMake(0.0, 0.0, 0.0, 0.0), CGSizeMakeZero(), [CPNull null], [CPNull null], [CPNull null], [CPNull null]]
|
return [CPDictionary dictionaryWithObjects:[CGInsetMake(0.0, 0.0, 0.0, 0.0), CGSizeMakeZero(), [CPNull null], [CPNull null], [CPNull null]]
|
||||||
forKeys:[@"resize-control-inset", @"resize-control-size", @"resize-control-color", @"bezel-color", @"button-bezel-color", @"button-text-color"]];
|
forKeys:[@"resize-control-inset", @"resize-control-size", @"resize-control-color", @"bezel-color", @"button-bezel-color"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithFrame:(CGRect)aFrame
|
- (id)initWithFrame:(CGRect)aFrame
|
||||||
@@ -99,8 +82,25 @@
|
|||||||
_buttons = [CPArray arrayWithArray:buttons];
|
_buttons = [CPArray arrayWithArray:buttons];
|
||||||
|
|
||||||
for (var i = 0, count = [_buttons count]; i < count; i++)
|
for (var i = 0, count = [_buttons count]; i < count; i++)
|
||||||
[_buttons[i] setBordered:YES];
|
{
|
||||||
|
var button = _buttons[i];
|
||||||
|
|
||||||
|
var normalColor = [self valueForThemeAttribute:@"button-bezel-color" inState:CPThemeStateNormal],
|
||||||
|
highlightedColor = [self valueForThemeAttribute:@"button-bezel-color" inState:CPThemeStateHighlighted],
|
||||||
|
disabledColor = [self valueForThemeAttribute:@"button-bezel-color" inState:CPThemeStateDisabled];
|
||||||
|
|
||||||
|
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal|CPThemeStateBordered];
|
||||||
|
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted|CPThemeStateBordered];
|
||||||
|
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled|CPThemeStateBordered];
|
||||||
|
|
||||||
|
// FIXME shouldn't need this
|
||||||
|
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal|CPThemeStateBordered|CPPopUpButtonStatePullsDown];
|
||||||
|
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted|CPThemeStateBordered|CPPopUpButtonStatePullsDown];
|
||||||
|
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled|CPThemeStateBordered|CPPopUpButtonStatePullsDown];
|
||||||
|
|
||||||
|
[button setBordered:YES];
|
||||||
|
}
|
||||||
|
|
||||||
[self setNeedsLayout];
|
[self setNeedsLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,11 +176,6 @@
|
|||||||
{
|
{
|
||||||
[self setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
|
[self setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
|
||||||
|
|
||||||
var normalColor = [self valueForThemeAttribute:@"button-bezel-color" inState:CPThemeStateNormal],
|
|
||||||
highlightedColor = [self valueForThemeAttribute:@"button-bezel-color" inState:CPThemeStateHighlighted],
|
|
||||||
disabledColor = [self valueForThemeAttribute:@"button-bezel-color" inState:CPThemeStateDisabled],
|
|
||||||
textColor = [self valueForThemeAttribute:@"button-text-color" inState:CPThemeStateNormal];
|
|
||||||
|
|
||||||
var buttonsNotHidden = [CPArray arrayWithArray:_buttons],
|
var buttonsNotHidden = [CPArray arrayWithArray:_buttons],
|
||||||
count = [buttonsNotHidden count];
|
count = [buttonsNotHidden count];
|
||||||
|
|
||||||
@@ -189,23 +184,13 @@
|
|||||||
[buttonsNotHidden removeObject:buttonsNotHidden[count]];
|
[buttonsNotHidden removeObject:buttonsNotHidden[count]];
|
||||||
|
|
||||||
var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1,
|
var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1,
|
||||||
bounds = [self bounds],
|
height = CGRectGetHeight([self bounds]) - 1;
|
||||||
height = CGRectGetHeight(bounds) - 1,
|
|
||||||
frameWidth = CGRectGetWidth(bounds),
|
|
||||||
resizeRect = _hasResizeControl ? [self rectForEphemeralSubviewNamed:"resize-control-view"] : CGRectMakeZero(),
|
|
||||||
resizeWidth = CGRectGetWidth(resizeRect),
|
|
||||||
availableWidth = frameWidth - resizeWidth - 1;
|
|
||||||
|
|
||||||
for (var i = 0, count = [buttonsNotHidden count]; i < count; i++)
|
for (var i = 0, count = [buttonsNotHidden count]; i < count; i++)
|
||||||
{
|
{
|
||||||
var button = buttonsNotHidden[i],
|
var button = buttonsNotHidden[i],
|
||||||
width = CGRectGetWidth([button frame]);
|
width = CGRectGetWidth([button frame]);
|
||||||
|
|
||||||
if (availableWidth > width)
|
|
||||||
availableWidth -=width;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (_resizeControlIsLeftAligned)
|
if (_resizeControlIsLeftAligned)
|
||||||
{
|
{
|
||||||
[button setFrame:CGRectMake(currentButtonOffset - width, 1, width, height)];
|
[button setFrame:CGRectMake(currentButtonOffset - width, 1, width, height)];
|
||||||
@@ -217,16 +202,6 @@
|
|||||||
currentButtonOffset += width - 1;
|
currentButtonOffset += width - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal|CPThemeStateBordered];
|
|
||||||
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted|CPThemeStateBordered];
|
|
||||||
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled|CPThemeStateBordered];
|
|
||||||
[button setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateBordered];
|
|
||||||
|
|
||||||
// FIXME shouldn't need this
|
|
||||||
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal|CPThemeStateBordered|CPPopUpButtonStatePullsDown];
|
|
||||||
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted|CPThemeStateBordered|CPPopUpButtonStatePullsDown];
|
|
||||||
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled|CPThemeStateBordered|CPPopUpButtonStatePullsDown];
|
|
||||||
|
|
||||||
[self addSubview:button];
|
[self addSubview:button];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,12 +216,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameSize:(CGSize)aSize
|
|
||||||
{
|
|
||||||
[super setFrameSize:aSize];
|
|
||||||
[self setNeedsLayout];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey",
|
var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey",
|
||||||
@@ -277,3 +246,4 @@ var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey",
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -61,27 +61,4 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)takeStateFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
|
|
||||||
{
|
|
||||||
var count = objects.length,
|
|
||||||
value = [objects[0] valueForKeyPath:aKeyPath] ? CPOnState : CPOffState;
|
|
||||||
|
|
||||||
[self setAllowsMixedState:NO];
|
|
||||||
[self setState:value];
|
|
||||||
|
|
||||||
while (count-- > 1)
|
|
||||||
{
|
|
||||||
if (value !== ([objects[count] valueForKeyPath:aKeyPath] ? CPOnState : CPOffState))
|
|
||||||
{
|
|
||||||
[self setAllowsMixedState:YES];
|
|
||||||
[self setState:CPMixedState];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)takeValueFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
|
|
||||||
{
|
|
||||||
[self takeStateFromKeyPath:aKeyPath ofObjects:objects];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
+6
-28
@@ -190,39 +190,17 @@
|
|||||||
- (BOOL)autoscroll:(CPEvent)anEvent
|
- (BOOL)autoscroll:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
var bounds = [self bounds],
|
var bounds = [self bounds],
|
||||||
eventLocation = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
eventLocation = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||||
superview = [self superview],
|
|
||||||
deltaX = 0,
|
|
||||||
deltaY = 0;
|
|
||||||
|
|
||||||
if (CGRectContainsPoint(bounds, eventLocation))
|
if (CPRectContainsPoint(bounds, eventLocation))
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if (![superview isKindOfClass:[CPScrollView class]] || [superview hasVerticalScroller])
|
var newRect = CGRectMakeZero();
|
||||||
{
|
|
||||||
if (eventLocation.y < CGRectGetMinY(bounds))
|
|
||||||
deltaY = CGRectGetMinY(bounds) - eventLocation.y;
|
|
||||||
else if (eventLocation.y > CGRectGetMaxY(bounds))
|
|
||||||
deltaY = CGRectGetMaxY(bounds) - eventLocation.y;
|
|
||||||
if (deltaY < -bounds.size.height)
|
|
||||||
deltaY = -bounds.size.height;
|
|
||||||
if (deltaY > bounds.size.height)
|
|
||||||
deltaY = bounds.size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (![superview isKindOfClass:[CPScrollView class]] || [superview hasHorizontalScroller])
|
newRect.origin = eventLocation;
|
||||||
{
|
newRect.size = CPSizeMake(10, 10);
|
||||||
if (eventLocation.x < CGRectGetMinX(bounds))
|
|
||||||
deltaX = CGRectGetMinX(bounds) - eventLocation.x;
|
|
||||||
else if (eventLocation.x > CGRectGetMaxX(bounds))
|
|
||||||
deltaX = CGRectGetMaxX(bounds) - eventLocation.x;
|
|
||||||
if (deltaX < -bounds.size.width)
|
|
||||||
deltaX = -bounds.size.width;
|
|
||||||
if (deltaX > bounds.size.width)
|
|
||||||
deltaX = bounds.size.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [self scrollToPoint:CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY)];
|
return [_documentView scrollRectToVisible:newRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
+76
-93
@@ -30,16 +30,16 @@
|
|||||||
@import "CPCollectionViewItem.j"
|
@import "CPCollectionViewItem.j"
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ingroup appkit
|
@ingroup appkit
|
||||||
@class CPCollectionView
|
@class CPCollectionView
|
||||||
|
|
||||||
This class displays an array as a grid of objects, where each object is represented by a view.
|
This class displays an array as a grid of objects, where each object is represented by a view.
|
||||||
The view is controlled by creating a CPCollectionViewItem and specifying its view, then
|
The view is controlled by creating a CPCollectionViewItem and specifying its view, then
|
||||||
setting that item as the collection view prototype.
|
setting that item as the collection view prototype.
|
||||||
|
|
||||||
@par Delegate Methods
|
@par Delegate Methods
|
||||||
|
|
||||||
@delegate -(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
@delegate -(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
||||||
Called when the selection in the collection view has changed.
|
Called when the selection in the collection view has changed.
|
||||||
@param collectionView the collection view who's selection changed
|
@param collectionView the collection view who's selection changed
|
||||||
@@ -67,35 +67,35 @@
|
|||||||
{
|
{
|
||||||
CPArray _content;
|
CPArray _content;
|
||||||
CPArray _items;
|
CPArray _items;
|
||||||
|
|
||||||
CPData _itemData;
|
CPData _itemData;
|
||||||
CPCollectionViewItem _itemPrototype;
|
CPCollectionViewItem _itemPrototype;
|
||||||
CPCollectionViewItem _itemForDragging;
|
CPCollectionViewItem _itemForDragging;
|
||||||
CPMutableArray _cachedItems;
|
CPMutableArray _cachedItems;
|
||||||
|
|
||||||
unsigned _maxNumberOfRows;
|
unsigned _maxNumberOfRows;
|
||||||
unsigned _maxNumberOfColumns;
|
unsigned _maxNumberOfColumns;
|
||||||
|
|
||||||
CGSize _minItemSize;
|
CGSize _minItemSize;
|
||||||
CGSize _maxItemSize;
|
CGSize _maxItemSize;
|
||||||
|
|
||||||
CPArray _backgroundColors;
|
CPArray _backgroundColors;
|
||||||
|
|
||||||
float _tileWidth;
|
float _tileWidth;
|
||||||
|
|
||||||
BOOL _isSelectable;
|
BOOL _isSelectable;
|
||||||
BOOL _allowsMultipleSelection;
|
BOOL _allowsMultipleSelection;
|
||||||
BOOL _allowsEmptySelection;
|
BOOL _allowsEmptySelection;
|
||||||
CPIndexSet _selectionIndexes;
|
CPIndexSet _selectionIndexes;
|
||||||
|
|
||||||
CGSize _itemSize;
|
CGSize _itemSize;
|
||||||
|
|
||||||
float _horizontalMargin;
|
float _horizontalMargin;
|
||||||
float _verticalMargin;
|
float _verticalMargin;
|
||||||
|
|
||||||
unsigned _numberOfRows;
|
unsigned _numberOfRows;
|
||||||
unsigned _numberOfColumns;
|
unsigned _numberOfColumns;
|
||||||
|
|
||||||
id _delegate;
|
id _delegate;
|
||||||
|
|
||||||
CPEvent _mouseDownEvent;
|
CPEvent _mouseDownEvent;
|
||||||
@@ -104,14 +104,14 @@
|
|||||||
- (id)initWithFrame:(CGRect)aFrame
|
- (id)initWithFrame:(CGRect)aFrame
|
||||||
{
|
{
|
||||||
self = [super initWithFrame:aFrame];
|
self = [super initWithFrame:aFrame];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
_items = [];
|
_items = [];
|
||||||
_content = [];
|
_content = [];
|
||||||
|
|
||||||
_cachedItems = [];
|
_cachedItems = [];
|
||||||
|
|
||||||
_itemSize = CGSizeMakeZero();
|
_itemSize = CGSizeMakeZero();
|
||||||
_minItemSize = CGSizeMakeZero();
|
_minItemSize = CGSizeMakeZero();
|
||||||
_maxItemSize = CGSizeMakeZero();
|
_maxItemSize = CGSizeMakeZero();
|
||||||
@@ -120,12 +120,12 @@
|
|||||||
|
|
||||||
_verticalMargin = 5.0;
|
_verticalMargin = 5.0;
|
||||||
_tileWidth = -1.0;
|
_tileWidth = -1.0;
|
||||||
|
|
||||||
_selectionIndexes = [CPIndexSet indexSet];
|
_selectionIndexes = [CPIndexSet indexSet];
|
||||||
_allowsEmptySelection = YES;
|
_allowsEmptySelection = YES;
|
||||||
_isSelectable = YES;
|
_isSelectable = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +196,8 @@
|
|||||||
|
|
||||||
// Setting the Content
|
// Setting the Content
|
||||||
/*!
|
/*!
|
||||||
Sets the content of the collection view to the content in \c anArray.
|
Sets the content of the collection view to the content in \c anArray.
|
||||||
This array can be of any type, and each element will be passed to the \c -setRepresentedObject: method.
|
This array can be of any type, and each element will be passed to the \c -setRepresentedObject: method.
|
||||||
It's the responsibility of your custom collection view item to interpret the object.
|
It's the responsibility of your custom collection view item to interpret the object.
|
||||||
@param anArray the content array
|
@param anArray the content array
|
||||||
*/
|
*/
|
||||||
@@ -205,9 +205,9 @@
|
|||||||
{
|
{
|
||||||
if (_content == anArray)
|
if (_content == anArray)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_content = anArray;
|
_content = anArray;
|
||||||
|
|
||||||
[self reloadContent];
|
[self reloadContent];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +236,13 @@
|
|||||||
{
|
{
|
||||||
if (_isSelectable == isSelectable)
|
if (_isSelectable == isSelectable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_isSelectable = isSelectable;
|
_isSelectable = isSelectable;
|
||||||
|
|
||||||
if (!_isSelectable)
|
if (!_isSelectable)
|
||||||
{
|
{
|
||||||
var index = CPNotFound;
|
var index = CPNotFound;
|
||||||
|
|
||||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||||
[_items[index] setSelected:NO];
|
[_items[index] setSelected:NO];
|
||||||
}
|
}
|
||||||
@@ -299,19 +299,19 @@
|
|||||||
{
|
{
|
||||||
if (_selectionIndexes == anIndexSet || !_isSelectable)
|
if (_selectionIndexes == anIndexSet || !_isSelectable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var index = CPNotFound;
|
var index = CPNotFound;
|
||||||
|
|
||||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||||
[_items[index] setSelected:NO];
|
[_items[index] setSelected:NO];
|
||||||
|
|
||||||
_selectionIndexes = anIndexSet;
|
_selectionIndexes = anIndexSet;
|
||||||
|
|
||||||
var index = CPNotFound;
|
var index = CPNotFound;
|
||||||
|
|
||||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||||
[_items[index] setSelected:YES];
|
[_items[index] setSelected:YES];
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
|
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
|
||||||
[_delegate collectionViewDidChangeSelection:self]
|
[_delegate collectionViewDidChangeSelection:self]
|
||||||
}
|
}
|
||||||
@@ -326,10 +326,10 @@
|
|||||||
|
|
||||||
/* @ignore */
|
/* @ignore */
|
||||||
- (void)reloadContent
|
- (void)reloadContent
|
||||||
{
|
{
|
||||||
// Remove current views
|
// Remove current views
|
||||||
var count = _items.length;
|
var count = _items.length;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
[[_items[count] view] removeFromSuperview];
|
[[_items[count] view] removeFromSuperview];
|
||||||
@@ -337,7 +337,7 @@
|
|||||||
|
|
||||||
_cachedItems.push(_items[count]);
|
_cachedItems.push(_items[count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_items = [];
|
_items = [];
|
||||||
|
|
||||||
if (!_itemPrototype || !_content)
|
if (!_itemPrototype || !_content)
|
||||||
@@ -350,7 +350,7 @@
|
|||||||
for (; index < count; ++index)
|
for (; index < count; ++index)
|
||||||
{
|
{
|
||||||
_items.push([self newItemForRepresentedObject:_content[index]]);
|
_items.push([self newItemForRepresentedObject:_content[index]]);
|
||||||
|
|
||||||
[self addSubview:[_items[index] view]];
|
[self addSubview:[_items[index] view]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,49 +365,49 @@
|
|||||||
- (void)tile
|
- (void)tile
|
||||||
{
|
{
|
||||||
var width = CGRectGetWidth([self bounds]);
|
var width = CGRectGetWidth([self bounds]);
|
||||||
|
|
||||||
if (![_content count] || width == _tileWidth)
|
if (![_content count] || width == _tileWidth)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// We try to fit as many views per row as possible. Any remaining space is then
|
// We try to fit as many views per row as possible. Any remaining space is then
|
||||||
// either proportioned out to the views (if their minSize != maxSize) or used as
|
// either proportioned out to the views (if their minSize != maxSize) or used as
|
||||||
// margin
|
// margin
|
||||||
var itemSize = CGSizeMakeCopy(_minItemSize);
|
var itemSize = CGSizeMakeCopy(_minItemSize);
|
||||||
|
|
||||||
_numberOfColumns = MAX(1.0, FLOOR(width / itemSize.width));
|
_numberOfColumns = MAX(1.0, FLOOR(width / itemSize.width));
|
||||||
|
|
||||||
if (_maxNumberOfColumns > 0)
|
if (_maxNumberOfColumns > 0)
|
||||||
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
|
_numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
|
||||||
|
|
||||||
var remaining = width - _numberOfColumns * itemSize.width,
|
var remaining = width - _numberOfColumns * itemSize.width,
|
||||||
itemsNeedSizeUpdate = NO;
|
itemsNeedSizeUpdate = NO;
|
||||||
|
|
||||||
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
||||||
itemSize.width = MIN(_maxItemSize.width, itemSize.width + FLOOR(remaining / _numberOfColumns));
|
itemSize.width = MIN(_maxItemSize.width, itemSize.width + FLOOR(remaining / _numberOfColumns));
|
||||||
|
|
||||||
// When we ONE column and a non-integral width, the FLOORing above can cause the item width to be smaller than the total width.
|
// When we ONE column and a non-integral width, the FLOORing above can cause the item width to be smaller than the total width.
|
||||||
if (_maxNumberOfColumns == 1 && itemSize.width < _maxItemSize.width && itemSize.width < width)
|
if (_maxNumberOfColumns == 1 && itemSize.width < _maxItemSize.width && itemSize.width < width)
|
||||||
itemSize.width = MIN(_maxItemSize.width, width);
|
itemSize.width = MIN(_maxItemSize.width, width);
|
||||||
|
|
||||||
if (!CGSizeEqualToSize(_itemSize, itemSize))
|
if (!CGSizeEqualToSize(_itemSize, itemSize))
|
||||||
{
|
{
|
||||||
_itemSize = itemSize;
|
_itemSize = itemSize;
|
||||||
itemsNeedSizeUpdate = YES;
|
itemsNeedSizeUpdate = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = _items.length;
|
count = _items.length;
|
||||||
|
|
||||||
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
|
||||||
count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);
|
count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);
|
||||||
|
|
||||||
_numberOfRows = CEIL(count / _numberOfColumns);
|
_numberOfRows = CEIL(count / _numberOfColumns);
|
||||||
|
|
||||||
_horizontalMargin = FLOOR((width - _numberOfColumns * itemSize.width) / (_numberOfColumns + 1));
|
_horizontalMargin = FLOOR((width - _numberOfColumns * itemSize.width) / (_numberOfColumns + 1));
|
||||||
|
|
||||||
var x = _horizontalMargin,
|
var x = _horizontalMargin,
|
||||||
y = -itemSize.height;
|
y = -itemSize.height;
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for (; index < count; ++index)
|
||||||
{
|
{
|
||||||
if (index % _numberOfColumns == 0)
|
if (index % _numberOfColumns == 0)
|
||||||
@@ -415,28 +415,19 @@
|
|||||||
x = _horizontalMargin;
|
x = _horizontalMargin;
|
||||||
y += _verticalMargin + itemSize.height;
|
y += _verticalMargin + itemSize.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
var view = [_items[index] view];
|
var view = [_items[index] view];
|
||||||
|
|
||||||
[view setFrameOrigin:CGPointMake(x, y)];
|
[view setFrameOrigin:CGPointMake(x, y)];
|
||||||
|
|
||||||
if (itemsNeedSizeUpdate)
|
if (itemsNeedSizeUpdate)
|
||||||
[view setFrameSize:_itemSize];
|
[view setFrameSize:_itemSize];
|
||||||
|
|
||||||
x += itemSize.width + _horizontalMargin;
|
x += itemSize.width + _horizontalMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
var superview = [self superview],
|
|
||||||
proposedHeight = y + itemSize.height + _verticalMargin;
|
|
||||||
|
|
||||||
if ([superview isKindOfClass:[CPClipView class]])
|
|
||||||
{
|
|
||||||
var superviewSize = [superview bounds].size;
|
|
||||||
proposedHeight = MAX(superviewSize.height, proposedHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
_tileWidth = width;
|
_tileWidth = width;
|
||||||
[self setFrameSize:CGSizeMake(width, proposedHeight)];
|
[self setFrameSize:CGSizeMake(width, y + itemSize.height + _verticalMargin)];
|
||||||
_tileWidth = -1.0;
|
_tileWidth = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,9 +445,9 @@
|
|||||||
{
|
{
|
||||||
if (_maxNumberOfRows == aMaxNumberOfRows)
|
if (_maxNumberOfRows == aMaxNumberOfRows)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_maxNumberOfRows = aMaxNumberOfRows;
|
_maxNumberOfRows = aMaxNumberOfRows;
|
||||||
|
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,9 +467,9 @@
|
|||||||
{
|
{
|
||||||
if (_maxNumberOfColumns == aMaxNumberOfColumns)
|
if (_maxNumberOfColumns == aMaxNumberOfColumns)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_maxNumberOfColumns = aMaxNumberOfColumns;
|
_maxNumberOfColumns = aMaxNumberOfColumns;
|
||||||
|
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,9 +506,9 @@
|
|||||||
{
|
{
|
||||||
if (CGSizeEqualToSize(_minItemSize, aSize))
|
if (CGSizeEqualToSize(_minItemSize, aSize))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_minItemSize = CGSizeMakeCopy(aSize);
|
_minItemSize = CGSizeMakeCopy(aSize);
|
||||||
|
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,9 +528,9 @@
|
|||||||
{
|
{
|
||||||
if (CGSizeEqualToSize(_maxItemSize, aSize))
|
if (CGSizeEqualToSize(_maxItemSize, aSize))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_maxItemSize = CGSizeMakeCopy(aSize);
|
_maxItemSize = CGSizeMakeCopy(aSize);
|
||||||
|
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,14 +590,6 @@
|
|||||||
|
|
||||||
- (void)mouseDragged:(CPEvent)anEvent
|
- (void)mouseDragged:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
var locationInWindow = [anEvent locationInWindow],
|
|
||||||
mouseDownLocationInWindow = [_mouseDownEvent locationInWindow];
|
|
||||||
|
|
||||||
// FIXME: This is because Safari's drag hysteresis is 3px x 3px
|
|
||||||
if ((ABS(locationInWindow.x - mouseDownLocationInWindow.x) < 3) &&
|
|
||||||
(ABS(locationInWindow.y - mouseDownLocationInWindow.y) < 3))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (![_delegate respondsToSelector:@selector(collectionView:dragTypesForItemsAtIndexes:)])
|
if (![_delegate respondsToSelector:@selector(collectionView:dragTypesForItemsAtIndexes:)])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -665,9 +648,9 @@
|
|||||||
{
|
{
|
||||||
if (_verticalMargin == aVerticalMargin)
|
if (_verticalMargin == aVerticalMargin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_verticalMargin = aVerticalMargin;
|
_verticalMargin = aVerticalMargin;
|
||||||
|
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,7 +701,7 @@
|
|||||||
count = [indexArray count];
|
count = [indexArray count];
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for (; index < count; ++index)
|
||||||
frame = CGRectUnion(frame, [self frameForItemAtIndex:indexArray[index]]);
|
frame = CGRectUnion(frame, [self rectForItemAtIndex:indexArray[index]]);
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
@@ -738,7 +721,7 @@
|
|||||||
- (void)moveLeft:(id)sender
|
- (void)moveLeft:(id)sender
|
||||||
{
|
{
|
||||||
var index = [[self selectionIndexes] firstIndex];
|
var index = [[self selectionIndexes] firstIndex];
|
||||||
if (index === CPNotFound)
|
if (index === CPNotFound)
|
||||||
index = [[self items] count];
|
index = [[self items] count];
|
||||||
|
|
||||||
index = MAX(index - 1, 0);
|
index = MAX(index - 1, 0);
|
||||||
@@ -766,7 +749,7 @@
|
|||||||
- (void)moveUp:(id)sender
|
- (void)moveUp:(id)sender
|
||||||
{
|
{
|
||||||
var index = [[self selectionIndexes] firstIndex];
|
var index = [[self selectionIndexes] firstIndex];
|
||||||
if (index == CPNotFound)
|
if (index == CPNotFound)
|
||||||
index = [[self items] count];
|
index = [[self items] count];
|
||||||
|
|
||||||
index = MAX(0, index - [self numberOfColumns]);
|
index = MAX(0, index - [self numberOfColumns]);
|
||||||
@@ -838,20 +821,20 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
|||||||
_cachedItems = [];
|
_cachedItems = [];
|
||||||
|
|
||||||
_itemSize = CGSizeMakeZero();
|
_itemSize = CGSizeMakeZero();
|
||||||
|
|
||||||
_minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero();
|
_minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero();
|
||||||
_maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero();
|
_maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero();
|
||||||
|
|
||||||
_verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey];
|
_verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey];
|
||||||
|
|
||||||
_isSelectable = [aCoder decodeBoolForKey:CPCollectionViewSelectableKey];
|
_isSelectable = [aCoder decodeBoolForKey:CPCollectionViewSelectableKey];
|
||||||
|
|
||||||
[self setBackgroundColors:[aCoder decodeObjectForKey:CPCollectionViewBackgroundColorsKey]];
|
[self setBackgroundColors:[aCoder decodeObjectForKey:CPCollectionViewBackgroundColorsKey]];
|
||||||
|
|
||||||
_tileWidth = -1.0;
|
_tileWidth = -1.0;
|
||||||
|
|
||||||
_selectionIndexes = [CPIndexSet indexSet];
|
_selectionIndexes = [CPIndexSet indexSet];
|
||||||
|
|
||||||
_allowsEmptySelection = YES;
|
_allowsEmptySelection = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -864,12 +847,12 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
|||||||
|
|
||||||
if (!CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
|
if (!CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
|
||||||
[aCoder encodeSize:_minItemSize forKey:CPCollectionViewMinItemSizeKey];
|
[aCoder encodeSize:_minItemSize forKey:CPCollectionViewMinItemSizeKey];
|
||||||
|
|
||||||
if (!CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
|
if (!CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
|
||||||
[aCoder encodeSize:_maxItemSize forKey:CPCollectionViewMaxItemSizeKey];
|
[aCoder encodeSize:_maxItemSize forKey:CPCollectionViewMaxItemSizeKey];
|
||||||
|
|
||||||
[aCoder encodeBool:_isSelectable forKey:CPCollectionViewSelectableKey];
|
[aCoder encodeBool:_isSelectable forKey:CPCollectionViewSelectableKey];
|
||||||
|
|
||||||
[aCoder encodeFloat:_verticalMargin forKey:CPCollectionViewVerticalMarginKey];
|
[aCoder encodeFloat:_verticalMargin forKey:CPCollectionViewVerticalMarginKey];
|
||||||
|
|
||||||
[aCoder encodeObject:_backgroundColors forKey:CPCollectionViewBackgroundColorsKey];
|
[aCoder encodeObject:_backgroundColors forKey:CPCollectionViewBackgroundColorsKey];
|
||||||
|
|||||||
@@ -231,17 +231,11 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
|||||||
|
|
||||||
- (void)mouseDown:(CPEvent)anEvent
|
- (void)mouseDown:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
if (![self isEnabled])
|
|
||||||
return;
|
|
||||||
|
|
||||||
[self drawBezelWithHighlight:YES];
|
[self drawBezelWithHighlight:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDragged:(CPEvent)anEvent
|
- (void)mouseDragged:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
if (![self isEnabled])
|
|
||||||
return;
|
|
||||||
|
|
||||||
[self drawBezelWithHighlight:CGRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil])];
|
[self drawBezelWithHighlight:CGRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil])];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +243,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
|||||||
{
|
{
|
||||||
[self drawBezelWithHighlight:NO];
|
[self drawBezelWithHighlight:NO];
|
||||||
|
|
||||||
if (!CGRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil]) || ![self isEnabled])
|
if (!CGRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self activate:YES];
|
[self activate:YES];
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ CPInputTypeCanBeChangedFeature = 1 << 25;
|
|||||||
CPHTML5DragAndDropSourceYOffBy1 = 1 << 26;
|
CPHTML5DragAndDropSourceYOffBy1 = 1 << 26;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var USER_AGENT = "",
|
var USER_AGENT = "",
|
||||||
PLATFORM_ENGINE = CPUnknownBrowserEngine,
|
PLATFORM_ENGINE = CPUnknownBrowserEngine,
|
||||||
PLATFORM_FEATURES = 0;
|
PLATFORM_FEATURES = 0;
|
||||||
@@ -73,7 +75,7 @@ var USER_AGENT = "",
|
|||||||
|
|
||||||
PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature;
|
PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature;
|
||||||
|
|
||||||
if (typeof window !== "undefined" && typeof window.navigator !== "undefined")
|
if (typeof window != "undfined" && typeof window.navigator != "undefined")
|
||||||
USER_AGENT = window.navigator.userAgent;
|
USER_AGENT = window.navigator.userAgent;
|
||||||
|
|
||||||
// Opera
|
// Opera
|
||||||
|
|||||||
+2
-2
@@ -488,10 +488,10 @@ var CPDocumentUntitledCount = 0;
|
|||||||
|
|
||||||
[_writeRequest setValue:@"close" forHTTPHeaderField:@"Connection"];
|
[_writeRequest setValue:@"close" forHTTPHeaderField:@"Connection"];
|
||||||
|
|
||||||
if (aSaveOperation === CPSaveOperation)
|
if (aSaveOperation == CPSaveOperation)
|
||||||
[_writeRequest setValue:@"true" forHTTPHeaderField:@"x-cappuccino-overwrite"];
|
[_writeRequest setValue:@"true" forHTTPHeaderField:@"x-cappuccino-overwrite"];
|
||||||
|
|
||||||
if (aSaveOperation !== CPSaveToOperation)
|
if (aSaveOperation != CPSaveToOperation)
|
||||||
[self updateChangeCount:CPChangeCleared];
|
[self updateChangeCount:CPChangeCleared];
|
||||||
|
|
||||||
// FIXME: Oh man is this every looking for trouble, we need to handle login at the Cappuccino level, with HTTP Errors.
|
// FIXME: Oh man is this every looking for trouble, we need to handle login at the Cappuccino level, with HTTP Errors.
|
||||||
|
|||||||
+33
-96
@@ -40,10 +40,29 @@ CPDragOperationEvery = -1;
|
|||||||
|
|
||||||
#define DRAGGING_WINDOW(anObject) ([anObject isKindOfClass:[CPWindow class]] ? anObject : [anObject window])
|
#define DRAGGING_WINDOW(anObject) ([anObject isKindOfClass:[CPWindow class]] ? anObject : [anObject window])
|
||||||
|
|
||||||
var CPDragServerPreviousEvent = nil,
|
var CPDragServerPreviousEvent = nil,
|
||||||
CPDragServerPeriodicUpdateInterval = 0.05;
|
CPDragServerAutoscrollInterval = nil;
|
||||||
|
/*
|
||||||
|
var CPDragServerAutoscroll = function()
|
||||||
|
{
|
||||||
|
[CPDragServerSource autoscroll:CPDragServerPreviousEvent];
|
||||||
|
}
|
||||||
|
|
||||||
var CPSharedDragServer = nil;
|
if (CPDragServerAutoscrollInterval === nil)
|
||||||
|
{
|
||||||
|
if ([CPDragServerSource respondsToSelector:@selector(autoscroll:)])
|
||||||
|
CPDragServerAutoscrollInterval = setInterval(CPDragServerAutoscroll, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
CPDragServerPreviousEvent = anEvent;
|
||||||
|
|
||||||
|
if (CPDragServerAutoscrollInterval !== nil)
|
||||||
|
clearInterval(CPDragServerAutoscrollInterval);
|
||||||
|
|
||||||
|
CPDragServerAutoscrollInterval = nil;
|
||||||
|
*/
|
||||||
|
|
||||||
|
var CPSharedDragServer = nil;
|
||||||
|
|
||||||
var CPDragServerSource = nil;
|
var CPDragServerSource = nil;
|
||||||
var CPDragServerDraggingInfo = nil;
|
var CPDragServerDraggingInfo = nil;
|
||||||
@@ -108,7 +127,7 @@ var CPDragServerDraggingInfo = nil;
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||||
CPDraggingSource_draggedImage_endedAt_operation_ = 1 << 1,
|
CPDraggingSource_draggedImage_endAt_operation_ = 1 << 1,
|
||||||
CPDraggingSource_draggedView_movedTo_ = 1 << 2,
|
CPDraggingSource_draggedView_movedTo_ = 1 << 2,
|
||||||
CPDraggingSource_draggedView_endedAt_operation_ = 1 << 3;
|
CPDraggingSource_draggedView_endedAt_operation_ = 1 << 3;
|
||||||
|
|
||||||
@@ -131,13 +150,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
|||||||
|
|
||||||
CGPoint _draggingLocation;
|
CGPoint _draggingLocation;
|
||||||
id _draggingDestination;
|
id _draggingDestination;
|
||||||
BOOL _draggingDestinationWantsPeriodicUpdates;
|
|
||||||
|
|
||||||
CGPoint _startDragLocation;
|
CGPoint _startDragLocation;
|
||||||
BOOL _shouldSlideBack;
|
BOOL _shouldSlideBack;
|
||||||
unsigned _dragOperation;
|
unsigned _dragOperation;
|
||||||
|
|
||||||
CPTimer _draggingUpdateTimer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -218,9 +234,6 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
|||||||
|
|
||||||
- (CPDragOperation)draggingUpdatedInPlatformWindow:(CPPlatformWindow)aPlatformWindow location:(CGPoint)aLocation
|
- (CPDragOperation)draggingUpdatedInPlatformWindow:(CPPlatformWindow)aPlatformWindow location:(CGPoint)aLocation
|
||||||
{
|
{
|
||||||
[_draggingUpdateTimer invalidate];
|
|
||||||
_draggingUpdateTimer = nil;
|
|
||||||
|
|
||||||
var dragOperation = CPDragOperationCopy;
|
var dragOperation = CPDragOperationCopy;
|
||||||
// We have to convert base to bridge since the drag event comes from the source window, not the drag window.
|
// We have to convert base to bridge since the drag event comes from the source window, not the drag window.
|
||||||
var draggingDestination = [aPlatformWindow _dragHitTest:aLocation pasteboard:[CPDragServerDraggingInfo draggingPasteboard]];
|
var draggingDestination = [aPlatformWindow _dragHitTest:aLocation pasteboard:[CPDragServerDraggingInfo draggingPasteboard]];
|
||||||
@@ -230,95 +243,31 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
|||||||
|
|
||||||
if(draggingDestination !== _draggingDestination)
|
if(draggingDestination !== _draggingDestination)
|
||||||
{
|
{
|
||||||
if ([_draggingDestination respondsToSelector:@selector(draggingExited:)])
|
if (_draggingDestination && [_draggingDestination respondsToSelector:@selector(draggingExited:)])
|
||||||
[_draggingDestination draggingExited:CPDragServerDraggingInfo];
|
[_draggingDestination draggingExited:CPDragServerDraggingInfo];
|
||||||
|
|
||||||
_draggingDestination = draggingDestination;
|
_draggingDestination = draggingDestination;
|
||||||
|
|
||||||
if ([_draggingDestination respondsToSelector:@selector(wantsPeriodicDraggingUpdates)])
|
if (_draggingDestination && [_draggingDestination respondsToSelector:@selector(draggingEntered:)])
|
||||||
_draggingDestinationWantsPeriodicUpdates = [_draggingDestination wantsPeriodicDraggingUpdates];
|
|
||||||
else
|
|
||||||
_draggingDestinationWantsPeriodicUpdates = YES;
|
|
||||||
|
|
||||||
if ([_draggingDestination respondsToSelector:@selector(draggingEntered:)])
|
|
||||||
dragOperation = [_draggingDestination draggingEntered:CPDragServerDraggingInfo];
|
dragOperation = [_draggingDestination draggingEntered:CPDragServerDraggingInfo];
|
||||||
}
|
}
|
||||||
else if ([_draggingDestination respondsToSelector:@selector(draggingUpdated:)])
|
else if (_draggingDestination && [_draggingDestination respondsToSelector:@selector(draggingUpdated:)])
|
||||||
dragOperation = [_draggingDestination draggingUpdated:CPDragServerDraggingInfo];
|
dragOperation = [_draggingDestination draggingUpdated:CPDragServerDraggingInfo];
|
||||||
|
|
||||||
if (!_draggingDestination)
|
if (!_draggingDestination)
|
||||||
dragOperation = CPDragOperationNone;
|
dragOperation = CPDragOperationNone;
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_draggingDestinationWantsPeriodicUpdates)
|
|
||||||
_draggingUpdateTimer = [CPTimer scheduledTimerWithTimeInterval:CPDragServerPeriodicUpdateInterval
|
|
||||||
target:self
|
|
||||||
selector:@selector(_sendPeriodicDraggingUpdate:)
|
|
||||||
userInfo:[CPDictionary dictionaryWithJSObject:{platformWindow:aPlatformWindow, location:aLocation}]
|
|
||||||
repeats:NO];
|
|
||||||
|
|
||||||
var scrollView = [_draggingDestination isKindOfClass:[CPView class]] ? [_draggingDestination enclosingScrollView] : nil;
|
|
||||||
if (scrollView)
|
|
||||||
{
|
|
||||||
var contentView = [scrollView contentView],
|
|
||||||
bounds = [contentView bounds],
|
|
||||||
insetBounds = CGRectInset(bounds, 10, 10)
|
|
||||||
eventLocation = [contentView convertPoint:_draggingLocation fromView:nil],
|
|
||||||
deltaX = 0,
|
|
||||||
deltaY = 0;
|
|
||||||
|
|
||||||
if (!CGRectContainsPoint(insetBounds, eventLocation))
|
|
||||||
{
|
|
||||||
if ([scrollView hasVerticalScroller])
|
|
||||||
{
|
|
||||||
if (eventLocation.y < CGRectGetMinY(insetBounds))
|
|
||||||
deltaY = CGRectGetMinY(insetBounds) - eventLocation.y;
|
|
||||||
else if (eventLocation.y > CGRectGetMaxY(insetBounds))
|
|
||||||
deltaY = CGRectGetMaxY(insetBounds) - eventLocation.y;
|
|
||||||
if (deltaY < -insetBounds.size.height)
|
|
||||||
deltaY = -insetBounds.size.height;
|
|
||||||
if (deltaY > insetBounds.size.height)
|
|
||||||
deltaY = insetBounds.size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([scrollView hasHorizontalScroller])
|
|
||||||
{
|
|
||||||
if (eventLocation.x < CGRectGetMinX(insetBounds))
|
|
||||||
deltaX = CGRectGetMinX(insetBounds) - eventLocation.x;
|
|
||||||
else if (eventLocation.x > CGRectGetMaxX(insetBounds))
|
|
||||||
deltaX = CGRectGetMaxX(insetBounds) - eventLocation.x;
|
|
||||||
if (deltaX < -insetBounds.size.width)
|
|
||||||
deltaX = -insetBounds.size.width;
|
|
||||||
if (deltaX > insetBounds.size.width)
|
|
||||||
deltaX = insetBounds.size.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
[contentView scrollToPoint:CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dragOperation;
|
return dragOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_sendPeriodicDraggingUpdate:(CPTimer)aTimer
|
|
||||||
{
|
|
||||||
var userInfo = [aTimer userInfo];
|
|
||||||
_dragOperation = [self draggingUpdatedInPlatformWindow:[userInfo objectForKey:@"platformWindow"]
|
|
||||||
location:[userInfo objectForKey:@"location"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)draggingEndedInPlatformWindow:(CPPlatformWindow)aPlatformWindow globalLocation:(CGPoint)aLocation operation:(CPDragOperation)anOperation
|
- (void)draggingEndedInPlatformWindow:(CPPlatformWindow)aPlatformWindow globalLocation:(CGPoint)aLocation operation:(CPDragOperation)anOperation
|
||||||
{
|
{
|
||||||
[_draggingUpdateTimer invalidate];
|
|
||||||
_draggingUpdateTimer = nil;
|
|
||||||
|
|
||||||
[_draggedView removeFromSuperview];
|
[_draggedView removeFromSuperview];
|
||||||
|
|
||||||
if (![CPPlatform supportsDragAndDrop])
|
if (![CPPlatform supportsDragAndDrop])
|
||||||
[_draggedWindow orderOut:self];
|
[_draggedWindow orderOut:self];
|
||||||
|
|
||||||
if (_implementedDraggingSourceMethods & CPDraggingSource_draggedImage_endedAt_operation_)
|
if (_implementedDraggingSourceMethods & CPDraggingSource_draggedImage_endAt_operation_)
|
||||||
[_draggingSource draggedImage:[_draggedView image] endedAt:aLocation operation:anOperation];
|
[_draggingSource draggedImage:[_draggedView image] endedAt:aLocation operation:anOperation];
|
||||||
else if (_implementedDraggingSourceMethods & CPDraggingSource_draggedView_endedAt_operation_)
|
else if (_implementedDraggingSourceMethods & CPDraggingSource_draggedView_endedAt_operation_)
|
||||||
[_draggingSource draggedView:_draggedView endedAt:aLocation operation:anOperation];
|
[_draggingSource draggedView:_draggedView endedAt:aLocation operation:anOperation];
|
||||||
@@ -393,8 +342,8 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
|||||||
if ([_draggingSource respondsToSelector:@selector(draggedImage:movedTo:)])
|
if ([_draggingSource respondsToSelector:@selector(draggedImage:movedTo:)])
|
||||||
_implementedDraggingSourceMethods |= CPDraggingSource_draggedImage_movedTo_;
|
_implementedDraggingSourceMethods |= CPDraggingSource_draggedImage_movedTo_;
|
||||||
|
|
||||||
if ([_draggingSource respondsToSelector:@selector(draggedImage:endedAt:operation:)])
|
if ([_draggingSource respondsToSelector:@selector(draggedImage:endAt:operation:)])
|
||||||
_implementedDraggingSourceMethods |= CPDraggingSource_draggedImage_endedAt_operation_;
|
_implementedDraggingSourceMethods |= CPDraggingSource_draggedImage_endAt_operation_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -455,25 +404,13 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
|||||||
// Stop tracking events.
|
// Stop tracking events.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (type === CPKeyDown)
|
|
||||||
{
|
[self draggingSourceUpdatedWithGlobalLocation:platformWindowLocation];
|
||||||
var keyCode = [anEvent keyCode];
|
_dragOperation = [self draggingUpdatedInPlatformWindow:platformWindow location:platformWindowLocation];
|
||||||
if (keyCode === CPEscapeKeyCode)
|
|
||||||
{
|
|
||||||
_dragOperation = CPDragOperationNone;
|
|
||||||
[self draggingEndedInPlatformWindow:platformWindow globalLocation:CGPointMakeZero() operation:_dragOperation];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[self draggingSourceUpdatedWithGlobalLocation:platformWindowLocation];
|
|
||||||
_dragOperation = [self draggingUpdatedInPlatformWindow:platformWindow location:platformWindowLocation];
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're not a mouse up, then we're going to want to grab the next event.
|
// If we're not a mouse up, then we're going to want to grab the next event.
|
||||||
[CPApp setTarget:self selector:@selector(trackDragging:)
|
[CPApp setTarget:self selector:@selector(trackDragging:)
|
||||||
forNextEventMatchingMask:CPMouseMovedMask | CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPKeyDownMask
|
forNextEventMatchingMask:CPMouseMovedMask | CPLeftMouseDraggedMask | CPLeftMouseUpMask
|
||||||
untilDate:nil inMode:0 dequeue:NO];
|
untilDate:nil inMode:0 dequeue:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -128,7 +128,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
|||||||
BOOL _isARepeat;
|
BOOL _isARepeat;
|
||||||
unsigned _keyCode;
|
unsigned _keyCode;
|
||||||
DOMEvent _DOMEvent;
|
DOMEvent _DOMEvent;
|
||||||
|
|
||||||
float _deltaX;
|
float _deltaX;
|
||||||
float _deltaY;
|
float _deltaY;
|
||||||
float _deltaZ;
|
float _deltaZ;
|
||||||
@@ -345,10 +345,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
|||||||
*/
|
*/
|
||||||
- (int)buttonNumber
|
- (int)buttonNumber
|
||||||
{
|
{
|
||||||
if (_type === CPRightMouseDown || _type === CPRightMouseUp || _type === CPRightMouseDragged)
|
return _buttonNumber;
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ var LEFT_SHADOW_INSET = 3.0,
|
|||||||
return _isEditable;
|
return _isEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(CPDraggingInfo)aSender
|
- (void)performDragOperation:(CPDraggingInfo)aSender
|
||||||
{
|
{
|
||||||
var images = [CPKeyedUnarchiver unarchiveObjectWithData:[[aSender draggingPasteboard] dataForType:CPImagesPboardType]];
|
var images = [CPKeyedUnarchiver unarchiveObjectWithData:[[aSender draggingPasteboard] dataForType:CPImagesPboardType]];
|
||||||
|
|
||||||
@@ -374,8 +374,6 @@ var LEFT_SHADOW_INSET = 3.0,
|
|||||||
[self setImage:images[0]];
|
[self setImage:images[0]];
|
||||||
[self sendAction:[self action] to:[self target]];
|
[self sendAction:[self action] to:[self target]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -747,9 +747,6 @@ var _CPMenuBarVisible = NO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show it.
|
// Show it.
|
||||||
if ([CPPlatform isBrowser])
|
|
||||||
[menuWindow setPlatformWindow:[[aView window] platformWindow]];
|
|
||||||
|
|
||||||
[menuWindow orderFront:self];
|
[menuWindow orderFront:self];
|
||||||
|
|
||||||
// Track it.
|
// Track it.
|
||||||
@@ -819,9 +816,6 @@ var _CPMenuBarVisible = NO,
|
|||||||
[menuWindow setFrameOrigin:CGRectIntersection(unconstrainedFrame, constraintRect).origin];
|
[menuWindow setFrameOrigin:CGRectIntersection(unconstrainedFrame, constraintRect).origin];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([CPPlatform isBrowser])
|
|
||||||
[menuWindow setPlatformWindow:[[aView window] platformWindow]];
|
|
||||||
|
|
||||||
[menuWindow orderFront:self];
|
[menuWindow orderFront:self];
|
||||||
|
|
||||||
[[_CPMenuManager sharedMenuManager]
|
[[_CPMenuManager sharedMenuManager]
|
||||||
|
|||||||
+36
-45
@@ -85,8 +85,6 @@ CPOutlineViewDropOnItemIndex = -1;
|
|||||||
|
|
||||||
BOOL _shouldRetargetChildIndex;
|
BOOL _shouldRetargetChildIndex;
|
||||||
CPInteger _retargedChildIndex;
|
CPInteger _retargedChildIndex;
|
||||||
CPTimer _dragHoverTimer;
|
|
||||||
id _dropItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithFrame:(CGRect)aFrame
|
- (id)initWithFrame:(CGRect)aFrame
|
||||||
@@ -110,7 +108,6 @@ CPOutlineViewDropOnItemIndex = -1;
|
|||||||
|
|
||||||
_retargedChildIndex = nil;
|
_retargedChildIndex = nil;
|
||||||
_shouldRetargetChildIndex = NO;
|
_shouldRetargetChildIndex = NO;
|
||||||
_startHoverTime = nil;
|
|
||||||
|
|
||||||
[self setIndentationPerLevel:16.0];
|
[self setIndentationPerLevel:16.0];
|
||||||
[self setIndentationMarkerFollowsDataView:YES];
|
[self setIndentationMarkerFollowsDataView:YES];
|
||||||
@@ -385,14 +382,43 @@ CPOutlineViewDropOnItemIndex = -1;
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_performSelection:(BOOL)select forRow:(CPInteger)rowIndex context:(id)context
|
- (void)selectRowIndexes:(CPIndexSet)rows byExtendingSelection:(BOOL)shouldExtendSelection
|
||||||
{
|
{
|
||||||
[super _performSelection:select forRow:rowIndex context:context];
|
// First un highlight the old disclosure controls
|
||||||
|
var previousSelectedRows = [];
|
||||||
|
[[self selectedRowIndexes] getIndexes:previousSelectedRows maxCount:-1 inIndexRange:nil];
|
||||||
|
|
||||||
var control = _disclosureControlsForRows[rowIndex],
|
var index = [previousSelectedRows count];
|
||||||
selector = select ? @"setThemeState:" : @"unsetThemeState:";
|
while (index--)
|
||||||
|
{
|
||||||
|
var rowIndex = previousSelectedRows[index],
|
||||||
|
item = [self itemAtRow:rowIndex];
|
||||||
|
|
||||||
[control performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
if (![self isExpandable:item])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var control = _disclosureControlsForRows[rowIndex];
|
||||||
|
[control setHighlighted:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
[super selectRowIndexes:rows byExtendingSelection:shouldExtendSelection];
|
||||||
|
|
||||||
|
// Now highlight the new disclosure controls
|
||||||
|
var selectedRows = [];
|
||||||
|
[rows getIndexes:selectedRows maxCount:-1 inIndexRange:nil];
|
||||||
|
|
||||||
|
var index = [selectedRows count];
|
||||||
|
while (index--)
|
||||||
|
{
|
||||||
|
var rowIndex = selectedRows[index],
|
||||||
|
item = [self itemAtRow:rowIndex];
|
||||||
|
|
||||||
|
if (![self isExpandable:item])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var control = _disclosureControlsForRows[rowIndex];
|
||||||
|
[control setHighlighted:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDelegate:(id)aDelegate
|
- (void)setDelegate:(id)aDelegate
|
||||||
@@ -508,29 +534,6 @@ CPOutlineViewDropOnItemIndex = -1;
|
|||||||
|
|
||||||
- (void)setDropItem:(id)theItem dropChildIndex:(int)theIndex
|
- (void)setDropItem:(id)theItem dropChildIndex:(int)theIndex
|
||||||
{
|
{
|
||||||
if (_dropItem !== theItem && theIndex < 0 && [self isExpandable:theItem] && ![self isItemExpanded:theItem])
|
|
||||||
{
|
|
||||||
if (_dragHoverTimer)
|
|
||||||
[_dragHoverTimer invalidate];
|
|
||||||
|
|
||||||
var autoExpandCallBack = function(){
|
|
||||||
if (_dropItem)
|
|
||||||
{
|
|
||||||
[_dropOperationFeedbackView blink];
|
|
||||||
[CPTimer scheduledTimerWithTimeInterval:.3 callback:objj_msgSend(self, "expandItem:", _dropItem) repeats:NO]; //[self expandItem:_dropItem];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_dragHoverTimer = [CPTimer scheduledTimerWithTimeInterval:.8 callback:autoExpandCallBack repeats:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theIndex >= 0)
|
|
||||||
{
|
|
||||||
[_dragHoverTimer invalidate];
|
|
||||||
_dragHoverTimer = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
_dropItem = theItem;
|
|
||||||
_retargetedItem = theItem;
|
_retargetedItem = theItem;
|
||||||
_shouldRetargetItem = YES;
|
_shouldRetargetItem = YES;
|
||||||
|
|
||||||
@@ -538,14 +541,6 @@ CPOutlineViewDropOnItemIndex = -1;
|
|||||||
_shouldRetargetChildIndex = YES;
|
_shouldRetargetChildIndex = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_draggingEnded
|
|
||||||
{
|
|
||||||
[super _draggingEnded];
|
|
||||||
_dropItem = nil;
|
|
||||||
[_dragHoverTimer invalidate];
|
|
||||||
_dragHoverTimer = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id)_parentItemForUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex atMouseOffset:(CPPoint)theOffset
|
- (id)_parentItemForUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex atMouseOffset:(CPPoint)theOffset
|
||||||
{
|
{
|
||||||
if (_shouldRetargetItem)
|
if (_shouldRetargetItem)
|
||||||
@@ -624,8 +619,6 @@ CPOutlineViewDropOnItemIndex = -1;
|
|||||||
_disclosureControlsForRows[row] = control;
|
_disclosureControlsForRows[row] = control;
|
||||||
|
|
||||||
[control setState:[self isItemExpanded:item] ? CPOnState : CPOffState];
|
[control setState:[self isItemExpanded:item] ? CPOnState : CPOffState];
|
||||||
var selector = [self isRowSelected:row] ? @"setThemeState:" : @"unsetThemeState:";
|
|
||||||
[control performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
|
||||||
[control setFrame:frame];
|
[control setFrame:frame];
|
||||||
|
|
||||||
[self addSubview:control];
|
[self addSubview:control];
|
||||||
@@ -1087,10 +1080,8 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
|||||||
CGContextAddLineToPoint(context, 0.0, 0.0);
|
CGContextAddLineToPoint(context, 0.0, 0.0);
|
||||||
|
|
||||||
CGContextClosePath(context);
|
CGContextClosePath(context);
|
||||||
var isHighlighted = [self hasThemeState:CPThemeStateHighlighted];
|
|
||||||
var color = [self hasThemeState:CPThemeStateSelected] ? (isHighlighted ? [CPColor lightGrayColor] : [CPColor whiteColor]) : (isHighlighted ? [CPColor blackColor] : [CPColor grayColor]);
|
CGContextSetFillColor(context, [self isHighlighted] ? [CPColor whiteColor] : [CPColor grayColor]);
|
||||||
|
|
||||||
CGContextSetFillColor(context, color);
|
|
||||||
CGContextFillPath(context);
|
CGContextFillPath(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -703,23 +703,6 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
|||||||
[self sendAction:[self action] to:[self target]];
|
[self sendAction:[self action] to:[self target]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)takeValueFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
|
|
||||||
{
|
|
||||||
var count = objects.length,
|
|
||||||
value = [objects[0] valueForKeyPath:aKeyPath];
|
|
||||||
|
|
||||||
[self selectItemWithTag:value];
|
|
||||||
[self setEnabled:YES];
|
|
||||||
|
|
||||||
while (count-- > 1)
|
|
||||||
{
|
|
||||||
if (value !== [objects[count] valueForKeyPath:aKeyPath])
|
|
||||||
{
|
|
||||||
[[self selectedItem] setState:CPOffState];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
var CPPopUpButtonMenuKey = @"CPPopUpButtonMenuKey",
|
var CPPopUpButtonMenuKey = @"CPPopUpButtonMenuKey",
|
||||||
|
|||||||
+1
-5
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
@import <Foundation/CPObject.j>
|
@import <Foundation/CPObject.j>
|
||||||
|
|
||||||
|
|
||||||
#import "CoreGraphics/CGGeometry.h"
|
#import "CoreGraphics/CGGeometry.h"
|
||||||
#import "Platform/Platform.h"
|
|
||||||
|
|
||||||
@implementation CPScreen : CPObject
|
@implementation CPScreen : CPObject
|
||||||
{
|
{
|
||||||
@@ -10,11 +10,7 @@
|
|||||||
|
|
||||||
- (CGRect)visibleFrame
|
- (CGRect)visibleFrame
|
||||||
{
|
{
|
||||||
#if PLATFORM(DOM)
|
|
||||||
return _CGRectMake(window.screen.availLeft, window.screen.availTop, window.screen.availWidth, window.screen.availHeight);
|
return _CGRectMake(window.screen.availLeft, window.screen.availTop, window.screen.availWidth, window.screen.availHeight);
|
||||||
#else
|
|
||||||
return _CGRectMakeZero();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
+10
-31
@@ -445,7 +445,9 @@
|
|||||||
|
|
||||||
- (CPView)_headerView
|
- (CPView)_headerView
|
||||||
{
|
{
|
||||||
return [_headerClipView documentView];
|
var headerClipViewSubviews = [_headerClipView subviews];
|
||||||
|
|
||||||
|
return [headerClipViewSubviews count] ? headerClipViewSubviews[0] : nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)_cornerViewFrame
|
- (CGRect)_cornerViewFrame
|
||||||
@@ -668,32 +670,15 @@
|
|||||||
*/
|
*/
|
||||||
- (void)scrollWheel:(CPEvent)anEvent
|
- (void)scrollWheel:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
[self _respondToScrollWheelEventWithDeltaX:[anEvent deltaX] * _horizontalLineScroll
|
var documentFrame = [[self documentView] frame],
|
||||||
deltaY:[anEvent deltaY] * _verticalLineScroll];
|
contentBounds = [_contentView bounds];
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_respondToScrollWheelEventWithDeltaX:(float)deltaX deltaY:(float)deltaY
|
|
||||||
{
|
|
||||||
var documentFrame = [[self documentView] frame],
|
|
||||||
contentBounds = [_contentView bounds],
|
|
||||||
contentFrame = [_contentView frame],
|
|
||||||
enclosingScrollView = [self enclosingScrollView],
|
|
||||||
extraX = 0,
|
|
||||||
extraY = 0;
|
|
||||||
|
|
||||||
// We want integral bounds!
|
// We want integral bounds!
|
||||||
contentBounds.origin.x = ROUND(contentBounds.origin.x + deltaX);
|
contentBounds.origin.x = ROUND(contentBounds.origin.x + [anEvent deltaX] * _horizontalLineScroll);
|
||||||
contentBounds.origin.y = ROUND(contentBounds.origin.y + deltaY);
|
contentBounds.origin.y = ROUND(contentBounds.origin.y + [anEvent deltaY] * _verticalLineScroll);
|
||||||
|
|
||||||
var constrainedOrigin = [_contentView constrainScrollPoint:CGPointCreateCopy(contentBounds.origin)];
|
[_contentView scrollToPoint:contentBounds.origin];
|
||||||
extraX = ((contentBounds.origin.x - constrainedOrigin.x) / _horizontalLineScroll) * [enclosingScrollView horizontalLineScroll];
|
[_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0.0)];
|
||||||
extraY = ((contentBounds.origin.y - constrainedOrigin.y) / _verticalLineScroll) * [enclosingScrollView verticalLineScroll];
|
|
||||||
|
|
||||||
[_contentView scrollToPoint:constrainedOrigin];
|
|
||||||
[_headerClipView scrollToPoint:CGPointMake(constrainedOrigin.x, 0.0)];
|
|
||||||
|
|
||||||
if (extraX || extraY)
|
|
||||||
[enclosingScrollView _respondToScrollWheelEventWithDeltaX:extraX deltaY:extraY];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyDown:(CPEvent)anEvent
|
- (void)keyDown:(CPEvent)anEvent
|
||||||
@@ -774,13 +759,7 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
|||||||
|
|
||||||
_contentView = [aCoder decodeObjectForKey:CPScrollViewContentViewKey];
|
_contentView = [aCoder decodeObjectForKey:CPScrollViewContentViewKey];
|
||||||
_headerClipView = [aCoder decodeObjectForKey:CPScrollViewHeaderClipViewKey];
|
_headerClipView = [aCoder decodeObjectForKey:CPScrollViewHeaderClipViewKey];
|
||||||
|
|
||||||
if (!_headerClipView)
|
|
||||||
{
|
|
||||||
_headerClipView = [[CPClipView alloc] init];
|
|
||||||
[self addSubview:_headerClipView];
|
|
||||||
}
|
|
||||||
|
|
||||||
_verticalScroller = [aCoder decodeObjectForKey:CPScrollViewVScrollerKey];
|
_verticalScroller = [aCoder decodeObjectForKey:CPScrollViewVScrollerKey];
|
||||||
_horizontalScroller = [aCoder decodeObjectForKey:CPScrollViewHScrollerKey];
|
_horizontalScroller = [aCoder decodeObjectForKey:CPScrollViewHScrollerKey];
|
||||||
|
|
||||||
|
|||||||
@@ -396,18 +396,6 @@ CPCircularSlider = 1;
|
|||||||
_sendActionOn &= ~CPLeftMouseDraggedMask;
|
_sendActionOn &= ~CPLeftMouseDraggedMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)takeValueFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
|
|
||||||
{
|
|
||||||
var count = objects.length,
|
|
||||||
value = [objects[0] valueForKeyPath:aKeyPath];
|
|
||||||
|
|
||||||
[self setObjectValue:value];
|
|
||||||
|
|
||||||
while (count-- > 1)
|
|
||||||
if (value !== ([objects[count] valueForKeyPath:aKeyPath]))
|
|
||||||
return [self setFloatValue:1.0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
var CPSliderMinValueKey = "CPSliderMinValueKey",
|
var CPSliderMinValueKey = "CPSliderMinValueKey",
|
||||||
|
|||||||
@@ -217,9 +217,10 @@ var CPSplitViewHorizontalImage = nil,
|
|||||||
_DOMDividerElements[_drawingDivider].style.backgroundRepeat = "repeat";
|
_DOMDividerElements[_drawingDivider].style.backgroundRepeat = "repeat";
|
||||||
|
|
||||||
CPDOMDisplayServerAppendChild(_DOMElement, _DOMDividerElements[_drawingDivider]);
|
CPDOMDisplayServerAppendChild(_DOMElement, _DOMDividerElements[_drawingDivider]);
|
||||||
|
|
||||||
|
[self _setupDOMDivider];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self _setupDOMDivider];
|
|
||||||
CPDOMDisplayServerSetStyleLeftTop(_DOMDividerElements[_drawingDivider], NULL, _CGRectGetMinX(aRect), _CGRectGetMinY(aRect));
|
CPDOMDisplayServerSetStyleLeftTop(_DOMDividerElements[_drawingDivider], NULL, _CGRectGetMinX(aRect), _CGRectGetMinY(aRect));
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMDividerElements[_drawingDivider], _CGRectGetWidth(aRect), _CGRectGetHeight(aRect));
|
CPDOMDisplayServerSetStyleSize(_DOMDividerElements[_drawingDivider], _CGRectGetWidth(aRect), _CGRectGetHeight(aRect));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -348,14 +348,7 @@ CPTableColumnUserResizingMask = 1 << 1;
|
|||||||
|
|
||||||
- (void)setHidden:(BOOL)shouldBeHidden
|
- (void)setHidden:(BOOL)shouldBeHidden
|
||||||
{
|
{
|
||||||
shouldBeHidden = !!shouldBeHidden
|
|
||||||
if (_isHidden === shouldBeHidden)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_isHidden = shouldBeHidden;
|
_isHidden = shouldBeHidden;
|
||||||
|
|
||||||
[[self headerView] setHidden:shouldBeHidden];
|
|
||||||
[[self tableView] _tableColumnVisibilityDidChange:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isHidden
|
- (BOOL)isHidden
|
||||||
|
|||||||
+151
-304
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
@implementation _CPTableColumnHeaderView : CPView
|
@implementation _CPTableColumnHeaderView : CPView
|
||||||
{
|
{
|
||||||
_CPImageAndTextView _textField;
|
_CPImageAndTextView _textField;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initWithFrame:(CGRect)frame
|
- (void)initWithFrame:(CGRect)frame
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
{
|
{
|
||||||
[self _init];
|
[self _init];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
{
|
{
|
||||||
_textField = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(5, 1, CGRectGetWidth([self bounds]) - 10, CGRectGetHeight([self bounds]) - 1)];
|
_textField = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(5, 1, CGRectGetWidth([self bounds]) - 10, CGRectGetHeight([self bounds]) - 1)];
|
||||||
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||||
|
|
||||||
[_textField setLineBreakMode:CPLineBreakByTruncatingTail];
|
[_textField setLineBreakMode:CPLineBreakByTruncatingTail];
|
||||||
[_textField setTextColor: [CPColor colorWithHexString: @"333333"]];
|
[_textField setTextColor: [CPColor colorWithHexString: @"333333"]];
|
||||||
[_textField setFont:[CPFont boldSystemFontOfSize:12.0]];
|
[_textField setFont:[CPFont boldSystemFontOfSize:12.0]];
|
||||||
@@ -137,7 +137,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder:aCoder];
|
[super encodeWithCoder:aCoder];
|
||||||
|
|
||||||
[aCoder encodeObject:[_textField text] forKey:_CPTableColumnHeaderViewStringValueKey];
|
[aCoder encodeObject:[_textField text] forKey:_CPTableColumnHeaderViewStringValueKey];
|
||||||
[aCoder encodeObject:[_textField image] forKey:_CPTableColumnHeaderViewImageKey];
|
[aCoder encodeObject:[_textField image] forKey:_CPTableColumnHeaderViewImageKey];
|
||||||
[aCoder encodeObject:[_textField font] forKey:_CPTableColumnHeaderViewFontKey];
|
[aCoder encodeObject:[_textField font] forKey:_CPTableColumnHeaderViewFontKey];
|
||||||
@@ -147,32 +147,25 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
|
|
||||||
@implementation CPTableHeaderView : CPView
|
@implementation CPTableHeaderView : CPView
|
||||||
{
|
{
|
||||||
CPPoint _mouseDownLocation;
|
int _resizedColumn @accessors(readonly, property=resizedColumn);
|
||||||
CPPoint _previousTrackingLocation;
|
int _draggedColumn @accessors(readonly, property=draggedColumn);
|
||||||
int _activeColumn;
|
int _pressedColumn @accessors(readonly, property=pressedColumn);
|
||||||
int _pressedColumn;
|
|
||||||
|
float _draggedDistance @accessors(readonly, property=draggedDistance);
|
||||||
BOOL _isResizing;
|
float _lastLocation;
|
||||||
BOOL _isDragging;
|
float _columnOldWidth;
|
||||||
BOOL _isTrackingColumn;
|
|
||||||
|
CPTableView _tableView @accessors(property=tableView);
|
||||||
float _columnOldWidth;
|
|
||||||
|
|
||||||
CPTableView _tableView @accessors(property=tableView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_init
|
- (void)_init
|
||||||
{
|
{
|
||||||
_mouseDownLocation = CPPointMakeZero();
|
_resizedColumn = -1;
|
||||||
_previousTrackingLocation = CPPointMakeZero();
|
_draggedColumn = -1;
|
||||||
_activeColumn = -1;
|
|
||||||
_pressedColumn = -1;
|
_pressedColumn = -1;
|
||||||
|
_draggedDistance = 0.0;
|
||||||
_isResizing = NO;
|
_lastLocation = nil;
|
||||||
_isDragging = NO;
|
_columnOldWidth = nil;
|
||||||
_isTrackingColumn = NO;
|
|
||||||
|
|
||||||
_columnOldWidth = 0.0;
|
|
||||||
|
|
||||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
|
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
|
||||||
}
|
}
|
||||||
@@ -189,18 +182,26 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
|
|
||||||
- (int)columnAtPoint:(CGPoint)aPoint
|
- (int)columnAtPoint:(CGPoint)aPoint
|
||||||
{
|
{
|
||||||
return [_tableView columnAtPoint:CGPointMake(aPoint.x, aPoint.y)];
|
return [_tableView columnAtPoint:CGPointMake(aPoint.x, 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)headerRectOfColumn:(int)aColumnIndex
|
- (CGRect)headerRectOfColumn:(int)aColumnIndex
|
||||||
{
|
{
|
||||||
var headerRect = [self bounds],
|
var tableColumns = [_tableView tableColumns];
|
||||||
columnRect = [_tableView rectOfColumn:aColumnIndex];
|
|
||||||
|
|
||||||
headerRect.origin.x = CPRectGetMinX(columnRect);
|
if (aColumnIndex < 0 || aColumnIndex > [tableColumns count])
|
||||||
headerRect.size.width = CPRectGetWidth(columnRect);
|
[CPException raise:"invalid" reason:"tried to get headerRectOfColumn: on invalid column"];
|
||||||
|
|
||||||
return headerRect;
|
// UPDATE COLUMN RANGES ?
|
||||||
|
|
||||||
|
var tableRange = _tableView._tableColumnRanges[aColumnIndex],
|
||||||
|
bounds = [self bounds];
|
||||||
|
|
||||||
|
var rMinX = ROUND(tableRange.location);
|
||||||
|
bounds.origin.x = rMinX;
|
||||||
|
bounds.size.width = FLOOR(tableRange.length + tableRange.location - rMinX);
|
||||||
|
|
||||||
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)_cursorRectForColumn:(int)column
|
- (CGRect)_cursorRectForColumn:(int)column
|
||||||
@@ -223,292 +224,116 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
|
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
|
||||||
[headerView unsetThemeState:CPThemeStateHighlighted];
|
[headerView unsetThemeState:CPThemeStateHighlighted];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column != -1)
|
if (column != -1)
|
||||||
{
|
{
|
||||||
var headerView = [_tableView._tableColumns[column] headerView];
|
var headerView = [_tableView._tableColumns[column] headerView];
|
||||||
[headerView setThemeState:CPThemeStateHighlighted];
|
[headerView setThemeState:CPThemeStateHighlighted];
|
||||||
}
|
}
|
||||||
|
|
||||||
_pressedColumn = column;
|
_pressedColumn = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(CPEvent)theEvent
|
- (void)mouseDown:(CPEvent)theEvent
|
||||||
{
|
{
|
||||||
[self trackMouse:theEvent];
|
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||||
|
clickedColumn = [self columnAtPoint:mouseLocation];
|
||||||
|
|
||||||
|
// should we send column -1 ?
|
||||||
|
[_tableView _sendDelegateDidMouseDownInHeader:clickedColumn];
|
||||||
|
|
||||||
|
var resizeLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
||||||
|
resizedColumn = [self columnAtPoint:resizeLocation];
|
||||||
|
|
||||||
|
if (resizedColumn == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 2 different tracking methods: one for resizing/stop-resizing, another one for selection/reordering
|
||||||
|
if ([_tableView allowsColumnResizing]
|
||||||
|
&& CGRectContainsPoint([self _cursorRectForColumn:resizedColumn], mouseLocation))
|
||||||
|
{
|
||||||
|
_resizedColumn = resizedColumn;
|
||||||
|
[_tableView._tableColumns[_resizedColumn] setDisableResizingPosting:YES];
|
||||||
|
[_tableView setDisableAutomaticResizing:YES];
|
||||||
|
[self trackResizeWithEvent:theEvent];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self _setPressedColumn:clickedColumn];
|
||||||
|
[self trackMouseWithEvent:theEvent];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)trackMouse:(CPEvent)theEvent
|
- (void)trackMouseWithEvent:(CPEvent)theEvent
|
||||||
{
|
{
|
||||||
var type = [theEvent type],
|
var type = [theEvent type];
|
||||||
currentLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
|
||||||
|
if (type == CPLeftMouseUp)
|
||||||
// Take the right columns resize tracking area into account
|
|
||||||
currentLocation.x -= 5.0;
|
|
||||||
|
|
||||||
var columnIndex = [self columnAtPoint:currentLocation],
|
|
||||||
shouldResize = [self shouldResizeTableColumn:columnIndex at:CPPointMake(currentLocation.x + 5.0, currentLocation.y)];
|
|
||||||
|
|
||||||
if (type === CPLeftMouseUp)
|
|
||||||
{
|
{
|
||||||
if (shouldResize)
|
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||||
[self stopResizingTableColumn:_activeColumn at:currentLocation];
|
clickedColumn = [self columnAtPoint:location];
|
||||||
else if ([self _shouldStopTrackingTableColumn:columnIndex at:currentLocation])
|
|
||||||
{
|
|
||||||
[_tableView _didClickTableColumn:columnIndex modifierFlags:[theEvent modifierFlags]];
|
|
||||||
[self stopTrackingTableColumn:columnIndex at:currentLocation];
|
|
||||||
|
|
||||||
_isTrackingColumn = NO;
|
[self _setPressedColumn:-1];
|
||||||
}
|
|
||||||
|
if (clickedColumn != -1)
|
||||||
[self _updateResizeCursor:[CPApp currentEvent]];
|
[_tableView _didClickTableColumn:clickedColumn modifierFlags:[theEvent modifierFlags]];
|
||||||
|
|
||||||
_activeColumn = CPNotFound;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === CPLeftMouseDown)
|
[CPApp setTarget:self selector:@selector(trackMouseWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPLeftMouseDownMask untilDate:nil inMode:nil dequeue:YES];
|
||||||
{
|
}
|
||||||
if (columnIndex === -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_mouseDownLocation = currentLocation;
|
- (void)trackResizeWithEvent:(CPEvent)anEvent
|
||||||
_activeColumn = columnIndex;
|
{
|
||||||
|
var location = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
||||||
|
tableColumn = [[_tableView tableColumns] objectAtIndex:_resizedColumn],
|
||||||
|
type = [anEvent type];
|
||||||
|
|
||||||
[_tableView _sendDelegateDidMouseDownInHeader:columnIndex];
|
if (_lastLocation == nil)
|
||||||
|
_lastLocation = location;
|
||||||
|
|
||||||
if (shouldResize)
|
if (_columnOldWidth == nil)
|
||||||
[self startResizingTableColumn:columnIndex at:currentLocation];
|
_columnOldWidth = [tableColumn width];
|
||||||
else
|
|
||||||
{
|
if (type === CPLeftMouseUp)
|
||||||
[self startTrackingTableColumn:columnIndex at:currentLocation];
|
{
|
||||||
_isTrackingColumn = YES;
|
[self _updateResizeCursor:anEvent];
|
||||||
}
|
|
||||||
}
|
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
||||||
|
[tableColumn setDisableResizingPosting:NO];
|
||||||
|
[_tableView setDisableAutomaticResizing:NO];
|
||||||
|
|
||||||
|
_resizedColumn = -1;
|
||||||
|
_lastLocation = nil;
|
||||||
|
_columnOldWidth = nil;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if (type === CPLeftMouseDragged)
|
else if (type === CPLeftMouseDragged)
|
||||||
{
|
{
|
||||||
if (shouldResize)
|
var newWidth = [tableColumn width] + location.x - _lastLocation.x;
|
||||||
[self continueResizingTableColumn:_activeColumn at:currentLocation];
|
|
||||||
|
if (newWidth < [tableColumn minWidth])
|
||||||
|
[[CPCursor resizeRightCursor] set];
|
||||||
|
else if (newWidth > [tableColumn maxWidth])
|
||||||
|
[[CPCursor resizeLeftCursor] set];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_activeColumn === columnIndex && CPRectContainsPoint([self headerRectOfColumn:columnIndex], currentLocation))
|
_tableView._lastColumnShouldSnap = NO;
|
||||||
{
|
[tableColumn setWidth:newWidth];
|
||||||
if (_isTrackingColumn && _pressedColumn !== -1)
|
// FIXME: there has to be a better way to do this...
|
||||||
{
|
// We should refactor the auto resizing crap.
|
||||||
if (![self continueTrackingTableColumn:columnIndex at:currentLocation])
|
// We need to figure out the exact cocoa behavior here though.
|
||||||
return; // Stop tracking the column, because it's being dragged
|
_lastLocation = location;
|
||||||
} else
|
|
||||||
[self startTrackingTableColumn:columnIndex at:currentLocation];
|
|
||||||
|
|
||||||
} else if (_isTrackingColumn && _pressedColumn !== -1)
|
[[CPCursor resizeLeftRightCursor] set];
|
||||||
[self stopTrackingTableColumn:_activeColumn at:currentLocation];
|
[self setNeedsLayout];
|
||||||
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_previousTrackingLocation = currentLocation;
|
[CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
|
||||||
[CPApp setTarget:self selector:@selector(trackMouse:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)startTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
[self _setPressedColumn:aColumnIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)continueTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
if ([self _shouldDragTableColumn:aColumnIndex at:aPoint])
|
|
||||||
{
|
|
||||||
var columnRect = [self headerRectOfColumn:aColumnIndex],
|
|
||||||
offset = CPPointMakeZero(),
|
|
||||||
view = [_tableView _dragViewForColumn:aColumnIndex event:[CPApp currentEvent] offset:offset],
|
|
||||||
viewLocation = CPPointMakeZero();
|
|
||||||
|
|
||||||
viewLocation.x = ( CPRectGetMinX(columnRect) + offset.x ) + ( aPoint.x - _mouseDownLocation.x );
|
|
||||||
viewLocation.y = CPRectGetMinY(columnRect) + offset.y;
|
|
||||||
|
|
||||||
[self dragView:view at:viewLocation offset:CPSizeMakeZero() event:[CPApp currentEvent]
|
|
||||||
pasteboard:[CPPasteboard pasteboardWithName:CPDragPboard] source:self slideBack:YES];
|
|
||||||
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)_shouldStopTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
return _isTrackingColumn && _activeColumn === aColumnIndex &&
|
|
||||||
CPRectContainsPoint([self headerRectOfColumn:aColumnIndex], aPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)stopTrackingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
[self _setPressedColumn:CPNotFound];
|
|
||||||
[self _updateResizeCursor:[CPApp currentEvent]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)_shouldDragTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
return [_tableView allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (CPRect)_headerRectOfLastVisibleColumn
|
|
||||||
{
|
|
||||||
var tableColumns = [_tableView tableColumns],
|
|
||||||
columnIndex = [tableColumns count];
|
|
||||||
|
|
||||||
while (columnIndex--)
|
|
||||||
{
|
|
||||||
var tableColumn = [tableColumns objectAtIndex:columnIndex];
|
|
||||||
|
|
||||||
if (![tableColumn isHidden])
|
|
||||||
return [self headerRectOfColumn:columnIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_constrainDragView:(CPView)theDragView at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
var tableColumns = [_tableView tableColumns],
|
|
||||||
lastColumnRect = [self _headerRectOfLastVisibleColumn];
|
|
||||||
activeColumnRect = [self headerRectOfColumn:_activeColumn];
|
|
||||||
dragWindow = [theDragView window],
|
|
||||||
frame = [dragWindow frame];
|
|
||||||
|
|
||||||
// Convert the frame origin from the global coordinate system to the windows' coordinate system
|
|
||||||
frame.origin = [[self window] convertGlobalToBase:frame.origin];
|
|
||||||
// the from the window to the view
|
|
||||||
frame.origin = [self convertPoint:frame.origin fromView:nil];
|
|
||||||
|
|
||||||
// This effectively clamps the value between the minimum and maximum
|
|
||||||
frame.origin.x = MAX(0.0, MIN(CGRectGetMinX(frame), CGRectGetMaxX(lastColumnRect) - CGRectGetWidth(activeColumnRect)));
|
|
||||||
|
|
||||||
// Make sure the column cannot move vertically
|
|
||||||
frame.origin.y = CPRectGetMinY(lastColumnRect);
|
|
||||||
|
|
||||||
// Convert the calculated origin back to the window coordinate system
|
|
||||||
frame.origin = [self convertPoint:frame.origin toView:nil];
|
|
||||||
// Then back to the global coordinate system
|
|
||||||
frame.origin = [[self window] convertBaseToGlobal:frame.origin];
|
|
||||||
|
|
||||||
[dragWindow setFrame:frame];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_moveColumn:(int)aFromIndex toColumn:(int)aToIndex
|
|
||||||
{
|
|
||||||
[_tableView moveColumn:aFromIndex toColumn:aToIndex];
|
|
||||||
_activeColumn = aToIndex;
|
|
||||||
_pressedColumn = _activeColumn;
|
|
||||||
|
|
||||||
[_tableView _setDraggedColumn:_activeColumn];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)draggedView:(CPView)aView beganAt:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
_isDragging = YES;
|
|
||||||
|
|
||||||
[[[[_tableView tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:YES];
|
|
||||||
[_tableView _setDraggedColumn:_activeColumn];
|
|
||||||
|
|
||||||
[self setNeedsDisplay:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)draggedView:(CPView)aView movedTo:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
[self _constrainDragView:aView at:aPoint];
|
|
||||||
|
|
||||||
var dragWindow = [aView window],
|
|
||||||
dragWindowFrame = [dragWindow frame];
|
|
||||||
|
|
||||||
var hoverPoint = CGPointCreateCopy(aPoint);
|
|
||||||
|
|
||||||
if (aPoint.x < _previousTrackingLocation.x)
|
|
||||||
hoverPoint = CGPointMake(CGRectGetMinX(dragWindowFrame), CGRectGetMinY(dragWindowFrame));
|
|
||||||
else if (aPoint.x > _previousTrackingLocation.x)
|
|
||||||
hoverPoint = CGPointMake(CGRectGetMaxX(dragWindowFrame), CGRectGetMinY(dragWindowFrame));
|
|
||||||
|
|
||||||
// Convert the hover point from the global coordinate system to windows' coordinate system
|
|
||||||
hoverPoint = [[self window] convertGlobalToBase:hoverPoint];
|
|
||||||
// then to the view
|
|
||||||
hoverPoint = [self convertPoint:hoverPoint fromView:nil];
|
|
||||||
|
|
||||||
var hoveredColumn = [self columnAtPoint:hoverPoint];
|
|
||||||
|
|
||||||
if (hoveredColumn !== -1)
|
|
||||||
{
|
|
||||||
var columnRect = [self headerRectOfColumn:hoveredColumn],
|
|
||||||
columnCenterPoint = [self convertPoint:CGPointMake(CGRectGetMidX(columnRect), CGRectGetMidY(columnRect)) fromView:self];
|
|
||||||
if (hoveredColumn < _activeColumn && hoverPoint.x < columnCenterPoint.x)
|
|
||||||
[self _moveColumn:_activeColumn toColumn:hoveredColumn];
|
|
||||||
else if (hoveredColumn > _activeColumn && hoverPoint.x > columnCenterPoint.x)
|
|
||||||
[self _moveColumn:_activeColumn toColumn:hoveredColumn];
|
|
||||||
}
|
|
||||||
|
|
||||||
_previousTrackingLocation = aPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)draggedView:(CPImage)aView endedAt:(CGPoint)aLocation operation:(CPDragOperation)anOperation
|
|
||||||
{
|
|
||||||
_isDragging = NO;
|
|
||||||
_isTrackingColumn = NO; // We need to do this explicitly because the mouse up section of trackMouse is never reached
|
|
||||||
|
|
||||||
[_tableView _setDraggedColumn:-1];
|
|
||||||
[[[[_tableView tableColumns] objectAtIndex:_activeColumn] headerView] setHidden:NO];
|
|
||||||
[self stopTrackingTableColumn:_activeColumn at:aLocation];
|
|
||||||
|
|
||||||
[self setNeedsDisplay:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)shouldResizeTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
if (_isResizing)
|
|
||||||
return YES;
|
|
||||||
|
|
||||||
if (_isTrackingColumn)
|
|
||||||
return NO;
|
|
||||||
|
|
||||||
return [_tableView allowsColumnResizing] && CPRectContainsPoint([self _cursorRectForColumn:aColumnIndex], aPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)startResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
_isResizing = YES;
|
|
||||||
|
|
||||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
|
|
||||||
|
|
||||||
[tableColumn setDisableResizingPosting:YES];
|
|
||||||
[_tableView setDisableAutomaticResizing:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)continueResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex],
|
|
||||||
newWidth = [tableColumn width] + aPoint.x - _previousTrackingLocation.x;
|
|
||||||
|
|
||||||
if (newWidth < [tableColumn minWidth])
|
|
||||||
[[CPCursor resizeRightCursor] set];
|
|
||||||
else if (newWidth > [tableColumn maxWidth])
|
|
||||||
[[CPCursor resizeLeftCursor] set];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_tableView._lastColumnShouldSnap = NO;
|
|
||||||
[tableColumn setWidth:newWidth];
|
|
||||||
|
|
||||||
[[CPCursor resizeLeftRightCursor] set];
|
|
||||||
[self setNeedsLayout];
|
|
||||||
[self setNeedsDisplay:YES];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)stopResizingTableColumn:(int)aColumnIndex at:(CPPoint)aPoint
|
|
||||||
{
|
|
||||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
|
|
||||||
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
|
||||||
[tableColumn setDisableResizingPosting:NO];
|
|
||||||
[_tableView setDisableAutomaticResizing:NO];
|
|
||||||
|
|
||||||
_isResizing = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_updateResizeCursor:(CPEvent)theEvent
|
- (void)_updateResizeCursor:(CPEvent)theEvent
|
||||||
@@ -523,12 +348,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||||
mouseOverLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
mouseOverLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
||||||
overColumn = [self columnAtPoint:mouseOverLocation];
|
overColumn = [self columnAtPoint:mouseOverLocation];
|
||||||
|
|
||||||
if (overColumn >= 0 && CGRectContainsPoint([self _cursorRectForColumn:overColumn], mouseLocation))
|
if (overColumn >= 0 && CGRectContainsPoint([self _cursorRectForColumn:overColumn], mouseLocation))
|
||||||
{
|
{
|
||||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:overColumn],
|
var tableColumn = [[_tableView tableColumns] objectAtIndex:overColumn],
|
||||||
width = [tableColumn width];
|
width = [tableColumn width];
|
||||||
|
|
||||||
if (width == [tableColumn minWidth])
|
if (width == [tableColumn minWidth])
|
||||||
[[CPCursor resizeRightCursor] set];
|
[[CPCursor resizeRightCursor] set];
|
||||||
else if (width == [tableColumn maxWidth])
|
else if (width == [tableColumn maxWidth])
|
||||||
@@ -540,6 +365,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
[[CPCursor arrowCursor] set];
|
[[CPCursor arrowCursor] set];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)viewDidMoveToWindow
|
||||||
|
{
|
||||||
|
//if ([_tableView allowsColumnResizing])
|
||||||
|
// [[self window] setAcceptsMouseMovedEvents:YES];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)mouseEntered:(CPEvent)theEvent
|
- (void)mouseEntered:(CPEvent)theEvent
|
||||||
{
|
{
|
||||||
[self _updateResizeCursor:theEvent];
|
[self _updateResizeCursor:theEvent];
|
||||||
@@ -560,12 +391,12 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
{
|
{
|
||||||
var tableColumns = [_tableView tableColumns],
|
var tableColumns = [_tableView tableColumns],
|
||||||
count = [tableColumns count];
|
count = [tableColumns count];
|
||||||
|
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var column = [tableColumns objectAtIndex:i],
|
var column = [tableColumns objectAtIndex:i],
|
||||||
headerView = [column headerView];
|
headerView = [column headerView];
|
||||||
|
|
||||||
var frame = [self headerRectOfColumn:i];
|
var frame = [self headerRectOfColumn:i];
|
||||||
frame.size.height -= 0.5;
|
frame.size.height -= 0.5;
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
@@ -573,9 +404,9 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
frame.origin.x += 0.5;
|
frame.origin.x += 0.5;
|
||||||
frame.size.width -= 1;
|
frame.size.width -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[headerView setFrame:frame];
|
[headerView setFrame:frame];
|
||||||
|
|
||||||
if([headerView superview] != self)
|
if([headerView superview] != self)
|
||||||
[self addSubview:headerView];
|
[self addSubview:headerView];
|
||||||
}
|
}
|
||||||
@@ -602,28 +433,43 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
|||||||
var columnArrayIndex = 0,
|
var columnArrayIndex = 0,
|
||||||
columnArrayCount = columnsArray.length,
|
columnArrayCount = columnsArray.length,
|
||||||
columnMaxX;
|
columnMaxX;
|
||||||
|
|
||||||
CGContextBeginPath(context);
|
CGContextBeginPath(context);
|
||||||
for(; columnArrayIndex < columnArrayCount; columnArrayIndex++)
|
for(; columnArrayIndex < columnArrayCount; columnArrayIndex++)
|
||||||
{
|
{
|
||||||
// grab each column rect and add vertical lines
|
// grab each column rect and add vertical lines
|
||||||
var columnIndex = columnsArray[columnArrayIndex],
|
var columnIndex = columnsArray[columnArrayIndex],
|
||||||
columnToStroke = [self headerRectOfColumn:columnIndex];
|
columnToStroke = [self headerRectOfColumn:columnIndex];
|
||||||
|
|
||||||
columnMaxX = CGRectGetMaxX(columnToStroke);
|
columnMaxX = CGRectGetMaxX(columnToStroke);
|
||||||
|
|
||||||
CGContextMoveToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMinY(columnToStroke)));
|
CGContextMoveToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMinY(columnToStroke)));
|
||||||
CGContextAddLineToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMaxY(columnToStroke)));
|
CGContextAddLineToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMaxY(columnToStroke)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CGContextClosePath(context);
|
CGContextClosePath(context);
|
||||||
CGContextStrokePath(context);
|
CGContextStrokePath(context);
|
||||||
|
|
||||||
if (_isDragging)
|
/*
|
||||||
|
var maxY = CGRectGetMaxY([self bounds]);
|
||||||
|
// draw normal gradient for remaining space
|
||||||
|
if (supportsCanvasGradient)
|
||||||
{
|
{
|
||||||
CGContextSetFillColor(context, [CPColor grayColor]);
|
aRect.origin.x = columnMaxX - 0.5;
|
||||||
CGContextFillRect(context, [self headerRectOfColumn:_activeColumn])
|
aRect.size.width -= columnMaxX;
|
||||||
}
|
CGContextBeginPath(context);
|
||||||
|
CGContextAddRect(context, CGRectMake(columnMaxX + 1, 0, CGRectGetMaxX([self bounds]) - columnMaxX, CGRectGetHeight([self bounds])));
|
||||||
|
CGContextClosePath(context);
|
||||||
|
CGContextDrawLinearGradient(context, [_CPTableColumnHeaderView headerGradient], CGPointMake(0,0), CGPointMake(0, maxY - 1),0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw bottom line
|
||||||
|
CGContextBeginPath(context);
|
||||||
|
CGContextMoveToPoint(context, 0, maxY - 0.5);
|
||||||
|
CGContextAddLineToPoint(context, CGRectGetMaxX([self bounds]), maxY - 0.5);
|
||||||
|
CGContextClosePath(context);
|
||||||
|
CGContextStrokePath(context);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -649,4 +495,5 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
|
|||||||
[aCoder encodeObject:_tableView forKey:CPTableHeaderViewTableViewKey];
|
[aCoder encodeObject:_tableView forKey:CPTableHeaderViewTableViewKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
+135
-239
@@ -86,7 +86,7 @@ CPTableViewSolidVerticalGridLineMask = 1 << 0;
|
|||||||
CPTableViewSolidHorizontalGridLineMask = 1 << 1;
|
CPTableViewSolidHorizontalGridLineMask = 1 << 1;
|
||||||
|
|
||||||
CPTableViewNoColumnAutoresizing = 0;
|
CPTableViewNoColumnAutoresizing = 0;
|
||||||
CPTableViewUniformColumnAutoresizingStyle = 1; // FIX ME: This is FUBAR
|
CPTableViewUniformColumnAutoresizingStyle = 1;
|
||||||
CPTableViewSequentialColumnAutoresizingStyle = 2;
|
CPTableViewSequentialColumnAutoresizingStyle = 2;
|
||||||
CPTableViewReverseSequentialColumnAutoresizingStyle = 3;
|
CPTableViewReverseSequentialColumnAutoresizingStyle = 3;
|
||||||
CPTableViewLastColumnOnlyAutoresizingStyle = 4;
|
CPTableViewLastColumnOnlyAutoresizingStyle = 4;
|
||||||
@@ -212,9 +212,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
CPGradient _sourceListActiveGradient;
|
CPGradient _sourceListActiveGradient;
|
||||||
CPColor _sourceListActiveTopLineColor;
|
CPColor _sourceListActiveTopLineColor;
|
||||||
CPColor _sourceListActiveBottomLineColor;
|
CPColor _sourceListActiveBottomLineColor;
|
||||||
|
|
||||||
int _draggedColumnIndex;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CPGradient _sourceListInactiveGradient;
|
CPGradient _sourceListInactiveGradient;
|
||||||
CPColor _sourceListInactiveTopLineColor;
|
CPColor _sourceListInactiveTopLineColor;
|
||||||
@@ -235,6 +232,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
_allowsEmptySelection = YES;
|
_allowsEmptySelection = YES;
|
||||||
_allowsColumnSelection = NO;
|
_allowsColumnSelection = NO;
|
||||||
_disableAutomaticResizing = NO;
|
_disableAutomaticResizing = NO;
|
||||||
|
_tableViewFlags = 0;
|
||||||
|
|
||||||
//Setting Display Attributes
|
//Setting Display Attributes
|
||||||
_selectionHighlightStyle = CPTableViewSelectionHighlightStyleRegular;
|
_selectionHighlightStyle = CPTableViewSelectionHighlightStyleRegular;
|
||||||
@@ -247,13 +245,28 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
_dirtyTableColumnRangeIndex = CPNotFound;
|
_dirtyTableColumnRangeIndex = CPNotFound;
|
||||||
_numberOfHiddenColumns = 0;
|
_numberOfHiddenColumns = 0;
|
||||||
|
|
||||||
|
_objectValues = { };
|
||||||
|
_dataViewsForTableColumns = { };
|
||||||
|
_dataViews= [];
|
||||||
|
_numberOfRows = 0;
|
||||||
|
_exposedRows = [CPIndexSet indexSet];
|
||||||
|
_exposedColumns = [CPIndexSet indexSet];
|
||||||
|
_cachedDataViews = { };
|
||||||
_intercellSpacing = _CGSizeMake(0.0, 0.0);
|
_intercellSpacing = _CGSizeMake(0.0, 0.0);
|
||||||
_rowHeight = 23.0;
|
_rowHeight = 23.0;
|
||||||
|
|
||||||
[self setGridColor:[CPColor colorWithHexString:@"dce0e2"]];
|
[self setGridColor:[CPColor colorWithHexString:@"dce0e2"]];
|
||||||
[self setGridStyleMask:CPTableViewGridNone];
|
[self setGridStyleMask:CPTableViewGridNone];
|
||||||
|
|
||||||
|
_headerView = [[CPTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, _rowHeight)];
|
||||||
|
|
||||||
|
[_headerView setTableView:self];
|
||||||
|
|
||||||
|
_cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))];
|
||||||
|
|
||||||
_lastSelectedRow = -1;
|
_lastSelectedRow = -1;
|
||||||
|
_selectedColumnIndexes = [CPIndexSet indexSet];
|
||||||
|
_selectedRowIndexes = [CPIndexSet indexSet];
|
||||||
_currentHighlightedTableColumn = nil;
|
_currentHighlightedTableColumn = nil;
|
||||||
|
|
||||||
_sortDescriptors = [CPArray array];
|
_sortDescriptors = [CPArray array];
|
||||||
@@ -266,8 +279,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
_dragOperationDefaultMask = nil;
|
_dragOperationDefaultMask = nil;
|
||||||
_destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular;
|
_destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular;
|
||||||
|
|
||||||
[self setBackgroundColor:[CPColor whiteColor]];
|
_tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self];
|
||||||
|
[_tableDrawView setBackgroundColor:[CPColor clearColor]];
|
||||||
|
[self addSubview:_tableDrawView];
|
||||||
[self _init];
|
[self _init];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@@ -276,45 +292,12 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
// FIX ME: we have a lot of redundent init stuff in initWithFrame: and initWithCoder: we should move it all into here.
|
// FIX ME: we have a lot of redundent init stuff in initWithFrame: and initWithCoder: we should move it all into here.
|
||||||
- (void)_init
|
- (void)_init
|
||||||
{
|
{
|
||||||
_tableViewFlags = 0;
|
|
||||||
|
|
||||||
_selectedColumnIndexes = [CPIndexSet indexSet];
|
|
||||||
_selectedRowIndexes = [CPIndexSet indexSet];
|
|
||||||
|
|
||||||
_dropOperationFeedbackView = [[_CPDropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()];
|
_dropOperationFeedbackView = [[_CPDropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()];
|
||||||
[_dropOperationFeedbackView setTableView:self];
|
[_dropOperationFeedbackView setTableView:self];
|
||||||
|
|
||||||
_lastColumnShouldSnap = NO;
|
_lastColumnShouldSnap = NO;
|
||||||
|
_backgroundColor = [CPColor whiteColor];
|
||||||
|
|
||||||
if (!_alternatingRowBackgroundColors)
|
|
||||||
_alternatingRowBackgroundColors = [[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]];
|
|
||||||
|
|
||||||
_tableColumnRanges = [];
|
|
||||||
_dirtyTableColumnRangeIndex = 0;
|
|
||||||
_numberOfHiddenColumns = 0;
|
|
||||||
|
|
||||||
_objectValues = { };
|
|
||||||
_dataViewsForTableColumns = { };
|
|
||||||
_dataViews= [];
|
|
||||||
_numberOfRows = 0;
|
|
||||||
_exposedRows = [CPIndexSet indexSet];
|
|
||||||
_exposedColumns = [CPIndexSet indexSet];
|
|
||||||
_cachedDataViews = { };
|
|
||||||
|
|
||||||
_tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self];
|
|
||||||
[_tableDrawView setBackgroundColor:[CPColor clearColor]];
|
|
||||||
[self addSubview:_tableDrawView];
|
|
||||||
|
|
||||||
if (!_headerView)
|
|
||||||
_headerView = [[CPTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, _rowHeight)];
|
|
||||||
|
|
||||||
[_headerView setTableView:self];
|
|
||||||
|
|
||||||
if (!_cornerView)
|
|
||||||
_cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))];
|
|
||||||
|
|
||||||
_draggedColumnIndex = -1;
|
|
||||||
|
|
||||||
// Gradients for the source list
|
// Gradients for the source list
|
||||||
_sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [89.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2);
|
_sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [89.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2);
|
||||||
_sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(61.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0];
|
_sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(61.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0];
|
||||||
@@ -677,15 +660,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
[self setNeedsLayout];
|
[self setNeedsLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_setDraggedColumn:(int)aColumnIndex
|
|
||||||
{
|
|
||||||
if (_draggedColumnIndex === aColumnIndex)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_draggedColumnIndex = aColumnIndex;
|
|
||||||
|
|
||||||
[self reloadDataForRowIndexes:_exposedRows columnIndexes:[CPIndexSet indexSetWithIndex:aColumnIndex]];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Moves the column and heading at a given index to a new given index.
|
Moves the column and heading at a given index to a new given index.
|
||||||
@@ -705,37 +679,15 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
else
|
else
|
||||||
_dirtyTableColumnRangeIndex = MIN(fromIndex, toIndex, _dirtyTableColumnRangeIndex);
|
_dirtyTableColumnRangeIndex = MIN(fromIndex, toIndex, _dirtyTableColumnRangeIndex);
|
||||||
|
|
||||||
|
if (toIndex > fromIndex)
|
||||||
|
--toIndex;
|
||||||
|
|
||||||
var tableColumn = _tableColumns[fromIndex];
|
var tableColumn = _tableColumns[fromIndex];
|
||||||
|
|
||||||
[_tableColumns removeObjectAtIndex:fromIndex];
|
[_tableColumns removeObjectAtIndex:fromIndex];
|
||||||
[_tableColumns insertObject:tableColumn atIndex:toIndex];
|
[_tableColumns insertObject:tableColumn atIndex:toIndex];
|
||||||
|
|
||||||
[[self headerView] setNeedsLayout];
|
|
||||||
[[self headerView] setNeedsDisplay:YES];
|
|
||||||
|
|
||||||
var rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self numberOfRows])],
|
[self setNeedsLayout];
|
||||||
columnIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(fromIndex, toIndex)];
|
|
||||||
|
|
||||||
[self reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
@ignore
|
|
||||||
*/
|
|
||||||
- (void)_tableColumnVisibilityDidChange:(CPTableColumn)aColumn
|
|
||||||
{
|
|
||||||
var columnIndex = [[self tableColumns] indexOfObjectIdenticalTo:aColumn];
|
|
||||||
|
|
||||||
if (_dirtyTableColumnRangeIndex < 0)
|
|
||||||
_dirtyTableColumnRangeIndex = columnIndex;
|
|
||||||
else
|
|
||||||
_dirtyTableColumnRangeIndex = MIN(columnIndex, _dirtyTableColumnRangeIndex);
|
|
||||||
|
|
||||||
[[self headerView] setNeedsLayout];
|
|
||||||
[[self headerView] setNeedsDisplay:YES];
|
|
||||||
|
|
||||||
var rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self numberOfRows])];
|
|
||||||
[self reloadDataForRowIndexes:rowIndexes columnIndexes:[CPIndexSet indexSetWithIndex:columnIndex]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CPArray)tableColumns
|
- (CPArray)tableColumns
|
||||||
@@ -853,22 +805,22 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
|
|
||||||
var count = deselectRows.length;
|
var count = deselectRows.length;
|
||||||
while (count--)
|
while (count--)
|
||||||
[self _performSelection:NO forRow:deselectRows[count] context:dataViewsInTableColumn];
|
{
|
||||||
|
var rowIndex = deselectRows[count];
|
||||||
|
var view = dataViewsInTableColumn[rowIndex];
|
||||||
|
[view unsetThemeState:CPThemeStateSelected];
|
||||||
|
}
|
||||||
|
|
||||||
count = selectRows.length;
|
count = selectRows.length;
|
||||||
while (count--)
|
while (count--)
|
||||||
[self _performSelection:YES forRow:selectRows[count] context:dataViewsInTableColumn];
|
{
|
||||||
|
var rowIndex = selectRows[count];
|
||||||
|
var view = dataViewsInTableColumn[rowIndex];
|
||||||
|
[view setThemeState:CPThemeStateSelected];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_performSelection:(BOOL)select forRow:(CPInteger)rowIndex context:(id)context
|
|
||||||
{
|
|
||||||
var view = context[rowIndex],
|
|
||||||
selector = select ? @"setThemeState:" : @"unsetThemeState:";
|
|
||||||
|
|
||||||
[view performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_updateHighlightWithOldColumns:(CPIndexSet)oldColumns newColumns:(CPIndexSet)newColumns
|
- (void)_updateHighlightWithOldColumns:(CPIndexSet)oldColumns newColumns:(CPIndexSet)newColumns
|
||||||
{
|
{
|
||||||
var firstExposedColumn = [_exposedColumns firstIndex],
|
var firstExposedColumn = [_exposedColumns firstIndex],
|
||||||
@@ -1092,8 +1044,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
if (_dirtyTableColumnRangeIndex < 0)
|
if (_dirtyTableColumnRangeIndex < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_numberOfHiddenColumns = 0;
|
|
||||||
|
|
||||||
var index = _dirtyTableColumnRangeIndex,
|
var index = _dirtyTableColumnRangeIndex,
|
||||||
count = NUMBER_OF_COLUMNS(),
|
count = NUMBER_OF_COLUMNS(),
|
||||||
x = index === 0 ? 0.0 : CPMaxRange(_tableColumnRanges[index - 1]);
|
x = index === 0 ? 0.0 : CPMaxRange(_tableColumnRanges[index - 1]);
|
||||||
@@ -1103,10 +1053,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
var tableColumn = _tableColumns[index];
|
var tableColumn = _tableColumns[index];
|
||||||
|
|
||||||
if ([tableColumn isHidden])
|
if ([tableColumn isHidden])
|
||||||
{
|
|
||||||
_numberOfHiddenColumns += 1;
|
|
||||||
_tableColumnRanges[index] = CPMakeRange(x, 0.0);
|
_tableColumnRanges[index] = CPMakeRange(x, 0.0);
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1127,10 +1074,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
- (CGRect)rectOfColumn:(CPInteger)aColumnIndex
|
- (CGRect)rectOfColumn:(CPInteger)aColumnIndex
|
||||||
{
|
{
|
||||||
aColumnIndex = +aColumnIndex;
|
aColumnIndex = +aColumnIndex;
|
||||||
|
|
||||||
var column = [[self tableColumns] objectAtIndex:aColumnIndex];
|
|
||||||
|
|
||||||
if ([column isHidden] || aColumnIndex < 0 || aColumnIndex >= NUMBER_OF_COLUMNS())
|
if (aColumnIndex < 0 || aColumnIndex >= NUMBER_OF_COLUMNS())
|
||||||
return _CGRectMakeZero();
|
return _CGRectMakeZero();
|
||||||
|
|
||||||
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
||||||
@@ -1283,63 +1228,68 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
return _CGRectMake(tableColumnRange.location, _CGRectGetMinY(rectOfRow), tableColumnRange.length, _CGRectGetHeight(rectOfRow));
|
return _CGRectMake(tableColumnRange.location, _CGRectGetMinY(rectOfRow), tableColumnRange.length, _CGRectGetHeight(rectOfRow));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIX ME: We should refactor this!
|
||||||
- (void)resizeWithOldSuperviewSize:(CGSize)aSize
|
- (void)resizeWithOldSuperviewSize:(CGSize)aSize
|
||||||
{
|
{
|
||||||
[super resizeWithOldSuperviewSize:aSize];
|
[super resizeWithOldSuperviewSize:aSize];
|
||||||
|
|
||||||
if (_disableAutomaticResizing)
|
if (_disableAutomaticResizing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mask = _columnAutoResizingStyle;
|
var mask = _columnAutoResizingStyle;
|
||||||
|
|
||||||
if(mask === CPTableViewUniformColumnAutoresizingStyle)
|
if(mask === CPTableViewUniformColumnAutoresizingStyle)
|
||||||
|
{
|
||||||
[self _resizeAllColumnUniformlyWithOldSize:aSize];
|
[self _resizeAllColumnUniformlyWithOldSize:aSize];
|
||||||
else if(mask === CPTableViewLastColumnOnlyAutoresizingStyle)
|
}
|
||||||
|
|
||||||
|
if(mask === CPTableViewLastColumnOnlyAutoresizingStyle)
|
||||||
|
{
|
||||||
[self sizeLastColumnToFit];
|
[self sizeLastColumnToFit];
|
||||||
else if(mask === CPTableViewFirstColumnOnlyAutoresizingStyle)
|
}
|
||||||
[self _autoResizeFirstColumn];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_autoResizeFirstColumn
|
if(mask === CPTableViewFirstColumnOnlyAutoresizingStyle)
|
||||||
{
|
{
|
||||||
var superview = [self superview];
|
var superview = [self superview];
|
||||||
|
|
||||||
if (!superview)
|
if (!superview)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var superviewSize = [superview bounds].size;
|
var superviewSize = [superview bounds].size;
|
||||||
|
|
||||||
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
UPDATE_COLUMN_RANGES_IF_NECESSARY();
|
||||||
|
|
||||||
var count = NUMBER_OF_COLUMNS(),
|
var count = NUMBER_OF_COLUMNS();
|
||||||
visColumns = [[CPArray alloc] init],
|
|
||||||
totalWidth = 0,
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for(; i < count; i++)
|
var visColumns = [[CPArray alloc] init];
|
||||||
{
|
var totalWidth = 0;
|
||||||
if(![_tableColumns[i] isHidden])
|
|
||||||
{
|
|
||||||
[visColumns addObject:i];
|
|
||||||
totalWidth += [_tableColumns[i] width];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
count = [visColumns count];
|
for(var i=0; i < count; i++)
|
||||||
|
{
|
||||||
|
if(![_tableColumns[i] isHidden])
|
||||||
|
{
|
||||||
|
[visColumns addObject:i];
|
||||||
|
totalWidth += [_tableColumns[i] width];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if there are rows
|
count = [visColumns count];
|
||||||
if (count > 0)
|
|
||||||
{
|
|
||||||
var columnToResize = _tableColumns[visColumns[0]];
|
|
||||||
var newWidth = superviewSize.width - totalWidth;// - [columnToResize width];
|
|
||||||
newWidth += [columnToResize width];
|
|
||||||
newWidth = (newWidth < [columnToResize minWidth]) ? [columnToResize minWidth] : newWidth;
|
|
||||||
newWidth = (newWidth > [columnToResize maxWidth]) ? [columnToResize maxWidth] : newWidth;
|
|
||||||
|
|
||||||
[columnToResize setWidth:FLOOR(newWidth)];
|
//if there are rows
|
||||||
}
|
if (count > 0)
|
||||||
|
{
|
||||||
|
var columnToResize = _tableColumns[visColumns[0]];
|
||||||
|
var newWidth = superviewSize.width - totalWidth;// - [columnToResize width];
|
||||||
|
newWidth += [columnToResize width];
|
||||||
|
newWidth = (newWidth < [columnToResize minWidth]) ? [columnToResize minWidth] : newWidth;
|
||||||
|
newWidth = (newWidth > [columnToResize maxWidth]) ? [columnToResize maxWidth] : newWidth;
|
||||||
|
|
||||||
|
[columnToResize setWidth:FLOOR(newWidth)];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setNeedsLayout];
|
||||||
|
}
|
||||||
|
|
||||||
[self setNeedsLayout];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_resizeAllColumnUniformlyWithOldSize:(CGSize)oldSize
|
- (void)_resizeAllColumnUniformlyWithOldSize:(CGSize)oldSize
|
||||||
@@ -1818,7 +1768,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
return [[CPImage alloc] initWithContentsOfFile:@"Frameworks/AppKit/Resources/GenericFile.png" size:CGSizeMake(32,32)];
|
return [[CPImage alloc] initWithContentsOfFile:@"Frameworks/AppKit/Resources/GenericFile.png" size:CGSizeMake(32,32)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows tableColumns:(CPArray)theTableColumns event:(CPEvent)theDragEvent offset:(CPPointPointer)dragViewOffset
|
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows tableColumns:(CPArray)theTableColumns event:(CPEvent)theDragEvent offset:(CPPoint)dragViewOffset
|
||||||
{
|
{
|
||||||
var bounds = [self bounds],
|
var bounds = [self bounds],
|
||||||
view = [[CPView alloc] initWithFrame:bounds];
|
view = [[CPView alloc] initWithFrame:bounds];
|
||||||
@@ -1854,55 +1804,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
@ignore
|
|
||||||
// Fetches all the data views (from the datasource) for the column and it's visible rows
|
|
||||||
// Copy the dataviews add them to a transparent drag view and use that drag view
|
|
||||||
// to make it appear we are dragging images of those rows (as you would do in regular Cocoa)
|
|
||||||
*/
|
|
||||||
- (CPView)_dragViewForColumn:(int)theColumnIndex event:(CPEvent)theDragEvent offset:(CPPointPointer)theDragViewOffset
|
|
||||||
{
|
|
||||||
var dragView = [[CPView alloc] initWithFrame:CPRectMakeZero()];
|
|
||||||
tableColumn = [[self tableColumns] objectAtIndex:theColumnIndex],
|
|
||||||
bounds = CPRectMake(0.0, 0.0, [tableColumn width], CPRectGetHeight([self _exposedRect]) + 23.0),
|
|
||||||
columnRect = [self rectOfColumn:theColumnIndex],
|
|
||||||
headerView = [tableColumn headerView];
|
|
||||||
|
|
||||||
row = [_exposedRows firstIndex];
|
|
||||||
while (row !== CPNotFound)
|
|
||||||
{
|
|
||||||
var dataView = [self _newDataViewForRow:row tableColumn:tableColumn],
|
|
||||||
dataViewFrame = [self frameOfDataViewAtColumn:theColumnIndex row:row];
|
|
||||||
|
|
||||||
// Only one column is ever dragged so we just place the view at
|
|
||||||
dataViewFrame.origin.x = 0.0;
|
|
||||||
|
|
||||||
// Offset by table header height - scroll position
|
|
||||||
dataViewFrame.origin.y = ( CPRectGetMinY(dataViewFrame) - CPRectGetMinY([self _exposedRect]) ) + 23.0;
|
|
||||||
[dataView setFrame:dataViewFrame];
|
|
||||||
|
|
||||||
[dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]];
|
|
||||||
[dragView addSubview:dataView];
|
|
||||||
|
|
||||||
row = [_exposedRows indexGreaterThanIndex:row];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the column header view
|
|
||||||
var headerFrame = [headerView frame];
|
|
||||||
headerFrame.origin = CPPointMakeZero();
|
|
||||||
|
|
||||||
columnHeaderView = [[_CPTableColumnHeaderView alloc] initWithFrame:headerFrame];
|
|
||||||
[columnHeaderView setStringValue:[headerView stringValue]];
|
|
||||||
[columnHeaderView setThemeState:[headerView themeState]];
|
|
||||||
[dragView addSubview:columnHeaderView];
|
|
||||||
|
|
||||||
[dragView setBackgroundColor:[CPColor whiteColor]];
|
|
||||||
[dragView setAlphaValue:0.7];
|
|
||||||
[dragView setFrame:bounds];
|
|
||||||
|
|
||||||
return dragView;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setDraggingSourceOperationMask:(CPDragOperation)mask forLocal:(BOOL)isLocal
|
- (void)setDraggingSourceOperationMask:(CPDragOperation)mask forLocal:(BOOL)isLocal
|
||||||
{
|
{
|
||||||
//ignoral local for the time being since only one capp app can run at a time...
|
//ignoral local for the time being since only one capp app can run at a time...
|
||||||
@@ -2141,14 +2042,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
columnsCount = columnArray.length;
|
columnsCount = columnArray.length;
|
||||||
|
|
||||||
for (; columnIndex < columnsCount; ++columnIndex)
|
for (; columnIndex < columnsCount; ++columnIndex)
|
||||||
{
|
{
|
||||||
var column = columnArray[columnIndex],
|
var column = columnArray[columnIndex],
|
||||||
tableColumn = _tableColumns[column];
|
tableColumn = _tableColumns[column],
|
||||||
|
tableColumnUID = [tableColumn UID];
|
||||||
if ([tableColumn isHidden] || columnIndex === _draggedColumnIndex)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var tableColumnUID = [tableColumn UID];
|
|
||||||
|
|
||||||
if (!_dataViewsForTableColumns[tableColumnUID])
|
if (!_dataViewsForTableColumns[tableColumnUID])
|
||||||
_dataViewsForTableColumns[tableColumnUID] = [];
|
_dataViewsForTableColumns[tableColumnUID] = [];
|
||||||
@@ -2261,9 +2158,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
|
|
||||||
- (void)_enqueueReusableDataView:(CPView)aDataView
|
- (void)_enqueueReusableDataView:(CPView)aDataView
|
||||||
{
|
{
|
||||||
if (!aDataView)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// FIXME: yuck!
|
// FIXME: yuck!
|
||||||
var identifier = aDataView.identifier;
|
var identifier = aDataView.identifier;
|
||||||
|
|
||||||
@@ -2301,21 +2195,20 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
[self drawBackgroundInClipRect:exposedRect];
|
[self drawBackgroundInClipRect:exposedRect];
|
||||||
[self drawGridInClipRect:exposedRect];
|
[self drawGridInClipRect:exposedRect];
|
||||||
[self highlightSelectionInClipRect:exposedRect];
|
[self highlightSelectionInClipRect:exposedRect];
|
||||||
|
|
||||||
if (_draggedColumnIndex === -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
|
||||||
columnRect = [self rectOfColumn:_draggedColumnIndex];
|
|
||||||
|
|
||||||
CGContextSetFillColor(context, [CPColor grayColor]);
|
|
||||||
CGContextFillRect(context, columnRect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawBackgroundInClipRect:(CGRect)aRect
|
- (void)drawBackgroundInClipRect:(CGRect)aRect
|
||||||
{
|
{
|
||||||
if (!_usesAlternatingRowBackgroundColors)
|
if (!_usesAlternatingRowBackgroundColors)
|
||||||
|
{
|
||||||
|
var context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||||
|
|
||||||
|
CGContextSetFillColor(context, _backgroundColor);
|
||||||
|
CGContextFillRect(context, aRect);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var rowColors = [self alternatingRowBackgroundColors],
|
var rowColors = [self alternatingRowBackgroundColors],
|
||||||
colorCount = [rowColors count];
|
colorCount = [rowColors count];
|
||||||
@@ -2454,9 +2347,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
|
|
||||||
- (void)highlightSelectionInClipRect:(CGRect)aRect
|
- (void)highlightSelectionInClipRect:(CGRect)aRect
|
||||||
{
|
{
|
||||||
if (_selectionHighlightStyle === CPTableViewDraggingDestinationFeedbackStyleNone)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||||
indexes = [],
|
indexes = [],
|
||||||
rectSelector = @selector(rectOfRow:);
|
rectSelector = @selector(rectOfRow:);
|
||||||
@@ -2486,8 +2376,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
if (!count)
|
if (!count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var drawGradient = (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList && [_selectedRowIndexes count] >= 1),
|
var drawGradient = (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList && [_selectedRowIndexes count] >= 1);
|
||||||
deltaHeight = 0.5 * (_gridStyleMask & CPTableViewSolidHorizontalGridLineMask);
|
|
||||||
|
var deltaHeight = 0.5 * (_gridStyleMask & CPTableViewSolidHorizontalGridLineMask);
|
||||||
|
|
||||||
CGContextBeginPath(context);
|
CGContextBeginPath(context);
|
||||||
while (count--)
|
while (count--)
|
||||||
@@ -2550,9 +2441,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
|
|
||||||
for(var c = firstExposedColumn; c < exposedColumnCount; c++)
|
for(var c = firstExposedColumn; c < exposedColumnCount; c++)
|
||||||
{
|
{
|
||||||
|
//console.log(columnIndexes);
|
||||||
var colRect = [self rectOfColumn:exposedColumnIndexes[c]],
|
var colRect = [self rectOfColumn:exposedColumnIndexes[c]],
|
||||||
colX = CGRectGetMaxX(colRect) + 0.5;
|
colX = CGRectGetMaxX(colRect) + 0.5;
|
||||||
|
//console.log(colX);
|
||||||
CGContextMoveToPoint(context, colX, minY);
|
CGContextMoveToPoint(context, colX, minY);
|
||||||
CGContextAddLineToPoint(context, colX, maxY);
|
CGContextAddLineToPoint(context, colX, maxY);
|
||||||
}
|
}
|
||||||
@@ -2676,10 +2568,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
{
|
{
|
||||||
// Prevent CPControl from eating the mouse events when we are in a drag session
|
// Prevent CPControl from eating the mouse events when we are in a drag session
|
||||||
if (![_draggedRowIndexes count])
|
if (![_draggedRowIndexes count])
|
||||||
{
|
|
||||||
[self autoscroll:anEvent];
|
|
||||||
[super trackMouse:anEvent];
|
[super trackMouse:anEvent];
|
||||||
}
|
|
||||||
else
|
else
|
||||||
[CPApp sendEvent:anEvent];
|
[CPApp sendEvent:anEvent];
|
||||||
}
|
}
|
||||||
@@ -2992,7 +2881,14 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
[_dropOperationFeedbackView setFrame:rect];
|
[_dropOperationFeedbackView setFrame:rect];
|
||||||
[_dropOperationFeedbackView setCurrentRow:row];
|
[_dropOperationFeedbackView setCurrentRow:row];
|
||||||
[self addSubview:_dropOperationFeedbackView];
|
[self addSubview:_dropOperationFeedbackView];
|
||||||
|
|
||||||
|
// FIXME : Maybe we should do this in a timer outside this method.
|
||||||
|
// Problem: we don't know when the scroll ends or when the next -draggingUpdated is called.
|
||||||
|
if (row > 0 && location.y - CGRectGetMinY(exposedClipRect) < _rowHeight)
|
||||||
|
[self scrollRowToVisible:row - 1];
|
||||||
|
else if (row < numberOfRows && CGRectGetMaxY(exposedClipRect) - location.y < _rowHeight)
|
||||||
|
[self scrollRowToVisible:row + 1];
|
||||||
|
|
||||||
return dragOperation;
|
return dragOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3160,7 +3056,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
|||||||
|
|
||||||
- (void)keyDown:(CPEvent)anEvent
|
- (void)keyDown:(CPEvent)anEvent
|
||||||
{
|
{
|
||||||
[self interpretKeyEvents:[anEvent]];
|
[self interpretKeyEvents:[CPArray arrayWithObject:anEvent]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveDown:(id)sender
|
- (void)moveDown:(id)sender
|
||||||
@@ -3298,18 +3194,34 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
|||||||
_allowsEmptySelection = [aCoder decodeBoolForKey:CPTableViewEmptySelectionKey];
|
_allowsEmptySelection = [aCoder decodeBoolForKey:CPTableViewEmptySelectionKey];
|
||||||
_allowsColumnSelection = [aCoder decodeBoolForKey:CPTableViewColumnSelectionKey];
|
_allowsColumnSelection = [aCoder decodeBoolForKey:CPTableViewColumnSelectionKey];
|
||||||
|
|
||||||
|
_tableViewFlags = 0;
|
||||||
|
|
||||||
//Setting Display Attributes
|
//Setting Display Attributes
|
||||||
_selectionHighlightStyle = CPTableViewSelectionHighlightStyleRegular;
|
_selectionHighlightStyle = CPTableViewSelectionHighlightStyleRegular;
|
||||||
|
|
||||||
_tableColumns = [aCoder decodeObjectForKey:CPTableViewTableColumnsKey] || [];
|
_usesAlternatingRowBackgroundColors = [aCoder decodeBoolForKey:CPTableViewUsesAlternatingBackgroundKey];
|
||||||
|
[self setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]]];
|
||||||
|
|
||||||
|
_tableColumns = [aCoder decodeObjectForKey:CPTableViewTableColumnsKey];
|
||||||
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
|
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
|
||||||
|
|
||||||
if ([aCoder containsValueForKey:CPTableViewRowHeightKey])
|
_tableColumnRanges = [];
|
||||||
_rowHeight = [aCoder decodeFloatForKey:CPTableViewRowHeightKey];
|
_dirtyTableColumnRangeIndex = 0;
|
||||||
else
|
_numberOfHiddenColumns = 0;
|
||||||
_rowHeight = 23.0;
|
|
||||||
|
_objectValues = { };
|
||||||
|
_dataViewsForTableColumns = { };
|
||||||
|
_dataViews= [];
|
||||||
|
_numberOfRows = 0;
|
||||||
|
_exposedRows = [CPIndexSet indexSet];
|
||||||
|
_exposedColumns = [CPIndexSet indexSet];
|
||||||
|
_cachedDataViews = { };
|
||||||
|
_rowHeight = [aCoder decodeFloatForKey:CPTableViewRowHeightKey];
|
||||||
|
|
||||||
_intercellSpacing = [aCoder decodeSizeForKey:CPTableViewIntercellSpacingKey] || _CGSizeMake(0.0, 0.0);
|
if ([aCoder containsValueForKey:CPTableViewIntercellSpacingKey])
|
||||||
|
_intercellSpacing = [aCoder decodeSizeForKey:CPTableViewIntercellSpacingKey];
|
||||||
|
else
|
||||||
|
_intercellSpacing = _CGSizeMake(0.0, 0.0);
|
||||||
|
|
||||||
_gridColor = [aCoder decodeObjectForKey:CPTableViewGridColorKey] || [CPColor grayColor];
|
_gridColor = [aCoder decodeObjectForKey:CPTableViewGridColorKey] || [CPColor grayColor];
|
||||||
_gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone;
|
_gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone;
|
||||||
@@ -3320,9 +3232,15 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
|||||||
_headerView = [aCoder decodeObjectForKey:CPTableViewHeaderViewKey];
|
_headerView = [aCoder decodeObjectForKey:CPTableViewHeaderViewKey];
|
||||||
_cornerView = [aCoder decodeObjectForKey:CPTableViewCornerViewKey];
|
_cornerView = [aCoder decodeObjectForKey:CPTableViewCornerViewKey];
|
||||||
|
|
||||||
|
_selectedColumnIndexes = [CPIndexSet indexSet];
|
||||||
|
_selectedRowIndexes = [CPIndexSet indexSet];
|
||||||
|
|
||||||
_dataSource = [aCoder decodeObjectForKey:CPTableViewDataSourceKey];
|
_dataSource = [aCoder decodeObjectForKey:CPTableViewDataSourceKey];
|
||||||
_delegate = [aCoder decodeObjectForKey:CPTableViewDelegateKey];
|
_delegate = [aCoder decodeObjectForKey:CPTableViewDelegateKey];
|
||||||
|
|
||||||
|
_tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self];
|
||||||
|
[_tableDrawView setBackgroundColor:[CPColor clearColor]];
|
||||||
|
[self addSubview:_tableDrawView];
|
||||||
[self _init];
|
[self _init];
|
||||||
|
|
||||||
[self viewWillMoveToSuperview:[self superview]];
|
[self viewWillMoveToSuperview:[self superview]];
|
||||||
@@ -3403,12 +3321,11 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
|||||||
unsigned dropOperation @accessors;
|
unsigned dropOperation @accessors;
|
||||||
CPTableView tableView @accessors;
|
CPTableView tableView @accessors;
|
||||||
int currentRow @accessors;
|
int currentRow @accessors;
|
||||||
BOOL isBlinking @accessors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(CGRect)aRect
|
- (void)drawRect:(CGRect)aRect
|
||||||
{
|
{
|
||||||
if(tableView._destinationDragStyle === CPTableViewDraggingDestinationFeedbackStyleNone || isBlinking)
|
if(tableView._destinationDragStyle === CPTableViewDraggingDestinationFeedbackStyleNone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var context = [[CPGraphicsContext currentContext] graphicsPort];
|
var context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||||
@@ -3474,28 +3391,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
|||||||
CGContextStrokePath(context);
|
CGContextStrokePath(context);
|
||||||
//CGContextStrokeLineSegments(context, [aRect.origin.x + 8, aRect.origin.y + 8, 300 , aRect.origin.y + 8]);
|
//CGContextStrokeLineSegments(context, [aRect.origin.x + 8, aRect.origin.y + 8, 300 , aRect.origin.y + 8]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (void)blink
|
|
||||||
{
|
|
||||||
if (dropOperation !== CPTableViewDropOn)
|
|
||||||
return;
|
|
||||||
|
|
||||||
isBlinking = YES;
|
|
||||||
|
|
||||||
var showCallback = function() {
|
|
||||||
objj_msgSend(self, "setHidden:", NO)
|
|
||||||
isBlinking = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
var hideCallback = function() {
|
|
||||||
objj_msgSend(self, "setHidden:", YES)
|
|
||||||
isBlinking = YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
objj_msgSend(self, "setHidden:", YES);
|
|
||||||
[CPTimer scheduledTimerWithTimeInterval:0.1 callback:showCallback repeats:NO];
|
|
||||||
[CPTimer scheduledTimerWithTimeInterval:0.19 callback:hideCallback repeats:NO];
|
|
||||||
[CPTimer scheduledTimerWithTimeInterval:0.27 callback:showCallback repeats:NO];
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|||||||
+1
-17
@@ -997,7 +997,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
|||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)bezelRectForBounds:(CGRect)bounds
|
- (CGRect)bezelRectForBounds:(CFRect)bounds
|
||||||
{
|
{
|
||||||
var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"];
|
var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"];
|
||||||
|
|
||||||
@@ -1087,22 +1087,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)takeValueFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
|
|
||||||
{
|
|
||||||
var count = objects.length,
|
|
||||||
value = [objects[0] valueForKeyPath:aKeyPath];
|
|
||||||
|
|
||||||
[self setStringValue:value];
|
|
||||||
[self setPlaceholderString:@""];
|
|
||||||
|
|
||||||
while (count-- > 1)
|
|
||||||
if (value !== [objects[count] valueForKeyPath:aKeyPath])
|
|
||||||
{
|
|
||||||
[self setPlaceholderString:@"Multiple Values"];
|
|
||||||
[self setStringValue:@""];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
var secureStringForString = function(aString)
|
var secureStringForString = function(aString)
|
||||||
|
|||||||
@@ -449,9 +449,6 @@ CPToolbarItemVisibilityPriorityUser
|
|||||||
|
|
||||||
- (void)validate
|
- (void)validate
|
||||||
{
|
{
|
||||||
var action = [self action],
|
|
||||||
target = [self target];
|
|
||||||
|
|
||||||
// View items do not do any target-action analysis.
|
// View items do not do any target-action analysis.
|
||||||
if (_view)
|
if (_view)
|
||||||
{
|
{
|
||||||
@@ -461,9 +458,13 @@ CPToolbarItemVisibilityPriorityUser
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var action = [self action];
|
||||||
|
|
||||||
if (!action)
|
if (!action)
|
||||||
return [self setEnabled:NO];
|
return [self setEnabled:NO];
|
||||||
|
|
||||||
|
var target = [self target];
|
||||||
|
|
||||||
if (target && ![target respondsToSelector:action])
|
if (target && ![target respondsToSelector:action])
|
||||||
return [self setEnabled:NO];
|
return [self setEnabled:NO];
|
||||||
|
|
||||||
|
|||||||
+20
-45
@@ -94,8 +94,7 @@ var DOMElementPrototype = nil,
|
|||||||
BackgroundTrivialColor = 0,
|
BackgroundTrivialColor = 0,
|
||||||
BackgroundVerticalThreePartImage = 1,
|
BackgroundVerticalThreePartImage = 1,
|
||||||
BackgroundHorizontalThreePartImage = 2,
|
BackgroundHorizontalThreePartImage = 2,
|
||||||
BackgroundNinePartImage = 3,
|
BackgroundNinePartImage = 3;
|
||||||
BackgroundTransparentColor = 4;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var CPViewFlags = { },
|
var CPViewFlags = { },
|
||||||
@@ -140,7 +139,6 @@ var CPViewFlags = { },
|
|||||||
|
|
||||||
BOOL _isHidden;
|
BOOL _isHidden;
|
||||||
BOOL _hitTests;
|
BOOL _hitTests;
|
||||||
BOOL _clipsToBounds;
|
|
||||||
|
|
||||||
BOOL _postsFrameChangedNotifications;
|
BOOL _postsFrameChangedNotifications;
|
||||||
BOOL _postsBoundsChangedNotifications;
|
BOOL _postsBoundsChangedNotifications;
|
||||||
@@ -279,7 +277,6 @@ var CPViewFlags = { },
|
|||||||
|
|
||||||
_autoresizingMask = CPViewNotSizable;
|
_autoresizingMask = CPViewNotSizable;
|
||||||
_autoresizesSubviews = YES;
|
_autoresizesSubviews = YES;
|
||||||
_clipsToBounds = YES;
|
|
||||||
|
|
||||||
_opacity = 1.0;
|
_opacity = 1.0;
|
||||||
_isHidden = NO;
|
_isHidden = NO;
|
||||||
@@ -838,33 +835,28 @@ var CPViewFlags = { },
|
|||||||
|
|
||||||
if (_backgroundType !== BackgroundTrivialColor)
|
if (_backgroundType !== BackgroundTrivialColor)
|
||||||
{
|
{
|
||||||
if (_backgroundType === BackgroundTransparentColor)
|
var images = [[_backgroundColor patternImage] imageSlices];
|
||||||
|
|
||||||
|
if (_backgroundType === BackgroundVerticalThreePartImage)
|
||||||
{
|
{
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], size.width, size.height);
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], size.width, size.height - _DOMImageSizes[0].height - _DOMImageSizes[2].height);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
else if (_backgroundType === BackgroundHorizontalThreePartImage)
|
||||||
{
|
{
|
||||||
var images = [[_backgroundColor patternImage] imageSlices];
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], size.width - _DOMImageSizes[0].width - _DOMImageSizes[2].width, size.height);
|
||||||
|
}
|
||||||
|
|
||||||
if (_backgroundType === BackgroundVerticalThreePartImage)
|
else if (_backgroundType === BackgroundNinePartImage)
|
||||||
{
|
{
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], size.width, size.height - _DOMImageSizes[0].height - _DOMImageSizes[2].height);
|
var width = size.width - _DOMImageSizes[0].width - _DOMImageSizes[2].width,
|
||||||
}
|
height = size.height - _DOMImageSizes[0].height - _DOMImageSizes[6].height;
|
||||||
else if (_backgroundType === BackgroundHorizontalThreePartImage)
|
|
||||||
{
|
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], size.width - _DOMImageSizes[0].width - _DOMImageSizes[2].width, size.height);
|
|
||||||
}
|
|
||||||
else if (_backgroundType === BackgroundNinePartImage)
|
|
||||||
{
|
|
||||||
var width = size.width - _DOMImageSizes[0].width - _DOMImageSizes[2].width,
|
|
||||||
height = size.height - _DOMImageSizes[0].height - _DOMImageSizes[6].height;
|
|
||||||
|
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], width, _DOMImageSizes[0].height);
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], width, _DOMImageSizes[0].height);
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[3], _DOMImageSizes[3].width, height);
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[3], _DOMImageSizes[3].width, height);
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[4], width, height);
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[4], width, height);
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[5], _DOMImageSizes[5].width, height);
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[5], _DOMImageSizes[5].width, height);
|
||||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[7], width, _DOMImageSizes[7].height);
|
CPDOMDisplayServerSetStyleSize(_DOMImageParts[7], width, _DOMImageSizes[7].height);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1196,23 +1188,6 @@ var CPViewFlags = { },
|
|||||||
return _isHidden;
|
return _isHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setClipsToBounds:(BOOL)shouldClip
|
|
||||||
{
|
|
||||||
if (_clipsToBounds === shouldClip)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_clipsToBounds = shouldClip;
|
|
||||||
|
|
||||||
#if PLATFORM(DOM)
|
|
||||||
_DOMElement.style.overflow = _clipsToBounds ? "hidden" : "visible";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)clipsToBounds
|
|
||||||
{
|
|
||||||
return _clipsToBounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Sets the opacity of the receiver. The value must be in the range of 0.0 to 1.0, where 0.0 is
|
Sets the opacity of the receiver. The value must be in the range of 0.0 to 1.0, where 0.0 is
|
||||||
completely transparent and 1.0 is completely opaque.
|
completely transparent and 1.0 is completely opaque.
|
||||||
@@ -1386,7 +1361,7 @@ var CPViewFlags = { },
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_backgroundType = colorNeedsDOMElement ? BackgroundTransparentColor : BackgroundTrivialColor;
|
_backgroundType = BackgroundTrivialColor;
|
||||||
amount = (colorNeedsDOMElement ? 1 : 0) - _DOMImageParts.length;
|
amount = (colorNeedsDOMElement ? 1 : 0) - _DOMImageParts.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1409,7 +1384,7 @@ var CPViewFlags = { },
|
|||||||
_DOMElement.removeChild(_DOMImageParts.pop());
|
_DOMElement.removeChild(_DOMImageParts.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_backgroundType === BackgroundTrivialColor || _backgroundType === BackgroundTransparentColor)
|
if (_backgroundType === BackgroundTrivialColor)
|
||||||
{
|
{
|
||||||
var colorCSS = colorExists ? [_backgroundColor cssString] : "";
|
var colorCSS = colorExists ? [_backgroundColor cssString] : "";
|
||||||
|
|
||||||
|
|||||||
+8
-52
@@ -69,13 +69,11 @@ CPWebViewScrollNative = 2;
|
|||||||
|
|
||||||
CPString _url;
|
CPString _url;
|
||||||
CPString _html;
|
CPString _html;
|
||||||
|
|
||||||
Function _loadCallback;
|
Function _loadCallback;
|
||||||
|
|
||||||
int _scrollMode;
|
int _scrollMode;
|
||||||
CGSize _scrollSize;
|
CGSize _scrollSize;
|
||||||
|
|
||||||
int _loadHTMLStringTimer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithFrame:(CPRect)frameRect frameName:(CPString)frameName groupName:(CPString)groupName
|
- (id)initWithFrame:(CPRect)frameRect frameName:(CPString)frameName groupName:(CPString)groupName
|
||||||
@@ -112,7 +110,6 @@ CPWebViewScrollNative = 2;
|
|||||||
_iframe.style.width = "100%";
|
_iframe.style.width = "100%";
|
||||||
_iframe.style.height = "100%";
|
_iframe.style.height = "100%";
|
||||||
_iframe.style.borderWidth = "0px";
|
_iframe.style.borderWidth = "0px";
|
||||||
_iframe.frameBorder = "0";
|
|
||||||
|
|
||||||
[self setDrawsBackground:YES];
|
[self setDrawsBackground:YES];
|
||||||
|
|
||||||
@@ -174,32 +171,7 @@ CPWebViewScrollNative = 2;
|
|||||||
[self _resizeWebFrame];
|
[self _resizeWebFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_attachScrollEventIfNecessary
|
- (BOOL)_resizeWebFrame
|
||||||
{
|
|
||||||
if (_scrollMode !== CPWebViewScrollAppKit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var win = null;
|
|
||||||
try { win = [self DOMWindow]; } catch (e) {}
|
|
||||||
|
|
||||||
if (win && win.addEventListener)
|
|
||||||
{
|
|
||||||
var scrollEventHandler = function(anEvent)
|
|
||||||
{
|
|
||||||
var frameBounds = [self bounds],
|
|
||||||
frameCenter = CGPointMake(CGRectGetMidX(frameBounds), CGRectGetMidY(frameBounds)),
|
|
||||||
windowOrigin = [self convertPoint:frameCenter toView:nil],
|
|
||||||
globalOrigin = [[self window] convertBaseToBridge:windowOrigin];
|
|
||||||
|
|
||||||
anEvent._overrideLocation = globalOrigin;
|
|
||||||
[[[self window] platformWindow] scrollEvent:anEvent];
|
|
||||||
};
|
|
||||||
|
|
||||||
win.addEventListener("DOMMouseScroll", scrollEventHandler, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_resizeWebFrame
|
|
||||||
{
|
{
|
||||||
if (_scrollMode === CPWebViewScrollAppKit)
|
if (_scrollMode === CPWebViewScrollAppKit)
|
||||||
{
|
{
|
||||||
@@ -209,14 +181,13 @@ CPWebViewScrollNative = 2;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var visibleRect = [_frameView visibleRect];
|
[_frameView setFrameSize:[_scrollView contentSize]];
|
||||||
[_frameView setFrameSize:CGSizeMake(CGRectGetMaxX(visibleRect), CGRectGetMaxY(visibleRect))];
|
|
||||||
|
|
||||||
// try to get the document size so we can correctly set the frame
|
// try to get the document size so we can correctly set the frame
|
||||||
var win = null;
|
var win = null;
|
||||||
try { win = [self DOMWindow]; } catch (e) {}
|
try { win = [self DOMWindow]; } catch (e) {}
|
||||||
|
|
||||||
if (win && win.document && win.document.body)
|
if (win && win.document)
|
||||||
{
|
{
|
||||||
var width = win.document.body.scrollWidth,
|
var width = win.document.body.scrollWidth,
|
||||||
height = win.document.body.scrollHeight;
|
height = win.document.body.scrollHeight;
|
||||||
@@ -232,8 +203,6 @@ CPWebViewScrollNative = 2;
|
|||||||
|
|
||||||
[_frameView setFrameSize:CGSizeMake(800, 1600)];
|
[_frameView setFrameSize:CGSizeMake(800, 1600)];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_frameView scrollRectToVisible:visibleRect];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,10 +217,7 @@ CPWebViewScrollNative = 2;
|
|||||||
|
|
||||||
- (void)_setScrollMode:(int)aScrollMode
|
- (void)_setScrollMode:(int)aScrollMode
|
||||||
{
|
{
|
||||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
_scrollMode = aScrollMode;
|
||||||
_scrollMode = CPWebViewScrollNative;
|
|
||||||
else
|
|
||||||
_scrollMode = aScrollMode;
|
|
||||||
|
|
||||||
_ignoreLoadStart = YES;
|
_ignoreLoadStart = YES;
|
||||||
_ignoreLoadEnd = YES;
|
_ignoreLoadEnd = YES;
|
||||||
@@ -290,8 +256,6 @@ CPWebViewScrollNative = 2;
|
|||||||
|
|
||||||
[self _setScrollMode:CPWebViewScrollAppKit];
|
[self _setScrollMode:CPWebViewScrollAppKit];
|
||||||
|
|
||||||
[_frameView setFrameSize:[_scrollView contentSize]];
|
|
||||||
|
|
||||||
[self _startedLoading];
|
[self _startedLoading];
|
||||||
|
|
||||||
_ignoreLoadStart = YES;
|
_ignoreLoadStart = YES;
|
||||||
@@ -329,15 +293,8 @@ CPWebViewScrollNative = 2;
|
|||||||
// clear the iframe
|
// clear the iframe
|
||||||
_iframe.src = "";
|
_iframe.src = "";
|
||||||
|
|
||||||
if (_loadHTMLStringTimer !== nil)
|
|
||||||
{
|
|
||||||
window.clearTimeout(_loadHTMLStringTimer);
|
|
||||||
_loadHTMLStringTimer = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
// need to give the browser a chance to reset iframe, otherwise we'll be document.write()-ing the previous document
|
// need to give the browser a chance to reset iframe, otherwise we'll be document.write()-ing the previous document
|
||||||
_loadHTMLStringTimer = window.setTimeout(function()
|
window.setTimeout(function() {
|
||||||
{
|
|
||||||
var win = [self DOMWindow];
|
var win = [self DOMWindow];
|
||||||
|
|
||||||
win.document.write(_html);
|
win.document.write(_html);
|
||||||
@@ -358,8 +315,7 @@ CPWebViewScrollNative = 2;
|
|||||||
- (void)_finishedLoading
|
- (void)_finishedLoading
|
||||||
{
|
{
|
||||||
[self _resizeWebFrame];
|
[self _resizeWebFrame];
|
||||||
[self _attachScrollEventIfNecessary];
|
|
||||||
|
|
||||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWebViewProgressFinishedNotification object:self];
|
[[CPNotificationCenter defaultCenter] postNotificationName:CPWebViewProgressFinishedNotification object:self];
|
||||||
|
|
||||||
if ([_frameLoadDelegate respondsToSelector:@selector(webView:didFinishLoadForFrame:)])
|
if ([_frameLoadDelegate respondsToSelector:@selector(webView:didFinishLoadForFrame:)])
|
||||||
|
|||||||
@@ -372,15 +372,6 @@ CPTexturedBackgroundWindowMask
|
|||||||
[self setPlatformWindow:[CPPlatformWindow primaryPlatformWindow]];
|
[self setPlatformWindow:[CPPlatformWindow primaryPlatformWindow]];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// give zero sized borderless bridge windows a default size if we're not in the browser so they show up in NativeHost.
|
|
||||||
if ((aStyleMask & CPBorderlessBridgeWindowMask) && aContentRect.size.width === 0 && aContentRect.size.height === 0)
|
|
||||||
{
|
|
||||||
var visibleFrame = [[[CPScreen alloc] init] visibleFrame];
|
|
||||||
_frame.size.height = MIN(768.0, visibleFrame.size.height);
|
|
||||||
_frame.size.width = MIN(1024.0, visibleFrame.size.width);
|
|
||||||
_frame.origin.x = (visibleFrame.size.width - _frame.size.width) / 2;
|
|
||||||
_frame.origin.y = (visibleFrame.size.height - _frame.size.height) / 2;
|
|
||||||
}
|
|
||||||
[self setPlatformWindow:[[CPPlatformWindow alloc] initWithContentRect:_frame]];
|
[self setPlatformWindow:[[CPPlatformWindow alloc] initWithContentRect:_frame]];
|
||||||
[self platformWindow]._only = self;
|
[self platformWindow]._only = self;
|
||||||
}
|
}
|
||||||
@@ -892,23 +883,6 @@ CPTexturedBackgroundWindowMask
|
|||||||
return _contentView;
|
return _contentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Applies an alpha value to the window.
|
|
||||||
@param aValue the alpha value to apply
|
|
||||||
*/
|
|
||||||
- (void)setAlphaValue:(float)aValue
|
|
||||||
{
|
|
||||||
[_windowView setAlphaValue:aValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the alpha value of the window.
|
|
||||||
*/
|
|
||||||
- (float)alphaValue
|
|
||||||
{
|
|
||||||
return [_windowView alphaValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Sets the window's background color.
|
Sets the window's background color.
|
||||||
@param aColor the new color for the background
|
@param aColor the new color for the background
|
||||||
@@ -1933,8 +1907,7 @@ CPTexturedBackgroundWindowMask
|
|||||||
[keyWindow makeKeyWindow];
|
[keyWindow makeKeyWindow];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var mainMenu = [CPApp mainMenu],
|
var menuWindow = [CPApp mainMenu]._menuWindow;
|
||||||
menuWindow = mainMenu ? mainMenu._menuWindow : nil;
|
|
||||||
for (var i = 0; i < windowCount; i++)
|
for (var i = 0; i < windowCount; i++)
|
||||||
{
|
{
|
||||||
var currentWindow = allWindows[i];
|
var currentWindow = allWindows[i];
|
||||||
@@ -1962,8 +1935,7 @@ CPTexturedBackgroundWindowMask
|
|||||||
[mainWindow makeMainWindow];
|
[mainWindow makeMainWindow];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var mainMenu = [CPApp mainMenu],
|
var menuWindow = [CPApp mainMenu]._menuWindow;
|
||||||
menuWindow = mainMenu ? mainMenu._menuWindow : nil;
|
|
||||||
for (var i = 0; i < windowCount; i++)
|
for (var i = 0; i < windowCount; i++)
|
||||||
{
|
{
|
||||||
var currentWindow = allWindows[i];
|
var currentWindow = allWindows[i];
|
||||||
|
|||||||
@@ -71,12 +71,11 @@ var _CPToolbarViewBackgroundColor = nil;
|
|||||||
[self addSubview:_toolbarBackgroundView positioned:CPWindowBelow relativeTo:nil];
|
[self addSubview:_toolbarBackgroundView positioned:CPWindowBelow relativeTo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
var frame = CGRectMakeZero(),
|
var frame = CGRectMakeZero();
|
||||||
toolbarOffset = [self toolbarOffset];
|
|
||||||
|
frame.origin = CGPointMakeCopy([self toolbarOffset]);
|
||||||
frame.origin = CGPointMake(toolbarOffset.width, toolbarOffset.height);
|
|
||||||
frame.size = [_toolbarView frame].size;
|
frame.size = [_toolbarView frame].size;
|
||||||
|
|
||||||
[_toolbarBackgroundView setFrame:frame];
|
[_toolbarBackgroundView setFrame:frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
|||||||
CGSize _resizeIndicatorOffset;
|
CGSize _resizeIndicatorOffset;
|
||||||
|
|
||||||
CPView _toolbarView;
|
CPView _toolbarView;
|
||||||
CGSize _toolbarOffset;
|
|
||||||
// BOOL _isAnimatingToolbar;
|
// BOOL _isAnimatingToolbar;
|
||||||
|
|
||||||
|
|
||||||
@@ -81,8 +80,8 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
|||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
_styleMask = aStyleMask;
|
_styleMask = aStyleMask;
|
||||||
_resizeIndicatorOffset = CGSizeMakeZero();
|
_resizeIndicatorOffset = CGSizeMake(0.0, 0.0);
|
||||||
_toolbarOffset = CGSizeMakeZero();
|
_toolbarOffset = CGSizeMake(0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@@ -270,7 +269,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
|||||||
|
|
||||||
- (CGSize)toolbarOffset
|
- (CGSize)toolbarOffset
|
||||||
{
|
{
|
||||||
return _toolbarOffset;
|
return CGSizeMakeZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CPColor)toolbarLabelColor
|
- (CPColor)toolbarLabelColor
|
||||||
|
|||||||
+14
-14
@@ -37,12 +37,12 @@ var CPCibOwner = @"CPCibOwner";
|
|||||||
|
|
||||||
@implementation CPBundle (CPCibLoading)
|
@implementation CPBundle (CPCibLoading)
|
||||||
|
|
||||||
+ (CPCib)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable
|
+ (void)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable
|
||||||
{
|
{
|
||||||
return [[[CPCib alloc] initWithContentsOfURL:anAbsolutePath] instantiateCibWithExternalNameTable:aNameTable];
|
[[[CPCib alloc] initWithContentsOfURL:anAbsolutePath] instantiateCibWithExternalNameTable:aNameTable];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPCib)loadCibNamed:(CPString)aName owner:(id)anOwner
|
+ (void)loadCibNamed:(CPString)aName owner:(id)anOwner
|
||||||
{
|
{
|
||||||
if (![aName hasSuffix:@".cib"])
|
if (![aName hasSuffix:@".cib"])
|
||||||
aName = [aName stringByAppendingString:@".cib"];
|
aName = [aName stringByAppendingString:@".cib"];
|
||||||
@@ -51,24 +51,24 @@ var CPCibOwner = @"CPCibOwner";
|
|||||||
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle],
|
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle],
|
||||||
path = [bundle pathForResource:aName];
|
path = [bundle pathForResource:aName];
|
||||||
|
|
||||||
return [self loadCibFile:path externalNameTable:[CPDictionary dictionaryWithObject:anOwner forKey:CPCibOwner]];
|
[self loadCibFile:path externalNameTable:[CPDictionary dictionaryWithObject:anOwner forKey:CPCibOwner]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CPCib)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable
|
- (void)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable
|
||||||
{
|
{
|
||||||
return [[[CPCib alloc] initWithContentsOfURL:aFileName] instantiateCibWithExternalNameTable:aNameTable];
|
[[[CPCib alloc] initWithContentsOfURL:aFileName] instantiateCibWithExternalNameTable:aNameTable];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPCib)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable loadDelegate:aDelegate
|
+ (void)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable loadDelegate:aDelegate
|
||||||
{
|
{
|
||||||
return ([[CPCib alloc]
|
[[CPCib alloc]
|
||||||
initWithContentsOfURL:anAbsolutePath
|
initWithContentsOfURL:anAbsolutePath
|
||||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||||
initWithLoadDelegate:aDelegate
|
initWithLoadDelegate:aDelegate
|
||||||
externalNameTable:aNameTable]]);
|
externalNameTable:aNameTable]];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPCib)loadCibNamed:(CPString)aName owner:(id)anOwner loadDelegate:(id)aDelegate
|
+ (void)loadCibNamed:(CPString)aName owner:(id)anOwner loadDelegate:(id)aDelegate
|
||||||
{
|
{
|
||||||
if (![aName hasSuffix:@".cib"])
|
if (![aName hasSuffix:@".cib"])
|
||||||
aName = [aName stringByAppendingString:@".cib"];
|
aName = [aName stringByAppendingString:@".cib"];
|
||||||
@@ -77,17 +77,17 @@ var CPCibOwner = @"CPCibOwner";
|
|||||||
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle],
|
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle],
|
||||||
path = [bundle pathForResource:aName];
|
path = [bundle pathForResource:aName];
|
||||||
|
|
||||||
return [self loadCibFile:path externalNameTable:[CPDictionary dictionaryWithObject:anOwner forKey:CPCibOwner] loadDelegate:aDelegate];
|
[self loadCibFile:path externalNameTable:[CPDictionary dictionaryWithObject:anOwner forKey:CPCibOwner] loadDelegate:aDelegate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CPCib)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable loadDelegate:(id)aDelegate
|
- (void)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable loadDelegate:(id)aDelegate
|
||||||
{
|
{
|
||||||
return ([[CPCib alloc]
|
[[CPCib alloc]
|
||||||
initWithCibNamed:aFileName
|
initWithCibNamed:aFileName
|
||||||
bundle:self
|
bundle:self
|
||||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||||
initWithLoadDelegate:aDelegate
|
initWithLoadDelegate:aDelegate
|
||||||
externalNameTable:aNameTable]]);
|
externalNameTable:aNameTable]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ var PrimaryPlatformWindow = NULL;
|
|||||||
|
|
||||||
DOMElement _DOMBodyElement;
|
DOMElement _DOMBodyElement;
|
||||||
DOMElement _DOMFocusElement;
|
DOMElement _DOMFocusElement;
|
||||||
DOMElement _DOMEventGuard;
|
|
||||||
|
|
||||||
CPArray _windowLevels;
|
CPArray _windowLevels;
|
||||||
CPDictionary _windowLayers;
|
CPDictionary _windowLayers;
|
||||||
@@ -74,15 +73,6 @@ var PrimaryPlatformWindow = NULL;
|
|||||||
return [CPSet set];
|
return [CPSet set];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)supportsMultipleInstances
|
|
||||||
{
|
|
||||||
#if PLATFORM(DOM)
|
|
||||||
return !CPBrowserIsEngine(CPInternetExplorerBrowserEngine);
|
|
||||||
#else
|
|
||||||
return NO;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (CPPlatformWindow)primaryPlatformWindow
|
+ (CPPlatformWindow)primaryPlatformWindow
|
||||||
{
|
{
|
||||||
return PrimaryPlatformWindow;
|
return PrimaryPlatformWindow;
|
||||||
|
|||||||
@@ -40,16 +40,6 @@ var screenNeedsInitialization = NO,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
screenNeedsInitialization = [CPPlatform isBrowser];
|
screenNeedsInitialization = [CPPlatform isBrowser];
|
||||||
|
|
||||||
// We do this here because doing it later breaks IE.
|
|
||||||
if (document.documentElement)
|
|
||||||
document.documentElement.style.overflow = "hidden";
|
|
||||||
|
|
||||||
if ([CPPlatform isBrowser])
|
|
||||||
window.onunload = function()
|
|
||||||
{
|
|
||||||
[CPApp terminate:nil];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)isBrowser
|
+ (BOOL)isBrowser
|
||||||
@@ -131,6 +121,9 @@ var screenNeedsInitialization = NO,
|
|||||||
|
|
||||||
bodyElement.style.overflow = "hidden";
|
bodyElement.style.overflow = "hidden";
|
||||||
|
|
||||||
|
if (document.documentElement)
|
||||||
|
document.documentElement.style.overflow = "hidden";
|
||||||
|
|
||||||
[[CPNotificationCenter defaultCenter]
|
[[CPNotificationCenter defaultCenter]
|
||||||
postNotificationName:CPPlatformDidClearBodyElementNotification
|
postNotificationName:CPPlatformDidClearBodyElementNotification
|
||||||
object:self];
|
object:self];
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ var CPDOMEventGetClickCount,
|
|||||||
StopDOMEventPropagation,
|
StopDOMEventPropagation,
|
||||||
StopContextMenuDOMEventPropagation;
|
StopContextMenuDOMEventPropagation;
|
||||||
|
|
||||||
|
var _DOMEventGuard;
|
||||||
|
|
||||||
//right now we hard code q, w, r and t as keys to propogate
|
//right now we hard code q, w, r and t as keys to propogate
|
||||||
//these aren't normal keycodes, they are with modifier key codes
|
//these aren't normal keycodes, they are with modifier key codes
|
||||||
//might be mac only, we should investigate futher later.
|
//might be mac only, we should investigate futher later.
|
||||||
@@ -278,7 +280,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
_DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
|
_DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
|
||||||
|
|
||||||
// FIXME: Always do this?
|
// FIXME: Always do this?
|
||||||
if (supportsNativeDragAndDrop)
|
if ([CPPlatform supportsDragAndDrop])
|
||||||
_DOMBodyElement.style["-khtml-user-select"] = "none";
|
_DOMBodyElement.style["-khtml-user-select"] = "none";
|
||||||
|
|
||||||
_DOMBodyElement.webkitTouchCallout = "none";
|
_DOMBodyElement.webkitTouchCallout = "none";
|
||||||
@@ -467,7 +469,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
[PlatformWindows addObject:self];
|
[PlatformWindows addObject:self];
|
||||||
|
|
||||||
// FIXME: cpSetFrame?
|
// FIXME: cpSetFrame?
|
||||||
_DOMWindow.document.write("<!DOCTYPE html><html lang='en'><head></head><body style='background-color:transparent;'></body></html>");
|
_DOMWindow.document.write("<html><head></head><body style = 'background-color:transparent;'></body></html>");
|
||||||
_DOMWindow.document.close();
|
_DOMWindow.document.close();
|
||||||
|
|
||||||
if (![CPPlatform isBrowser])
|
if (![CPPlatform isBrowser])
|
||||||
@@ -514,11 +516,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
DOMDragElement.style.left = -_CGRectGetWidth(draggedWindowFrame) + "px";
|
DOMDragElement.style.left = -_CGRectGetWidth(draggedWindowFrame) + "px";
|
||||||
DOMDragElement.style.top = -_CGRectGetHeight(draggedWindowFrame) + "px";
|
DOMDragElement.style.top = -_CGRectGetHeight(draggedWindowFrame) + "px";
|
||||||
|
|
||||||
var parentNode = DOMDragElement.parentNode;
|
|
||||||
|
|
||||||
if (parentNode)
|
|
||||||
parentNode.removeChild(DOMDragElement);
|
|
||||||
|
|
||||||
_DOMBodyElement.appendChild(DOMDragElement);
|
_DOMBodyElement.appendChild(DOMDragElement);
|
||||||
|
|
||||||
var draggingOffset = [dragServer draggingOffset];
|
var draggingOffset = [dragServer draggingOffset];
|
||||||
@@ -851,13 +848,12 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
if(!aDOMEvent)
|
if(!aDOMEvent)
|
||||||
aDOMEvent = window.event;
|
aDOMEvent = window.event;
|
||||||
|
|
||||||
var location = nil;
|
|
||||||
if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15))
|
if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15))
|
||||||
{
|
{
|
||||||
var x = aDOMEvent._offsetX || 0.0,
|
var x = 0.0,
|
||||||
y = aDOMEvent._offsetY || 0.0,
|
y = 0.0,
|
||||||
element = aDOMEvent.target;
|
element = aDOMEvent.target;
|
||||||
|
|
||||||
while (element.nodeType !== 1)
|
while (element.nodeType !== 1)
|
||||||
element = element.parentNode;
|
element = element.parentNode;
|
||||||
|
|
||||||
@@ -871,13 +867,11 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
} while (element = element.offsetParent);
|
} while (element = element.offsetParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15)));
|
var location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15)));
|
||||||
}
|
}
|
||||||
else if (aDOMEvent._overrideLocation)
|
|
||||||
location = aDOMEvent._overrideLocation;
|
|
||||||
else
|
else
|
||||||
location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);
|
var location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);
|
||||||
|
|
||||||
var deltaX = 0.0,
|
var deltaX = 0.0,
|
||||||
deltaY = 0.0,
|
deltaY = 0.0,
|
||||||
windowNumber = 0,
|
windowNumber = 0,
|
||||||
@@ -886,7 +880,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
(aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
|
(aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
|
||||||
(aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
|
(aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
|
||||||
(aDOMEvent.metaKey ? CPCommandKeyMask : 0);
|
(aDOMEvent.metaKey ? CPCommandKeyMask : 0);
|
||||||
|
|
||||||
StopDOMEventPropagation = YES;
|
StopDOMEventPropagation = YES;
|
||||||
|
|
||||||
var theWindow = [self hitTest:location];
|
var theWindow = [self hitTest:location];
|
||||||
@@ -1195,7 +1189,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
|||||||
|
|
||||||
[_windowLevels insertObject:aLevel atIndex:insertionIndex];
|
[_windowLevels insertObject:aLevel atIndex:insertionIndex];
|
||||||
layer._DOMElement.style.zIndex = aLevel;
|
layer._DOMElement.style.zIndex = aLevel;
|
||||||
|
|
||||||
_DOMBodyElement.appendChild(layer._DOMElement);
|
_DOMBodyElement.appendChild(layer._DOMElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Test custom cursors with .cur images.</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(disappearingItemCursor.cur), default">disappearingItemCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(closedHandCursor.cur), default">closedHandCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(contextMenuCursor.cur), default">contextMenuCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(dragCopyCursor.cur), default">dragCopyCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(dragLinkCursor.cur), default">dragLinkCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(openHandCursor.cur), default">openHandCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeDownCursor.cur), default">resizeDownCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeLeftCursor.cur), default">resizeLeftCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeRightCursor.cur), default">resizeRightCursor</div>
|
||||||
|
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeUpCursor.cur), default">resizeUpCursor</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 506 B |
@@ -439,7 +439,7 @@
|
|||||||
isVertical:NO]);
|
isVertical:NO]);
|
||||||
|
|
||||||
[button setValue:CPLeftTextAlignment forThemeAttribute:@"alignment" inState:CPThemeStateBordered];
|
[button setValue:CPLeftTextAlignment forThemeAttribute:@"alignment" inState:CPThemeStateBordered];
|
||||||
[button setValue:[CPFont systemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBordered];
|
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBordered];
|
||||||
[button setValue:CGInsetMake(0.0, 0.0, 0.0, 20.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
|
[button setValue:CGInsetMake(0.0, 0.0, 0.0, 20.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
|
||||||
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
||||||
[button setValue:bezelColorSelected forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateSelected];
|
[button setValue:bezelColorSelected forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateSelected];
|
||||||
@@ -493,7 +493,7 @@
|
|||||||
isVertical:NO]);
|
isVertical:NO]);
|
||||||
|
|
||||||
[button setValue:CPLeftTextAlignment forThemeAttribute:@"alignment" inState:CPThemeStateBordered];
|
[button setValue:CPLeftTextAlignment forThemeAttribute:@"alignment" inState:CPThemeStateBordered];
|
||||||
[button setValue:[CPFont systemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBordered];
|
[button setValue:[CPFont boldSystemFontOfSize:12.0] forThemeAttribute:@"font" inState:CPThemeStateBordered];
|
||||||
[button setValue:CGInsetMake(0.0, 0.0, 0.0, 20.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
|
[button setValue:CGInsetMake(0.0, 0.0, 0.0, 20.0) forThemeAttribute:@"content-inset" inState:CPThemeStateBordered];
|
||||||
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
[button setValue:bezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
||||||
[button setValue:bezelColorSelected forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateSelected];
|
[button setValue:bezelColorSelected forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateSelected];
|
||||||
@@ -721,7 +721,7 @@
|
|||||||
|
|
||||||
+ (CPButtonBar)themedButtonBar
|
+ (CPButtonBar)themedButtonBar
|
||||||
{
|
{
|
||||||
var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 147.0, 26.0)],
|
var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 140.0, 26.0)],
|
||||||
color = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 26.0)]];
|
color = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 26.0)]];
|
||||||
|
|
||||||
[buttonBar setHasResizeControl:YES];
|
[buttonBar setHasResizeControl:YES];
|
||||||
@@ -761,13 +761,8 @@
|
|||||||
[buttonBar setValue:buttonBezelColor forThemeAttribute:@"button-bezel-color"];
|
[buttonBar setValue:buttonBezelColor forThemeAttribute:@"button-bezel-color"];
|
||||||
[buttonBar setValue:buttonBezelHighlightedColor forThemeAttribute:@"button-bezel-color" inState:CPThemeStateHighlighted];
|
[buttonBar setValue:buttonBezelHighlightedColor forThemeAttribute:@"button-bezel-color" inState:CPThemeStateHighlighted];
|
||||||
[buttonBar setValue:buttonBezelDisabledColor forThemeAttribute:@"button-bezel-color" inState:CPThemeStateDisabled];
|
[buttonBar setValue:buttonBezelDisabledColor forThemeAttribute:@"button-bezel-color" inState:CPThemeStateDisabled];
|
||||||
[buttonBar setValue:[CPColor blackColor] forThemeAttribute:@"button-text-color"];
|
|
||||||
|
|
||||||
var popup = [CPButtonBar actionPopupButton];
|
[buttonBar setButtons:[[CPButtonBar plusButton], [CPButtonBar minusButton], [self themedPullDownMenu]]];
|
||||||
[popup addItemWithTitle:"Item 1"];
|
|
||||||
[popup addItemWithTitle:"Item 2"];
|
|
||||||
|
|
||||||
[buttonBar setButtons:[[CPButtonBar plusButton], [CPButtonBar minusButton], popup]];
|
|
||||||
|
|
||||||
return buttonBar;
|
return buttonBar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ var HORIZONTAL_MARGIN = 3.0,
|
|||||||
|
|
||||||
CPCellImagePosition _imagePosition;
|
CPCellImagePosition _imagePosition;
|
||||||
CPImageScaling _imageScaling;
|
CPImageScaling _imageScaling;
|
||||||
BOOL _shouldDimImage;
|
|
||||||
|
|
||||||
CPImage _image;
|
CPImage _image;
|
||||||
CPString _text;
|
CPString _text;
|
||||||
@@ -212,17 +211,6 @@ var HORIZONTAL_MARGIN = 3.0,
|
|||||||
return _imageScaling;
|
return _imageScaling;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDimsImage:(BOOL)shouldDim
|
|
||||||
{
|
|
||||||
var shouldDimImage = !!shouldDimImage;
|
|
||||||
|
|
||||||
if (_shouldDimImage !== shouldDimImage)
|
|
||||||
{
|
|
||||||
_shouldDimImage = shouldDim;
|
|
||||||
[self setNeedsLayout];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setTextColor:(CPColor)aTextColor
|
- (void)setTextColor:(CPColor)aTextColor
|
||||||
{
|
{
|
||||||
if (_textColor === aTextColor)
|
if (_textColor === aTextColor)
|
||||||
@@ -584,11 +572,6 @@ var HORIZONTAL_MARGIN = 3.0,
|
|||||||
imageHeight *= scale;
|
imageHeight *= scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CPFeatureIsCompatible(CPOpacityRequiresFilterFeature))
|
|
||||||
imageStyle.filter = @"alpha(opacity=" + _shouldDimImage ? 35 : 100 + ")";
|
|
||||||
else
|
|
||||||
imageStyle.opacity = _shouldDimImage ? 0.35 : 1.0;
|
|
||||||
|
|
||||||
_DOMImageElement.width = imageWidth;
|
_DOMImageElement.width = imageWidth;
|
||||||
_DOMImageElement.height = imageHeight;
|
_DOMImageElement.height = imageHeight;
|
||||||
imageStyle.width = MAX(imageWidth, 0) + "px";
|
imageStyle.width = MAX(imageWidth, 0) + "px";
|
||||||
|
|||||||
+9
-47
@@ -10,8 +10,6 @@ var FILE = require("file");
|
|||||||
var OS = require("os");
|
var OS = require("os");
|
||||||
var UTIL = require("util");
|
var UTIL = require("util");
|
||||||
|
|
||||||
var CACHEMANIFEST = require("objective-j/cache-manifest");
|
|
||||||
|
|
||||||
var stream = require("term").stream;
|
var stream = require("term").stream;
|
||||||
var parser = new (require("args").Parser)();
|
var parser = new (require("args").Parser)();
|
||||||
|
|
||||||
@@ -46,15 +44,6 @@ parser.option("-s", "--split", "number", "split")
|
|||||||
.def(0)
|
.def(0)
|
||||||
.help("Split into multiple files");
|
.help("Split into multiple files");
|
||||||
|
|
||||||
parser.option("-c", "--compressor", "compressor")
|
|
||||||
.def("shrinksafe")
|
|
||||||
.set()
|
|
||||||
.help("Select a compressor to use (closure-compiler, yuicompressor, shrinksafe), or \"none\" (default: shrinksafe)");
|
|
||||||
|
|
||||||
parser.option("--manifest", "manifest")
|
|
||||||
.set(true)
|
|
||||||
.help("Generate HTML5 cache manifest.");
|
|
||||||
|
|
||||||
parser.option("-v", "--verbose", "verbose")
|
parser.option("-v", "--verbose", "verbose")
|
||||||
.def(false)
|
.def(false)
|
||||||
.set(true)
|
.set(true)
|
||||||
@@ -121,24 +110,10 @@ function main(args)
|
|||||||
FILE.copyTree(rootPath, outputPath);
|
FILE.copyTree(rootPath, outputPath);
|
||||||
|
|
||||||
applicationJSs.forEach(function(applicationJS, n) {
|
applicationJSs.forEach(function(applicationJS, n) {
|
||||||
var name = "Application"+(n||"")+".js";
|
outputPath.join("Application"+(n||"")+".js").write(applicationJS);
|
||||||
if (options.compressor === "none") {
|
|
||||||
print("skipping compression: " + name);
|
|
||||||
} else {
|
|
||||||
print("compressing: " + name);
|
|
||||||
applicationJS = require("minify/"+options.compressor).compress(applicationJS, { charset : "UTF-8", useServer : true });
|
|
||||||
}
|
|
||||||
outputPath.join(name).write(applicationJS, { charset : "UTF-8" });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rewriteMainHTML(outputPath.join(options.index));
|
rewriteMainHTML(outputPath.join(options.index));
|
||||||
|
|
||||||
if (options.manifest) {
|
|
||||||
CACHEMANIFEST.generateManifest(outputPath, {
|
|
||||||
index : outputPath.join(options.index),
|
|
||||||
exclude : Object.keys(flattener.filesToCache).map(function(path) { return outputPath.join(path).toString(); })
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectiveJFlattener inherits from ObjectiveJRuntimeAnalyzer
|
// ObjectiveJFlattener inherits from ObjectiveJRuntimeAnalyzer
|
||||||
@@ -158,14 +133,11 @@ ObjectiveJFlattener.prototype.buildApplicationJS = function() {
|
|||||||
this.serializeFunctions();
|
this.serializeFunctions();
|
||||||
this.serializeFileCache();
|
this.serializeFileCache();
|
||||||
|
|
||||||
var additions = FILE.read(FILE.join(FILE.dirname(module.path), "..", "..", "cappuccino", "lib", "cappuccino", "objj-flatten-additions.js"), { charset:"UTF-8" });
|
|
||||||
|
|
||||||
var applicationJSs = [];
|
var applicationJSs = [];
|
||||||
|
|
||||||
if (this.options.split === 0) {
|
if (this.options.split === 0) {
|
||||||
var buffer = [];
|
var buffer = [];
|
||||||
buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
|
buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
|
||||||
buffer.push(additions);
|
|
||||||
buffer.push(this.fileCacheBuffer.join("\n"));
|
buffer.push(this.fileCacheBuffer.join("\n"));
|
||||||
buffer.push(this.functionsBuffer.join("\n"));
|
buffer.push(this.functionsBuffer.join("\n"));
|
||||||
buffer.push("ObjectiveJ.bootstrap();");
|
buffer.push("ObjectiveJ.bootstrap();");
|
||||||
@@ -188,13 +160,11 @@ ObjectiveJFlattener.prototype.buildApplicationJS = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffers[0].push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
|
buffers[0].push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
|
||||||
buffers[0].push(additions);
|
|
||||||
|
|
||||||
buffers[0].push("var appFilesCount = " + appFilesCount +";");
|
buffers[0].push("var appFilesCount = " + appFilesCount +";");
|
||||||
buffers[0].push("for (var i = 1; i <= appFilesCount; i++) {");
|
buffers[0].push("for (var i = 1; i <= appFilesCount; i++) {");
|
||||||
buffers[0].push(" var script = document.createElement(\"script\");");
|
buffers[0].push(" var script = document.createElement(\"script\");");
|
||||||
buffers[0].push(" script.src = \"Application\"+i+\".js\";");
|
buffers[0].push(" script.src = \"Application\"+i+\".js\";");
|
||||||
buffers[0].push(" script.charset = \"UTF-8\";");
|
|
||||||
buffers[0].push(" script.onload = function() { if (--appFilesCount === 0) ObjectiveJ.bootstrap(); };");
|
buffers[0].push(" script.onload = function() { if (--appFilesCount === 0) ObjectiveJ.bootstrap(); };");
|
||||||
buffers[0].push(" document.getElementsByTagName(\"head\")[0].appendChild(script);");
|
buffers[0].push(" document.getElementsByTagName(\"head\")[0].appendChild(script);");
|
||||||
buffers[0].push("}");
|
buffers[0].push("}");
|
||||||
@@ -267,6 +237,7 @@ ObjectiveJFlattener.prototype.serializeFunctions = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjectiveJFlattener.prototype.serializeFileCache = function() {
|
ObjectiveJFlattener.prototype.serializeFileCache = function() {
|
||||||
|
this.fileCacheBuffer.push(FILE.read(FILE.join(FILE.dirname(module.path), "..", "..", "cappuccino", "lib", "cappuccino", "objj-flatten-additions.js"), { charset:"UTF-8" }));
|
||||||
for (var relative in this.filesToCache) {
|
for (var relative in this.filesToCache) {
|
||||||
var contents = this.filesToCache[relative];
|
var contents = this.filesToCache[relative];
|
||||||
print("caching: " + relative + " => " + (contents == null ? 404 : 200));
|
print("caching: " + relative + " => " + (contents == null ? 404 : 200));
|
||||||
@@ -311,30 +282,21 @@ ObjectiveJFlattener.prototype.setupFileCache = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "$1" is the matching indentation
|
// "$1" is the matching indentation
|
||||||
var scriptTagsBefore =
|
var scriptTagsBefore = '$1<script type = "text/javascript">\n$1 OBJJ_AUTO_BOOTSTRAP = false;\n$1</script>';
|
||||||
'$1<script type = "text/javascript">\n'+
|
var scriptTagsAfter = '$1<script type = "text/javascript" src = "Application.js"></script>';
|
||||||
'$1 OBJJ_AUTO_BOOTSTRAP = false;\n'+
|
|
||||||
'$1</script>';
|
|
||||||
|
|
||||||
var scriptTagsAfter =
|
|
||||||
'$1<script type="text/javascript" src="Application.js" charset="UTF-8"></script>';
|
|
||||||
|
|
||||||
// enable CPLog:
|
// enable CPLog:
|
||||||
// scriptTagsAfter = '$1<script type="text/javascript">\n$1 CPLogRegister(CPLogConsole);\n$1</script>\n' + scriptTagsAfter;
|
// scriptTagsAfter = '$1<script type = "text/javascript">\n$1 CPLogRegister(CPLogConsole);\n$1</script>\n' + scriptTagsAfter;
|
||||||
|
|
||||||
function rewriteMainHTML(indexHTMLPath) {
|
function rewriteMainHTML(indexHTMLPath) {
|
||||||
if (indexHTMLPath.isFile()) {
|
if (indexHTMLPath.isFile()) {
|
||||||
var indexHTML = indexHTMLPath.read({ charset : "UTF-8" });
|
var indexHTML = indexHTMLPath.read();
|
||||||
|
|
||||||
// inline the Application.js if it's smallish
|
// inline the Application.js if it's smallish
|
||||||
var applicationJSPath = indexHTMLPath.dirname().join("Application.js");
|
var applicationJSPath = indexHTMLPath.dirname().join("Application.js");
|
||||||
if (applicationJSPath.size() < 10*1024) {
|
if (applicationJSPath.size() < 10*1024) {
|
||||||
// escape any dollar signs by replacing them with two
|
var applicationJS = applicationJSPath.read().split("\n").join("\n$1 ");
|
||||||
// then indent by splitting/joining on newlines
|
scriptTagsAfter = '$1<script type = "text/javascript">\n$1 '+applicationJS+'\n$1</script>'
|
||||||
scriptTagsAfter =
|
|
||||||
'$1<script type="text/javascript">\n'+
|
|
||||||
'$1 ' + applicationJSPath.read({ charset : "UTF-8" }).replace(/\$/g, "$$$$").split("\n").join("\n$1 ")+'\n'+
|
|
||||||
'$1</script>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to find Objective-J script tag and add ours
|
// attempt to find Objective-J script tag and add ours
|
||||||
@@ -343,7 +305,7 @@ function rewriteMainHTML(indexHTMLPath) {
|
|||||||
|
|
||||||
if (newIndexHTML !== indexHTML) {
|
if (newIndexHTML !== indexHTML) {
|
||||||
stream.print("\0green(Modified: "+indexHTMLPath+".\0)");
|
stream.print("\0green(Modified: "+indexHTMLPath+".\0)");
|
||||||
indexHTMLPath.write(newIndexHTML, { charset : "UTF-8" });
|
indexHTMLPath.write(newIndexHTML);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ require("narwhal").ensureEngine("rhino");
|
|||||||
var FILE = require("file");
|
var FILE = require("file");
|
||||||
var OS = require("os");
|
var OS = require("os");
|
||||||
|
|
||||||
var CACHEMANIFEST = require("objective-j/cache-manifest");
|
|
||||||
|
|
||||||
var stream = require("term").stream;
|
var stream = require("term").stream;
|
||||||
var parser = new (require("args").Parser)();
|
var parser = new (require("args").Parser)();
|
||||||
|
|
||||||
@@ -33,20 +31,11 @@ parser.option("-f", "--force", "force")
|
|||||||
.set(true)
|
.set(true)
|
||||||
.help("Force overwriting OUTPUT_PROJECT if it exists");
|
.help("Force overwriting OUTPUT_PROJECT if it exists");
|
||||||
|
|
||||||
parser.option("--index", "index")
|
|
||||||
.def("index.html")
|
|
||||||
.set()
|
|
||||||
.help("The root HTML file to modify (default: index.html) (NOTE: currently only used by '--manifest' option)");
|
|
||||||
|
|
||||||
parser.option("-p", "--pngcrush", "png")
|
parser.option("-p", "--pngcrush", "png")
|
||||||
.def(false)
|
.def(false)
|
||||||
.set(true)
|
.set(true)
|
||||||
.help("Run pngcrush on all PNGs (pngcrush must be installed!)");
|
.help("Run pngcrush on all PNGs (pngcrush must be installed!)");
|
||||||
|
|
||||||
parser.option("--manifest", "manifest")
|
|
||||||
.set(true)
|
|
||||||
.help("Generate HTML5 cache manifest.");
|
|
||||||
|
|
||||||
parser.option("-v", "--verbose", "verbose")
|
parser.option("-v", "--verbose", "verbose")
|
||||||
.def(false)
|
.def(false)
|
||||||
.set(true)
|
.set(true)
|
||||||
@@ -157,12 +146,6 @@ function press(rootPath, outputPath, options) {
|
|||||||
if (options.png) {
|
if (options.png) {
|
||||||
pngcrushDirectory(outputPath);
|
pngcrushDirectory(outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.manifest) {
|
|
||||||
CACHEMANIFEST.generateManifest(outputPath, {
|
|
||||||
index : outputPath.join(options.index)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pressEnvironment(rootPath, outputFiles, environment, options) {
|
function pressEnvironment(rootPath, outputFiles, environment, options) {
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
var FILE = require("file");
|
|
||||||
var OS = require("os");
|
|
||||||
|
|
||||||
var NATIVEHOST_SOURCE = FILE.path(module.path).dirname().dirname().dirname().join("support", "NativeHost.app");
|
|
||||||
|
|
||||||
exports.buildNativeHost = function(rootPath, buildNative, options) {
|
|
||||||
options = options || {};
|
|
||||||
options.index = options.index || "index.html";
|
|
||||||
|
|
||||||
rootPath = FILE.path(rootPath);
|
|
||||||
buildNative = FILE.path(buildNative);
|
|
||||||
|
|
||||||
if (buildNative.exists())
|
|
||||||
buildNative.rmtree();
|
|
||||||
|
|
||||||
buildNative.dirname().mkdirs();
|
|
||||||
// FIXME: Narwhal doesn't preserve permissions
|
|
||||||
// FILE.copyTree(NATIVEHOST_SOURCE, buildNative);
|
|
||||||
OS.system(["cp", "-r", NATIVEHOST_SOURCE, buildNative]);
|
|
||||||
FILE.chmod(buildNative.join("Contents", "MacOS", "NativeHost"), 0755);
|
|
||||||
|
|
||||||
var rootBaseName = rootPath.basename();
|
|
||||||
var buildClientDirectory = buildNative.join("Contents", "Resources", rootBaseName);
|
|
||||||
|
|
||||||
FILE.mkdirs(FILE.dirname(buildClientDirectory));
|
|
||||||
// FILE.copyTree(rootPath, buildClientDirectory);
|
|
||||||
OS.system(["cp", "-r", rootPath, buildClientDirectory]);
|
|
||||||
|
|
||||||
var defaultBundleName = buildNative.basename().match(/^(.*)(\.app)?$/)[1];
|
|
||||||
|
|
||||||
function mergePlist(plist, path) {
|
|
||||||
var otherPlist = CFPropertyList.readPropertyListFromFile(String(path));
|
|
||||||
|
|
||||||
otherPlist.keys().forEach(function(key) {
|
|
||||||
var value = otherPlist.valueForKey(key);
|
|
||||||
plist.setValueForKey(key, value);
|
|
||||||
|
|
||||||
if (key === "CPBundleName")
|
|
||||||
plist.setValueForKey("CFBundleName", value);
|
|
||||||
|
|
||||||
if (key === "CFBundleIconFile") {
|
|
||||||
var iconPath = rootPath.join("Resources", value);
|
|
||||||
if (iconPath.isFile())
|
|
||||||
iconPath.copy(buildNative.join("Contents", "Resources", value));
|
|
||||||
else
|
|
||||||
print("Warning: CFBundleIconFile references " + value + " but does not exist in the resources directory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key === "CFBundleExecutable") {
|
|
||||||
buildNative.join("Contents", "MacOS", "NativeHost").rename(value);
|
|
||||||
// FIXME:
|
|
||||||
FILE.chmod(buildNative.join("Contents", "MacOS", value), 0755);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
CFPropertyList.modifyPlist(buildNative.join("Contents", "Info.plist"), function(plist) {
|
|
||||||
|
|
||||||
plist.setValueForKey("CFBundleName", defaultBundleName);
|
|
||||||
plist.setValueForKey("NHInitialResource", FILE.join(rootBaseName, options.index));
|
|
||||||
|
|
||||||
// merge Cappuccino plist
|
|
||||||
var cappPlistPath = rootPath.join("Info.plist");
|
|
||||||
if (cappPlistPath.isFile())
|
|
||||||
mergePlist(plist, cappPlistPath);
|
|
||||||
|
|
||||||
if (options.extraPlistPath)
|
|
||||||
mergePlist(plist, options.extraPlistPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -31,11 +31,6 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
|
|||||||
return url ? url.absoluteURL().path() : null;
|
return url ? url.absoluteURL().path() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.require("cappuccino/objj-flatten-additions");
|
|
||||||
|
|
||||||
if (!this.context.global.CFHTTPRequest._lookupCachedRequest)
|
|
||||||
print("Warning: CFHTTPRequest._lookupCachedRequest. Need to import objj-flatten-additions module.");
|
|
||||||
|
|
||||||
var requestedURLs = this.requestedURLs = {};
|
var requestedURLs = this.requestedURLs = {};
|
||||||
var _lookupCachedRequest = this.context.global.CFHTTPRequest._lookupCachedRequest;
|
var _lookupCachedRequest = this.context.global.CFHTTPRequest._lookupCachedRequest;
|
||||||
this.context.global.CFHTTPRequest._lookupCachedRequest = function(aURL) {
|
this.context.global.CFHTTPRequest._lookupCachedRequest = function(aURL) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
var URLCache = { };
|
var URLCache = { };
|
||||||
|
|
||||||
var CFHTTPRequest_open = CFHTTPRequest.prototype.open;
|
|
||||||
CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password)
|
CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password)
|
||||||
{
|
{
|
||||||
var cachedRequest = CFHTTPRequest._lookupCachedRequest(url);
|
var cachedRequest = CFHTTPRequest._lookupCachedRequest(url);
|
||||||
@@ -14,7 +13,7 @@ CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boo
|
|||||||
ObjectiveJ.determineAndDispatchHTTPRequestEvents(self);
|
ObjectiveJ.determineAndDispatchHTTPRequestEvents(self);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return CFHTTPRequest_open.apply(this, arguments);
|
return this._nativeRequest.open(method, url, async, user, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body)
|
CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body)
|
||||||
|
|||||||
+161
-177
@@ -37,7 +37,7 @@
|
|||||||
- (id)initWithArray:(CPArray)anArray
|
- (id)initWithArray:(CPArray)anArray
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
_array = anArray;
|
_array = anArray;
|
||||||
@@ -67,13 +67,13 @@
|
|||||||
- (id)initWithArray:(CPArray)anArray
|
- (id)initWithArray:(CPArray)anArray
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
_array = anArray;
|
_array = anArray;
|
||||||
_index = [_array count];
|
_index = [_array count];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@class CPArray
|
@class CPArray
|
||||||
@brief A mutable array backed by a JavaScript Array.
|
@brief A mutable array backed by a JavaScript Array.
|
||||||
@ingroup foundation
|
@ingroup foundation
|
||||||
@@ -105,7 +105,11 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)alloc
|
+ (id)alloc
|
||||||
{
|
{
|
||||||
return [];
|
var a = [];
|
||||||
|
a._retainCount = 1;
|
||||||
|
a._UID = objj_generateObjectUID();
|
||||||
|
OBJJ_MEMORY_TABLE[a._UID] = a;
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -113,7 +117,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)array
|
+ (id)array
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -123,7 +127,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)arrayWithArray:(CPArray)anArray
|
+ (id)arrayWithArray:(CPArray)anArray
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithArray:anArray];
|
return [[[self alloc] initWithArray:anArray] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -133,7 +137,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)arrayWithObject:(id)anObject
|
+ (id)arrayWithObject:(id)anObject
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithObjects:anObject];
|
return [[[self alloc] initWithObjects:anObject] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -145,12 +149,12 @@
|
|||||||
{
|
{
|
||||||
var i = 2,
|
var i = 2,
|
||||||
array = [[self alloc] init],
|
array = [[self alloc] init],
|
||||||
count = arguments.length;
|
argument;
|
||||||
|
|
||||||
for (; i < count; ++i)
|
for(; i < arguments.length && (argument = arguments[i]) != nil; ++i)
|
||||||
array.push(arguments[i]);
|
array.push(argument);
|
||||||
|
|
||||||
return array;
|
return [array autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -161,7 +165,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)arrayWithObjects:(id)objects count:(unsigned)aCount
|
+ (id)arrayWithObjects:(id)objects count:(unsigned)aCount
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithObjects:objects count:aCount];
|
return [[[self alloc] initWithObjects:objects count:aCount] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -182,10 +186,10 @@
|
|||||||
- (id)initWithArray:(CPArray)anArray
|
- (id)initWithArray:(CPArray)anArray
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
[self setArray:anArray];
|
[self setArray:anArray];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,22 +207,22 @@
|
|||||||
return [self initWithArray:anArray];
|
return [self initWithArray:anArray];
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = [anArray count];
|
count = [anArray count];
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
{
|
{
|
||||||
if (anArray[index].isa)
|
if (anArray[index].isa)
|
||||||
self[index] = [anArray[index] copy];
|
self[index] = [anArray[index] copy];
|
||||||
// Do a deep/shallow copy?
|
// Do a deep/shallow copy?
|
||||||
else
|
else
|
||||||
self[index] = anArray[index];
|
self[index] = anArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,12 +233,12 @@
|
|||||||
{
|
{
|
||||||
// The arguments array contains self and _cmd, so the first object is at position 2.
|
// The arguments array contains self and _cmd, so the first object is at position 2.
|
||||||
var i = 2,
|
var i = 2,
|
||||||
count = arguments.length;
|
argument;
|
||||||
|
|
||||||
|
for(; i < arguments.length && (argument = arguments[i]) != nil; ++i)
|
||||||
|
push(argument);
|
||||||
|
|
||||||
for (; i < count; ++i)
|
return self;
|
||||||
push(arguments[i]);
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -246,12 +250,12 @@
|
|||||||
- (id)initWithObjects:(id)objects count:(unsigned)aCount
|
- (id)initWithObjects:(id)objects count:(unsigned)aCount
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
|
||||||
for (; index < aCount; ++index)
|
for(; index < aCount; ++index)
|
||||||
push(objects[index]);
|
push(objects[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,88 +282,97 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in this array.
|
Returns the index of \c anObject in this array.
|
||||||
If the object is not in the array,
|
If the object is \c nil or not in the array,
|
||||||
returns \c CPNotFound. It first attempts to find
|
returns \c CPNotFound. It first attempts to find
|
||||||
a match using \c -isEqual:, then \c ===.
|
a match using \c -isEqual:, then \c ==.
|
||||||
@param anObject the object to search for
|
@param anObject the object to search for
|
||||||
*/
|
*/
|
||||||
- (int)indexOfObject:(id)anObject
|
- (int)indexOfObject:(id)anObject
|
||||||
{
|
{
|
||||||
var i = 0,
|
if (anObject === nil)
|
||||||
|
return CPNotFound;
|
||||||
|
|
||||||
|
var i = 0,
|
||||||
count = length;
|
count = length;
|
||||||
|
|
||||||
// Only use -isEqual: if our object is a CPObject.
|
// Only use -isEqual: if our object is a CPObject.
|
||||||
if (anObject && anObject.isa)
|
if (anObject.isa)
|
||||||
{
|
{
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
if ([self[i] isEqual:anObject])
|
if([self[i] isEqual:anObject])
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
// If indexOf exists, use it since it's probably
|
// If indexOf exists, use it since it's probably
|
||||||
// faster than anything we can implement.
|
// faster than anything we can implement.
|
||||||
else if (self.indexOf)
|
else if (self.indexOf)
|
||||||
return indexOf(anObject);
|
return indexOf(anObject);
|
||||||
// Last resort, do a straight forward linear O(N) search.
|
// Last resort, do a straight forward linear O(N) search.
|
||||||
else
|
else
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
if (self[i] === anObject)
|
if(self[i] == anObject)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
return CPNotFound;
|
return CPNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in the array
|
Returns the index of \c anObject in the array
|
||||||
within \c aRange. It first attempts to find
|
within \c aRange. It first attempts to find
|
||||||
a match using \c -isEqual:, then \c ===.
|
a match using \c -isEqual:, then \c ==.
|
||||||
@param anObject the object to search for
|
@param anObject the object to search for
|
||||||
@param aRange the range to search within
|
@param aRange the range to search within
|
||||||
@return the index of the object, or \c CPNotFound if it was not found.
|
@return the index of the object, or \c CPNotFound if it was not found.
|
||||||
*/
|
*/
|
||||||
- (int)indexOfObject:(id)anObject inRange:(CPRange)aRange
|
- (int)indexOfObject:(id)anObject inRange:(CPRange)aRange
|
||||||
{
|
{
|
||||||
var i = aRange.location,
|
if (anObject === nil)
|
||||||
|
return CPNotFound;
|
||||||
|
|
||||||
|
var i = aRange.location,
|
||||||
count = MIN(CPMaxRange(aRange), length);
|
count = MIN(CPMaxRange(aRange), length);
|
||||||
|
|
||||||
// Only use isEqual: if our object is a CPObject.
|
// Only use isEqual: if our object is a CPObject.
|
||||||
if (anObject && anObject.isa)
|
if (anObject.isa)
|
||||||
{
|
{
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
if ([self[i] isEqual:anObject])
|
if([self[i] isEqual:anObject])
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
// Last resort, do a straight forward linear O(N) search.
|
// Last resort, do a straight forward linear O(N) search.
|
||||||
else
|
else
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
if (self[i] === anObject)
|
if(self[i] == anObject)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
return CPNotFound;
|
return CPNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in the array. The test for equality is done using only \c ===.
|
Returns the index of \c anObject in the array. The test for equality is done using only \c ==.
|
||||||
@param anObject the object to search for
|
@param anObject the object to search for
|
||||||
@return the index of the object in the array. \c CPNotFound if the object is not in the array.
|
@return the index of the object in the array. \c CPNotFound if the object is not in the array.
|
||||||
*/
|
*/
|
||||||
- (int)indexOfObjectIdenticalTo:(id)anObject
|
- (int)indexOfObjectIdenticalTo:(id)anObject
|
||||||
{
|
{
|
||||||
// If indexOf exists, use it since it's probably
|
if (anObject === nil)
|
||||||
|
return CPNotFound;
|
||||||
|
|
||||||
|
// If indexOf exists, use it since it's probably
|
||||||
// faster than anything we can implement.
|
// faster than anything we can implement.
|
||||||
if (self.indexOf)
|
if (self.indexOf)
|
||||||
return indexOf(anObject);
|
return indexOf(anObject);
|
||||||
|
|
||||||
// Last resort, do a straight forward linear O(N) search.
|
// Last resort, do a straight forward linear O(N) search.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = length;
|
count = length;
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
if (self[index] === anObject)
|
if(self[index] === anObject)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CPNotFound;
|
return CPNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,33 +386,36 @@
|
|||||||
*/
|
*/
|
||||||
- (int)indexOfObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
|
- (int)indexOfObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
|
||||||
{
|
{
|
||||||
// If indexOf exists, use it since it's probably
|
if (anObject === nil)
|
||||||
|
return CPNotFound;
|
||||||
|
|
||||||
|
// If indexOf exists, use it since it's probably
|
||||||
// faster than anything we can implement.
|
// faster than anything we can implement.
|
||||||
if (self.indexOf)
|
if (self.indexOf)
|
||||||
{
|
{
|
||||||
var index = indexOf(anObject, aRange.location);
|
var index = indexOf(anObject, aRange.location);
|
||||||
|
|
||||||
if (CPLocationInRange(index, aRange))
|
if (CPLocationInRange(index, aRange))
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last resort, do a straight forward linear O(N) search.
|
// Last resort, do a straight forward linear O(N) search.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var index = aRange.location,
|
var index = aRange.location,
|
||||||
count = MIN(CPMaxRange(aRange), length);
|
count = MIN(CPMaxRange(aRange), length);
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
if (self[index] == anObject)
|
if(self[index] == anObject)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CPNotFound;
|
return CPNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
||||||
calling sortUsingSelector: with the selector passed to this method would result in.
|
calling sortUsingSelector: with the selector passed to this method would result in.
|
||||||
@param anObject the object to search for
|
@param anObject the object to search for
|
||||||
@param aSelector the comparison selector to call on each item in the list, the same
|
@param aSelector the comparison selector to call on each item in the list, the same
|
||||||
selector should have been used to sort the array (or to maintain its sorted order).
|
selector should have been used to sort the array (or to maintain its sorted order).
|
||||||
@@ -407,12 +423,12 @@
|
|||||||
*/
|
*/
|
||||||
- (unsigned)indexOfObject:(id)anObject sortedBySelector:(SEL)aSelector
|
- (unsigned)indexOfObject:(id)anObject sortedBySelector:(SEL)aSelector
|
||||||
{
|
{
|
||||||
return [self indexOfObject:anObject sortedByFunction:function(lhs, rhs) { objj_msgSend(lhs, aSelector, rhs); }];
|
return [self indexOfObject:anObject sortedByFunction: function(lhs, rhs) { objj_msgSend(lhs, aSelector, rhs); }];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
||||||
calling sortUsingFunction: with the selector passed to this method would result in.
|
calling sortUsingFunction: with the selector passed to this method would result in.
|
||||||
The function will be called like so:
|
The function will be called like so:
|
||||||
<pre>
|
<pre>
|
||||||
aFunction(anObject, currentObjectInArrayForComparison)
|
aFunction(anObject, currentObjectInArrayForComparison)
|
||||||
@@ -429,7 +445,7 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
||||||
calling sortUsingFunction: with the selector passed to this method would result in.
|
calling sortUsingFunction: with the selector passed to this method would result in.
|
||||||
The function will be called like so:
|
The function will be called like so:
|
||||||
<pre>
|
<pre>
|
||||||
aFunction(anObject, currentObjectInArrayForComparison, context)
|
aFunction(anObject, currentObjectInArrayForComparison, context)
|
||||||
@@ -442,23 +458,10 @@
|
|||||||
*/
|
*/
|
||||||
- (unsigned)indexOfObject:(id)anObject sortedByFunction:(Function)aFunction context:(id)aContext
|
- (unsigned)indexOfObject:(id)anObject sortedByFunction:(Function)aFunction context:(id)aContext
|
||||||
{
|
{
|
||||||
var result = [self _indexOfObject:anObject sortedByFunction:aFunction context:aContext];
|
if (!aFunction || anObject === undefined)
|
||||||
return result >= 0 ? result : CPNotFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (unsigned)_indexOfObject:(id)anObject sortedByFunction:(Function)aFunction context:(id)aContext
|
|
||||||
{
|
|
||||||
if (!aFunction)
|
|
||||||
return CPNotFound;
|
return CPNotFound;
|
||||||
|
|
||||||
if (length === 0)
|
var mid, c, first = 0, last = length - 1;
|
||||||
return -1;
|
|
||||||
|
|
||||||
var mid,
|
|
||||||
c,
|
|
||||||
first = 0,
|
|
||||||
last = length - 1;
|
|
||||||
|
|
||||||
while (first <= last)
|
while (first <= last)
|
||||||
{
|
{
|
||||||
mid = FLOOR((first + last) / 2);
|
mid = FLOOR((first + last) / 2);
|
||||||
@@ -477,12 +480,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -first - 1;
|
return CPNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
Returns the index of \c anObject in the array, which must be sorted in the same order as
|
||||||
calling sortUsingDescriptors: with the descriptors passed to this method would result in.
|
calling sortUsingDescriptors: with the descriptors passed to this method would result in.
|
||||||
@param anObject the object to search for
|
@param anObject the object to search for
|
||||||
@param descriptors the array of descriptors to use to compare each item in the array that we search. the same
|
@param descriptors the array of descriptors to use to compare each item in the array that we search. the same
|
||||||
descriptors should have been used to sort the array (or to maintain its sorted order).
|
descriptors should have been used to sort the array (or to maintain its sorted order).
|
||||||
@@ -497,7 +500,7 @@
|
|||||||
result = CPOrderedSame;
|
result = CPOrderedSame;
|
||||||
|
|
||||||
while (i < count)
|
while (i < count)
|
||||||
if ((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
|
if((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -510,10 +513,9 @@
|
|||||||
- (id)lastObject
|
- (id)lastObject
|
||||||
{
|
{
|
||||||
var count = [self count];
|
var count = [self count];
|
||||||
|
|
||||||
if (!count)
|
if (!count) return nil;
|
||||||
return nil;
|
|
||||||
|
|
||||||
return self[count - 1];
|
return self[count - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +541,7 @@
|
|||||||
var index = CPNotFound,
|
var index = CPNotFound,
|
||||||
objects = [];
|
objects = [];
|
||||||
|
|
||||||
while ((index = [indexes indexGreaterThanIndex:index]) !== CPNotFound)
|
while((index = [indexes indexGreaterThanIndex:index]) !== CPNotFound)
|
||||||
[objects addObject:[self objectAtIndex:index]];
|
[objects addObject:[self objectAtIndex:index]];
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
@@ -575,11 +577,11 @@
|
|||||||
{
|
{
|
||||||
if (!aSelector)
|
if (!aSelector)
|
||||||
[CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector: 'aSelector' can't be nil"];
|
[CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector: 'aSelector' can't be nil"];
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = length;
|
count = length;
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
objj_msgSend(self[index], aSelector);
|
objj_msgSend(self[index], aSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,10 +596,10 @@
|
|||||||
if (!aSelector)
|
if (!aSelector)
|
||||||
[CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector:withObject 'aSelector' can't be nil"];
|
[CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector:withObject 'aSelector' can't be nil"];
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = length;
|
count = length;
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
objj_msgSend(self[index], aSelector, anObject);
|
objj_msgSend(self[index], aSelector, anObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,7 +612,7 @@
|
|||||||
count = length,
|
count = length,
|
||||||
argumentsArray = [nil, aSelector].concat(objects || []);
|
argumentsArray = [nil, aSelector].concat(objects || []);
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
{
|
{
|
||||||
argumentsArray[0] = self[index];
|
argumentsArray[0] = self[index];
|
||||||
objj_msgSend.apply(this, argumentsArray);
|
objj_msgSend.apply(this, argumentsArray);
|
||||||
@@ -628,12 +630,12 @@
|
|||||||
{
|
{
|
||||||
if (![anArray count] || ![self count])
|
if (![anArray count] || ![self count])
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
var i = 0,
|
var i = 0,
|
||||||
count = [self count];
|
count = [self count];
|
||||||
|
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
if ([anArray containsObject:self[i]])
|
if([anArray containsObject:self[i]])
|
||||||
return self[i];
|
return self[i];
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
@@ -646,23 +648,23 @@
|
|||||||
{
|
{
|
||||||
if (self === anArray)
|
if (self === anArray)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
if (anArray === nil || length !== anArray.length)
|
if(length != anArray.length)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = [self count];
|
count = [self count];
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
{
|
{
|
||||||
var lhs = self[index],
|
var lhs = self[index],
|
||||||
rhs = anArray[index];
|
rhs = anArray[index];
|
||||||
|
|
||||||
// If they're not equal, and either doesn't have an isa, or they're !isEqual (not isEqual)
|
// If they're not equal, and either doesn't have an isa, or they're !isEqual (not isEqual)
|
||||||
if (lhs !== rhs && (lhs && !lhs.isa || rhs && !rhs.isa || ![lhs isEqual:rhs]))
|
if (lhs !== rhs && (lhs && !lhs.isa || rhs && !rhs.isa || ![lhs isEqual:rhs]))
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,8 +672,8 @@
|
|||||||
{
|
{
|
||||||
if (self === anObject)
|
if (self === anObject)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
if (![anObject isKindOfClass:[CPArray class]])
|
if(![anObject isKindOfClass:[CPArray class]])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
return [self isEqualToArray:anObject];
|
return [self isEqualToArray:anObject];
|
||||||
@@ -686,9 +688,14 @@
|
|||||||
*/
|
*/
|
||||||
- (CPArray)arrayByAddingObject:(id)anObject
|
- (CPArray)arrayByAddingObject:(id)anObject
|
||||||
{
|
{
|
||||||
var array = [self copy];
|
if (anObject === nil || anObject === undefined)
|
||||||
array.push(anObject);
|
[CPException raise:CPInvalidArgumentException
|
||||||
|
reason:"arrayByAddingObject: object can't be nil"];
|
||||||
|
|
||||||
|
var array = [self copy];
|
||||||
|
|
||||||
|
array.push(anObject);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,17 +708,17 @@
|
|||||||
return slice(0).concat(anArray);
|
return slice(0).concat(anArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- (CPArray)filteredArrayUsingPredicate:(CPPredicate)aPredicate
|
- (CPArray)filteredArrayUsingPredicate:(CPPredicate)aPredicate
|
||||||
{
|
{
|
||||||
var i= 0,
|
var i= 0,
|
||||||
count = [self count],
|
count = [self count],
|
||||||
array = [CPArray array];
|
array = [CPArray array];
|
||||||
|
|
||||||
for (; i<count; ++i)
|
for(; i<count; ++i)
|
||||||
if (aPredicate.evaluateWithObject(self[i]))
|
if(aPredicate.evaluateWithObject(self[i]))
|
||||||
array.push(self[i]);
|
array.push(self[i]);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -736,9 +743,9 @@
|
|||||||
- (CPArray)sortedArrayUsingDescriptors:(CPArray)descriptors
|
- (CPArray)sortedArrayUsingDescriptors:(CPArray)descriptors
|
||||||
{
|
{
|
||||||
var sorted = [self copy];
|
var sorted = [self copy];
|
||||||
|
|
||||||
[sorted sortUsingDescriptors:descriptors];
|
[sorted sortUsingDescriptors:descriptors];
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,9 +768,9 @@
|
|||||||
- (CPArray)sortedArrayUsingFunction:(Function)aFunction context:(id)aContext
|
- (CPArray)sortedArrayUsingFunction:(Function)aFunction context:(id)aContext
|
||||||
{
|
{
|
||||||
var sorted = [self copy];
|
var sorted = [self copy];
|
||||||
|
|
||||||
[sorted sortUsingFunction:aFunction context:aContext];
|
[sorted sortUsingFunction:aFunction context:aContext];
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -774,7 +781,7 @@
|
|||||||
- (CPArray)sortedArrayUsingSelector:(SEL)aSelector
|
- (CPArray)sortedArrayUsingSelector:(SEL)aSelector
|
||||||
{
|
{
|
||||||
var sorted = [self copy]
|
var sorted = [self copy]
|
||||||
|
|
||||||
[sorted sortUsingSelector:aSelector];
|
[sorted sortUsingSelector:aSelector];
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
@@ -808,7 +815,7 @@
|
|||||||
count = [self count],
|
count = [self count],
|
||||||
description = '(';
|
description = '(';
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
{
|
{
|
||||||
if (index === 0)
|
if (index === 0)
|
||||||
description += '\n';
|
description += '\n';
|
||||||
@@ -840,11 +847,11 @@
|
|||||||
var index = 0,
|
var index = 0,
|
||||||
count = [self count],
|
count = [self count],
|
||||||
array = [];
|
array = [];
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for(; index < count; ++index)
|
||||||
if (self[index].isa && [self[index] isKindOfClass:[CPString class]] && [filterTypes containsObject:[self[index] pathExtension]])
|
if (self[index].isa && [self[index] isKindOfClass:[CPString class]] && [filterTypes containsObject:[self[index] pathExtension]])
|
||||||
array.push(self[index]);
|
array.push(self[index]);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,8 +865,8 @@
|
|||||||
{
|
{
|
||||||
var i = 0,
|
var i = 0,
|
||||||
count = [self count];
|
count = [self count];
|
||||||
|
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
[self[i] setValue:aValue forKey:aKey];
|
[self[i] setValue:aValue forKey:aKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,10 +880,10 @@
|
|||||||
var i = 0,
|
var i = 0,
|
||||||
count = [self count],
|
count = [self count],
|
||||||
array = [];
|
array = [];
|
||||||
|
|
||||||
for (; i < count; ++i)
|
for(; i < count; ++i)
|
||||||
array.push([self[i] valueForKey:aKey]);
|
array.push([self[i] valueForKey:aKey]);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -890,7 +897,7 @@
|
|||||||
{
|
{
|
||||||
return slice(0);
|
return slice(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CPArray(CPMutableArray)
|
@implementation CPArray(CPMutableArray)
|
||||||
@@ -953,44 +960,22 @@
|
|||||||
{
|
{
|
||||||
var indexesCount = [indexes count],
|
var indexesCount = [indexes count],
|
||||||
objectsCount = [objects count];
|
objectsCount = [objects count];
|
||||||
|
|
||||||
if (indexesCount !== objectsCount)
|
if(indexesCount !== objectsCount)
|
||||||
[CPException raise:CPRangeException reason:"the counts of the passed-in array (" + objectsCount + ") and index set (" + indexesCount + ") must be identical."];
|
[CPException raise:CPRangeException reason:"the counts of the passed-in array (" + objectsCount + ") and index set (" + indexesCount + ") must be identical."];
|
||||||
|
|
||||||
var lastIndex = [indexes lastIndex];
|
var lastIndex = [indexes lastIndex];
|
||||||
|
|
||||||
if (lastIndex >= [self count] + indexesCount)
|
if(lastIndex >= [self count] + indexesCount)
|
||||||
[CPException raise:CPRangeException reason:"the last index (" + lastIndex + ") must be less than the sum of the original count (" + [self count] + ") and the insertion count (" + indexesCount + ")."];
|
[CPException raise:CPRangeException reason:"the last index (" + lastIndex + ") must be less than the sum of the original count (" + [self count] + ") and the insertion count (" + indexesCount + ")."];
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
currentIndex = [indexes firstIndex];
|
currentIndex = [indexes firstIndex];
|
||||||
|
|
||||||
for (; index < objectsCount; ++index, currentIndex = [indexes indexGreaterThanIndex:currentIndex])
|
for (; index < objectsCount; ++index, currentIndex = [indexes indexGreaterThanIndex:currentIndex])
|
||||||
[self insertObject:objects[index] atIndex:currentIndex];
|
[self insertObject:objects[index] atIndex:currentIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned)insertObject:(id)anObject inArraySortedByDescriptors:(CPArray)descriptors
|
|
||||||
{
|
|
||||||
var index = [self _indexOfObject:anObject sortedByFunction:function(lhs, rhs)
|
|
||||||
{
|
|
||||||
var i = 0,
|
|
||||||
count = [descriptors count],
|
|
||||||
result = CPOrderedSame;
|
|
||||||
|
|
||||||
while (i < count)
|
|
||||||
if ((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
} context:nil];
|
|
||||||
|
|
||||||
if (index < 0)
|
|
||||||
index = -index - 1;
|
|
||||||
|
|
||||||
[self insertObject:anObject atIndex:index];
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Replaces the element at \c anIndex with \c anObject.
|
Replaces the element at \c anIndex with \c anObject.
|
||||||
The current element at position \c anIndex will be removed from the array.
|
The current element at position \c anIndex will be removed from the array.
|
||||||
@@ -1009,10 +994,10 @@
|
|||||||
*/
|
*/
|
||||||
- (void)replaceObjectsAtIndexes:(CPIndexSet)anIndexSet withObjects:(CPArray)objects
|
- (void)replaceObjectsAtIndexes:(CPIndexSet)anIndexSet withObjects:(CPArray)objects
|
||||||
{
|
{
|
||||||
var i = 0,
|
var i = 0,
|
||||||
index = [anIndexSet firstIndex];
|
index = [anIndexSet firstIndex];
|
||||||
|
|
||||||
while (index != CPNotFound)
|
while(index != CPNotFound)
|
||||||
{
|
{
|
||||||
[self replaceObjectAtIndex:index withObject:objects[i++]];
|
[self replaceObjectAtIndex:index withObject:objects[i++]];
|
||||||
index = [anIndexSet indexGreaterThanIndex:index];
|
index = [anIndexSet indexGreaterThanIndex:index];
|
||||||
@@ -1053,9 +1038,8 @@
|
|||||||
*/
|
*/
|
||||||
- (void)setArray:(CPArray)anArray
|
- (void)setArray:(CPArray)anArray
|
||||||
{
|
{
|
||||||
if (self == anArray)
|
if(self == anArray) return;
|
||||||
return;
|
|
||||||
|
|
||||||
splice.apply(self, [0, length].concat(anArray));
|
splice.apply(self, [0, length].concat(anArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1093,7 +1077,7 @@
|
|||||||
- (void)removeObject:(id)anObject inRange:(CPRange)aRange
|
- (void)removeObject:(id)anObject inRange:(CPRange)aRange
|
||||||
{
|
{
|
||||||
var index;
|
var index;
|
||||||
|
|
||||||
while ((index = [self indexOfObject:anObject inRange:aRange]) != CPNotFound)
|
while ((index = [self indexOfObject:anObject inRange:aRange]) != CPNotFound)
|
||||||
{
|
{
|
||||||
[self removeObjectAtIndex:index];
|
[self removeObjectAtIndex:index];
|
||||||
@@ -1117,7 +1101,7 @@
|
|||||||
- (void)removeObjectsAtIndexes:(CPIndexSet)anIndexSet
|
- (void)removeObjectsAtIndexes:(CPIndexSet)anIndexSet
|
||||||
{
|
{
|
||||||
var index = [anIndexSet lastIndex];
|
var index = [anIndexSet lastIndex];
|
||||||
|
|
||||||
while (index != CPNotFound)
|
while (index != CPNotFound)
|
||||||
{
|
{
|
||||||
[self removeObjectAtIndex:index];
|
[self removeObjectAtIndex:index];
|
||||||
@@ -1146,7 +1130,7 @@
|
|||||||
{
|
{
|
||||||
var index,
|
var index,
|
||||||
count = [self count];
|
count = [self count];
|
||||||
|
|
||||||
while ((index = [self indexOfObjectIdenticalTo:anObject inRange:aRange]) !== CPNotFound)
|
while ((index = [self indexOfObjectIdenticalTo:anObject inRange:aRange]) !== CPNotFound)
|
||||||
{
|
{
|
||||||
[self removeObjectAtIndex:index];
|
[self removeObjectAtIndex:index];
|
||||||
@@ -1162,7 +1146,7 @@
|
|||||||
{
|
{
|
||||||
var index = 0,
|
var index = 0,
|
||||||
count = [anArray count];
|
count = [anArray count];
|
||||||
|
|
||||||
for (; index < count; ++index)
|
for (; index < count; ++index)
|
||||||
[self removeObject:anArray[index]];
|
[self removeObject:anArray[index]];
|
||||||
}
|
}
|
||||||
@@ -1196,11 +1180,11 @@
|
|||||||
var i = 0,
|
var i = 0,
|
||||||
count = [descriptors count],
|
count = [descriptors count],
|
||||||
result = CPOrderedSame;
|
result = CPOrderedSame;
|
||||||
|
|
||||||
while (i < count)
|
while(i < count)
|
||||||
if ((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
|
if((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
@import "CPObject.j"
|
||||||
|
|
||||||
|
var MAIN_POOL = nil;
|
||||||
|
|
||||||
|
@implementation CPAutoreleasePool : CPObject
|
||||||
|
{
|
||||||
|
CPArray _objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
MAIN_POOL = [CPAutoreleasePool new];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id)_mainAutoreleasePool
|
||||||
|
{
|
||||||
|
return MAIN_POOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)addObject:(id)anObject
|
||||||
|
{
|
||||||
|
[[self _mainAutoreleasePool] addObject:anObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
if (self = [super init])
|
||||||
|
{
|
||||||
|
_objects = [];
|
||||||
|
[[CPRunLoop currentRunLoop] performSelector:@selector(drain) target:self argument:nil order:0 modes:[CPDefaultRunLoopMode]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)addObject:(id)anObject
|
||||||
|
{
|
||||||
|
_objects.push(anObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drain
|
||||||
|
{
|
||||||
|
for (var i = 0, count = [_objects count]; i < count; i++)
|
||||||
|
[_objects.pop() release];
|
||||||
|
|
||||||
|
[[CPRunLoop currentRunLoop] performSelector:@selector(drain) target:self argument:nil order:0 modes:[CPDefaultRunLoopMode]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[self drain];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -72,7 +72,7 @@ var CPBundlesForURLStrings = { };
|
|||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
_bundle = new CFBundle(aURL);
|
_bundle = new CFBundle(aURL);
|
||||||
CPBundlesForURLStrings[URLString] = self;
|
CPBundlesForURLStrings[URLString] = [self retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|||||||
+5
-5
@@ -40,27 +40,27 @@
|
|||||||
|
|
||||||
+ (CPData)data
|
+ (CPData)data
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPData)dataWithRawString:(CPString)aString
|
+ (CPData)dataWithRawString:(CPString)aString
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithRawString:aString];
|
return [[[self alloc] initWithRawString:aString] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPData)dataWithPlistObject:(id)aPlistObject
|
+ (CPData)dataWithPlistObject:(id)aPlistObject
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithPlistObject:aPlistObject];
|
return [[[self alloc] initWithPlistObject:aPlistObject] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPData)dataWithPlistObject:(id)aPlistObject format:(CPPropertyListFormat)aFormat
|
+ (CPData)dataWithPlistObject:(id)aPlistObject format:(CPPropertyListFormat)aFormat
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithPlistObject:aPlistObject format:aFormat];
|
return [[[self alloc] initWithPlistObject:aPlistObject format:aFormat] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CPData)dataWithJSONObject:(Object)anObject
|
+ (CPData)dataWithJSONObject:(Object)anObject
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithJSONObject:anObject];
|
return [[[self alloc] initWithJSONObject:anObject] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithRawString:(CPString)aString
|
- (id)initWithRawString:(CPString)aString
|
||||||
|
|||||||
+19
-13
@@ -24,7 +24,13 @@
|
|||||||
@import "CPString.j"
|
@import "CPString.j"
|
||||||
|
|
||||||
|
|
||||||
var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
|
var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0)),
|
||||||
|
_CPDateAllocator = function(a) {
|
||||||
|
a._retainCount = 1;
|
||||||
|
a._UID = objj_generateObjectUID();
|
||||||
|
OBJJ_MEMORY_TABLE[a._UID] = a;
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@class CPDate
|
@class CPDate
|
||||||
@@ -39,48 +45,48 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
|
|||||||
|
|
||||||
+ (id)alloc
|
+ (id)alloc
|
||||||
{
|
{
|
||||||
return new Date;
|
return _CPDateAllocator(new Date);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)date
|
+ (id)date
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)dateWithTimeIntervalSinceNow:(CPTimeInterval)seconds
|
+ (id)dateWithTimeIntervalSinceNow:(CPTimeInterval)seconds
|
||||||
{
|
{
|
||||||
return [[CPDate alloc] initWithTimeIntervalSinceNow:seconds];
|
return [[[CPDate alloc] initWithTimeIntervalSinceNow:seconds] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)dateWithTimeIntervalSince1970:(CPTimeInterval)seconds
|
+ (id)dateWithTimeIntervalSince1970:(CPTimeInterval)seconds
|
||||||
{
|
{
|
||||||
return [[CPDate alloc] initWithTimeIntervalSince1970:seconds];
|
return [[[CPDate alloc] initWithTimeIntervalSince1970:seconds] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)dateWithTimeIntervalSinceReferenceDate:(CPTimeInterval)seconds
|
+ (id)dateWithTimeIntervalSinceReferenceDate:(CPTimeInterval)seconds
|
||||||
{
|
{
|
||||||
return [[CPDate alloc] initWithTimeIntervalSinceReferenceDate:seconds];
|
return [[[CPDate alloc] initWithTimeIntervalSinceReferenceDate:seconds] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)distantPast
|
+ (id)distantPast
|
||||||
{
|
{
|
||||||
return new Date(-10000,1,1,0,0,0,0);
|
return [_CPDateAllocator(new Date(-10000,1,1,0,0,0,0)) autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)distantFuture
|
+ (id)distantFuture
|
||||||
{
|
{
|
||||||
return new Date(10000,1,1,0,0,0,0);
|
return [_CPDateAllocator(new Date(10000,1,1,0,0,0,0)) autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithTimeIntervalSinceNow:(CPTimeInterval)seconds
|
- (id)initWithTimeIntervalSinceNow:(CPTimeInterval)seconds
|
||||||
{
|
{
|
||||||
self = new Date((new Date()).getTime() + seconds * 1000);
|
self = _CPDateAllocator(new Date((new Date()).getTime() + seconds * 1000));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithTimeIntervalSince1970:(CPTimeInterval)seconds
|
- (id)initWithTimeIntervalSince1970:(CPTimeInterval)seconds
|
||||||
{
|
{
|
||||||
self = new Date(seconds * 1000);
|
self = _CPDateAllocator(new Date(seconds * 1000));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +98,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
|
|||||||
|
|
||||||
- (id)initWithTimeInterval:(CPTimeInterval)seconds sinceDate:(CPDate)refDate
|
- (id)initWithTimeInterval:(CPTimeInterval)seconds sinceDate:(CPDate)refDate
|
||||||
{
|
{
|
||||||
self = new Date(refDate.getTime() + seconds * 1000);
|
self = _CPDateAllocator(new Date(refDate.getTime() + seconds * 1000));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +123,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
|
|||||||
date.setMinutes(d[5]);
|
date.setMinutes(d[5]);
|
||||||
date.setSeconds(d[6]);
|
date.setSeconds(d[6]);
|
||||||
|
|
||||||
self = new Date(date.getTime() + (timeZoneOffset - date.getTimezoneOffset()) * 60 * 1000);
|
self = _CPDateAllocator(new Date(date.getTime() + (timeZoneOffset - date.getTimezoneOffset()) * 60 * 1000));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +191,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
|
|||||||
|
|
||||||
- (id)copy
|
- (id)copy
|
||||||
{
|
{
|
||||||
return new Date(self.getTime());
|
return _CPDateAllocator(new Date(self.getTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)dictionary
|
+ (id)dictionary
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return [[[self alloc] init] autorelease];;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)dictionaryWithDictionary:(CPDictionary)aDictionary
|
+ (id)dictionaryWithDictionary:(CPDictionary)aDictionary
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithDictionary:aDictionary];
|
return [[[self alloc] initWithDictionary:aDictionary] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)dictionaryWithObject:(id)anObject forKey:(id)aKey
|
+ (id)dictionaryWithObject:(id)anObject forKey:(id)aKey
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithObjects:[anObject] forKeys:[aKey]];
|
return [[[self alloc] initWithObjects:[anObject] forKeys:[aKey]] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)dictionaryWithObjects:(CPArray)objects forKeys:(CPArray)keys
|
+ (id)dictionaryWithObjects:(CPArray)objects forKeys:(CPArray)keys
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithObjects:objects forKeys:keys];
|
return [[[self alloc] initWithObjects:objects forKeys:keys] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)dictionaryWithJSObject:(JSObject)object
|
+ (id)dictionaryWithJSObject:(JSObject)object
|
||||||
{
|
{
|
||||||
return [self dictionaryWithJSObject:object recursively:NO];
|
return [[self dictionaryWithJSObject:object recursively:NO] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)dictionaryWithJSObject:(JSObject)object recursively:(BOOL)recursively
|
+ (id)dictionaryWithJSObject:(JSObject)object recursively:(BOOL)recursively
|
||||||
{
|
{
|
||||||
var dictionary = [[self alloc] init];
|
var dictionary = [[[self alloc] init] autorelease];
|
||||||
|
|
||||||
for (var key in object)
|
for (var key in object)
|
||||||
{
|
{
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
arguments[0] = [self alloc];
|
arguments[0] = [self alloc];
|
||||||
arguments[1] = @selector(initWithObjectsAndKeys:);
|
arguments[1] = @selector(initWithObjectsAndKeys:);
|
||||||
|
|
||||||
return objj_msgSend.apply(this, arguments);
|
return [objj_msgSend.apply(this, arguments) autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)indexSet
|
+ (id)indexSet
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)indexSetWithIndex:(int)anIndex
|
+ (id)indexSetWithIndex:(int)anIndex
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithIndex:anIndex];
|
return [[[self alloc] initWithIndex:anIndex] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)indexSetWithIndexesInRange:(CPRange)aRange
|
+ (id)indexSetWithIndexesInRange:(CPRange)aRange
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithIndexesInRange:aRange];
|
return [[[self alloc] initWithIndexesInRange:aRange] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializing and Index Set
|
// Initializing and Index Set
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)invocationWithMethodSignature:(CPMethodSignature)aMethodSignature
|
+ (id)invocationWithMethodSignature:(CPMethodSignature)aMethodSignature
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithMethodSignature:aMethodSignature];
|
return [[[self alloc] initWithMethodSignature:aMethodSignature] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
|
|||||||
|
|
||||||
+ (CPJSONPConnection)connectionWithRequest:(CPURLRequest)aRequest callback:(CPString)callbackParameter delegate:(id)aDelegate
|
+ (CPJSONPConnection)connectionWithRequest:(CPURLRequest)aRequest callback:(CPString)callbackParameter delegate:(id)aDelegate
|
||||||
{
|
{
|
||||||
return [[[self class] alloc] initWithRequest:aRequest callback:callbackParameter delegate:aDelegate startImmediately:YES];
|
return [[[[self class] alloc] initWithRequest:aRequest callback:callbackParameter delegate:aDelegate startImmediately:YES] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithRequest:(CPURLRequest)aRequest callback:(CPString)aString delegate:(id)aDelegate
|
- (id)initWithRequest:(CPURLRequest)aRequest callback:(CPString)aString delegate:(id)aDelegate
|
||||||
@@ -88,12 +88,7 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
|
|||||||
{
|
{
|
||||||
CPJSONPConnectionCallbacks["callback"+[self UID]] = function(data)
|
CPJSONPConnectionCallbacks["callback"+[self UID]] = function(data)
|
||||||
{
|
{
|
||||||
if ([_delegate respondsToSelector:@selector(connection:didReceiveData:)])
|
[_delegate connection:self didReceiveData:data];
|
||||||
[_delegate connection:self didReceiveData:data];
|
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:@selector(connectionDidFinishLoading:)])
|
|
||||||
[_delegate connectionDidFinishLoading:self];
|
|
||||||
|
|
||||||
[self removeScriptTag];
|
[self removeScriptTag];
|
||||||
|
|
||||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||||
@@ -123,9 +118,7 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
|
|||||||
}
|
}
|
||||||
catch (exception)
|
catch (exception)
|
||||||
{
|
{
|
||||||
if ([_delegate respondsToSelector:@selector(connection:didFailWithError:)])
|
[_delegate connection: self didFailWithError: exception];
|
||||||
[_delegate connection: self didFailWithError: exception];
|
|
||||||
|
|
||||||
[self removeScriptTag];
|
[self removeScriptTag];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,12 +480,6 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
|||||||
|
|
||||||
- (void)willChangeValueForKey:(CPString)aKey
|
- (void)willChangeValueForKey:(CPString)aKey
|
||||||
{
|
{
|
||||||
var superClass = [self class],
|
|
||||||
methodSelector = @selector(willChangeValueForKey:),
|
|
||||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
|
||||||
|
|
||||||
methodImp(self, methodSelector, aKey);
|
|
||||||
|
|
||||||
if (!aKey)
|
if (!aKey)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -496,12 +490,6 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
|||||||
|
|
||||||
- (void)didChangeValueForKey:(CPString)aKey
|
- (void)didChangeValueForKey:(CPString)aKey
|
||||||
{
|
{
|
||||||
var superClass = [self class],
|
|
||||||
methodSelector = @selector(didChangeValueForKey:),
|
|
||||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
|
||||||
|
|
||||||
methodImp(self, methodSelector, aKey);
|
|
||||||
|
|
||||||
if (!aKey)
|
if (!aKey)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -510,12 +498,6 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
|||||||
|
|
||||||
- (void)willChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey
|
- (void)willChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey
|
||||||
{
|
{
|
||||||
var superClass = [self class],
|
|
||||||
methodSelector = @selector(willChange:valuesAtIndexes:forKey:),
|
|
||||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
|
||||||
|
|
||||||
methodImp(self, methodSelector, change, indexes, aKey);
|
|
||||||
|
|
||||||
if (!aKey)
|
if (!aKey)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -526,12 +508,6 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
|
|||||||
|
|
||||||
- (void)didChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey
|
- (void)didChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey
|
||||||
{
|
{
|
||||||
var superClass = [self class],
|
|
||||||
methodSelector = @selector(didChange:valuesAtIndexes:forKey:),
|
|
||||||
methodImp = class_getMethodImplementation(superClass, methodSelector);
|
|
||||||
|
|
||||||
methodImp(self, methodSelector, change, indexes, aKey);
|
|
||||||
|
|
||||||
if (!aKey)
|
if (!aKey)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ var _CPKeyedArchiverStringClass = Nil,
|
|||||||
+ (CPData)archivedDataWithRootObject:(id)anObject
|
+ (CPData)archivedDataWithRootObject:(id)anObject
|
||||||
{
|
{
|
||||||
var data = [CPData dataWithPlistObject:nil],
|
var data = [CPData dataWithPlistObject:nil],
|
||||||
archiver = [[self alloc] initForWritingWithMutableData:data];
|
archiver = [[[self alloc] initForWritingWithMutableData:data] autorelease];
|
||||||
|
|
||||||
[archiver encodeObject:anObject forKey:@"root"];
|
[archiver encodeObject:anObject forKey:@"root"];
|
||||||
[archiver finishEncoding];
|
[archiver finishEncoding];
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ var CPArrayClass = Ni
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
var unarchiver = [[self alloc] initForReadingWithData:aData],
|
var unarchiver = [[[self alloc] initForReadingWithData:aData] autorelease],
|
||||||
object = [unarchiver decodeObjectForKey:@"root"];
|
object = [unarchiver decodeObjectForKey:@"root"];
|
||||||
|
|
||||||
[unarchiver finishDecoding];
|
[unarchiver finishDecoding];
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPNotification)notificationWithName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
|
+ (CPNotification)notificationWithName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithName:aNotificationName object:anObject userInfo:aUserInfo];
|
return [[[self alloc] initWithName:aNotificationName object:anObject userInfo:aUserInfo] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPNotification)notificationWithName:(CPString)aNotificationName object:(id)anObject
|
+ (CPNotification)notificationWithName:(CPString)aNotificationName object:(id)anObject
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithName:aNotificationName object:anObject userInfo:nil];
|
return [[[self alloc] initWithName:aNotificationName object:anObject userInfo:nil] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
+3
-22
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
var CPNullSharedNull = nil;
|
var CPNullSharedNull = nil;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@class CPNull
|
@class CPNull
|
||||||
@ingroup foundation
|
@ingroup foundation
|
||||||
@brief An object representation of \c nil.
|
@brief An object representation of \c nil.
|
||||||
@@ -41,7 +41,7 @@ var CPNullSharedNull = nil;
|
|||||||
{
|
{
|
||||||
if (CPNullSharedNull)
|
if (CPNullSharedNull)
|
||||||
return CPNullSharedNull;
|
return CPNullSharedNull;
|
||||||
|
|
||||||
return [super alloc];
|
return [super alloc];
|
||||||
}*/
|
}*/
|
||||||
/*!
|
/*!
|
||||||
@@ -53,27 +53,8 @@ var CPNullSharedNull = nil;
|
|||||||
{
|
{
|
||||||
if (!CPNullSharedNull)
|
if (!CPNullSharedNull)
|
||||||
CPNullSharedNull = [[CPNull alloc] init];
|
CPNullSharedNull = [[CPNull alloc] init];
|
||||||
|
|
||||||
return CPNullSharedNull;
|
return CPNullSharedNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns CPNull null.
|
|
||||||
@param aCoder the coder from which to do nothing
|
|
||||||
@return [CPNull null]
|
|
||||||
*/
|
|
||||||
- (id)initWithCoder:(CPCoder)aCoder
|
|
||||||
{
|
|
||||||
return [CPNull null];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Writes out nothing to the specified coder.
|
|
||||||
@param aCoder the coder to which nothing will
|
|
||||||
be written
|
|
||||||
*/
|
|
||||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -333,4 +333,7 @@ FIXME: Do we need this?
|
|||||||
|
|
||||||
Number.prototype.isa = CPNumber;
|
Number.prototype.isa = CPNumber;
|
||||||
Boolean.prototype.isa = CPNumber;
|
Boolean.prototype.isa = CPNumber;
|
||||||
|
Number.prototype._retainCount = Infinity;
|
||||||
|
Boolean.prototype._retainCount = Infinity;
|
||||||
|
|
||||||
[CPNumber initialize];
|
[CPNumber initialize];
|
||||||
|
|||||||
+10
-1
@@ -89,7 +89,6 @@ CPLog(@"Got some class: %@", inst);
|
|||||||
*/
|
*/
|
||||||
+ (id)alloc
|
+ (id)alloc
|
||||||
{
|
{
|
||||||
// CPLog("calling alloc on " + self.name + ".");
|
|
||||||
return class_createInstance(self);
|
return class_createInstance(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +129,7 @@ CPLog(@"Got some class: %@", inst);
|
|||||||
*/
|
*/
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
delete OBJJ_MEMORY_TABLE[[self UID]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identifying classes
|
// Identifying classes
|
||||||
@@ -464,6 +464,7 @@ CPLog(@"Got some class: %@", inst);
|
|||||||
*/
|
*/
|
||||||
- (id)autorelease
|
- (id)autorelease
|
||||||
{
|
{
|
||||||
|
[CPAutoreleasePool addObject:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,6 +499,7 @@ CPLog(@"Got some class: %@", inst);
|
|||||||
*/
|
*/
|
||||||
- (id)retain
|
- (id)retain
|
||||||
{
|
{
|
||||||
|
_retainCount++;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,6 +508,11 @@ CPLog(@"Got some class: %@", inst);
|
|||||||
*/
|
*/
|
||||||
- (void)release
|
- (void)release
|
||||||
{
|
{
|
||||||
|
_retainCount--;
|
||||||
|
if (_retainCount === 0)
|
||||||
|
[self dealloc];
|
||||||
|
else if (OBJJ_ZOMBIE_DETECTION && _retainCount < 0)
|
||||||
|
throw ("Released a zombie object: "+self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -535,3 +542,5 @@ objj_class.prototype.toString = objj_object.prototype.toString = function()
|
|||||||
else
|
else
|
||||||
return String(this) + " (-description not implemented)";
|
return String(this) + " (-description not implemented)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@import "CPAutoreleasePool.j"
|
||||||
|
|||||||
+3
-25
@@ -73,7 +73,7 @@ var _CPRunLoopPerformPool = [],
|
|||||||
return perform;
|
return perform;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [[self alloc] initWithSelector:aSelector target:aTarget argument:anArgument order:anOrder modes:modes];
|
return [[[self alloc] initWithSelector:aSelector target:aTarget argument:anArgument order:anOrder modes:modes] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithSelector:(SEL)aSelector target:(SEL)aTarget argument:(id)anArgument order:(unsigned)anOrder modes:(CPArray)modes
|
- (id)initWithSelector:(SEL)aSelector target:(SEL)aTarget argument:(id)anArgument order:(unsigned)anOrder modes:(CPArray)modes
|
||||||
@@ -157,7 +157,6 @@ var CPRunLoopLastNativeRunLoop = 0;
|
|||||||
CPDate _effectiveDate;
|
CPDate _effectiveDate;
|
||||||
|
|
||||||
CPArray _orderedPerforms;
|
CPArray _orderedPerforms;
|
||||||
int _runLoopInsuranceTimer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -268,17 +267,6 @@ var CPRunLoopLastNativeRunLoop = 0;
|
|||||||
aTimer._lastNativeRunLoopsForModes = {};
|
aTimer._lastNativeRunLoopsForModes = {};
|
||||||
|
|
||||||
aTimer._lastNativeRunLoopsForModes[aMode] = CPRunLoopLastNativeRunLoop;
|
aTimer._lastNativeRunLoopsForModes[aMode] = CPRunLoopLastNativeRunLoop;
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Hack for not doing this in CommonJS
|
|
||||||
if ([CFBundle.environments() indexOfObject:("Browser")] !== CPNotFound)
|
|
||||||
{
|
|
||||||
if (!_runLoopInsuranceTimer)
|
|
||||||
_runLoopInsuranceTimer = window.setNativeTimeout(function()
|
|
||||||
{
|
|
||||||
[self limitDateForMode:CPDefaultRunLoopMode];
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -289,19 +277,9 @@ var CPRunLoopLastNativeRunLoop = 0;
|
|||||||
//simple locking to try to prevent concurrent iterating over timers
|
//simple locking to try to prevent concurrent iterating over timers
|
||||||
if (_runLoopLock)
|
if (_runLoopLock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_runLoopLock = YES;
|
_runLoopLock = YES;
|
||||||
|
|
||||||
// FIXME: Hack for not doing this in CommonJS
|
|
||||||
if ([CFBundle.environments() indexOfObject:("Browser")] !== CPNotFound)
|
|
||||||
{
|
|
||||||
if (_runLoopInsuranceTimer)
|
|
||||||
{
|
|
||||||
window.clearNativeTimeout(_runLoopInsuranceTimer);
|
|
||||||
_runLoopInsuranceTimer = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var now = _effectiveDate ? [_effectiveDate laterDate:[CPDate date]] : [CPDate date],
|
var now = _effectiveDate ? [_effectiveDate laterDate:[CPDate date]] : [CPDate date],
|
||||||
nextFireDate = nil,
|
nextFireDate = nil,
|
||||||
nextTimerFireDate = _nextTimerFireDatesForModes[aMode];
|
nextTimerFireDate = _nextTimerFireDatesForModes[aMode];
|
||||||
|
|||||||
+25
-30
@@ -23,7 +23,7 @@
|
|||||||
*
|
*
|
||||||
* TODO: Needs to implement CPCoding, CPCopying.
|
* TODO: Needs to implement CPCoding, CPCopying.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@import "CPObject.j"
|
@import "CPObject.j"
|
||||||
@import "CPArray.j"
|
@import "CPArray.j"
|
||||||
@import "CPNumber.j"
|
@import "CPNumber.j"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)set
|
+ (id)set
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)setWithArray:(CPArray)array
|
+ (id)setWithArray:(CPArray)array
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithArray:array];
|
return [[[self alloc] initWithArray:array] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)setWithObject:(id)anObject
|
+ (id)setWithObject:(id)anObject
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithArray:[anObject]];
|
return [[[self alloc] initWithArray:[anObject]] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -73,13 +73,13 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)setWithObjects:(id)objects count:(unsigned)count
|
+ (id)setWithObjects:(id)objects count:(unsigned)count
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithObjects:objects count:count];
|
return [[[self alloc] initWithObjects:objects count:count] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates and returns a set containing the objects in a given argument list.
|
Creates and returns a set containing the objects in a given argument list.
|
||||||
@param anObject The first object to add to the new set.
|
@param anObject The first object to add to the new set.
|
||||||
@param ... A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
@param ... A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
||||||
*/
|
*/
|
||||||
+ (id)setWithObjects:(id)anObject, ...
|
+ (id)setWithObjects:(id)anObject, ...
|
||||||
{
|
{
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
|
|
||||||
for(; i < argLength && ((argument = arguments[i]) !== nil); ++i)
|
for(; i < argLength && ((argument = arguments[i]) !== nil); ++i)
|
||||||
[set addObject:argument];
|
[set addObject:argument];
|
||||||
|
|
||||||
return set;
|
return [set autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)setWithSet:(CPSet)set
|
+ (id)setWithSet:(CPSet)set
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithSet:set];
|
return [[[self alloc] initWithSet:set] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
_count = 0;
|
_count = 0;
|
||||||
_contents = {};
|
_contents = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,21 +121,21 @@
|
|||||||
@param array An array of objects to add to the new set. If the same object appears more than once in array, it is represented only once in the returned set.
|
@param array An array of objects to add to the new set. If the same object appears more than once in array, it is represented only once in the returned set.
|
||||||
*/
|
*/
|
||||||
- (id)initWithArray:(CPArray)anArray
|
- (id)initWithArray:(CPArray)anArray
|
||||||
{
|
{
|
||||||
if (self = [self init])
|
if (self = [self init])
|
||||||
{
|
{
|
||||||
var count = anArray.length;
|
var count = anArray.length;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
[self addObject:anArray[count]];
|
[self addObject:anArray[count]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initializes a newly allocated set with members taken from the specified list of objects.
|
Initializes a newly allocated set with members taken from the specified list of objects.
|
||||||
@param objects A array of objects to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
@param objects A array of objects to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
||||||
@param count The number of objects from objects to add to the new set.
|
@param count The number of objects from objects to add to the new set.
|
||||||
*/
|
*/
|
||||||
- (id)initWithObjects:(id)objects count:(unsigned)count
|
- (id)initWithObjects:(id)objects count:(unsigned)count
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
for(; i < argLength && (argument = arguments[i]) != nil; ++i)
|
for(; i < argLength && (argument = arguments[i]) != nil; ++i)
|
||||||
[self addObject:argument];
|
[self addObject:argument];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,9 +179,9 @@
|
|||||||
|
|
||||||
if (!aSet)
|
if (!aSet)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
var contents = aSet._contents;
|
var contents = aSet._contents;
|
||||||
|
|
||||||
for (var property in contents)
|
for (var property in contents)
|
||||||
{
|
{
|
||||||
if (contents.hasOwnProperty(property))
|
if (contents.hasOwnProperty(property))
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
[self addObject:contents[property]];
|
[self addObject:contents[property]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,13 +202,13 @@
|
|||||||
- (CPArray)allObjects
|
- (CPArray)allObjects
|
||||||
{
|
{
|
||||||
var array = [];
|
var array = [];
|
||||||
|
|
||||||
for (var property in _contents)
|
for (var property in _contents)
|
||||||
{
|
{
|
||||||
if (_contents.hasOwnProperty(property))
|
if (_contents.hasOwnProperty(property))
|
||||||
array.push(_contents[property]);
|
array.push(_contents[property]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@
|
|||||||
if (_contents.hasOwnProperty(property))
|
if (_contents.hasOwnProperty(property))
|
||||||
return _contents[property];
|
return _contents[property];
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@
|
|||||||
|
|
||||||
if (obj !== undefined && [obj isEqual:anObject])
|
if (obj !== undefined && [obj isEqual:anObject])
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@
|
|||||||
@param set The set with which to compare the receiver.
|
@param set The set with which to compare the receiver.
|
||||||
*/
|
*/
|
||||||
- (BOOL)isEqualToSet:(CPSet)set
|
- (BOOL)isEqualToSet:(CPSet)set
|
||||||
{
|
{
|
||||||
// If both are subsets of each other, they are equal
|
// If both are subsets of each other, they are equal
|
||||||
return self === set || ([self count] === [set count] && [set isSubsetOfSet:self]);
|
return self === set || ([self count] === [set count] && [set isSubsetOfSet:self]);
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@
|
|||||||
if (![set containsObject:items[i]])
|
if (![set containsObject:items[i]])
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@
|
|||||||
{
|
{
|
||||||
if ([self containsObject:object])
|
if ([self containsObject:object])
|
||||||
return object;
|
return object;
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,11 +467,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CPString)description
|
|
||||||
{
|
|
||||||
return @"{(" + [self allObjects].join(", ") + ")}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CPSet (CPCopying)
|
@implementation CPSet (CPCopying)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ CPOrderedDescending = 1;
|
|||||||
|
|
||||||
+ (id)sortDescriptorWithKey:(CPString)aKey ascending:(BOOL)isAscending selector:(SEL)aSelector
|
+ (id)sortDescriptorWithKey:(CPString)aKey ascending:(BOOL)isAscending selector:(SEL)aSelector
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithKey:aKey ascending:isAscending selector:aSelector];
|
return [[[self alloc] initWithKey:aKey ascending:isAscending selector:aSelector] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -769,3 +769,4 @@ var CPStringRegexSpecialCharacters = [
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
String.prototype.isa = CPString;
|
String.prototype.isa = CPString;
|
||||||
|
String.prototype._retainCount = Infinity;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPTimer)scheduledTimerWithTimeInterval:(CPTimeInterval)seconds invocation:(CPInvocation)anInvocation repeats:(BOOL)shouldRepeat
|
+ (CPTimer)scheduledTimerWithTimeInterval:(CPTimeInterval)seconds invocation:(CPInvocation)anInvocation repeats:(BOOL)shouldRepeat
|
||||||
{
|
{
|
||||||
var timer = [[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds invocation:anInvocation repeats:shouldRepeat];
|
var timer = [[[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds invocation:anInvocation repeats:shouldRepeat] autorelease];
|
||||||
|
|
||||||
//add to the runloop
|
//add to the runloop
|
||||||
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
|
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPTimer)scheduledTimerWithTimeInterval:(CPTimeInterval)seconds target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)shouldRepeat
|
+ (CPTimer)scheduledTimerWithTimeInterval:(CPTimeInterval)seconds target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)shouldRepeat
|
||||||
{
|
{
|
||||||
var timer = [[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds target:aTarget selector:aSelector userInfo:userInfo repeats:shouldRepeat]
|
var timer = [[[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds target:aTarget selector:aSelector userInfo:userInfo repeats:shouldRepeat] autorelease];
|
||||||
|
|
||||||
//add to the runloop
|
//add to the runloop
|
||||||
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
|
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPTimer)scheduledTimerWithTimeInterval:(CPTimeInterval)seconds callback:(Function)aFunction repeats:(BOOL)shouldRepeat
|
+ (CPTimer)scheduledTimerWithTimeInterval:(CPTimeInterval)seconds callback:(Function)aFunction repeats:(BOOL)shouldRepeat
|
||||||
{
|
{
|
||||||
var timer = [[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds callback:aFunction repeats:shouldRepeat];
|
var timer = [[[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds callback:aFunction repeats:shouldRepeat] autorelease];
|
||||||
|
|
||||||
//add to the runloop
|
//add to the runloop
|
||||||
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
|
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPTimer)timerWithTimeInterval:(CPTimeInterval)seconds invocation:(CPInvocation)anInvocation repeats:(BOOL)shouldRepeat
|
+ (CPTimer)timerWithTimeInterval:(CPTimeInterval)seconds invocation:(CPInvocation)anInvocation repeats:(BOOL)shouldRepeat
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds invocation:anInvocation repeats:shouldRepeat];
|
return [[[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds invocation:anInvocation repeats:shouldRepeat] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPTimer)timerWithTimeInterval:(CPTimeInterval)seconds target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)shouldRepeat
|
+ (CPTimer)timerWithTimeInterval:(CPTimeInterval)seconds target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)shouldRepeat
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds target:aTarget selector:aSelector userInfo:userInfo repeats:shouldRepeat];
|
return [[[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds target:aTarget selector:aSelector userInfo:userInfo repeats:shouldRepeat] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (CPTimer)timerWithTimeInterval:(CPTimeInterval)seconds callback:(Function)aFunction repeats:(BOOL)shouldRepeat
|
+ (CPTimer)timerWithTimeInterval:(CPTimeInterval)seconds callback:(Function)aFunction repeats:(BOOL)shouldRepeat
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds callback:aFunction repeats:shouldRepeat];
|
return [[[self alloc] initWithFireDate:[CPDate dateWithTimeIntervalSinceNow:seconds] interval:seconds callback:aFunction repeats:shouldRepeat] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
|
|||||||
|
|
||||||
+ (id)URLWithString:(CPString)URLString
|
+ (id)URLWithString:(CPString)URLString
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithString:URLString];
|
return [[[self alloc] initWithString:URLString] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithString:(CPString)URLString relativeToURL:(CPURL)aBaseURL
|
- (id)initWithString:(CPString)URLString relativeToURL:(CPURL)aBaseURL
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ var CPURLConnectionDelegate = nil;
|
|||||||
*/
|
*/
|
||||||
+ (CPURLConnection)connectionWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate
|
+ (CPURLConnection)connectionWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithRequest:aRequest delegate:aDelegate];
|
return [[[self alloc] initWithRequest:aRequest delegate:aDelegate] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)requestWithURL:(CPURL)aURL
|
+ (id)requestWithURL:(CPURL)aURL
|
||||||
{
|
{
|
||||||
return [[CPURLRequest alloc] initWithURL:aURL];
|
return [[[CPURLRequest alloc] initWithURL:aURL] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ var _CPUndoGroupingPool = [],
|
|||||||
return grouping;
|
return grouping;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [[self alloc] initWithParent:anUndoGrouping];
|
return [[[self alloc] initWithParent:anUndoGrouping] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithParent:(_CPUndoGrouping)anUndoGrouping
|
- (id)initWithParent:(_CPUndoGrouping)anUndoGrouping
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
+ (id)valueWithJSObject:(JSObject)aJSObject
|
+ (id)valueWithJSObject:(JSObject)aJSObject
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithJSObject:aJSObject];
|
return [[[self alloc] initWithJSObject:aJSObject] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@import "CPAutoreleasePool.j"
|
||||||
@import "CPArray.j"
|
@import "CPArray.j"
|
||||||
@import "CPBundle.j"
|
@import "CPBundle.j"
|
||||||
@import "CPCoder.j"
|
@import "CPCoder.j"
|
||||||
|
|||||||
@@ -107,16 +107,14 @@ task ("documentation", function()
|
|||||||
|
|
||||||
// Downloads
|
// Downloads
|
||||||
|
|
||||||
task ("downloads", ["starter_download"]);
|
task ("downloads", ["starter_download", "tools_download"]);
|
||||||
|
|
||||||
$STARTER_README = FILE.join('Tools', 'READMEs', 'STARTER-README');
|
$STARTER_README = FILE.join('Tools', 'READMEs', 'STARTER-README');
|
||||||
$STARTER_BOOTSTRAP = 'bootstrap.sh';
|
|
||||||
$STARTER_DOWNLOAD = FILE.join($BUILD_DIR, 'Cappuccino', 'Starter');
|
$STARTER_DOWNLOAD = FILE.join($BUILD_DIR, 'Cappuccino', 'Starter');
|
||||||
$STARTER_DOWNLOAD_APPLICATION = FILE.join($STARTER_DOWNLOAD, 'NewApplication');
|
$STARTER_DOWNLOAD_APPLICATION = FILE.join($STARTER_DOWNLOAD, 'NewApplication');
|
||||||
$STARTER_DOWNLOAD_README = FILE.join($STARTER_DOWNLOAD, 'README');
|
$STARTER_DOWNLOAD_README = FILE.join($STARTER_DOWNLOAD, 'README');
|
||||||
$STARTER_DOWNLOAD_BOOTSTRAP = FILE.join($STARTER_DOWNLOAD, 'bootstrap.sh');
|
|
||||||
|
|
||||||
task ("starter_download", [$STARTER_DOWNLOAD_APPLICATION, $STARTER_DOWNLOAD_README, $STARTER_DOWNLOAD_BOOTSTRAP, "documentation"], function()
|
task ("starter_download", [$STARTER_DOWNLOAD_APPLICATION, $STARTER_DOWNLOAD_README, "documentation"], function()
|
||||||
{
|
{
|
||||||
if (FILE.exists($DOCUMENTATION_BUILD))
|
if (FILE.exists($DOCUMENTATION_BUILD))
|
||||||
{
|
{
|
||||||
@@ -132,8 +130,8 @@ filedir ($STARTER_DOWNLOAD_APPLICATION, ["CommonJS"], function()
|
|||||||
|
|
||||||
if (OS.system(["capp", "gen", $STARTER_DOWNLOAD_APPLICATION, "-t", "Application", "--noconfig"]))
|
if (OS.system(["capp", "gen", $STARTER_DOWNLOAD_APPLICATION, "-t", "Application", "--noconfig"]))
|
||||||
// FIXME: uncomment this: we get conversion errors
|
// FIXME: uncomment this: we get conversion errors
|
||||||
OS.exit(1); // rake abort if ($? != 0)
|
//OS.exit(1); // rake abort if ($? != 0)
|
||||||
//{}
|
{}
|
||||||
// No tools means no objective-j gem
|
// No tools means no objective-j gem
|
||||||
// FILE.rm(FILE.join($STARTER_DOWNLOAD_APPLICATION, 'Rakefile'))
|
// FILE.rm(FILE.join($STARTER_DOWNLOAD_APPLICATION, 'Rakefile'))
|
||||||
});
|
});
|
||||||
@@ -143,11 +141,36 @@ filedir ($STARTER_DOWNLOAD_README, [$STARTER_README], function()
|
|||||||
cp($STARTER_README, $STARTER_DOWNLOAD_README);
|
cp($STARTER_README, $STARTER_DOWNLOAD_README);
|
||||||
});
|
});
|
||||||
|
|
||||||
filedir ($STARTER_DOWNLOAD_BOOTSTRAP, [$STARTER_BOOTSTRAP], function()
|
$TOOLS_README = FILE.join('Tools', 'READMEs', 'TOOLS-README');
|
||||||
|
$TOOLS_EDITORS = FILE.join('Tools', 'Editors');
|
||||||
|
$TOOLS_INSTALLER = FILE.join('Tools', 'Install', 'install-tools');
|
||||||
|
$TOOLS_DOWNLOAD = FILE.join($BUILD_DIR, 'Cappuccino', 'Tools');
|
||||||
|
$TOOLS_DOWNLOAD_EDITORS = FILE.join($TOOLS_DOWNLOAD, 'Editors');
|
||||||
|
$TOOLS_DOWNLOAD_README = FILE.join($TOOLS_DOWNLOAD, 'README');
|
||||||
|
$TOOLS_DOWNLOAD_INSTALLER = FILE.join($TOOLS_DOWNLOAD, 'install-tools');
|
||||||
|
$TOOLS_DOWNLOAD_COMMONJS = FILE.join($BUILD_DIR, "Cappuccino", "Tools", "CommonJS", "objective-j");
|
||||||
|
|
||||||
|
task ("tools_download", [$TOOLS_DOWNLOAD_EDITORS, $TOOLS_DOWNLOAD_README, $TOOLS_DOWNLOAD_INSTALLER, $TOOLS_DOWNLOAD_COMMONJS]);
|
||||||
|
|
||||||
|
filedir ($TOOLS_DOWNLOAD_EDITORS, [$TOOLS_EDITORS], function()
|
||||||
{
|
{
|
||||||
var bootstrap = FILE.read($STARTER_BOOTSTRAP, { charset : "UTF-8" }).replace('install_capp=""', 'install_capp="yes"');
|
cp_r(FILE.join($TOOLS_EDITORS, '.'), $TOOLS_DOWNLOAD_EDITORS);
|
||||||
FILE.write($STARTER_DOWNLOAD_BOOTSTRAP, bootstrap, { charset : "UTF-8" });
|
});
|
||||||
OS.system(["chmod", "+x", $STARTER_DOWNLOAD_BOOTSTRAP]);
|
|
||||||
|
filedir ($TOOLS_DOWNLOAD_README, [$TOOLS_README], function()
|
||||||
|
{
|
||||||
|
cp($TOOLS_README, $TOOLS_DOWNLOAD_README);
|
||||||
|
});
|
||||||
|
|
||||||
|
filedir ($TOOLS_DOWNLOAD_INSTALLER, [$TOOLS_INSTALLER], function()
|
||||||
|
{
|
||||||
|
cp($TOOLS_INSTALLER, $TOOLS_DOWNLOAD_INSTALLER);
|
||||||
|
});
|
||||||
|
|
||||||
|
filedir ($TOOLS_DOWNLOAD_COMMONJS, ["CommonJS"], function()
|
||||||
|
{
|
||||||
|
rm_rf($TOOLS_DOWNLOAD_COMMONJS);
|
||||||
|
cp_r($COMMONJS_PRODUCT, $TOOLS_DOWNLOAD_COMMONJS);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Deployment
|
// Deployment
|
||||||
@@ -210,22 +233,15 @@ task ("demos", function()
|
|||||||
{
|
{
|
||||||
return this.name();
|
return this.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE.glob(FILE.join(demosDir, "demos", "**/Info.plist")).map(function(demoPath){
|
FILE.glob(FILE.join(demosDir, "demos", "**/Info.plist")).map(function(demoPath){
|
||||||
return new Demo(FILE.dirname(demoPath))
|
return new Demo(FILE.dirname(demoPath))
|
||||||
}).filter(function(demo){
|
}).filter(function(demo){
|
||||||
return !demo.excluded();
|
return !demo.excluded();
|
||||||
}).forEach(function(demo)
|
}).forEach(function(demo)
|
||||||
{
|
{
|
||||||
// copy frameworks into the demos
|
var outputPath = FILE.join(demosDir, demo.name().replace(/\s/g, "-")+".zip");
|
||||||
cp_r(FILE.join($STARTER_DOWNLOAD_APPLICATION, "Frameworks"), FILE.join(demo.path(), "Frameworks"));
|
OS.system("cd "+OS.enquote(FILE.dirname(demo.path()))+"; zip -ry -8 "+OS.enquote(outputPath)+" "+OS.enquote(demo.path()));
|
||||||
rm_rf(FILE.join(demo.path(), "Frameworks", "Debug"));
|
|
||||||
|
|
||||||
var outputPath = demo.name().replace(/\s/g, "-")+".zip";
|
|
||||||
OS.system("cd "+OS.enquote(FILE.dirname(demo.path()))+" && zip -ry -8 "+OS.enquote(outputPath)+" "+OS.enquote(FILE.basename(demo.path())));
|
|
||||||
|
|
||||||
// remove the frameworks
|
|
||||||
rm_rf(FILE.join(demo.path(), "Frameworks"));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
|
|||||||
this._infoDictionary = new CFDictionary();
|
this._infoDictionary = new CFDictionary();
|
||||||
|
|
||||||
this._eventDispatcher = new EventDispatcher(this);
|
this._eventDispatcher = new EventDispatcher(this);
|
||||||
|
|
||||||
|
this._UID = objj_generateObjectUID();
|
||||||
|
this._retainCount = 1;
|
||||||
|
OBJJ_MEMORY_TABLE[this._UID] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
DISPLAY_NAME(CFBundle);
|
DISPLAY_NAME(CFBundle);
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ GLOBAL(CFData) = function()
|
|||||||
|
|
||||||
this._bytes = NULL;
|
this._bytes = NULL;
|
||||||
this._base64 = NULL;
|
this._base64 = NULL;
|
||||||
|
|
||||||
|
this._UID = objj_generateObjectUID();
|
||||||
|
this._retainCount = 1;
|
||||||
|
OBJJ_MEMORY_TABLE[this._UID] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFData.prototype.propertyList = function()
|
CFData.prototype.propertyList = function()
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ GLOBAL(CFDictionary) = function(/*CFDictionary*/ aDictionary)
|
|||||||
this._count = 0;
|
this._count = 0;
|
||||||
this._buckets = { };
|
this._buckets = { };
|
||||||
this._UID = objj_generateObjectUID();
|
this._UID = objj_generateObjectUID();
|
||||||
|
this._retainCount = 1;
|
||||||
|
OBJJ_MEMORY_TABLE[this._UID] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
var indexOf = Array.prototype.indexOf,
|
var indexOf = Array.prototype.indexOf,
|
||||||
|
|||||||
@@ -92,23 +92,15 @@ if (!NativeRequest)
|
|||||||
|
|
||||||
GLOBAL(CFHTTPRequest) = function()
|
GLOBAL(CFHTTPRequest) = function()
|
||||||
{
|
{
|
||||||
this._isOpen = false;
|
|
||||||
this._requestHeaders = {};
|
|
||||||
this._mimeType = null;
|
|
||||||
|
|
||||||
this._eventDispatcher = new EventDispatcher(this);
|
this._eventDispatcher = new EventDispatcher(this);
|
||||||
this._nativeRequest = new NativeRequest();
|
this._nativeRequest = new NativeRequest();
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this._stateChangeHandler = function()
|
|
||||||
|
this._nativeRequest.onreadystatechange = function()
|
||||||
{
|
{
|
||||||
determineAndDispatchHTTPRequestEvents(self);
|
determineAndDispatchHTTPRequestEvents(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._nativeRequest.onreadystatechange = this._stateChangeHandler;
|
|
||||||
|
|
||||||
if (CFHTTPRequest.AuthenticationDelegate !== nil)
|
|
||||||
this._eventDispatcher.addEventListener("HTTP403", function(){CFHTTPRequest.AuthenticationDelegate(self)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CFHTTPRequest.UninitializedState = 0;
|
CFHTTPRequest.UninitializedState = 0;
|
||||||
@@ -117,9 +109,6 @@ CFHTTPRequest.LoadedState = 2;
|
|||||||
CFHTTPRequest.InteractiveState = 3;
|
CFHTTPRequest.InteractiveState = 3;
|
||||||
CFHTTPRequest.CompleteState = 4;
|
CFHTTPRequest.CompleteState = 4;
|
||||||
|
|
||||||
//override to forward all CFHTTPRequest authorization failures to a single function
|
|
||||||
CFHTTPRequest.AuthenticationDelegate = nil;
|
|
||||||
|
|
||||||
CFHTTPRequest.prototype.status = function()
|
CFHTTPRequest.prototype.status = function()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -188,7 +177,7 @@ CFHTTPRequest.prototype.responseText = function()
|
|||||||
|
|
||||||
CFHTTPRequest.prototype.setRequestHeader = function(/*String*/ aHeader, /*Object*/ aValue)
|
CFHTTPRequest.prototype.setRequestHeader = function(/*String*/ aHeader, /*Object*/ aValue)
|
||||||
{
|
{
|
||||||
this._requestHeaders[aHeader] = aValue;
|
return this._nativeRequest.setRequestHeader(aHeader, aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFHTTPRequest.prototype.getResponseHeader = function(/*String*/ aHeader)
|
CFHTTPRequest.prototype.getResponseHeader = function(/*String*/ aHeader)
|
||||||
@@ -203,40 +192,17 @@ CFHTTPRequest.prototype.getAllResponseHeaders = function()
|
|||||||
|
|
||||||
CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
|
CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
|
||||||
{
|
{
|
||||||
this._mimeType = aMimeType;
|
if ("overrideMimeType" in this._nativeRequest)
|
||||||
|
return this._nativeRequest.overrideMimeType(aMimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword)
|
CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword)
|
||||||
{
|
{
|
||||||
this._isOpen = true;
|
|
||||||
this._URL = aURL;
|
|
||||||
this._async = isAsynchronous;
|
|
||||||
this._method = aMethod;
|
|
||||||
this._user = aUser;
|
|
||||||
this._password = aPassword;
|
|
||||||
return this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword);
|
return this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
|
CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
|
||||||
{
|
{
|
||||||
for (var i in this._requestHeaders)
|
|
||||||
{
|
|
||||||
if (this._requestHeaders.hasOwnProperty(i))
|
|
||||||
this._nativeRequest.setRequestHeader(i, this._requestHeaders[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this._isOpen)
|
|
||||||
{
|
|
||||||
delete this._nativeRequest.onreadystatechange;
|
|
||||||
this._nativeRequest.open(this._method, this._URL, this._async, this._user, this._password);
|
|
||||||
this._nativeRequest.onreadystatechange = this._stateChangeHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._mimeType && "overrideMimeType" in this._nativeRequest)
|
|
||||||
this._nativeRequest.overrideMimeType(this._mimeType);
|
|
||||||
|
|
||||||
this._isOpen = false;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return this._nativeRequest.send(aBody);
|
return this._nativeRequest.send(aBody);
|
||||||
@@ -250,7 +216,6 @@ CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
|
|||||||
|
|
||||||
CFHTTPRequest.prototype.abort = function()
|
CFHTTPRequest.prototype.abort = function()
|
||||||
{
|
{
|
||||||
this._isOpen = false;
|
|
||||||
return this._nativeRequest.abort();
|
return this._nativeRequest.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,20 +236,20 @@ function determineAndDispatchHTTPRequestEvents(/*CFHTTPRequest*/ aRequest)
|
|||||||
eventDispatcher.dispatchEvent({ type:"readystatechange", request:aRequest});
|
eventDispatcher.dispatchEvent({ type:"readystatechange", request:aRequest});
|
||||||
|
|
||||||
var nativeRequest = aRequest._nativeRequest,
|
var nativeRequest = aRequest._nativeRequest,
|
||||||
readyStates = ["uninitialized", "loading", "loaded", "interactive", "complete"];
|
readyState = ["uninitialized", "loading", "loaded", "interactive", "complete"][aRequest.readyState()];
|
||||||
|
|
||||||
if (readyStates[aRequest.readyState()] === "complete")
|
eventDispatcher.dispatchEvent({ type:readyState, request:aRequest});
|
||||||
|
|
||||||
|
if (readyState === "complete")
|
||||||
{
|
{
|
||||||
var status = "HTTP" + aRequest.status();
|
var status = "HTTP" + aRequest.status();
|
||||||
|
|
||||||
eventDispatcher.dispatchEvent({ type:status, request:aRequest });
|
eventDispatcher.dispatchEvent({ type:status, request:aRequest });
|
||||||
|
|
||||||
var result = aRequest.success() ? "success" : "failure";
|
var result = aRequest.success() ? "success" : "failure";
|
||||||
eventDispatcher.dispatchEvent({ type:result, request:aRequest });
|
|
||||||
|
|
||||||
eventDispatcher.dispatchEvent({ type:readyStates[aRequest.readyState()], request:aRequest});
|
eventDispatcher.dispatchEvent({ type:result, request:aRequest });
|
||||||
}
|
}
|
||||||
else
|
|
||||||
eventDispatcher.dispatchEvent({ type:readyStates[aRequest.readyState()], request:aRequest});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function FileRequest(/*CFURL*/ aURL, onsuccess, onfailure)
|
function FileRequest(/*CFURL*/ aURL, onsuccess, onfailure)
|
||||||
|
|||||||
@@ -91,16 +91,6 @@ CFPropertyList.writePropertyListToFile = function(/*CFPropertyList*/ aPropertyLi
|
|||||||
{
|
{
|
||||||
return FILE.write(aFilePath, CFPropertyList.stringFromPropertyList(aPropertyList, aFormat), { charset:"UTF-8" });
|
return FILE.write(aFilePath, CFPropertyList.stringFromPropertyList(aPropertyList, aFormat), { charset:"UTF-8" });
|
||||||
}
|
}
|
||||||
CFPropertyList.modifyPlist = function(/*String*/ aFilePath, /*Function*/ aCallback, /*String*/ aFormat)
|
|
||||||
{
|
|
||||||
var string = FILE.read(aFilePath, { charset:"UTF-8" });
|
|
||||||
var format = CFPropertyList.sniffedFormatOfString(string);
|
|
||||||
var plist = CFPropertyList.propertyListFromString(string, format);
|
|
||||||
|
|
||||||
aCallback(plist);
|
|
||||||
|
|
||||||
CFPropertyList.writePropertyListToFile(plist, aFilePath, aFormat || format);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
function serializePropertyList(/*CFPropertyList*/ aPropertyList, /*Object*/ serializers)
|
function serializePropertyList(/*CFPropertyList*/ aPropertyList, /*Object*/ serializers)
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ GLOBAL(CFURL) = function(/*CFURL|String*/ aURL, /*CFURL*/ aBaseURL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._UID = objj_generateObjectUID();
|
this._UID = objj_generateObjectUID();
|
||||||
|
this._retainCount = 1;
|
||||||
|
OBJJ_MEMORY_TABLE[this._UID] = this;
|
||||||
|
|
||||||
this._string = aURL;
|
this._string = aURL;
|
||||||
this._baseURL = aBaseURL;
|
this._baseURL = aBaseURL;
|
||||||
|
|||||||
@@ -182,11 +182,5 @@ exports.fullVersionString = function() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.ObjectiveJ = {};
|
|
||||||
|
|
||||||
for (key in exports)
|
|
||||||
if (Object.prototype.hasOwnProperty.call(exports, key))
|
|
||||||
global.ObjectiveJ[key] = exports[key];
|
|
||||||
|
|
||||||
if (require.main == module.id)
|
if (require.main == module.id)
|
||||||
exports.run(system.args);
|
exports.run(system.args);
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
|
|
||||||
var FILE = require("file");
|
|
||||||
var MD5 = require("md5");
|
|
||||||
|
|
||||||
var FileList = require("jake").FileList;
|
|
||||||
var BundleTask = require("objective-j/jake/bundletask").BundleTask;
|
|
||||||
|
|
||||||
exports.generateManifest = function(productPath, options)
|
|
||||||
{
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
indexFilePath = options.index || FILE.join(productPath, "index.html");
|
|
||||||
|
|
||||||
if (!FILE.isFile(indexFilePath)) {
|
|
||||||
print("Warning: Skipping cache manifest generation, no index file at "+indexFilePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = FILE.read(indexFilePath, { charset : "UTF-8" });
|
|
||||||
|
|
||||||
var manifestName = "app.manifest";
|
|
||||||
var manifestPath = FILE.join(productPath, manifestName);
|
|
||||||
var manifestAttribute = 'manifest="'+manifestName+'"';
|
|
||||||
|
|
||||||
print("Generating cache manifest: " + manifestPath);
|
|
||||||
|
|
||||||
var manifestOut = FILE.open(manifestPath, "w", { charset : "UTF-8" });
|
|
||||||
manifestOut.print("CACHE MANIFEST");
|
|
||||||
manifestOut.print("");
|
|
||||||
manifestOut.print("CACHE:");
|
|
||||||
|
|
||||||
var list = new FileList(FILE.join(productPath, "**", "*"));
|
|
||||||
list.exclude(manifestPath);
|
|
||||||
list.exclude("**/.DS_Store", "**/.htaccess");
|
|
||||||
list.exclude("**/LICENSE");
|
|
||||||
list.exclude("**/MHTML*");
|
|
||||||
list.exclude("**/CommonJS.environment/*");
|
|
||||||
list.exclude("**/*.cur"); // FIXME: sprite these?
|
|
||||||
|
|
||||||
// FIXME: bleh. heuristic for whether index file includes debug frameworks
|
|
||||||
if (index.indexOf('"Frameworks/Debug"') < 0)
|
|
||||||
list.exclude("**/Frameworks/Debug/*");
|
|
||||||
|
|
||||||
if (options.exclude)
|
|
||||||
options.exclude.forEach(list.exclude.bind(list));
|
|
||||||
|
|
||||||
list.forEach(function(path) {
|
|
||||||
if (FILE.isFile(path)) {
|
|
||||||
var relative = FILE.relative(productPath, path);
|
|
||||||
|
|
||||||
// FIXME: check the actual sprited images file
|
|
||||||
// check index for references to file (for spinner.gif, etc)
|
|
||||||
if (BundleTask.isSpritable(path) && index.indexOf(relative) < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// include hash of each file in comments to expire when any file changes
|
|
||||||
var hash = MD5.hash(FILE.read(path, "b")).decodeToString("base16");
|
|
||||||
manifestOut.print("# " + hash);
|
|
||||||
manifestOut.print(relative);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
manifestOut.print("");
|
|
||||||
manifestOut.print("NETWORK:");
|
|
||||||
manifestOut.print("*");
|
|
||||||
manifestOut.close();
|
|
||||||
|
|
||||||
// Insert "manifest" attribute in <html> tag of index file
|
|
||||||
var matchTag = index.match(/<html[^>]*>/i);
|
|
||||||
if (matchTag) {
|
|
||||||
var htmlTag = matchTag[0];
|
|
||||||
var newHTMLTag = null;
|
|
||||||
|
|
||||||
var matchAttr = htmlTag.match(/manifest\s*=\s*"([^"]*)"/i);
|
|
||||||
if (matchAttr) {
|
|
||||||
if (matchAttr[1] !== manifestName) {
|
|
||||||
newHTMLTag = htmlTag.replace(matchAttr[0], manifestAttribute);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newHTMLTag = htmlTag.replace(/>$/, " "+manifestAttribute+">");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newHTMLTag) {
|
|
||||||
print("Replacing html tag: \n " + htmlTag + "\nwith:\n " + newHTMLTag);
|
|
||||||
var newIndex = index.replace(htmlTag, newHTMLTag);
|
|
||||||
if (newIndex === index) {
|
|
||||||
print("Warning: No change!");
|
|
||||||
} else {
|
|
||||||
FILE.write(indexFilePath, newIndex, { charset : "UTF-8" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print("Warning: Couldn't find <html> tag in "+indexFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Content-Type "text/cache-manifest" for manifest file to .htaccess
|
|
||||||
// This allows manifests to work out of the box on Apache (if htaccess overrides are allowed)
|
|
||||||
var htaccessPath = FILE.join(productPath, ".htaccess");
|
|
||||||
var htaccess = FILE.isFile(htaccessPath) ? FILE.read(htaccessPath, { charset : "UTF-8" }) : "";
|
|
||||||
|
|
||||||
var htaccessOut = FILE.open(htaccessPath, "w", { charset : "UTF-8" });
|
|
||||||
htaccessOut.print(htaccess);
|
|
||||||
|
|
||||||
var openTag = "<Files "+manifestName+">";
|
|
||||||
if (htaccess.indexOf(openTag) < 0) {
|
|
||||||
htaccessOut.print("");
|
|
||||||
htaccessOut.print(openTag);
|
|
||||||
htaccessOut.print("\tHeader set Content-Type text/cache-manifest");
|
|
||||||
htaccessOut.print("</Files>");
|
|
||||||
}
|
|
||||||
htaccessOut.close();
|
|
||||||
}
|
|
||||||
@@ -17,8 +17,6 @@ function ApplicationTask(aName)
|
|||||||
this._frameworksPath = "Frameworks";
|
this._frameworksPath = "Frameworks";
|
||||||
else
|
else
|
||||||
this._frameworksPath = null;
|
this._frameworksPath = null;
|
||||||
|
|
||||||
this._shouldGenerateCacheManifest = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationTask.__proto__ = BundleTask;
|
ApplicationTask.__proto__ = BundleTask;
|
||||||
@@ -35,7 +33,6 @@ ApplicationTask.prototype.defineTasks = function()
|
|||||||
|
|
||||||
this.defineFrameworksTask();
|
this.defineFrameworksTask();
|
||||||
this.defineIndexFileTask();
|
this.defineIndexFileTask();
|
||||||
this.defineCacheManifestTask();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationTask.prototype.setIndexFilePath = function(aFilePath)
|
ApplicationTask.prototype.setIndexFilePath = function(aFilePath)
|
||||||
@@ -62,16 +59,6 @@ ApplicationTask.prototype.frameworksPath = function()
|
|||||||
return this._frameworksPath;
|
return this._frameworksPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationTask.prototype.setShouldGenerateCacheManifest = function(shouldGenerateCacheManifest)
|
|
||||||
{
|
|
||||||
this._shouldGenerateCacheManifest = shouldGenerateCacheManifest;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationTask.prototype.shouldGenerateCacheManifest = function()
|
|
||||||
{
|
|
||||||
return this._shouldGenerateCacheManifest;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationTask.prototype.defineFrameworksTask = function()
|
ApplicationTask.prototype.defineFrameworksTask = function()
|
||||||
{
|
{
|
||||||
// FIXME: platform requires...
|
// FIXME: platform requires...
|
||||||
@@ -85,7 +72,7 @@ ApplicationTask.prototype.defineFrameworksTask = function()
|
|||||||
Jake.fileCreate(newFrameworks, function()
|
Jake.fileCreate(newFrameworks, function()
|
||||||
{
|
{
|
||||||
if (thisTask._frameworksPath === "capp")
|
if (thisTask._frameworksPath === "capp")
|
||||||
OS.system(["capp", "gen", "-f", "--force", buildPath]);
|
OS.system("capp gen -f --force " + buildPath);
|
||||||
else if (thisTask._frameworksPath)
|
else if (thisTask._frameworksPath)
|
||||||
{
|
{
|
||||||
if (FILE.exists(newFrameworks))
|
if (FILE.exists(newFrameworks))
|
||||||
@@ -119,23 +106,6 @@ ApplicationTask.prototype.defineIndexFileTask = function()
|
|||||||
this.enhance([buildIndexFilePath]);
|
this.enhance([buildIndexFilePath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationTask.prototype.defineCacheManifestTask = function()
|
|
||||||
{
|
|
||||||
if (!this.shouldGenerateCacheManifest())
|
|
||||||
return;
|
|
||||||
|
|
||||||
var productPath = FILE.join(this.buildProductPath(), "");
|
|
||||||
var indexFilePath = this.buildIndexFilePath();
|
|
||||||
|
|
||||||
// TODO: can we conditionally generate based on outdated files?
|
|
||||||
var manifestPath = FILE.join(productPath, "app.manifest");
|
|
||||||
Jake.task(manifestPath, function() {
|
|
||||||
require("../cache-manifest").generateManifest(productPath, { index : indexFilePath });
|
|
||||||
});
|
|
||||||
|
|
||||||
this.enhance([manifestPath]);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.ApplicationTask = ApplicationTask;
|
exports.ApplicationTask = ApplicationTask;
|
||||||
|
|
||||||
exports.app = function(aName, aFunction)
|
exports.app = function(aName, aFunction)
|
||||||
|
|||||||
@@ -451,16 +451,10 @@ BundleTask.prototype.resourcesPath = function()
|
|||||||
return FILE.join(this.buildProductPath(), "Resources", "");
|
return FILE.join(this.buildProductPath(), "Resources", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't sprite images larger than 32KB, IE 8 doesn't like it.
|
|
||||||
BundleTask.isSpritable = function(aResourcePath) {
|
|
||||||
return isImage(aResourcePath) && FILE.size(aResourcePath) < 32768 &&
|
|
||||||
("data:" + mimeType(aResourcePath) + ";base64," +
|
|
||||||
base64.encode(FILE.read(aResourcePath, "b"))).length < 32768;
|
|
||||||
}
|
|
||||||
|
|
||||||
BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPath)
|
BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPath)
|
||||||
{
|
{
|
||||||
if (this.spritesResources() && BundleTask.isSpritable(aResourcePath))
|
// Don't sprite images larger than 32KB, IE 8 doesn't like it.
|
||||||
|
if (this.spritesResources() && isImage(aResourcePath) && FILE.size(aResourcePath) < 32768)
|
||||||
{
|
{
|
||||||
this.environments().forEach(function(/*Environment*/ anEnvironment)
|
this.environments().forEach(function(/*Environment*/ anEnvironment)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,3 +73,8 @@ GLOBAL(PI_2) = Math.PI / 2.0;
|
|||||||
|
|
||||||
GLOBAL(SQRT1_2) = Math.SQRT1_2;
|
GLOBAL(SQRT1_2) = Math.SQRT1_2;
|
||||||
GLOBAL(SQRT2) = Math.SQRT2;
|
GLOBAL(SQRT2) = Math.SQRT2;
|
||||||
|
|
||||||
|
GLOBAL(OBJJ_MEMORY_TABLE) = [];
|
||||||
|
|
||||||
|
GLOBAL($) = function(pointer) { return OBJJ_MEMORY_TABLE[pointer]; }
|
||||||
|
GLOBAL($$) = function(object) { return object._UID; }
|
||||||
|
|||||||
@@ -20,9 +20,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef BROWSER
|
|
||||||
CPLogRegister(CPLogDefault);
|
CPLogRegister(CPLogDefault);
|
||||||
#endif
|
|
||||||
|
|
||||||
// formatting helpers
|
// formatting helpers
|
||||||
|
|
||||||
@@ -219,3 +217,6 @@ GLOBAL(objj_debug_typecheck) = function(expectedType, object)
|
|||||||
|
|
||||||
throw ("expected=" + expectedType + ", actual=" + actualType);
|
throw ("expected=" + expectedType + ", actual=" + actualType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof window.OBJJ_ZOMBIE_DETECTION === "undefined")
|
||||||
|
OBJJ_ZOMBIE_DETECTION = false;
|
||||||
|
|||||||
+1
-100
@@ -35,11 +35,7 @@ function Executable(/*String*/ aCode, /*Array*/ fileDependencies, /*CFURL|String
|
|||||||
this._function = aFunction || NULL;
|
this._function = aFunction || NULL;
|
||||||
this._URL = makeAbsoluteURL(aURL || new CFURL("(Anonymous" + (AnonymousExecutableCount++) + ")"));
|
this._URL = makeAbsoluteURL(aURL || new CFURL("(Anonymous" + (AnonymousExecutableCount++) + ")"));
|
||||||
|
|
||||||
this._fileDependencies = fileDependencies || [];
|
this._fileDependencies = fileDependencies;
|
||||||
|
|
||||||
#ifndef COMMONJS
|
|
||||||
this._fileDependencies.push.apply(this._fileDependencies, parseRequireFileDependencies(aCode));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fileDependencies.length)
|
if (fileDependencies.length)
|
||||||
{
|
{
|
||||||
@@ -57,23 +53,6 @@ function Executable(/*String*/ aCode, /*Array*/ fileDependencies, /*CFURL|String
|
|||||||
|
|
||||||
exports.Executable = Executable;
|
exports.Executable = Executable;
|
||||||
|
|
||||||
function parseRequireFileDependencies(aCode)
|
|
||||||
{
|
|
||||||
var dependencies = [];
|
|
||||||
if (aCode)
|
|
||||||
{
|
|
||||||
var pattern = /(?:^|[^\w.])require\s*\(\s*["']([^"']+)["']\s*\)/g;
|
|
||||||
while (match = pattern.exec(aCode))
|
|
||||||
{
|
|
||||||
var id = match[1];
|
|
||||||
if (!(/\.[^\/]+$/).test(id))
|
|
||||||
id += ".js";
|
|
||||||
dependencies.push(new FileDependency(new CFURL(id), (/^[.\/]/).test(id)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
Executable.prototype.path = function()
|
Executable.prototype.path = function()
|
||||||
{
|
{
|
||||||
return this.URL().path();
|
return this.URL().path();
|
||||||
@@ -94,8 +73,6 @@ Executable.prototype.functionParameters = function()
|
|||||||
|
|
||||||
#ifdef COMMONJS
|
#ifdef COMMONJS
|
||||||
functionParameters = functionParameters.concat("require", "exports", "module", "system", "print", "window");
|
functionParameters = functionParameters.concat("require", "exports", "module", "system", "print", "window");
|
||||||
#else
|
|
||||||
functionParameters = functionParameters.concat("require", "exports", "module");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return functionParameters;
|
return functionParameters;
|
||||||
@@ -109,65 +86,11 @@ Executable.prototype.functionArguments = function()
|
|||||||
|
|
||||||
#ifdef COMMONJS
|
#ifdef COMMONJS
|
||||||
functionArguments = functionArguments.concat(Executable.commonJSArguments());
|
functionArguments = functionArguments.concat(Executable.commonJSArguments());
|
||||||
#else
|
|
||||||
functionArguments = functionArguments.concat(this.getCommonJSRequire(), this.getCommonJSExports(), this.getCommonJSModule());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return functionArguments;
|
return functionArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Executable.prototype.getCommonJSRequire = function()
|
|
||||||
{
|
|
||||||
if (!this._commonJSRequire)
|
|
||||||
{
|
|
||||||
var executor = this.fileExecuter();
|
|
||||||
var importer = this.fileImporter();
|
|
||||||
|
|
||||||
var req = function(id)
|
|
||||||
{
|
|
||||||
if (!(/\.[^\/]+$/).test(id))
|
|
||||||
id += ".js";
|
|
||||||
|
|
||||||
return executor(id, (id.charAt(0) === "." || id.charAt(0) === "/"), NO);
|
|
||||||
}
|
|
||||||
req.async = function(id, callback) {
|
|
||||||
if (!(/\.[^\/]+$/).test(id))
|
|
||||||
id += ".js";
|
|
||||||
|
|
||||||
importer(id, (id.charAt(0) === "." || id.charAt(0) === "/"), function() {
|
|
||||||
callback(req(id));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
req.paths = OBJJ_INCLUDE_PATHS;
|
|
||||||
this._commonJSRequire = req;
|
|
||||||
}
|
|
||||||
return this._commonJSRequire;
|
|
||||||
}
|
|
||||||
|
|
||||||
Executable.prototype.getCommonJSExports = function()
|
|
||||||
{
|
|
||||||
if (!this._commonJSExports)
|
|
||||||
this._commonJSExports = {};
|
|
||||||
return this._commonJSExports;
|
|
||||||
}
|
|
||||||
|
|
||||||
Executable.prototype.setCommonJSExports = function(commonJSExports)
|
|
||||||
{
|
|
||||||
if (this._commonJSExports)
|
|
||||||
throw "CommonJS exports for " + this.URL() + " already set.";
|
|
||||||
this._commonJSExports = commonJSExports;
|
|
||||||
}
|
|
||||||
|
|
||||||
Executable.prototype.getCommonJSModule = function()
|
|
||||||
{
|
|
||||||
if (!this._commonJSModule)
|
|
||||||
this._commonJSModule = {
|
|
||||||
path : this.path(),
|
|
||||||
url : this.URL().toString()
|
|
||||||
};
|
|
||||||
return this._commonJSModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY_NAME(Executable.prototype.functionArguments);
|
DISPLAY_NAME(Executable.prototype.functionArguments);
|
||||||
|
|
||||||
#ifdef COMMONJS
|
#ifdef COMMONJS
|
||||||
@@ -427,36 +350,14 @@ Executable.fileExecuterForURL = function(/*CFURL|String*/ aURL)
|
|||||||
{
|
{
|
||||||
cachedFileExecuter = function(/*CFURL*/ aURL, /*BOOL*/ isQuoted, /*BOOL*/ shouldForce)
|
cachedFileExecuter = function(/*CFURL*/ aURL, /*BOOL*/ isQuoted, /*BOOL*/ shouldForce)
|
||||||
{
|
{
|
||||||
// CommonJS "exports" support:
|
|
||||||
// this is a little hacky. we use the internaly created "exports" if it executes synchronously,
|
|
||||||
// otherwise we have to create our own exports object that we can return immediately
|
|
||||||
// then set it on the executable right before it is eventually executed.
|
|
||||||
var commonJSExports = {},
|
|
||||||
hasSetExports = false,
|
|
||||||
hasReturnedExports = false;
|
|
||||||
|
|
||||||
Executable.fileExecutableSearcherForURL(referenceURL)(aURL, isQuoted,
|
Executable.fileExecutableSearcherForURL(referenceURL)(aURL, isQuoted,
|
||||||
function(/*FileExecutable*/ aFileExecutable)
|
function(/*FileExecutable*/ aFileExecutable)
|
||||||
{
|
{
|
||||||
if (!aFileExecutable.hasLoadedFileDependencies())
|
if (!aFileExecutable.hasLoadedFileDependencies())
|
||||||
throw "No executable loaded for file at URL " + aURL;
|
throw "No executable loaded for file at URL " + aURL;
|
||||||
|
|
||||||
if (hasReturnedExports && !hasSetExports)
|
|
||||||
{
|
|
||||||
aFileExecutable.setCommonJSExports(commonJSExports);
|
|
||||||
hasSetExports = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
aFileExecutable.execute(shouldForce);
|
aFileExecutable.execute(shouldForce);
|
||||||
|
|
||||||
if (!hasReturnedExports)
|
|
||||||
{
|
|
||||||
commonJSExports = aFileExecutable.getCommonJSExports();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
hasReturnedExports = true;
|
|
||||||
return commonJSExports;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedFileExecuters[referenceURLString] = cachedFileExecuter;
|
cachedFileExecuters[referenceURLString] = cachedFileExecuter;
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ var TOKEN_ACCESSORS = "accessors",
|
|||||||
TOKEN_SUPER = "super",
|
TOKEN_SUPER = "super",
|
||||||
TOKEN_VAR = "var",
|
TOKEN_VAR = "var",
|
||||||
TOKEN_IN = "in",
|
TOKEN_IN = "in",
|
||||||
TOKEN_PRAGMA = "pragma",
|
|
||||||
TOKEN_MARK = "mark",
|
|
||||||
|
|
||||||
TOKEN_EQUAL = '=',
|
TOKEN_EQUAL = '=',
|
||||||
TOKEN_PLUS = '+',
|
TOKEN_PLUS = '+',
|
||||||
@@ -52,7 +50,6 @@ var TOKEN_ACCESSORS = "accessors",
|
|||||||
TOKEN_OPEN_BRACKET = '[',
|
TOKEN_OPEN_BRACKET = '[',
|
||||||
TOKEN_DOUBLE_QUOTE = '"',
|
TOKEN_DOUBLE_QUOTE = '"',
|
||||||
TOKEN_PREPROCESSOR = '@',
|
TOKEN_PREPROCESSOR = '@',
|
||||||
TOKEN_HASH = '#',
|
|
||||||
TOKEN_CLOSE_BRACKET = ']',
|
TOKEN_CLOSE_BRACKET = ']',
|
||||||
TOKEN_QUESTION_MARK = '?',
|
TOKEN_QUESTION_MARK = '?',
|
||||||
TOKEN_OPEN_PARENTHESIS = '(',
|
TOKEN_OPEN_PARENTHESIS = '(',
|
||||||
@@ -366,29 +363,6 @@ Preprocessor.prototype.directive = function(tokens, aStringBuffer, allowedDirect
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preprocessor.prototype.hash = function(tokens, aStringBuffer)
|
|
||||||
{
|
|
||||||
// Grab the next token, C preprocessor directives follow '#' immediately.
|
|
||||||
var buffer = aStringBuffer ? aStringBuffer : new StringBuffer(),
|
|
||||||
token = tokens.next();
|
|
||||||
|
|
||||||
// #pragma (C Preprocessor directive)
|
|
||||||
if (token === TOKEN_PRAGMA)
|
|
||||||
{
|
|
||||||
token = tokens.skip_whitespace();
|
|
||||||
|
|
||||||
// '#pragma mark' directive is used in Xcode editor for creating labels,
|
|
||||||
// which is irrelevant to Cappuccino - just swallow this line
|
|
||||||
if (token === TOKEN_MARK)
|
|
||||||
{
|
|
||||||
while ((token = tokens.next()).indexOf("\n") < 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if not a #pragma directive, it should not be processed here
|
|
||||||
else
|
|
||||||
throw new SyntaxError(this.error_message("*** Expected \"pragma\" to follow # but instead saw \"" + token + "\"."));
|
|
||||||
}
|
|
||||||
|
|
||||||
Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStringBuffer)
|
Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStringBuffer)
|
||||||
{
|
{
|
||||||
var buffer = aStringBuffer,
|
var buffer = aStringBuffer,
|
||||||
@@ -568,11 +542,6 @@ Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStrin
|
|||||||
|
|
||||||
CONCAT(instance_methods, this.method(tokens, ivar_names));
|
CONCAT(instance_methods, this.method(tokens, ivar_names));
|
||||||
}
|
}
|
||||||
// If we reach a # symbol, we may be at a C preprocessor directive.
|
|
||||||
else if (token == TOKEN_HASH)
|
|
||||||
{
|
|
||||||
this.hash(tokens, buffer);
|
|
||||||
}
|
|
||||||
// Check if we've reached @end...
|
// Check if we've reached @end...
|
||||||
else if (token == TOKEN_PREPROCESSOR)
|
else if (token == TOKEN_PREPROCESSOR)
|
||||||
{
|
{
|
||||||
@@ -927,10 +896,6 @@ Preprocessor.prototype.preprocess = function(tokens, /*StringBuffer*/ aStringBuf
|
|||||||
// If we reach an @ symbol, we are at a preprocessor directive.
|
// If we reach an @ symbol, we are at a preprocessor directive.
|
||||||
else if (token == TOKEN_PREPROCESSOR)
|
else if (token == TOKEN_PREPROCESSOR)
|
||||||
this.directive(tokens, buffer);
|
this.directive(tokens, buffer);
|
||||||
|
|
||||||
// If we reach a # symbol, we may be at a C preprocessor directive.
|
|
||||||
else if (token == TOKEN_HASH)
|
|
||||||
this.hash(tokens, buffer);
|
|
||||||
|
|
||||||
// If we reach a bracket, we will either be preprocessing a message send, a literal
|
// If we reach a bracket, we will either be preprocessing a message send, a literal
|
||||||
// array, or an array index.
|
// array, or an array index.
|
||||||
|
|||||||
@@ -392,6 +392,8 @@ GLOBAL(class_createInstance) = function(/*Class*/ aClass)
|
|||||||
|
|
||||||
object.isa = aClass;
|
object.isa = aClass;
|
||||||
object._UID = objj_generateObjectUID();
|
object._UID = objj_generateObjectUID();
|
||||||
|
object._retainCount = 1;
|
||||||
|
OBJJ_MEMORY_TABLE[object._UID] = object;
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@@ -514,6 +516,9 @@ GLOBAL(objj_msgSend) = function(/*id*/ aReceiver, /*SEL*/ aSelector)
|
|||||||
if (aReceiver == nil)
|
if (aReceiver == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
|
if (OBJJ_ZOMBIE_DETECTION && typeof aReceiver._retainCount !== "undefined" && aReceiver._retainCount < 1 && $($$(aReceiver)) !== aReceiver)
|
||||||
|
throw ("Sending a message to a zombie object: "+$$(aReceiver));
|
||||||
|
|
||||||
var isa = aReceiver.isa;
|
var isa = aReceiver.isa;
|
||||||
|
|
||||||
CLASS_GET_METHOD_IMPLEMENTATION(var implementation, isa, aSelector);
|
CLASS_GET_METHOD_IMPLEMENTATION(var implementation, isa, aSelector);
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
- (void)testsInsertObjectsAtIndexes
|
- (void)testsInsertObjectsAtIndexes
|
||||||
{
|
{
|
||||||
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four"],
|
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four", nil],
|
||||||
newAdditions = [CPArray arrayWithObjects:@"a", @"b"],
|
newAdditions = [CPArray arrayWithObjects:@"a", @"b", nil],
|
||||||
indexes = [CPMutableIndexSet indexSetWithIndex:1];
|
indexes = [CPMutableIndexSet indexSetWithIndex:1];
|
||||||
|
|
||||||
[indexes addIndex:3];
|
[indexes addIndex:3];
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
[self assert:array equals:[@"one", @"a", @"two", @"b", @"three", @"four"]];
|
[self assert:array equals:[@"one", @"a", @"two", @"b", @"three", @"four"]];
|
||||||
|
|
||||||
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four"],
|
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four", nil],
|
||||||
newAdditions = [CPArray arrayWithObjects:@"a", @"b"],
|
newAdditions = [CPArray arrayWithObjects:@"a", @"b", nil],
|
||||||
indexes = [CPMutableIndexSet indexSetWithIndex:5];
|
indexes = [CPMutableIndexSet indexSetWithIndex:5];
|
||||||
|
|
||||||
[indexes addIndex:4];
|
[indexes addIndex:4];
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
|
|
||||||
[self assert:array equals:[@"one", @"two", @"three", @"four", @"a", @"b"]];
|
[self assert:array equals:[@"one", @"two", @"three", @"four", @"a", @"b"]];
|
||||||
|
|
||||||
var array = [CPMutableArray arrayWithObjects: @"one", @"two", @"three", @"four"],
|
var array = [CPMutableArray arrayWithObjects: @"one", @"two", @"three", @"four", nil],
|
||||||
newAdditions = [CPArray arrayWithObjects: @"a", @"b", @"c"],
|
newAdditions = [CPArray arrayWithObjects: @"a", @"b", @"c", nil],
|
||||||
indexes = [CPMutableIndexSet indexSetWithIndex:1];
|
indexes = [CPMutableIndexSet indexSetWithIndex:1];
|
||||||
|
|
||||||
[indexes addIndex:2];
|
[indexes addIndex:2];
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
[self assert:array equals:[@"one", @"a", @"b", @"two", @"c", @"three", @"four"]];
|
[self assert:array equals:[@"one", @"a", @"b", @"two", @"c", @"three", @"four"]];
|
||||||
|
|
||||||
|
|
||||||
var array = [CPMutableArray arrayWithObjects: @"one", @"two", @"three", @"four"],
|
var array = [CPMutableArray arrayWithObjects: @"one", @"two", @"three", @"four", nil],
|
||||||
newAdditions = [CPArray arrayWithObjects: @"a", @"b", @"c"],
|
newAdditions = [CPArray arrayWithObjects: @"a", @"b", @"c", nil],
|
||||||
indexes = [CPMutableIndexSet indexSetWithIndex:1];
|
indexes = [CPMutableIndexSet indexSetWithIndex:1];
|
||||||
|
|
||||||
[indexes addIndex:2];
|
[indexes addIndex:2];
|
||||||
@@ -64,9 +64,10 @@
|
|||||||
|
|
||||||
[self assert:array equals:[@"one", @"a", @"b", @"two", @"three", @"four", @"c"]];
|
[self assert:array equals:[@"one", @"a", @"b", @"two", @"three", @"four", @"c"]];
|
||||||
|
|
||||||
|
//
|
||||||
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four"],
|
|
||||||
newAdditions = [CPArray arrayWithObjects:@"a", @"b"],
|
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four", nil],
|
||||||
|
newAdditions = [CPArray arrayWithObjects:@"a", @"b", nil],
|
||||||
indexes = [CPMutableIndexSet indexSetWithIndex:5];
|
indexes = [CPMutableIndexSet indexSetWithIndex:5];
|
||||||
|
|
||||||
[indexes addIndex:6];
|
[indexes addIndex:6];
|
||||||
@@ -87,10 +88,10 @@
|
|||||||
{
|
{
|
||||||
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four", nil],
|
var array = [CPMutableArray arrayWithObjects:@"one", @"two", @"three", @"four", nil],
|
||||||
indexes = [CPMutableIndexSet indexSetWithIndex: 2];
|
indexes = [CPMutableIndexSet indexSetWithIndex: 2];
|
||||||
|
|
||||||
[array removeObjectsAtIndexes: indexes];
|
[array removeObjectsAtIndexes: indexes];
|
||||||
|
|
||||||
[self assert:array equals:[@"one", @"two", @"four", nil]];
|
[self assert:array equals:[@"one", @"two", @"four"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testIndexOfObjectSortedByFunction
|
- (void)testIndexOfObjectSortedByFunction
|
||||||
@@ -154,82 +155,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testInsertObjectInArraySortedByDescriptors
|
|
||||||
{
|
|
||||||
var descriptors = [[[CPSortDescriptor alloc] initWithKey:@"intValue" ascending:YES]];
|
|
||||||
var array = [1, 3, 5];
|
|
||||||
|
|
||||||
[array insertObject: 0 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[0, 1, 3, 5] equals:array];
|
|
||||||
|
|
||||||
array = [1, 3, 5];
|
|
||||||
[array insertObject: 2 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[1, 2, 3, 5] equals:array];
|
|
||||||
|
|
||||||
array = [1, 3, 5];
|
|
||||||
[array insertObject: 1 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[1, 1, 3, 5] equals:array];
|
|
||||||
|
|
||||||
array = [1, 3, 5];
|
|
||||||
[array insertObject: 6 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[1, 3, 5, 6] equals:array];
|
|
||||||
|
|
||||||
array = [1, 3, 5];
|
|
||||||
[array insertObject: 3 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[1, 3, 3, 5] equals:array];
|
|
||||||
|
|
||||||
array = [];
|
|
||||||
[array insertObject: 3 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[3] equals:array];
|
|
||||||
|
|
||||||
descriptors = [[[CPSortDescriptor alloc] initWithKey:@"intValue" ascending:NO]];
|
|
||||||
|
|
||||||
array = [5, 3, 1];
|
|
||||||
[array insertObject: 0 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[5, 3, 1, 0] equals:array];
|
|
||||||
|
|
||||||
array = [5, 3, 1];
|
|
||||||
[array insertObject: 2 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[5, 3, 2, 1] equals:array];
|
|
||||||
|
|
||||||
array = [5, 3, 1];
|
|
||||||
[array insertObject: 1 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[5, 3, 1, 1] equals:array];
|
|
||||||
|
|
||||||
array = [5, 3, 1];
|
|
||||||
[array insertObject: 6 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[6, 5, 3, 1] equals:array];
|
|
||||||
|
|
||||||
array = [5, 3, 1];
|
|
||||||
[array insertObject: 3 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[5, 3, 3, 1] equals:array];
|
|
||||||
|
|
||||||
array = [];
|
|
||||||
[array insertObject: 3 inArraySortedByDescriptors:descriptors];
|
|
||||||
[self assert:[3] equals:array];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)testInitWithArrayCopyItems
|
- (void)testInitWithArrayCopyItems
|
||||||
{
|
{
|
||||||
var a = [[CopyableObject new], 2, 3, {empty:true}];
|
var a = [[CopyableObject new], 2, 3];
|
||||||
var b = [[CPArray alloc] initWithArray:a copyItems:YES];
|
var b = [[CPArray alloc] initWithArray:a copyItems:YES];
|
||||||
|
|
||||||
[self assert:a notEqual:b];
|
[self assert:a notEqual:b];
|
||||||
|
|
||||||
[self assert:a[0] notEqual:b[0]];
|
|
||||||
[self assert:a[1] equals:b[1]];
|
|
||||||
[self assert:a[2] equals:b[2]];
|
|
||||||
[self assertTrue:a[3] === b[3]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)testIsEqualToArray
|
|
||||||
{
|
|
||||||
var a = [1, 2, 3],
|
|
||||||
b = [5];
|
|
||||||
|
|
||||||
[self assertTrue:[a isEqualToArray:a]];
|
|
||||||
[self assertFalse:[a isEqualToArray:b]];
|
|
||||||
[self assertFalse:[a isEqualToArray:nil]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
@import <Foundation/CPNull.j>
|
|
||||||
@import <Foundation/CPKeyedArchiver.j>
|
|
||||||
@import <Foundation/CPKeyedUnarchiver.j>
|
|
||||||
|
|
||||||
@implementation CPNullTest : OJTestCase
|
|
||||||
|
|
||||||
- (void)testArchiving
|
|
||||||
{
|
|
||||||
[self assert:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:[CPNull null]]] equals:[CPNull null]];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -56,17 +56,4 @@
|
|||||||
[self assertFalse:[set containsObject:nil]];
|
[self assertFalse:[set containsObject:nil]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testDescription
|
|
||||||
{
|
|
||||||
[self assert:@"{()}" equals:[set description]];
|
|
||||||
[set addObject:"horizon"];
|
|
||||||
[set addObject:"surfer"];
|
|
||||||
[set addObject:"7"];
|
|
||||||
var desc = [set description];
|
|
||||||
// Ordering may not be guaranteed.
|
|
||||||
[self assertTrue:desc.match(new RegExp("{\(.*horizon.*\)}"))];
|
|
||||||
[self assertTrue:desc.match(new RegExp("{\(.*surfer.*\)}"))];
|
|
||||||
[self assertTrue:desc.match(new RegExp("{\(.*7.*\)}"))];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -29,16 +29,6 @@
|
|||||||
- (CPArray)children
|
- (CPArray)children
|
||||||
{
|
{
|
||||||
return [[Node withValue:1],
|
return [[Node withValue:1],
|
||||||
[Node withValue:2],
|
|
||||||
[Node withValue:3],
|
|
||||||
[Node withValue:2],
|
|
||||||
[Node withValue:3],
|
|
||||||
[Node withValue:2],
|
|
||||||
[Node withValue:3],
|
|
||||||
[Node withValue:2],
|
|
||||||
[Node withValue:3],
|
|
||||||
[Node withValue:2],
|
|
||||||
[Node withValue:3],
|
|
||||||
[Node withValue:2],
|
[Node withValue:2],
|
||||||
[Node withValue:3],
|
[Node withValue:3],
|
||||||
[Node withValue:4]];
|
[Node withValue:4]];
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../../../AppKit/CPBrowser.j
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>Test custom cursors with .cur images.</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/disappearingItemCursor.cur), default">disappearingItemCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/closedHandCursor.cur), default">closedHandCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/contextMenuCursor.cur), default">contextMenuCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/dragCopyCursor.cur), default">dragCopyCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/dragLinkCursor.cur), default">dragLinkCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/openHandCursor.cur), default">openHandCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeDownCursor.cur), default">resizeDownCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeLeftCursor.cur), default">resizeLeftCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeRightCursor.cur), default">resizeRightCursor</div>
|
|
||||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeUpCursor.cur), default">resizeUpCursor</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?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>CPApplicationDelegateClass</key>
|
|
||||||
<string>AppController</string>
|
|
||||||
<key>CPBundleName</key>
|
|
||||||
<string>TestApp</string>
|
|
||||||
<key>CPPrincipalClass</key>
|
|
||||||
<string>CPApplication</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -1,101 +0,0 @@
|
|||||||
<!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
|
|
||||||
TestApp
|
|
||||||
|
|
||||||
Created by You on May 11, 2010.
|
|
||||||
Copyright 2010, Your Company All rights reserved.
|
|
||||||
-->
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="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>TestApp</title>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
OBJJ_MAIN_FILE = "main.j";
|
|
||||||
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript" 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 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 TestApp...</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>
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<!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
|
|
||||||
TestApp
|
|
||||||
|
|
||||||
Created by You on May 11, 2010.
|
|
||||||
Copyright 2010, Your Company All rights reserved.
|
|
||||||
-->
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="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>TestApp</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 TestApp...</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>
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
exports.stdio = {
|
|
||||||
print : function() {
|
|
||||||
throw "shouldn't be using system.stdio.print"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* AppController.j
|
|
||||||
* TestApp
|
|
||||||
*
|
|
||||||
* Created by You on May 11, 2010.
|
|
||||||
* Copyright 2010, Your Company All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @import <Foundation/Foundation.j>
|
|
||||||
|
|
||||||
var url = window.location.toString();
|
|
||||||
var dir = url.substring(0, url.lastIndexOf("/"));
|
|
||||||
|
|
||||||
var testNames = [
|
|
||||||
"absolute",
|
|
||||||
"cyclic",
|
|
||||||
"determinism", // failing
|
|
||||||
"exactExports",
|
|
||||||
"hasOwnProperty", // failing
|
|
||||||
"method",
|
|
||||||
"missing", // failing
|
|
||||||
"monkeys",
|
|
||||||
"nested",
|
|
||||||
"relative",
|
|
||||||
"transitive"
|
|
||||||
];
|
|
||||||
|
|
||||||
// ObjectiveJ.asyncLoader = false;
|
|
||||||
|
|
||||||
print = function() {
|
|
||||||
test.logs.push(Array.prototype.join.apply(arguments, [","]));
|
|
||||||
console.warn.apply(console, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
var tests = [];
|
|
||||||
var test = { pass : true, logs : [] };
|
|
||||||
var pause = false;
|
|
||||||
|
|
||||||
function main(args, namedArgs)
|
|
||||||
{
|
|
||||||
var hash = window.location.hash.substring(1);
|
|
||||||
if (hash) {
|
|
||||||
tests = JSON.parse(decodeURIComponent(hash))
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = tests.length;
|
|
||||||
|
|
||||||
test.name = testNames[index];
|
|
||||||
|
|
||||||
function next() {
|
|
||||||
window.clearNativeTimeout(timeout);
|
|
||||||
|
|
||||||
tests.push(test);
|
|
||||||
if (index < testNames.length - 1) {
|
|
||||||
window.location.hash = "#" + encodeURIComponent(JSON.stringify(tests));
|
|
||||||
window.location.reload();
|
|
||||||
} else {
|
|
||||||
alert(tests.map(function(test) {
|
|
||||||
return test.logs.map(function(log) {
|
|
||||||
return test.name + ": " + log;
|
|
||||||
}).join("\n") + "\n" +
|
|
||||||
"== " + (test.pass ? "PASS" : "FAIL") + " ==\n";
|
|
||||||
}).join("\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var timeout = window.setNativeTimeout(function() {
|
|
||||||
test.pass = false;
|
|
||||||
if (pause) alert(test.name + ": timed out")
|
|
||||||
next();
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
try {
|
|
||||||
console.log("running: " + test.name);
|
|
||||||
|
|
||||||
var testDir = dir + "/tests/" + test.name;
|
|
||||||
require.paths.unshift(dir + "/lib", testDir);
|
|
||||||
require.async(testDir + "/program", function() {
|
|
||||||
if (pause) alert(test.name + ": completed");
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
test.pass = false;
|
|
||||||
print(test.name+ ": exception=" + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user