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

This commit is contained in:
Tom Robinson committed 2009-06-02 15:04:09 -07:00
commit 7c305c45fc
45 files changed
+399 -175

No files matched your search

+2
View File
@@ -505,10 +505,12 @@ var CPControlBlackColor = [CPColor blackColor];
}
#define BRIDGE(UPPERCASE, LOWERCASE, ATTRIBUTENAME) \
/*! Sets the value for ATTRIBUTENAME */\
- (void)set##UPPERCASE:(id)aValue\
{\
[self setValue:aValue forThemeAttribute:ATTRIBUTENAME];\
}\
/*! Returns the current value for ATTRIBUTENAME */\
- (id)LOWERCASE\
{\
return [self valueForThemeAttribute:ATTRIBUTENAME];\
+25 -1
View File
@@ -206,6 +206,7 @@ var _CPEventPeriodicEventPeriod = 0,
unsigned _clickCount;
float _pressure;
CPWindow _window;
Number _windowNumber;
CPString _characters;
CPString _charactersIgnoringModifiers
BOOL _isARepeat;
@@ -327,7 +328,7 @@ var _CPEventPeriodicEventPeriod = 0,
_charactersIgnoringModifiers = unmodCharacters;
_isARepeat = isARepeat;
_keyCode = code;
_window = [CPApp windowWithWindowNumber:aWindowNumber];
_windowNumber = aWindowNumber;
}
return self;
@@ -397,6 +398,9 @@ var _CPEventPeriodicEventPeriod = 0,
*/
- (CPWindow)window
{
if (!_window)
_window = [CPApp windowWithWindowNumber:_windowNumber];
return _window;
}
@@ -532,3 +536,23 @@ function _CPEventFirePeriodEvent()
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
}
var CPEventClass = [CPEvent class];
function _CPEventFromNativeMouseEvent(aNativeEvent, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, anEventNumber, aClickCount, aPressure)
{
aNativeEvent.isa = CPEventClass;
aNativeEvent._type = anEventType;
aNativeEvent._location = aPoint;
aNativeEvent._modifierFlags = modifierFlags;
aNativeEvent._timestamp = aTimestamp;
aNativeEvent._windowNumber = aWindowNumber;
aNativeEvent._window = nil;
aNativeEvent._context = aGraphicsContext;
aNativeEvent._eventNumber = anEventNumber;
aNativeEvent._clickCount = aClickCount;
aNativeEvent._pressure = aPressure;
return aNativeEvent;
}
+18 -25
View File
@@ -38,6 +38,8 @@
*/
@implementation CPMenuItem : CPObject
{
BOOL _isSeparator;
CPString _title;
//CPAttributedString _attributedTitle;
@@ -89,6 +91,8 @@
if (self)
{
_isSeparator = NO;
_title = aTitle;
_action = anAction;
@@ -479,7 +483,11 @@ CPOffState
*/
+ (CPMenuItem)separatorItem
{
return [[_CPMenuItemSeparator alloc] init];
var separatorItem = [[self alloc] initWithTitle:@"" action:nil keyEquivalent:nil];
separatorItem._isSeparator = YES;
return separatorItem;
}
/*!
@@ -487,7 +495,7 @@ CPOffState
*/
- (BOOL)isSeparatorItem
{
return NO;
return _isSeparator;
}
// Managing the Owning Menu
@@ -731,29 +739,9 @@ CPControlKeyMask
@end
/* @ignore */
@implementation _CPMenuItemSeparator : CPMenuItem
{
}
var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
- (id)init
{
self = [super initWithTitle:@"" action:nil keyEquivalent:nil];
if (self)
[self setEnabled:NO];
return self;
}
- (BOOL)isSeparatorItem
{
return YES;
}
@end
var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemTargetKey = @"CPMenuItemTargetKey",
CPMenuItemActionKey = @"CPMenuItemActionKey",
@@ -787,6 +775,8 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
if (self)
{
_isSeparator = [aCoder containsValueForKey:CPMenuItemIsSeparatorKey] && [aCoder decodeBoolForKey:CPMenuItemIsSeparatorKey];
_title = [aCoder decodeObjectForKey:CPMenuItemTitleKey];
// _font;
@@ -832,6 +822,9 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
if (_isSeparator)
[aCoder encodeBool:_isSeparator forKey:CPMenuItemIsSeparatorKey];
[aCoder encodeObject:_title forKey:CPMenuItemTitleKey];
[aCoder encodeObject:_target forKey:CPMenuItemTargetKey];
@@ -1195,7 +1188,7 @@ var _CPMenuItemSelectionColor = nil,
- (CPColor)textColor
{
return [_menuItem isEnabled] ? (_textColor ? _textColor : [CPColor colorWithCalibratedRed:70.0 / 255.0 green:69.0 / 255.0 blue:69.0 / 255.0 alpha:1.0]) : [CPColor darkGrayColor];
return [_menuItem isEnabled] ? (_textColor ? _textColor : [CPColor colorWithCalibratedRed:70.0 / 255.0 green:69.0 / 255.0 blue:69.0 / 255.0 alpha:1.0]) : [CPColor lightGrayColor];
}
- (void)setTextShadowColor:(CPColor)aColor
-2
View File
@@ -39,8 +39,6 @@ var SharedOpenPanel = nil;
- (unsigned)runModalForDirectory:(CPString)absoluteDirectoryPath file:(CPString)filename types:(CPArray)fileTypes
{
#if PLATFORM(DOM)
console.log("0 "+Titanium);
console.log("1 "+window.Titanium);
if (window.Titanium)
{
_files = Titanium.Desktop.openFiles({
+1
View File
@@ -39,6 +39,7 @@ CPHTMLPboardType = @"CPHTMLPboardType";
CPStringPboardType = @"CPStringPboardType";
CPURLPboardType = @"CPURLPboardType";
CPImagePboardType = @"CPImagePboardType";
CPVideoPboardType = @"CPVideoPboardType";
var CPPasteboards = nil;
+4 -4
View File
@@ -1208,7 +1208,7 @@ var DOMElementPrototype = nil,
amount = 0 - _DOMImageParts.length;
}
if (amount > 0)
while (amount--)
{
@@ -1236,16 +1236,16 @@ var DOMElementPrototype = nil,
else
{
var slices = [patternImage imageSlices],
count = slices.length,
count = MIN(_DOMImageParts.length, slices.length),
frameSize = _frame.size;
while (count--)
{
var image = slices[count],
size = _DOMImageSizes[count] = image ? [image size] : _CGSizeMakeZero();
CPDOMDisplayServerSetStyleSize(_DOMImageParts[count], size.width, size.height);
_DOMImageParts[count].style.background = image ? "url(\"" + [image filename] + "\")" : "";
}
+7 -1
View File
@@ -548,7 +548,9 @@ var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
*/
function CGContextAddEllipseInRect(aContext, aRect)
{
CGContextBeginPath(aContext);
CGContextAddPath(aContext, CGPathWithEllipseInRect(aRect));
CGContextClosePath(aContext);
}
/*!
@@ -658,7 +660,9 @@ function CGContextSetStrokeColor(aContext, aColor)
*/
function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
{
CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));
CGContextBeginPath(aContext);
CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));
CGContextClosePath(aContext);
CGContextFillPath(aContext);
}
@@ -675,7 +679,9 @@ function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, s
*/
function CGContextStrokeRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
{
CGContextBeginPath(aContext);
CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));
CGContextClosePath(aContext);
CGContextStrokePath(aContext);
}
+37 -20
View File
@@ -87,20 +87,20 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle,
var center = _CGPointMake(x, y),
end = _CGPointMake(COS(anEndAngle), SIN(anEndAngle)),
start = _CGPointMake(COS(aStartAngle), SIN(aStartAngle));
end = _CGPointApplyAffineTransform(end, aTransform);
start = _CGPointApplyAffineTransform(start, aTransform);
center = _CGPointApplyAffineTransform(center, aTransform);
x = center.x;
y = center.y;
var oldEndAngle = anEndAngle,
oldStartAngle = aStartAngle;
anEndAngle = ATAN2(end.y - aTransform.ty, end.x - aTransform.tx);
aStartAngle = ATAN2(start.y - aTransform.ty, start.x - aTransform.tx);
// Angles that equal "modulo" 2 pi return as equal after transforming them,
// so we have to make sure to make them different again if they were different
// to start out with. It's the difference between no circle and a full circle.
@@ -109,7 +109,7 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle,
anEndAngle = anEndAngle - PI2;
else
aStartAngle = aStartAngle - PI2;
aRadius = _CGSizeMake(aRadius, 0);
aRadius = _CGSizeApplyAffineTransform(aRadius, aTransform);
aRadius = SQRT(aRadius.width * aRadius.width + aRadius.height * aRadius.height);
@@ -169,23 +169,38 @@ function CGPathAddLineToPoint(aPath, aTransform, x, y)
function CGPathAddPath(aPath, aTransform, anotherPath)
{
var i = 0,
count = anotherPath.count;
for (; i < count; ++i)
for (var i = 0, count = anotherPath.count; i < count; ++i)
{
var element = anotherPath.elements[i];
aPath.elements[aPath.count] = { type:element.type, x:element.x, y:element.y,
cpx:element.cpx, cpy:element.cpy,
radius:element.radius, startAngle:element.startAngle, endAngle:element.endAngle,
cp1x:element.cp1x, cp1y:element.cp1y, cp2x:element.cp2x, cp2y:element.cp2y,
points: element.points ? element.points.slice() : nil};
aPath.count++
switch (element.type)
{
case kCGPathElementAddLineToPoint: CGPathAddLineToPoint(aPath, aTransform, element.x, element.y);
break;
case kCGPathElementAddCurveToPoint: CGPathAddCurveToPoint(aPath, aTransform,
element.cp1x, element.cp1y,
element.cp2x, element.cp2y,
element.x, element.y);
break;
case kCGPathElementAddArc: CGPathAddArc(aPath, aTransform, element.x, element.y,
element.radius, element.startAngle,
element.endAngle, element.isClockwise);
break;
case kCGPathElementAddQuadCurveToPoint: CGPathAddQuadCurveToPoint(aPath, aTransform,
element.cpx, element.cpy,
element.x, element.y);
break;
case kCGPathElementMoveToPoint: CGPathMoveToPoint(aPath, aTransform, element.x, element.y);
break;
case kCGPathElementCloseSubpath: CGPathCloseSubpath(aPath);
break;
}
}
aPath.current = anotherPath.current;
}
function CGPathAddQuadCurveToPoint(aPath, aTransform, cpx, cpy, x, y)
@@ -250,6 +265,8 @@ function CGPathMoveToPoint(aPath, aTransform, x, y)
aPath.elements[aPath.count++] = { type:kCGPathElementMoveToPoint, x:point.x, y:point.y };
}
var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
function CGPathWithEllipseInRect(aRect)
{
var path = CGPathCreateMutable();
+40 -24
View File
@@ -351,7 +351,7 @@ var CPDOMWindowGetFrame,
theWindow = candidateWindow;
}
}
return theWindow;
}
@@ -462,7 +462,7 @@ var CTRL_KEY_CODE = 17;
var theType = _overriddenEventType || aDOMEvent.type;
// IE's event order is down, up, up, dblclick, so we have create these events artificially.
if (theType == CPDOMEventDoubleClick)
if (theType === CPDOMEventDoubleClick)
{
_overriddenEventType = CPDOMEventMouseDown;
[self _bridgeMouseEvent:aDOMEvent];
@@ -474,9 +474,11 @@ var CTRL_KEY_CODE = 17;
return;
}
#ifndef DEBUG
try
{
{
#endif
var event,
location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY),
timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
@@ -495,7 +497,7 @@ var CTRL_KEY_CODE = 17;
{
var theWindow = [self hitTest:location];
if (aDOMEvent.type == CPDOMEventMouseDown && theWindow)
if ((aDOMEvent.type === CPDOMEventMouseDown) && theWindow)
_mouseDownWindow = theWindow;
windowNumber = [theWindow windowNumber];
@@ -510,12 +512,10 @@ var CTRL_KEY_CODE = 17;
}
switch (theType)
{
{
case CPDOMEventMouseUp: if(_mouseIsDown)
{
event = [CPEvent mouseEventWithType:CPLeftMouseUp location:location modifierFlags:modifierFlags
timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1
clickCount:CPDOMEventGetClickCount(_lastMouseUp, timestamp, location) pressure:0];
event = _CPEventFromNativeMouseEvent(aDOMEvent, CPLeftMouseUp, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseUp, timestamp, location), 0);
_mouseIsDown = NO;
_lastMouseUp = event;
@@ -547,9 +547,7 @@ var CTRL_KEY_CODE = 17;
return;
}
event = [CPEvent mouseEventWithType:CPLeftMouseDown location:location modifierFlags:modifierFlags
timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1
clickCount:CPDOMEventGetClickCount(_lastMouseDown, timestamp, location) pressure:0];
event = _CPEventFromNativeMouseEvent(aDOMEvent, CPLeftMouseDown, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseDown, timestamp, location), 0);
_mouseIsDown = YES;
_lastMouseDown = event;
@@ -558,10 +556,8 @@ var CTRL_KEY_CODE = 17;
case CPDOMEventMouseMoved: if (_DOMEventMode)
return;
event = [CPEvent mouseEventWithType:_mouseIsDown ? CPLeftMouseDragged : CPMouseMoved
location:location modifierFlags:modifierFlags timestamp:timestamp
windowNumber:windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
event = _CPEventFromNativeMouseEvent(aDOMEvent, _mouseIsDown ? CPLeftMouseDragged : CPMouseMoved, location, modifierFlags, timestamp, windowNumber, nil, -1, 1, 0);
break;
}
@@ -577,18 +573,22 @@ var CTRL_KEY_CODE = 17;
CPDOMEventStop(aDOMEvent);
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
#ifndef DEBUG
}
catch (anException)
{
objj_exception_report(anException, {path:@"CPDOMWindowBridge.j"});
}
#endif
}
/* @ignore */
- (void)_bridgeKeyEvent:(DOMEvent)aDOMEvent
{
#ifndef DEBUG
try
{
{
#endif
var event,
timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
sourceElement = (aDOMEvent.target || aDOMEvent.srcElement),
@@ -723,11 +723,13 @@ var CTRL_KEY_CODE = 17;
CPDOMEventStop(aDOMEvent);
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
#ifndef DEBUG
}
catch (anException)
{
objj_exception_report(anException, {path:@"CPDOMWindowBridge.j"});
}
#endif
}
/* @ignore */
@@ -736,8 +738,10 @@ var CTRL_KEY_CODE = 17;
if(!aDOMEvent)
aDOMEvent = window.event;
#ifndef DEBUG
try
{
#endif
if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15))
{
var x = 0.0,
@@ -816,19 +820,22 @@ var CTRL_KEY_CODE = 17;
CPDOMEventStop(aDOMEvent);
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
#ifndef DEBUG
}
catch (anException)
{
objj_exception_report(anException, {path:@"CPDOMWindowBridge.j"});
}
#endif
}
/* @ignore */
- (void)_bridgeResizeEvent:(DOMEvent)aDOMEvent
{
#ifndef DEBUG
try
{
#endif
// FIXME: This is not the right way to do this.
// We should pay attention to mouse down and mouse up in conjunction with this.
//window.liveResize = YES;
@@ -855,11 +862,13 @@ var CTRL_KEY_CODE = 17;
//window.liveResize = NO;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
#ifndef DEBUG
}
catch (anException)
{
objj_exception_report(anException, {path:@"CPDOMWindowBridge.j"});
}
#endif
}
// DOM event properties used in mouse bridge code
@@ -874,8 +883,10 @@ var CTRL_KEY_CODE = 17;
/* @ignore */
- (void)_bridgeTouchEvent:(DOMEvent)aDOMEvent
{
#ifndef DEBUG
try
{
#endif
if (aDOMEvent.touches && (aDOMEvent.touches.length == 1 || (aDOMEvent.touches.length == 0 && aDOMEvent.changedTouches.length == 1)))
{
var newEvent = {};
@@ -917,20 +928,23 @@ var CTRL_KEY_CODE = 17;
if (aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
}
#ifndef DEBUG
}
catch(e)
catch (anException)
{
objj_exception_report(e, {path:@"CPDOMWindowBridge.j"});
objj_exception_report(anException, {path:@"CPDOMWindowBridge.j"});
}
#endif
// handle touch cases specifically
}
/* @ignore */
- (void)_checkPasteboardElement
{
#ifndef DEBUG
try
{
#endif
var value = _DOMPasteboardElement.value;
if ([value length])
@@ -952,11 +966,13 @@ var CTRL_KEY_CODE = 17;
_pasteboardKeyDownEvent = nil;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
#ifndef DEBUG
}
catch (anException)
{
objj_exception_report(anException, {path:@"CPDOMWindowBridge.j"});
}
#endif
}
/* @ignore */
@@ -988,15 +1004,15 @@ var CPDOMEventStop = function(aDOMEvent)
// IE Model
aDOMEvent.cancelBubble = true;
aDOMEvent.returnValue = false;
// W3C Model
if (aDOMEvent.preventDefault)
aDOMEvent.preventDefault();
if (aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
if (aDOMEvent.type == CPDOMEventMouseDown)
if (aDOMEvent.type === CPDOMEventMouseDown)
{
CPSharedDOMWindowBridge._DOMFocusElement.focus();
CPSharedDOMWindowBridge._DOMFocusElement.blur();
+6 -13
View File
@@ -87,8 +87,10 @@
@end
/*!
@ingroup foundation
@class CPArray
@brief A mutable array backed by a JavaScript Array.
@ingroup foundation
A mutable array class backed by a JavaScript Array.
There is also a CPMutableArray class,
but it is just a child class of this class with an
@@ -255,18 +257,6 @@
return self;
}
/*!
Returns a hash of the CPArray.
@return an unsigned integer hash
*/
- (unsigned)hash
{
if (self.__address == nil)
self.__address = _objj_generateObjectHash();
return self.__address;
}
// Querying an array
/*!
Returns <code>YES</code> if the array contains <code>anObject</code>. Otherwise, it returns <code>NO</code>.
@@ -1204,6 +1194,9 @@
@end
/*!
@class CPMutableArray
@ingroup compatability
This class is just an empty subclass of CPArray.
CPArray already implements mutable methods and
this class only exists for source compatability.
+15 -3
View File
@@ -25,7 +25,8 @@
@import "CPDictionary.j"
@import "CPRange.j"
/*! @class CPAttributedString
/*!
@class CPAttributedString
@ingroup foundation
@brief A mutable character string with attributes.
@@ -486,8 +487,11 @@
//Changing Characters
/*!
Replaces the characters in the receiver with those of the specified string
over the range, <code>aRange</code>. The new characters inherit the
attributes of the first character in the range that they replace.
over the range, <code>aRange</code>. If the range has a length of 0 then
the specified string is inserted at the range location. The new characters
inherit the attributes of the first character in the range that they
replace or in the case if a 0 range length, the first character before of
after the insert (after if the insert is at location 0).
@note the replacement string need not be the same length as the range
being replaced. The full <code>aString</code> is inserted and thus the
receiver's length changes to match this
@@ -794,6 +798,14 @@
@end
/*!
@class CPMutableAttributedString
@ingroup compatability
This class is just an empty subclass of CPAttributedString.
CPAttributedString already implements mutable methods and
this class only exists for source compatability.
*/
@implementation CPMutableAttributedString : CPAttributedString {}
@end
+2
View File
@@ -26,7 +26,9 @@
@import "CPURLRequest.j"
/*!
@class CPBundle
@ingroup foundation
@brief Groups information about an application's code & resources.
*/
@implementation CPBundle : CPObject
+3 -1
View File
@@ -25,8 +25,10 @@
/*!
@ingroup foundation
@class CPCoder
@ingroup foundation
@brief Defines methods for use when archiving & restoring (enc/decoding).
Top-level class defining methods for use when archiving (encoding) objects to a byte array
or file, and when restoring (decoding) objects.
*/
+25 -1
View File
@@ -1,8 +1,32 @@
/*
* CPCountedSet.j
* Foundation
*
* Created by .
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPSet.j"
/*!
/*!
@class CPCountedSet
@ingroup foundation
@brief An mutable collection which may contain a specific object
numerous times.
*/
@implementation CPCountedSet : CPMutableSet
{
+5 -1
View File
@@ -23,8 +23,12 @@
@import "CPObject.j"
@import "CPString.j"
/*!
/*!
@class CPData
@ingroup foundation
@brief A Cappuccino wrapper for any data type.
*/
@implementation CPData : CPObject
+6 -2
View File
@@ -1,5 +1,5 @@
/*
* CPObject.j
* CPDate.j
* Foundation
*
* Created by Thomas Robinson.
@@ -26,8 +26,12 @@
var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
/*!
/*!
@class CPDate
@ingroup foundation
@brief A representation of a single point in time.
*/
@implementation CPDate : CPObject
{
+17 -12
View File
@@ -57,20 +57,22 @@
@end
/*!
@ingroup foundation
/*!
@class CPDictionary
A dictionary is the standard way of passing around key-value pairs in
the Cappuccino framework. It is similar to the
<a href="http://java.sun.com/javase/6/docs/api/index.html">Java map interface</a>,
except all keys are CPStrings and values can be any
Cappuccino or JavaScript object.</p>
@ingroup foundation
@brief A mutable key-value pair collection.
<p>If you are familiar with dictionaries in Cocoa, you'll notice that
there is no CPMutableDictionary class. The regular CPDictionary
has <code>setObject:</code> and <code>removeObjectForKey:</code> methods.
In Cappuccino there is no distinction between immutable and mutable classes.
They are all mutable.
A dictionary is the standard way of passing around key-value pairs in
the Cappuccino framework. It is similar to the
<a href="http://java.sun.com/javase/6/docs/api/index.html">Java map interface</a>,
except all keys are CPStrings and values can be any
Cappuccino or JavaScript object.
If you are familiar with dictionaries in Cocoa, you'll notice that
there is no CPMutableDictionary class. The regular CPDictionary
has <code>setObject:</code> and <code>removeObjectForKey:</code> methods.
In Cappuccino there is no distinction between immutable and mutable classes.
They are all mutable.
*/
@implementation CPDictionary : CPObject
{
@@ -595,6 +597,9 @@
@end
/*!
@class CPMutableDictionary
@ingroup compatability
This class is just an empty subclass of CPDictionary.
CPDictionary already implements mutable methods and
this class only exists for source compatability.
+7 -3
View File
@@ -23,10 +23,14 @@
@import "CPObject.j"
/*!
@ingroup foundation
*/
/*! @class CPEnumerator
/*!
@class CPEnumerator
@ingroup foundation
@brief Defines an interface for enumerators.
CPEnumerator is a superclass (with useless method bodies)
that defines an interface for subclasses to follow. The purpose of an
enumerator is to be a convenient system for traversing over the elements
@@ -52,4 +56,4 @@
return [];
}
@end
@end
+3 -1
View File
@@ -31,8 +31,10 @@ CPRangeException = "CPRangeException";
CPInternalInconsistencyException = "CPInternalInconsistencyException";
/*!
@ingroup foundation
@class CPException
@ingroup foundation
@brief Used to implement exception handling (creating & raising).
An example of throwing an exception in Objective-J:
<pre>
// some code here...
+8 -2
View File
@@ -25,9 +25,12 @@
/*!
@ingroup foundation
@class CPIndexSet
Instances of this class are collections of numbers. Each integer can appear in a collection only once.
@ingroup foundation
@brief A collection of unique integers.
Instances of this class are collections of numbers. Each integer can appear
in a collection only once.
*/
@implementation CPIndexSet : CPObject
{
@@ -816,6 +819,9 @@ var CPIndexSetCountKey = @"CPIndexSetCountKey",
@end
/*!
@class CPMutableIndexSet
@ingroup compatability
This class is an empty of subclass of CPIndexSet.
CPIndexSet already implements mutable methods, and
this class only exists for source compatability.
+3 -1
View File
@@ -25,8 +25,10 @@
/*!
@ingroup foundation
@class CPInvocation
@ingroup foundation
@brief An object representation of a message.
A CPInvocation is an object representation of a message sent to an object.
*/
@implementation CPInvocation : CPObject
+28 -15
View File
@@ -25,11 +25,12 @@
CPJSONPConnectionCallbacks = {};
CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
/*!
@ingroup foundation
*/
@brief Allows cross domain connections using JSONP protocol.
/*! @class CPJSONPConnection
Important note: CPJSONPConnection is <strong>only</strong> for JSONP APIs.
If aren't sure you <strong>need</strong>
<a href="http://ajaxian.com/archives/jsonp-json-with-padding">JSON<strong>P</strong></a>,
@@ -72,13 +73,8 @@ CPJSONPConnectionCallbacks = {};
_callbackParameter = aString;
CPJSONPConnectionCallbacks["callback"+[self hash]] = function(data)
{
[_delegate connection:self didReceiveData:data];
[self removeScriptTag];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
};
if (!_callbackParameter && [_request URL].indexOf(CPJSONPCallbackReplacementString) < 0)
[CPException raise:CPInvalidArgumentException reason:@"JSONP source specified without callback parameter or CPJSONPCallbackReplacementString in URL."];
if(shouldStartImmediately)
[self start];
@@ -90,12 +86,29 @@ CPJSONPConnectionCallbacks = {};
{
try
{
var head = document.getElementsByTagName("head").item(0);
var source = [_request URL];
source += (source.indexOf('?') < 0) ? "?" : "&";
source += _callbackParameter+"=CPJSONPConnectionCallbacks.callback"+[self hash];
CPJSONPConnectionCallbacks["callback"+[self hash]] = function(data)
{
[_delegate connection:self didReceiveData:data];
[self removeScriptTag];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
};
var head = document.getElementsByTagName("head").item(0),
source = [_request URL];
if (_callbackParameter)
{
source += (source.indexOf('?') < 0) ? "?" : "&";
source += _callbackParameter+"=CPJSONPConnectionCallbacks.callback"+[self hash];
}
else if (source.indexOf(CPJSONPCallbackReplacementString) >= 0)
{
source = [source stringByReplacingOccurrencesOfString:CPJSONPCallbackReplacementString withString:"CPJSONPConnectionCallbacks.callback"+[self hash]];
}
else
return;
_scriptTag = document.createElement("script");
_scriptTag.setAttribute("type", "text/javascript");
_scriptTag.setAttribute("charset", "utf-8");
@@ -114,7 +127,7 @@ CPJSONPConnectionCallbacks = {};
{
var head = document.getElementsByTagName("head").item(0);
if(_scriptTag.parentNode == head)
if(_scriptTag && _scriptTag.parentNode == head)
head.removeChild(_scriptTag);
CPJSONPConnectionCallbacks["callback"+[self hash]] = nil;
+2 -2
View File
@@ -247,9 +247,9 @@ CPUnknownUserInfoKey = @"CPUnknownUserInfoKey";
self[ivar] = aValue;
[self didChangeValueForKey:aKey];
return;
}
return;
}
[self setValue:aValue forUndefinedKey:aKey];
+3 -2
View File
@@ -60,9 +60,10 @@ var _CPKeyedArchiverStringClass = Nil,
}
@end
/*!
@ingroup foundation
/*!
@class CPKeyedArchiver
@ingroup foundation
@brief Implements keyed archiving of object graphs (e.g. for storing data).
Implements keyed archiving of object graphs. Archiving means to
write data out in a format that be read in again later, or possibly
+2
View File
@@ -51,7 +51,9 @@ var _CPKeyedUnarchiverArrayClass = Ni
_CPKeyedUnarchiverArchiverValueClass = Nil;
/*!
@class CPKeyedUnarchiver
@ingroup foundation
@brief Unarchives objects created using CPKeyedArchiver.
CPKeyedUnarchiver is used for creating objects out of
coded files or CPData objects that were created by
+10 -5
View File
@@ -24,13 +24,18 @@
@import "CPException.j"
/*!
@ingroup foundation
/*!
@class CPNotification
Represents a notification for posting to an CPNotificationCenter. Consists of a name, an object, and an optional dictionary. The notification center will check for observers registered to receive either notifications with the name, the object, or both and pass the notification instance on to them.
@ingroup foundation
@brief A notification that can be posted to a CPNotificationCenter.
To create a notification use one of the class methods. The default init method will throw a
CPUnsupportedMethodException.
Represents a notification for posting to an CPNotificationCenter. Consists
of a name, an object, and an optional dictionary. The notification center
will check for observers registered to receive either notifications with
the name, the object, or both and pass the notification instance on to them.
To create a notification use one of the class methods. The default init
method will throw a CPUnsupportedMethodException.
*/
@implementation CPNotification : CPObject
{
+11 -5
View File
@@ -25,15 +25,21 @@
@import "CPNotification.j"
@import "CPException.j"
/*!
@ingroup foundation
*/
var CPNotificationDefaultCenter = nil;
/*! @class CPNotificationCenter
/*!
@class CPNotificationCenter
@ingroup foundation
@brief Sends messages (CPNotification) between objects.
Cappuccino provides a framework for sending messages between objects within a process called notifications. Objects register with an CPNotificationCenter to be informed whenever other objects post CPNotifications to it matching certain criteria. The notification center processes notifications synchronously -- that is, control is only returned to the notification poster once every recipient of the notification has received it and processed it.
Cappuccino provides a framework for sending messages between objects within
a process called notifications. Objects register with an
CPNotificationCenter to be informed whenever other objects post
CPNotifications to it matching certain criteria. The notification center
processes notifications synchronously -- that is, control is only returned
to the notification poster once every recipient of the notification has
received it and processed it.
*/
@implementation CPNotificationCenter : CPObject
{
+4 -2
View File
@@ -26,8 +26,10 @@
var CPNullSharedNull = nil;
/*!
@ingroup foundation
@class CPNull
@ingroup foundation
@brief An object representation of <code>nil</code>.
This class is used as an object representation of <code>nil</code>. This is handy when a collection
only accepts objects as values, but you would like a <code>nil</code> representation in there.
*/
@@ -55,4 +57,4 @@ var CPNullSharedNull = nil;
return CPNullSharedNull;
}
@end
@end
+4 -2
View File
@@ -28,8 +28,10 @@ var __placeholder = new Number(),
_CPNumberHashes = { };
/*!
@ingroup foundation
@class CPNumber
@ingroup foundation
@brief A bridged object to native Javascript numbers.
This class primarily exists for source compatability. The JavaScript
<code>Number</code> type can be changed on the fly based on context,
so there is no need to call any of these methods.
@@ -186,7 +188,7 @@ var __placeholder = new Number(),
return anUnsignedShort;
}
- (CPString)hash
- (CPString)UID
{
if (!_CPNumberHashes[self])
_CPNumberHashes[self] = _objj_generateObjectHash();
+10 -1
View File
@@ -21,8 +21,9 @@
*/
/*!
@ingroup foundation
@class CPObject
@ingroup foundation
@brief The root class from which most classes are subclassed.
CPObject is the root class for most Cappuccino classes. Like in Objective-C,
you have to declare parent class explicitly in Objective-J, so your custom
@@ -459,6 +460,14 @@ CPLog(@"Got some class: %@", inst);</pre>
*/
- (unsigned)hash
{
return [self UID];
}
- (unsigned)UID
{
if (typeof self.__address === "undefined")
self.__address = _objj_generateObjectHash();
return __address;
}
+3 -2
View File
@@ -137,9 +137,10 @@ var _CPRunLoopPerformPool = [],
var CPRunLoopLastNativeRunLoop = 0;
/*!
@ingroup foundation
/*!
@class CPRunLoop
@ingroup foundation
@brief The main run loop for the application.
CPRunLoop instances handle various utility tasks that must be performed repetitively in an application, such as processing input events.
+27 -1
View File
@@ -5,7 +5,22 @@
* Created by Bailey Carlson
* Extended by Ross Boucher
* Extended by Nabil Elisa
*
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* TODO: Needs to implement CPCoding, CPCopying.
*/
@@ -15,7 +30,9 @@
@import "CPEnumerator.j"
/*!
@class CPSet
@ingroup foundation
@brief An unordered collection of objects.
*/
@implementation CPSet : CPObject
{
@@ -466,6 +483,15 @@ var CPSetObjectsKey = @"CPSetObjectsKey";
@end
/*!
@class CPMutableSet
@ingroup compatability
This class is just an empty subclass of CPSet.
CPSet already implements mutable methods and
this class only exists for source compatability.
*/
@implementation CPMutableSet : CPSet
@end
+4 -2
View File
@@ -44,8 +44,10 @@ CPOrderedSame = 0;
CPOrderedDescending = 1;
/*!
@ingroup foundation
@class CPSortDescriptor
@ingroup foundation
@brief Holds attributes necessary to describe how to sort a set of objects.
A CPSortDescriptor holds the attributes necessary to describe how
to sort a set of objects. The sort descriptor instance holds a property key path
to the sort item of the objects to compare, the method selector to call for sorting and the sort order.
@@ -136,4 +138,4 @@ CPOrderedDescending = 1;
return [[[self class] alloc] initWithKey:_key ascending:!_ascending selector:_selector];
}
@end
@end
+6 -4
View File
@@ -65,14 +65,16 @@ var CPStringRegexSpecialCharacters = [
CPStringRegexEscapeExpression = new RegExp("(\\" + CPStringRegexSpecialCharacters.join("|\\") + ")", 'g');
/*!
@ingroup foundation
@class CPString
@ingroup foundation
@brief An immutable string (collection of characters).
CPString is an object that allows management of strings. Because CPString is
based on the JavaScript <code>String</code> object, CPStrings are immutable, although the
class does have methods that create new CPStrings generated from modifications to the
receiving instance.</p>
receiving instance.
<p>A handy feature of CPString instances is that they can be used wherever a JavaScript is
A handy feature of CPString instances is that they can be used wherever a JavaScript is
required, and vice versa.
*/
@implementation CPString : CPObject
@@ -514,7 +516,7 @@ var CPStringRegexSpecialCharacters = [
/*!
Returns a hash of the string instance.
*/
- (unsigned)hash
- (unsigned)UID
{
var hash = dictionary_getValue(CPStringHashes, self);
+4 -1
View File
@@ -25,8 +25,11 @@
@import "CPDate.j"
@import "CPRunLoop.j"
/*!
/*!
@class CPTimer
@ingroup foundation
@brief A timer object that can send a message after the given time interval.
*/
@implementation CPTimer : CPObject
{
+3 -2
View File
@@ -34,8 +34,10 @@ var XMLHTTPRequestUninitialized = 0,
var CPURLConnectionDelegate = nil;
/*
/*!
@class CPURLConnection
@ingroup foundation
@brief Provides loading of a URL request.
An interface to downloading content at a specified URL. Using one of the
class methods, you can obtain the data.
@@ -76,7 +78,6 @@ var CPURLConnectionDelegate = nil;
@param connection the connection that received the authentication challenge.
*/
@implementation CPURLConnection : CPObject
{
CPURLRequest _request;
+3 -1
View File
@@ -24,8 +24,10 @@
/*!
@ingroup foundation
@class CPURLRequest
@ingroup foundation
@brief Contains data obtained during a request made with CPURLConnection.
A helper object for CPURLConnection, that contains
data obtained during the life of a request.
*/
+3
View File
@@ -30,7 +30,10 @@
CPString _textEncodingName;
*/
/*!
@class CPURLResponse
@ingroup foundation
@brief Protocol agnostic information about a request to a specifc URL.
Contains protocol agnostic information about a request to a specific URL.
*/
@implementation CPURLResponse : CPObject
+12 -2
View File
@@ -152,9 +152,19 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
@end
/*!
@ingroup foundation
@class CPUndoManager
CPUndoManager provides a general mechanism supporting implementation of user action "undo" in applications. Essentially, it allows you to store sequences of messages and receivers that need to be invoked to undo or redo an action. The various methods in this class provide for grouping of sets of actions, execution of undo or redo actions, and tuning behavior parameters such as the size of the undo stack. Each application entity with its own editing history (e.g., a document) should have its own undo manager instance. Obtain an instance through a simple <code>[[CPUndoManager alloc] init]</code> message.
@ingroup foundation
@brief A general mechanism for user action "undo".
CPUndoManager provides a general mechanism supporting implementation of user
action "undo" in applications. Essentially, it allows you to store sequences
of messages and receivers that need to be invoked to undo or redo an action.
The various methods in this class provide for grouping of sets of actions,
execution of undo or redo actions, and tuning behavior parameters such as
the size of the undo stack. Each application entity with its own editing
history (e.g., a document) should have its own undo manager instance.
Obtain an instance through a simple <code>[[CPUndoManager alloc] init]
</code> message.
*/
@implementation CPUndoManager : CPObject
{
+3 -1
View File
@@ -25,8 +25,10 @@
/*!
@ingroup foundation
@class CPValue
@ingroup foundation
@brief A generic "value". Can be subclassed to hold specific data types.
The class can be subclassed to hold different types of scalar values.
*/
@implementation CPValue : CPObject
+1
View File
@@ -70,4 +70,5 @@
@defgroup appkit AppKit
@defgroup foundation Foundation
@defgroup compatability Cocoa Compatability
*/
+3 -6
View File
@@ -472,12 +472,9 @@ function objj_msgSend(/*id*/ aReceiver, /*SEL*/ aSelector)
switch(arguments.length)
{
case 2:
return implementation(aReceiver, aSelector);
case 3:
return implementation(aReceiver, aSelector, arguments[2]);
case 4:
return implementation(aReceiver, aSelector, arguments[2], arguments[3]);
case 2: return implementation(aReceiver, aSelector);
case 3: return implementation(aReceiver, aSelector, arguments[2]);
case 4: return implementation(aReceiver, aSelector, arguments[2], arguments[3]);
}
return implementation.apply(aReceiver, arguments);
+16
View File
@@ -0,0 +1,16 @@
// Just doing @import <AppKit/CPCollectionView.j> failed on CPWindow not being defined somewhere.
@import <AppKit/AppKit.j>
@implementation CPCollectionViewTest : OJTestCase
- (void)testItemPrototypeActuallyReturnsTheItemPrototype
{
var propertiesCollectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()],
itemPrototype = [[CPCollectionViewItem alloc] init];
[propertiesCollectionView setItemPrototype:itemPrototype];
[self assert:[CPCollectionViewItem class] equals:[[propertiesCollectionView itemPrototype] class]];
}
@end
+1 -1
View File
@@ -247,7 +247,7 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
+2 -1
View File
@@ -33,6 +33,8 @@
if (self)
{
_isSeparator = [aCoder decodeObjectForKey:@"NSIsSeparator"] || NO;
_title = [aCoder decodeObjectForKey:"NSTitle"];
// _font = [aCoder decodeObjectForKey:"NSTitle"];
@@ -89,7 +91,6 @@
@end
@implementation NSMenuItemCell : NSButtonCell
{
}