From b1282b43629c09be362b66c4f4f326b321f2a602 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 21 Apr 2010 12:58:31 -0700 Subject: [PATCH 1/8] Fix an infinite recursion bug in CPBrowser, and add support for looking up a column/row by location. --- AppKit/CPBrowser.j | 93 ++++++++++++++++++++++++++++++++++---------- AppKit/CPTableView.j | 2 +- 2 files changed, 73 insertions(+), 22 deletions(-) diff --git a/AppKit/CPBrowser.j b/AppKit/CPBrowser.j index 8d524b4ed..e92a547af 100644 --- a/AppKit/CPBrowser.j +++ b/AppKit/CPBrowser.j @@ -64,14 +64,14 @@ + (CPImage)branchImage { - return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[self class]] + return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPBrowser class]] pathForResource:"browser-leaf.png"] size:CGSizeMake(9,9)]; } + (CPImage)highlightedBranchImage { - return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[self class]] + return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPBrowser class]] pathForResource:"browser-leaf-highlighted.png"] size:CGSizeMake(9,9)]; } @@ -213,8 +213,6 @@ [table setAllowsEmptySelection:_allowsEmptySelection]; [table registerForDraggedTypes:[self registeredDraggedTypes]]; - [self setNextResponder:table]; - [self _addTableColumnsToTableView:table forColumnIndex:index]; var delegate = [[_CPBrowserTableDelegate alloc] init]; @@ -314,6 +312,37 @@ [_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 +{ + for (var i = 0, count = _tableViews.length; i < count; i++) + { + var frame = [[_tableViews[i] enclosingScrollView] frame]; + if (CGRectContainsPoint(frame, aPoint)) + 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 - (id)itemAtRow:(int)row inColumn:(int)column @@ -357,6 +386,10 @@ // CLICK EVENTS +- (void)trackMouse:(CPEvent)anEvent +{ +} + - (void)_column:(unsigned)columnIndex clickedRow:(unsigned)rowIndex { [self setLastColumn:columnIndex]; @@ -382,6 +415,15 @@ [self sendAction:_doubleAction to:_target]; } +- (void)keyDown:(CPEvent)anEvent +{ + var column = [self selectedColumn]; + if (column === -1) + return; + + [_tableViews[column] keyDown:anEvent]; +} + // SIZING - (float)columnContentWidthForColumnWidth:(float)aWidth @@ -551,8 +593,6 @@ [[self tableViewInColumn:column] selectRowIndexes:indexSet byExtendingSelection:NO]; - [self setNextResponder:[self tableViewInColumn:[self lastColumn]]]; - [self scrollColumnToVisible:column]; if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)]) @@ -604,6 +644,8 @@ @end +var _CPBrowserResizeControlBackgroundImage = nil; + @implementation _CPBrowserResizeControl : CPView { CGPoint _mouseDownX; @@ -612,6 +654,26 @@ 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 { _mouseDownX = [anEvent locationInWindow].x; @@ -626,9 +688,11 @@ [_browser setWidth:_width + deltaX ofColumn:_index]; } -@end +- (void)mouseUp:(CPEvent)anEvent +{ +} -var _CPBrowserResizeControlBackgroundImage = nil; +@end @implementation _CPBrowserScrollView : CPScrollView { @@ -636,24 +700,11 @@ var _CPBrowserResizeControlBackgroundImage = nil; 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 { if (self = [super initWithFrame:aFrame]) { _resizeControl = [[_CPBrowserResizeControl alloc] initWithFrame:CGRectMakeZero()]; - [_resizeControl setBackgroundColor:[CPColor colorWithPatternImage:[[self class] backgroundImage]]]; [self addSubview:_resizeControl]; } diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 8dd282e4e..cbc4894a4 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -3049,7 +3049,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; - (void)keyDown:(CPEvent)anEvent { - [self interpretKeyEvents:[CPArray arrayWithObject:anEvent]]; + [self interpretKeyEvents:[anEvent]]; } - (void)moveDown:(id)sender From d2399b6157c6304167245638de00bdc5ff42bad2 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Tue, 13 Apr 2010 14:35:14 -0700 Subject: [PATCH 2/8] Add support for not clipping to bounds in cpview. --- AppKit/CPView.j | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index c3b2499b8..f2e4f3ab5 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -139,6 +139,7 @@ var CPViewFlags = { }, BOOL _isHidden; BOOL _hitTests; + BOOL _clipsToBounds; BOOL _postsFrameChangedNotifications; BOOL _postsBoundsChangedNotifications; @@ -277,6 +278,7 @@ var CPViewFlags = { }, _autoresizingMask = CPViewNotSizable; _autoresizesSubviews = YES; + _clipsToBounds = YES; _opacity = 1.0; _isHidden = NO; @@ -1188,6 +1190,23 @@ var CPViewFlags = { }, 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 completely transparent and 1.0 is completely opaque. From 5838f1aec84bfff93ddf00e7e8f44171d6a372b5 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 17 Apr 2010 18:27:00 -0400 Subject: [PATCH 3/8] Implemented CPCoding for CPNull. --- Foundation/CPNull.j | 25 ++++++++++++++++++++++--- Tests/Foundation/CPNullTest.j | 12 ++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 Tests/Foundation/CPNullTest.j diff --git a/Foundation/CPNull.j b/Foundation/CPNull.j index 43ba1cbc9..0eaca5773 100644 --- a/Foundation/CPNull.j +++ b/Foundation/CPNull.j @@ -25,7 +25,7 @@ var CPNullSharedNull = nil; -/*! +/*! @class CPNull @ingroup foundation @brief An object representation of \c nil. @@ -41,7 +41,7 @@ var CPNullSharedNull = nil; { if (CPNullSharedNull) return CPNullSharedNull; - + return [super alloc]; }*/ /*! @@ -53,8 +53,27 @@ var CPNullSharedNull = nil; { if (!CPNullSharedNull) CPNullSharedNull = [[CPNull alloc] init]; - + 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 diff --git a/Tests/Foundation/CPNullTest.j b/Tests/Foundation/CPNullTest.j new file mode 100644 index 000000000..7b99a14a2 --- /dev/null +++ b/Tests/Foundation/CPNullTest.j @@ -0,0 +1,12 @@ +@import +@import +@import + +@implementation CPNullTest : OJTestCase + +- (void)testArchiving +{ + [self assert:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:[CPNull null]]] equals:[CPNull null]]; +} + +@end \ No newline at end of file From 639a32ea7ecfdb3a098e8e116a72301029506b5c Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Thu, 15 Apr 2010 17:03:33 -0400 Subject: [PATCH 4/8] CPWindow alpha value support. --- AppKit/CPWindow/CPWindow.j | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 7a916d9eb..219963545 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -883,6 +883,23 @@ CPTexturedBackgroundWindowMask 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. @param aColor the new color for the background From 388f008189c58a046057b6a67b92edf37065999d Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Thu, 15 Apr 2010 23:48:30 -0400 Subject: [PATCH 5/8] Fixed: CPCollectionView frameForItemsAtIndexes used the deprecated method rectForItemAtIndex causing warnings. --- AppKit/CPCollectionView.j | 150 +++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 10c017f23..1f71f5876 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -30,16 +30,16 @@ @import "CPCollectionViewItem.j" -/*! +/*! @ingroup appkit @class CPCollectionView - 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 + 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 setting that item as the collection view prototype. - + @par Delegate Methods - + @delegate -(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView; Called when the selection in the collection view has changed. @param collectionView the collection view who's selection changed @@ -67,35 +67,35 @@ { CPArray _content; CPArray _items; - + CPData _itemData; CPCollectionViewItem _itemPrototype; CPCollectionViewItem _itemForDragging; CPMutableArray _cachedItems; - + unsigned _maxNumberOfRows; unsigned _maxNumberOfColumns; - + CGSize _minItemSize; CGSize _maxItemSize; CPArray _backgroundColors; float _tileWidth; - + BOOL _isSelectable; BOOL _allowsMultipleSelection; BOOL _allowsEmptySelection; CPIndexSet _selectionIndexes; - + CGSize _itemSize; - + float _horizontalMargin; float _verticalMargin; - + unsigned _numberOfRows; unsigned _numberOfColumns; - + id _delegate; CPEvent _mouseDownEvent; @@ -104,14 +104,14 @@ - (id)initWithFrame:(CGRect)aFrame { self = [super initWithFrame:aFrame]; - + if (self) { _items = []; _content = []; - + _cachedItems = []; - + _itemSize = CGSizeMakeZero(); _minItemSize = CGSizeMakeZero(); _maxItemSize = CGSizeMakeZero(); @@ -120,12 +120,12 @@ _verticalMargin = 5.0; _tileWidth = -1.0; - + _selectionIndexes = [CPIndexSet indexSet]; _allowsEmptySelection = YES; _isSelectable = YES; } - + return self; } @@ -196,8 +196,8 @@ // Setting the Content /*! - 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. + 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. It's the responsibility of your custom collection view item to interpret the object. @param anArray the content array */ @@ -205,9 +205,9 @@ { if (_content == anArray) return; - + _content = anArray; - + [self reloadContent]; } @@ -236,13 +236,13 @@ { if (_isSelectable == isSelectable) return; - + _isSelectable = isSelectable; - + if (!_isSelectable) { var index = CPNotFound; - + while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound) [_items[index] setSelected:NO]; } @@ -299,19 +299,19 @@ { if (_selectionIndexes == anIndexSet || !_isSelectable) return; - + var index = CPNotFound; - + while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound) [_items[index] setSelected:NO]; - + _selectionIndexes = anIndexSet; - + var index = CPNotFound; - + while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound) [_items[index] setSelected:YES]; - + if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)]) [_delegate collectionViewDidChangeSelection:self] } @@ -326,10 +326,10 @@ /* @ignore */ - (void)reloadContent -{ +{ // Remove current views var count = _items.length; - + while (count--) { [[_items[count] view] removeFromSuperview]; @@ -337,7 +337,7 @@ _cachedItems.push(_items[count]); } - + _items = []; if (!_itemPrototype || !_content) @@ -350,7 +350,7 @@ for (; index < count; ++index) { _items.push([self newItemForRepresentedObject:_content[index]]); - + [self addSubview:[_items[index] view]]; } @@ -365,49 +365,49 @@ - (void)tile { var width = CGRectGetWidth([self bounds]); - + if (![_content count] || width == _tileWidth) 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 // margin var itemSize = CGSizeMakeCopy(_minItemSize); - + _numberOfColumns = MAX(1.0, FLOOR(width / itemSize.width)); - + if (_maxNumberOfColumns > 0) _numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns); - + var remaining = width - _numberOfColumns * itemSize.width, itemsNeedSizeUpdate = NO; - + if (remaining > 0 && itemSize.width < _maxItemSize.width) 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. if (_maxNumberOfColumns == 1 && itemSize.width < _maxItemSize.width && itemSize.width < width) itemSize.width = MIN(_maxItemSize.width, width); - + if (!CGSizeEqualToSize(_itemSize, itemSize)) { _itemSize = itemSize; itemsNeedSizeUpdate = YES; } - + var index = 0, count = _items.length; - + if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0) count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows); - + _numberOfRows = CEIL(count / _numberOfColumns); _horizontalMargin = FLOOR((width - _numberOfColumns * itemSize.width) / (_numberOfColumns + 1)); - + var x = _horizontalMargin, y = -itemSize.height; - + for (; index < count; ++index) { if (index % _numberOfColumns == 0) @@ -415,17 +415,17 @@ x = _horizontalMargin; y += _verticalMargin + itemSize.height; } - + var view = [_items[index] view]; - + [view setFrameOrigin:CGPointMake(x, y)]; - + if (itemsNeedSizeUpdate) [view setFrameSize:_itemSize]; - + x += itemSize.width + _horizontalMargin; } - + _tileWidth = width; [self setFrameSize:CGSizeMake(width, y + itemSize.height + _verticalMargin)]; _tileWidth = -1.0; @@ -445,9 +445,9 @@ { if (_maxNumberOfRows == aMaxNumberOfRows) return; - + _maxNumberOfRows = aMaxNumberOfRows; - + [self tile]; } @@ -467,9 +467,9 @@ { if (_maxNumberOfColumns == aMaxNumberOfColumns) return; - + _maxNumberOfColumns = aMaxNumberOfColumns; - + [self tile]; } @@ -506,9 +506,9 @@ { if (CGSizeEqualToSize(_minItemSize, aSize)) return; - + _minItemSize = CGSizeMakeCopy(aSize); - + [self tile]; } @@ -528,9 +528,9 @@ { if (CGSizeEqualToSize(_maxItemSize, aSize)) return; - + _maxItemSize = CGSizeMakeCopy(aSize); - + [self tile]; } @@ -656,9 +656,9 @@ { if (_verticalMargin == aVerticalMargin) return; - + _verticalMargin = aVerticalMargin; - + [self tile]; } @@ -709,7 +709,7 @@ count = [indexArray count]; for (; index < count; ++index) - frame = CGRectUnion(frame, [self rectForItemAtIndex:indexArray[index]]); + frame = CGRectUnion(frame, [self frameForItemAtIndex:indexArray[index]]); return frame; } @@ -729,7 +729,7 @@ - (void)moveLeft:(id)sender { var index = [[self selectionIndexes] firstIndex]; - if (index === CPNotFound) + if (index === CPNotFound) index = [[self items] count]; index = MAX(index - 1, 0); @@ -757,7 +757,7 @@ - (void)moveUp:(id)sender { var index = [[self selectionIndexes] firstIndex]; - if (index == CPNotFound) + if (index == CPNotFound) index = [[self items] count]; index = MAX(0, index - [self numberOfColumns]); @@ -829,20 +829,20 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey", _cachedItems = []; _itemSize = CGSizeMakeZero(); - + _minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero(); _maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero(); - + _verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey]; - + _isSelectable = [aCoder decodeBoolForKey:CPCollectionViewSelectableKey]; [self setBackgroundColors:[aCoder decodeObjectForKey:CPCollectionViewBackgroundColorsKey]]; - + _tileWidth = -1.0; _selectionIndexes = [CPIndexSet indexSet]; - + _allowsEmptySelection = YES; } @@ -855,12 +855,12 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey", if (!CGSizeEqualToSize(_minItemSize, CGSizeMakeZero())) [aCoder encodeSize:_minItemSize forKey:CPCollectionViewMinItemSizeKey]; - + if (!CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero())) [aCoder encodeSize:_maxItemSize forKey:CPCollectionViewMaxItemSizeKey]; - + [aCoder encodeBool:_isSelectable forKey:CPCollectionViewSelectableKey]; - + [aCoder encodeFloat:_verticalMargin forKey:CPCollectionViewVerticalMarginKey]; [aCoder encodeObject:_backgroundColors forKey:CPCollectionViewBackgroundColorsKey]; From 0f5dd9d4694db4a62e0ab0599ee60e215681313e Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Fri, 16 Apr 2010 00:55:48 -0400 Subject: [PATCH 6/8] [CPSet description] with unit test. --- Foundation/CPSet.j | 43 ++++++++++++++++++++---------------- Tests/Foundation/CPSetTest.j | 13 +++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Foundation/CPSet.j b/Foundation/CPSet.j index 7026a376e..ad596c0fd 100644 --- a/Foundation/CPSet.j +++ b/Foundation/CPSet.j @@ -23,7 +23,7 @@ * * TODO: Needs to implement CPCoding, CPCopying. */ - + @import "CPObject.j" @import "CPArray.j" @import "CPNumber.j" @@ -79,7 +79,7 @@ /* 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 ... 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, ... { @@ -89,7 +89,7 @@ for(; i < argLength && ((argument = arguments[i]) !== nil); ++i) [set addObject:argument]; - + return set; } @@ -112,7 +112,7 @@ _count = 0; _contents = {}; } - + 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. */ - (id)initWithArray:(CPArray)anArray -{ +{ if (self = [self init]) { var count = anArray.length; - + while (count--) [self addObject:anArray[count]]; } - + return self; } /* 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. */ - (id)initWithObjects:(id)objects count:(unsigned)count @@ -158,7 +158,7 @@ for(; i < argLength && (argument = arguments[i]) != nil; ++i) [self addObject:argument]; } - + return self; } @@ -179,9 +179,9 @@ if (!aSet) return self; - + var contents = aSet._contents; - + for (var property in contents) { if (contents.hasOwnProperty(property)) @@ -192,7 +192,7 @@ [self addObject:contents[property]]; } } - + return self; } @@ -202,13 +202,13 @@ - (CPArray)allObjects { var array = []; - + for (var property in _contents) { if (_contents.hasOwnProperty(property)) array.push(_contents[property]); } - + return array; } @@ -222,7 +222,7 @@ if (_contents.hasOwnProperty(property)) return _contents[property]; } - + return nil; } @@ -236,7 +236,7 @@ if (obj !== undefined && [obj isEqual:anObject]) return YES; - + return NO; } @@ -277,7 +277,7 @@ @param set The set with which to compare the receiver. */ - (BOOL)isEqualToSet:(CPSet)set -{ +{ // If both are subsets of each other, they are equal return self === set || ([self count] === [set count] && [set isSubsetOfSet:self]); } @@ -295,7 +295,7 @@ if (![set containsObject:items[i]]) return NO; } - + return YES; } @@ -330,7 +330,7 @@ { if ([self containsObject:object]) return object; - + return nil; } @@ -467,6 +467,11 @@ } } +- (CPString)description +{ + return @"{(" + [self allObjects].join(", ") + ")}"; +} + @end @implementation CPSet (CPCopying) diff --git a/Tests/Foundation/CPSetTest.j b/Tests/Foundation/CPSetTest.j index 905d8fdb8..e8f4fd162 100644 --- a/Tests/Foundation/CPSetTest.j +++ b/Tests/Foundation/CPSetTest.j @@ -56,4 +56,17 @@ [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 From a7021e6b664d992231eccfe257b772bee5845f9e Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 17 Apr 2010 15:28:33 -0400 Subject: [PATCH 7/8] Fixed a parameter type typo. --- AppKit/CPTextField.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 7459fa772..acaf4139b 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -997,7 +997,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); return bounds; } -- (CGRect)bezelRectForBounds:(CFRect)bounds +- (CGRect)bezelRectForBounds:(CGRect)bounds { var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"]; From 4479233beaa4ebc268e2550ef8f5211ab91fc444 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 21 Apr 2010 20:57:53 -0700 Subject: [PATCH 8/8] Return nil fonts if they are the aristo default, so that the theme default is used instead of the arist default (for custom themes). --- Tools/nib2cib/NSFont.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/nib2cib/NSFont.j b/Tools/nib2cib/NSFont.j index 35508f4e9..41643eb22 100644 --- a/Tools/nib2cib/NSFont.j +++ b/Tools/nib2cib/NSFont.j @@ -33,8 +33,8 @@ if ((fontName === "LucidaGrande" || fontName === "LucidaGrande-Bold") && size === 13) { - CPLog.debug("Converting default IB font: <"+fontName+", "+size+"> to default Aristo font: "); - return [CPFont boldSystemFontOfSize:12.0]; + CPLog.debug("Removing default IB font: <"+fontName+", "+size+"> for theme default font."); + return nil; } // FIXME: Is this alwasy true?