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

This commit is contained in:
Alexander Ljungberg committed 2010-08-12 22:50:09 -04:00
commit 6310bfe084
9 files changed
+174 -16

No files matched your search

+9 -6
View File
@@ -61,15 +61,16 @@ CPGrooveBorder = 3;
self = [super initWithFrame:frameRect];
if (self)
{
_fillColor = [CPColor clearColor];
{
_borderType = CPBezelBorder;
_fillColor = [CPColor colorWithWhite:0.75 alpha:0.1];
_borderColor = [CPColor blackColor];
_borderWidth = 1.0;
_contentMargin = CGSizeMake(0.0, 0.0);
_contentView = [[CPView alloc] initWithFrame:[self bounds]];
[_contentView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[self addSubview:_contentView];
}
@@ -161,6 +162,7 @@ CPGrooveBorder = 3;
return;
[aView setFrame:CGRectInset([self bounds], _contentMargin.width + _borderWidth, _contentMargin.height + _borderWidth)];
[aView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[self replaceSubview:_contentView with:aView];
_contentView = aView;
@@ -213,16 +215,17 @@ CPGrooveBorder = 3;
bounds.size.height - _borderWidth);
CGContextSetFillColor(aContext, [self fillColor]);
CGContextSetStrokeColor(aContext, [self borderColor]);
CGContextSetLineWidth(aContext, _borderWidth);
switch(_borderType)
{
case CPLineBorder: CGContextFillRoundedRectangleInRect(aContext, fillRect, _cornerRadius, YES, YES, YES, YES);
case CPLineBorder: CGContextSetStrokeColor(aContext, [self borderColor]);
CGContextFillRoundedRectangleInRect(aContext, fillRect, _cornerRadius, YES, YES, YES, YES);
CGContextStrokeRoundedRectangleInRect(aContext, strokeRect, _cornerRadius, YES, YES, YES, YES);
break;
case CPBezelBorder: CGContextFillRoundedRectangleInRect(aContext, fillRect, _cornerRadius, YES, YES, YES, YES);
case CPBezelBorder: CGContextSetStrokeColor(aContext, [CPColor colorWithWhite:0 alpha:0.42]);
CGContextFillRoundedRectangleInRect(aContext, fillRect, _cornerRadius, YES, YES, YES, YES);
CGContextSetStrokeColor(aContext, [CPColor colorWithWhite:190.0/255.0 alpha:1.0]);
CGContextBeginPath(aContext);
CGContextMoveToPoint(aContext, strokeRect.origin.x, strokeRect.origin.y);
+50
View File
@@ -1275,6 +1275,56 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
@end
var CPOutlineViewIndentationPerLevelKey = @"CPOutlineViewIndentationPerLevelKey",
CPOutlineViewOutlineTableColumnKey = @"CPOutlineViewOutlineTableColumnKey",
CPOutlineViewDataSourceKey = @"CPOutlineViewDataSourceKey",
CPOutlineViewDelegateKey = @"CPOutlineViewDelegateKey";
@implementation CPOutlineView (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
// The root item has weight "0", thus represents the weight solely of its descendants.
_rootItemInfo = { isExpanded:YES, isExpandable:NO, level:-1, row:-1, children:[], weight:0 };
_itemsForRows = [];
_itemInfosForItems = { };
_disclosureControlsForRows = [];
[self setIndentationMarkerFollowsDataView:YES];
[self setDisclosureControlPrototype:[[CPDisclosureButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)]];
_outlineTableColumn = [aCoder decodeObjectForKey:CPOutlineViewOutlineTableColumnKey];
_indentationPerLevel = [aCoder decodeFloatForKey:CPOutlineViewIndentationPerLevelKey];
_outlineViewDataSource = [aCoder decodeObjectForKey:CPOutlineViewDataSourceKey];
_outlineViewDelegate = [aCoder decodeObjectForKey:CPOutlineViewDelegateKey];
[super setDataSource:[[_CPOutlineViewTableViewDataSource alloc] initWithOutlineView:self]];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_outlineTableColumn forKey:CPOutlineViewOutlineTableColumnKey];
[aCoder encodeFloat:_indentationPerLevel forKey:CPOutlineViewIndentationPerLevelKey];
[aCoder encodeObject:_outlineViewDataSource forKey:CPOutlineViewDataSourceKey];
[aCoder encodeObject:_outlineViewDelegate forKey:CPOutlineViewDelegateKey];
}
@end
var colorForDisclosureTriangle = function(isSelected, isHighlighted) {
return isSelected
? (isHighlighted
+2
View File
@@ -539,6 +539,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
[self _recalculateTableColumnRanges];
[self setNeedsLayout];
[_headerView setNeedsDisplay:YES];
[_headerView setNeedsLayout];
}
- (void)setThemeState:(int)astae
+3
View File
@@ -1846,6 +1846,9 @@ setBoundsOrigin:
- (void)displayRectIgnoringOpacity:(CGRect)aRect inContext:(CPGraphicsContext)aGraphicsContext
{
if ([self isHidden])
return;
#if PLATFORM(DOM)
[self lockFocus];
+30 -1
View File
@@ -337,6 +337,35 @@
return values;
}
/*!
Returns a new array containing the keys corresponding to all occurrences of a given object in the receiver.
@param anObject The value to look for in the receiver.
@return A new array containing the keys corresponding to all occurrences of anObject in the receiver. If no object matching anObject is found, returns an empty array.
Each object in the receiver is sent an isEqual: message to determine if itÕs equal to anObject.
If the check for isEqual fails a check is made to see if the two objects are the same object. This provides compatability for JSObjects.
*/
- (CPArray)allKeysForObject:(id)anObject
{
var count = _keys.length,
index = 0,
matchingKeys = [],
thisKey = nil,
thisValue = nil;
for (; index < count; ++index)
{
thisKey = _keys[index],
thisValue = _buckets[thisKey];
if (thisValue.isa && anObject && anObject.isa && [thisValue respondsToSelector:@selector(isEqual:)] && [thisValue isEqual:anObject])
matchingKeys.push(thisKey);
else if (thisValue === anObject)
matchingKeys.push(thisKey);
}
return matchingKeys;
}
/*!
Returns an enumerator that enumerates over all the dictionary's keys.
*/
@@ -425,7 +454,7 @@
@param aKey the key for the object's entry
@return the object for the entry
*/
- (id)objectForKey:(CPString)aKey
- (id)objectForKey:(id)aKey
{
var object = _buckets[aKey];
@@ -3,7 +3,7 @@
@import <Foundation/CPNumber.j>
@import <Foundation/CPSortDescriptor.j>
@implementation CPArrayPerformance : OJTestCase
@implementation CPArrayPerformanceTest : OJTestCase
- (void)testSortUsingDescriptorsSpeed
{
+13 -8
View File
@@ -17,7 +17,7 @@
}
}
string_dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key1", @"key2"]];
string_dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2", @"This is a String", @"This is a String"] forKeys:[@"key1", @"key2", @"key3", @"key4"]];
json_dict = [CPDictionary dictionaryWithJSObject:json recursively:YES];
}
@@ -90,19 +90,19 @@
- (void)testCount
{
[self assert:[string_dict count] equals:2];
[self assert:[string_dict count] equals:4];
[self assert:[json_dict count] equals:3];
}
- (void)testAllKeys
{
[self assert:[string_dict allKeys] equals:[@"key2", @"key1"]];
[self assert:[string_dict allKeys] equals:[@"key4", @"key3", @"key2", @"key1"]];
[self assert:[json_dict allKeys] equals:[@"key1", @"key2", @"key3"]];
}
- (void)testAllValues
{
[self assert:[string_dict allValues] equals:[@"1", @"2"]];
[self assert:[string_dict allValues] equals:[@"1", @"2", @"This is a String", @"This is a String"]];
// Had to get object from key to get test passing
[self assert:[json_dict allValues] equals:[[json_dict objectForKey:@"key3"], @"This is a string", ['1', '2', '3']]];
}
@@ -113,6 +113,11 @@
[self assert:[json_dict objectForKey:@"key1"] equals:['1', '2', '3']];
}
- (void)testAllKeysForObject
{
[self assert:[string_dict allKeysForObject:@"This is a String"] equals:[@"key4", @"key3"]];
}
- (void)testKeyEnumerator
{
var dict = [[CPDictionary alloc] init];
@@ -156,7 +161,7 @@
{
[string_dict removeObjectForKey:@"key1"];
[json_dict removeObjectForKey:@"key1"];
[self assert:[string_dict count] equals:1];
[self assert:[string_dict count] equals:3];
[self assert:[json_dict count] equals:2];
}
@@ -164,7 +169,7 @@
{
[string_dict removeObjectsForKeys:[@"key1"]];
[json_dict removeObjectsForKeys:[@"key1", @"key2"]];
[self assert:[string_dict count] equals:1];
[self assert:[string_dict count] equals:3];
[self assert:[json_dict count] equals:1];
}
@@ -178,10 +183,10 @@
- (void)testAddEntriesFromDictionary
{
var dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key4", @"key5"]];
var dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key5", @"key6"]];
[string_dict addEntriesFromDictionary:dict]
[json_dict addEntriesFromDictionary:dict]
[self assert:[string_dict count] equals:4];
[self assert:[string_dict count] equals:6];
[self assert:[json_dict count] equals:5];
}
+1
View File
@@ -41,6 +41,7 @@
@import "NSMenu.j"
@import "NSMenuItem.j"
@import "NSNibConnector.j"
@import "NSOutlineView.j"
@import "NSPopUpButton.j"
@import "NSResponder.j"
@import "NSScrollView.j"
+65
View File
@@ -0,0 +1,65 @@
/*
* NSOutlineView.j
* nib2cib
*
* Created by Andreas Falk.
* Copyright 2009, Andreas Falk.
*
* 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 <AppKit/CPOutlineView.j>
@implementation CPOutlineView (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
if([aCoder containsValueForKey:"NSOutlineViewOutlineTableColumnKey"])
_outlineTableColumn = [aCoder decodeObjectForKey:@"NSOutlineViewOutlineTableColumnKey"];
else
_outlineTableColumn = [[self tableColumns] objectAtIndex:0];
_indentationPerLevel = [aCoder decodeFloatForKey:@"NSOutlineViewIndentationPerLevelKey"];
_outlineViewDataSource = [aCoder decodeObjectForKey:@"NSDataSource"];
_outlineViewDelegate = [aCoder decodeObjectForKey:@"NSDelegate"];
}
return self;
}
@end
@implementation NSOutlineView : CPOutlineView
{
}
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
}
- (Class)classForKeyedArchiver
{
return [CPOutlineView class];
}
@end