Merge pull request #1700 from cacaodev/CPCollectionViewItem-loading

CPCollectionView -maxItemSize support, content binding, collection view item loading ... [+4]
This commit is contained in:
Alexander Ljungberg
2013-02-08 10:52:00 +00:00
13 changed files with 3660 additions and 185 deletions
+509 -184
View File
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#import "../Foundation/Ref.h"
@import <Foundation/CPArray.j>
@import <Foundation/CPData.j>
@import <Foundation/CPIndexSet.j>
@@ -67,6 +69,8 @@
@return an array of drag types (CPString)
*/
var HORIZONTAL_MARGIN = 2;
@implementation CPCollectionView : CPView
{
CPArray _content;
@@ -103,6 +107,17 @@
id _delegate;
CPEvent _mouseDownEvent;
BOOL _needsMinMaxItemSizeUpdate;
CGSize _storedFrameSize;
BOOL _uniformSubviewsResizing @accessors(property=uniformSubviewsResizing);
BOOL _lockResizing;
CPInteger _currentDropIndex;
CPDragOperation _currentDragOperation;
_CPCollectionViewDropIndicator _dropView;
}
- (id)initWithFrame:(CGRect)aFrame
@@ -111,28 +126,52 @@
if (self)
{
_items = [];
_content = [];
_maxNumberOfRows = 0;
_maxNumberOfColumns = 0;
_cachedItems = [];
_itemSize = CGSizeMakeZero();
_minItemSize = CGSizeMakeZero();
_maxItemSize = CGSizeMakeZero();
[self setBackgroundColors:nil];
_verticalMargin = 5.0;
_tileWidth = -1.0;
_selectionIndexes = [CPIndexSet indexSet];
_allowsEmptySelection = YES;
_isSelectable = YES;
_allowsEmptySelection = YES;
[self _init];
}
return self;
}
- (void)_init
{
_content = [];
_items = [];
_cachedItems = [];
_numberOfColumns = CPNotFound;
_numberOfRows = CPNotFound;
_itemSize = CGSizeMakeZero();
_selectionIndexes = [CPIndexSet indexSet];
_storedFrameSize = CGSizeMakeZero();
_needsMinMaxItemSizeUpdate = YES;
_uniformSubviewsResizing = NO;
_lockResizing = NO;
_currentDropIndex = -1;
_currentDragOperation = CPDragOperationNone;
_dropView = nil;
[self setAutoresizesSubviews:NO];
[self setAutoresizingMask:0];
}
/*!
Sets the item prototype to \c anItem
@@ -187,7 +226,7 @@
_itemForDragging = nil;
_itemPrototype = anItem;
[self reloadContent];
[self reloadContentCachingRemovedItems:NO];
}
/*!
@@ -210,13 +249,7 @@
item = _cachedItems.pop();
else
{
if (!_itemData)
if (_itemPrototype)
_itemData = [CPKeyedArchiver archivedDataWithRootObject:_itemPrototype];
item = [CPKeyedUnarchiver unarchiveObjectWithData:_itemData];
}
item = [_itemPrototype copy];
[item setRepresentedObject:anObject];
[[item view] setFrameSize:_itemSize];
@@ -382,8 +415,13 @@
return [_selectionIndexes copy];
}
/* @ignore */
- (void)reloadContent
{
[self reloadContentCachingRemovedItems:YES];
}
/* @ignore */
- (void)reloadContentCachingRemovedItems:(BOOL)shouldCache
{
// Remove current views
var count = _items.length;
@@ -393,7 +431,8 @@
[[_items[count] view] removeFromSuperview];
[_items[count] setSelected:NO];
_cachedItems.push(_items[count]);
if (shouldCache)
_cachedItems.push(_items[count]);
}
_items = [];
@@ -417,91 +456,159 @@
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound && index < count)
[_items[index] setSelected:YES];
[self tile];
[self tileIfNeeded:NO];
}
/* @ignore */
- (void)tile
- (void)resizeSubviewsWithOldSize:(CPSize)oldBoundsSize
{
var width = CGRectGetWidth([self bounds]);
// Desactivate subviews autoresizing
}
if (width == _tileWidth)
- (void)resizeWithOldSuperviewSize:(CPSize)oldBoundsSize
{
if (_lockResizing)
return;
// 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);
_lockResizing = YES;
_numberOfColumns = MAX(1.0, FLOOR(width / itemSize.width));
[self tile];
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)
{
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;
}
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;
[self setFrameSize:CGSizeMake(width, proposedHeight)];
_tileWidth = -1.0;
_lockResizing = NO;
}
- (void)resizeSubviewsWithOldSize:(CGSize)aSize
- (void)tile
{
[self tile];
[self tileIfNeeded:!_uniformSubviewsResizing];
}
- (void)tileIfNeeded:(BOOL)lazyFlag
{
var frameSize = [[self superview] frameSize],
count = _items.length,
oldNumberOfColumns = _numberOfColumns,
oldNumberOfRows = _numberOfRows,
oldItemSize = _itemSize,
storedFrameSize = _storedFrameSize;
[self _updateMinMaxItemSizeIfNeeded];
[self _computeGridWithSize:frameSize count:AT_REF(count)];
//CPLog.debug("frameSize="+CPStringFromSize(frameSize) + "itemSize="+CPStringFromSize(itemSize) + " ncols=" + colsRowsCount[0] +" nrows="+ colsRowsCount[1]+" displayCount="+ colsRowsCount[2]);
[self setFrameSize:_storedFrameSize];
//CPLog.debug("OLD " + oldNumberOfColumns + " NEW " + _numberOfColumns);
if (!lazyFlag ||
_numberOfColumns !== oldNumberOfColumns ||
_numberOfRows !== oldNumberOfRows ||
!CGSizeEqualToSize(_itemSize, oldItemSize))
[self displayItems:_items frameSize:_storedFrameSize itemSize:_itemSize columns:_numberOfColumns rows:_numberOfRows count:count];
}
- (void)_computeGridWithSize:(CGSize)aSuperviewSize count:(Function)countRef
{
var width = aSuperviewSize.width,
height = aSuperviewSize.height,
itemSize = CGSizeMakeCopy(_minItemSize),
maxItemSizeWidth = _maxItemSize.width,
maxItemSizeHeight = _maxItemSize.height,
itemsCount = [_items count],
numberOfRows,
numberOfColumns;
numberOfColumns = FLOOR(width / itemSize.width);
if (maxItemSizeWidth == 0)
numberOfColumns = MIN(numberOfColumns, _maxNumberOfColumns);
if (_maxNumberOfColumns > 0)
numberOfColumns = MIN(MIN(_maxNumberOfColumns, itemsCount), numberOfColumns);
numberOfColumns = MAX(1.0, numberOfColumns);
itemSize.width = FLOOR(width / numberOfColumns);
if (maxItemSizeWidth > 0)
{
itemSize.width = MIN(maxItemSizeWidth, itemSize.width);
if (numberOfColumns == 1)
itemSize.width = MIN(maxItemSizeWidth, width);
}
numberOfRows = MAX(1.0 , MIN(CEIL(itemsCount / numberOfColumns), _maxNumberOfRows));
height = MAX(height, numberOfRows * (_minItemSize.height + _verticalMargin));
var itemSizeHeight = FLOOR(height / numberOfRows);
if (maxItemSizeHeight > 0)
itemSizeHeight = MIN(itemSizeHeight, maxItemSizeHeight);
_itemSize = CGSizeMake(MAX(_minItemSize.width, itemSize.width), MAX(_minItemSize.height, itemSizeHeight));
_storedFrameSize = CGSizeMake(MAX(width, _minItemSize.width), height);
_numberOfColumns = numberOfColumns;
_numberOfRows = numberOfRows;
countRef(MIN(itemsCount, numberOfColumns * numberOfRows));
}
- (void)displayItems:(CPArray)displayItems frameSize:(CGSize)aFrameSize itemSize:(CGSize)anItemSize columns:(CPInteger)numberOfColumns rows:(CPInteger)numberOfRows count:(CPInteger)displayCount
{
// CPLog.debug("DISPLAY ITEMS " + numberOfColumns + " " + numberOfRows);
_horizontalMargin = _uniformSubviewsResizing ? FLOOR((aFrameSize.width - numberOfColumns * anItemSize.width) / (numberOfColumns + 1)) : HORIZONTAL_MARGIN;
var x = _horizontalMargin,
y = -anItemSize.height;
[displayItems enumerateObjectsUsingBlock:function(item, idx, stop)
{
var view = [item view];
if (idx >= displayCount)
{
[view setFrameOrigin:CGPointMake(-anItemSize.width, -anItemSize.height)];
return;
}
if (idx % numberOfColumns == 0)
{
x = _horizontalMargin;
y += _verticalMargin + anItemSize.height;
}
[view setFrameOrigin:CGPointMake(x, y)];
[view setFrameSize:anItemSize];
x += anItemSize.width + _horizontalMargin;
}];
}
- (void)_updateMinMaxItemSizeIfNeeded
{
if (!_needsMinMaxItemSizeUpdate)
return;
var prototypeView;
if (_itemPrototype && (prototypeView = [_itemPrototype view]))
{
if (_minItemSize.width == 0)
_minItemSize.width = [prototypeView frameSize].width;
if (_minItemSize.height == 0)
_minItemSize.height = [prototypeView frameSize].height;
if (_maxItemSize.height == 0 && !([prototypeView autoresizingMask] & CPViewHeightSizable))
_maxItemSize.height = [prototypeView frameSize].height;
if (_maxItemSize.width == 0 && !([prototypeView autoresizingMask] & CPViewWidthSizable))
_maxItemSize.width = [prototypeView frameSize].width;
_needsMinMaxItemSizeUpdate = NO;
}
}
// Laying Out the Collection View
@@ -574,11 +681,15 @@
{
if (aSize === nil || aSize === undefined)
[CPException raise:CPInvalidArgumentException reason:"Invalid value provided for minimum size"];
if (CGSizeEqualToSize(_minItemSize, aSize))
return;
_minItemSize = CGSizeMakeCopy(aSize);
if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
_needsMinMaxItemSizeUpdate = YES;
[self tile];
}
@@ -601,6 +712,9 @@
_maxItemSize = CGSizeMakeCopy(aSize);
// if (_maxItemSize.width == 0 || _maxItemSize.height == 0)
// _needsMinMaxItemSizeUpdate = YES;
[self tile];
}
@@ -620,7 +734,7 @@
_backgroundColors = backgroundColors;
if (!_backgroundColors)
_backgroundColors = [CPColor whiteColor];
_backgroundColors = [[CPColor whiteColor]];
if ([_backgroundColors count] === 1)
[self setBackgroundColor:_backgroundColors[0]];
@@ -692,65 +806,6 @@
[self setSelectionIndexes:[CPIndexSet indexSet]];
}
- (void)mouseDragged:(CPEvent)anEvent
{
// Don't crash if we never registered the intial click.
if (!_mouseDownEvent)
return;
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:)])
return;
// If we don't have any selected items, we've clicked away, and thus the drag is meaningless.
if (![_selectionIndexes count])
return;
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)] &&
![_delegate collectionView:self canDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
return;
// Set up the pasteboard
var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes];
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:dragTypes owner:self];
if (!_itemForDragging)
_itemForDragging = [self newItemForRepresentedObject:_content[[_selectionIndexes firstIndex]]];
else
[_itemForDragging setRepresentedObject:_content[[_selectionIndexes firstIndex]]];
var view = [_itemForDragging view];
[view setFrameSize:_itemSize];
[view setAlphaValue:0.7];
[self dragView:view
at:[[_items[[_selectionIndexes firstIndex]] view] frame].origin
offset:CGSizeMakeZero()
event:_mouseDownEvent
pasteboard:nil
source:self
slideBack:YES];
}
/*!
Places the selected items on the specified pasteboard. The items are requested from the collection's delegate.
@param aPasteboard the pasteboard to put the items on
@param aType the format the pasteboard data
*/
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
{
[aPasteboard setData:[_delegate collectionView:self dataForItemsAtIndexes:_selectionIndexes forType:aType] forType:aType];
}
// Cappuccino Additions
/*!
@@ -768,6 +823,13 @@
[self tile];
}
- (void)setUniformSubviewsResizing:(float)flag
{
_uniformSubviewsResizing = flag;
[self tileIfNeeded:NO];
}
/*!
Gets the collection view's current vertical spacing between elements.
*/
@@ -810,10 +872,17 @@
- (int)_indexAtPoint:(CGPoint)thePoint
{
var row = FLOOR(thePoint.y / (_itemSize.height + _verticalMargin)),
column = FLOOR(thePoint.x / (_itemSize.width + _horizontalMargin));
var column = FLOOR(thePoint.x / (_itemSize.width + _horizontalMargin));
return row * _numberOfColumns + column;
if (column < _numberOfColumns)
{
var row = FLOOR(thePoint.y / (_itemSize.height + _verticalMargin));
if (row < _numberOfRows)
return (row * _numberOfColumns + column);
}
return CPNotFound;
}
- (CPCollectionViewItem)itemAtIndex:(unsigned)anIndex
@@ -844,6 +913,284 @@
@end
@implementation CPCollectionView (DragAndDrop)
/*
TODO: dropOperation is not supported yet. The visible drop operation is like CPCollectionViewDropBefore.
*/
/*!
Places the selected items on the specified pasteboard. The items are requested from the collection's delegate.
@param aPasteboard the pasteboard to put the items on
@param aType the format the pasteboard data
*/
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
{
[aPasteboard setData:[_delegate collectionView:self dataForItemsAtIndexes:_selectionIndexes forType:aType] forType:aType];
}
- (void)mouseDragged:(CPEvent)anEvent
{
// Don't crash if we never registered the intial click.
if (!_mouseDownEvent)
return;
// Create and position the drop indicator view.
if (!_dropView)
_dropView = [[_CPCollectionViewDropIndicator alloc] initWithFrame:CGRectMake(-8, -8, 0, 0)];
[_dropView setFrameSize:CGSizeMake(10, _itemSize.height + _verticalMargin)];
[self addSubview:_dropView];
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:)])
return;
// If we don't have any selected items, we've clicked away, and thus the drag is meaningless.
if (![_selectionIndexes count])
return;
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)] &&
![_delegate collectionView:self canDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
return;
// Set up the pasteboard
var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes];
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:dragTypes owner:self];
var dragImageOffset = CGSizeMakeZero(),
view = [self _draggingViewForItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent offset:dragImageOffset];
[view setFrameSize:_itemSize];
[view setAlphaValue:0.7];
var dragLocation = [self convertPoint:locationInWindow fromView:nil],
dragPoint = CGPointMake(dragLocation.x - _itemSize.width / 2 , dragLocation.y - _itemSize.height / 2);
[self dragView:view
at:dragPoint
offset:dragImageOffset
event:_mouseDownEvent
pasteboard:nil
source:self
slideBack:YES];
}
- (CPView)_draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent offset:(CGPoint)offset
{
if ([_delegate respondsToSelector:@selector(collectionView:draggingViewForItemsAtIndexes:withEvent:offset:)])
return [_delegate collectionView:self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:offset];
return [self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:offset];
}
- (CPView)draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset
{
var idx = _content[[indexes firstIndex]];
if (!_itemForDragging)
_itemForDragging = [self newItemForRepresentedObject:idx];
else
[_itemForDragging setRepresentedObject:idx];
return [_itemForDragging view];
}
- (BOOL)_canDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent
{
if ([self respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)])
return [_delegate collectionView:self canDragItemsAtIndexes:indexes withEvent:anEvent];
return YES;
}
- (CPDragOperation)draggingEntered:(id)draggingInfo
{
var dropIndex = -1,
dropIndexRef = AT_REF(dropIndex);
var dragOp = [self _validateDragWithInfo:draggingInfo dropIndex:dropIndexRef dropOperation:1];
dropIndex = dropIndexRef();
[self _updateDragAndDropStateWithDraggingInfo:draggingInfo newDragOperation:dragOp newDropIndex:dropIndex newDropOperation:1];
return _currentDragOperation;
}
- (CPDragOperation)draggingUpdated:(id)draggingInfo
{
if (![self _dropIndexDidChange:draggingInfo])
return _currentDragOperation;
var dropIndex,
dropIndexRef = AT_REF(dropIndex);
var dragOperation = [self _validateDragWithInfo:draggingInfo dropIndex:dropIndexRef dropOperation:1];
dropIndex = dropIndexRef();
[self _updateDragAndDropStateWithDraggingInfo:draggingInfo newDragOperation:dragOperation newDropIndex:dropIndex newDropOperation:1];
return dragOperation;
}
- (CPDragOperation)_validateDragWithInfo:(id)draggingInfo dropIndex:(Function)dropIndexRef dropOperation:(int)dropOperation
{
var result = CPDragOperationMove,
dropIndex = [self _dropIndexForDraggingInfo:draggingInfo proposedDropOperation:dropOperation];
if ([_delegate respondsToSelector:@selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
{
var dropIndexRef2 = AT_REF(dropIndex);
result = [_delegate collectionView:self validateDrop:draggingInfo proposedIndex:dropIndexRef2 dropOperation:dropOperation];
if (result !== CPDragOperationNone)
{
dropIndex = dropIndexRef2();
}
}
dropIndexRef(dropIndex);
return result;
}
- (void)draggingExited:(id)draggingInfo
{
[self _updateDragAndDropStateWithDraggingInfo:draggingInfo newDragOperation:0 newDropIndex:-1 newDropOperation:1];
}
- (void)draggingEnded:(id)draggingInfo
{
[self _updateDragAndDropStateWithDraggingInfo:draggingInfo newDragOperation:0 newDropIndex:-1 newDropOperation:1];
}
/*
Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
- (BOOL)_writeItemsAtIndexes:(CPIndexSet)indexes toPasteboard:(CPPasteboard)pboard
{
if ([self respondsToSelector:@selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
return [_delegate collectionView:self writeItemsAtIndexes:indexes toPasteboard:pboard];
return NO;
}
*/
- (BOOL)performDragOperation:(id)draggingInfo
{
var result = NO;
if (_currentDragOperation && _currentDropIndex !== -1)
result = [_delegate collectionView:self acceptDrop:draggingInfo index:_currentDropIndex dropOperation:1];
[self draggingEnded:draggingInfo]; // Is this correct ?
return result;
}
- (void)_updateDragAndDropStateWithDraggingInfo:(id)draggingInfo newDragOperation:(CPDragOperation)dragOperation newDropIndex:(CPInteger)dropIndex newDropOperation:(CPInteger)dropOperation
{
_currentDropIndex = dropIndex;
_currentDragOperation = dragOperation;
var frameOrigin,
dropviewFrameWidth = CGRectGetWidth([_dropView frame]);
if (_currentDropIndex == -1 || _currentDragOperation == CPDragOperationNone)
frameOrigin = CGPointMake(-dropviewFrameWidth, 0);
else
{
var offset;
if ((_currentDropIndex % _numberOfColumns) !== 0 || _currentDropIndex == [_items count])
{
dropIndex = _currentDropIndex - 1;
offset = (_horizontalMargin - dropviewFrameWidth) / 2;
}
else
{
offset = - _itemSize.width - dropviewFrameWidth - (_horizontalMargin - dropviewFrameWidth) / 2;
}
var rect = [self frameForItemAtIndex:dropIndex];
frameOrigin = CGPointMake(CGRectGetMaxX(rect) + offset, rect.origin.y - _verticalMargin);
}
[_dropView setFrameOrigin:frameOrigin];
}
- (BOOL)_dropIndexDidChange:(id)draggingInfo
{
var dropIndex = [self _dropIndexForDraggingInfo:draggingInfo proposedDropOperation:1];
if (dropIndex == CPNotFound)
dropIndex = [[self content] count];
return (_currentDropIndex !== dropIndex)
}
- (CPInteger)_dropIndexForDraggingInfo:(id)draggingInfo proposedDropOperation:(int)dropOperation
{
var location = [self convertPoint:[draggingInfo draggingLocation] fromView:nil],
locationX = location.x + _itemSize.width / 2;
var column = MIN(FLOOR(locationX / (_itemSize.width + _horizontalMargin)), _numberOfColumns),
row = FLOOR(location.y / (_itemSize.height + _verticalMargin));
if (row >= _numberOfRows - 1)
{
if (row >= _numberOfRows)
{
row = _numberOfRows - 1;
column = _numberOfColumns;
}
return MIN((row * _numberOfColumns + column), [_items count]);
}
return (row * _numberOfColumns + column);
}
@end
@implementation _CPCollectionViewDropIndicator : CPView
{
}
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
width = CGRectGetWidth(aRect),
circleRect = CGRectMake(1, 1, width - 2, width - 2);
CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"4886ca"]);
CGContextSetFillColor(context, [CPColor whiteColor]);
CGContextSetLineWidth(context, 3);
//draw white under the circle thing
CGContextFillRect(context, circleRect);
//draw the circle thing
CGContextStrokeEllipseInRect(context, circleRect);
//then draw the line
CGContextBeginPath(context);
CGContextMoveToPoint(context, FLOOR(width / 2), CGRectGetMinY(aRect) + width);
CGContextAddLineToPoint(context, FLOOR(width / 2), CGRectGetHeight(aRect));
CGContextClosePath(context);
CGContextStrokePath(context);
}
@end
@implementation CPCollectionView (KeyboardInteraction)
- (void)_modifySelectionWithNewIndex:(int)anIndex direction:(int)aDirection expand:(BOOL)shouldExpand
@@ -953,6 +1300,11 @@
[self interpretKeyEvents:[anEvent]];
}
- (void)setAutoresizingMask:(int)aMask
{
[super setAutoresizingMask:0];
}
@end
@implementation CPCollectionView (Deprecated)
@@ -987,35 +1339,12 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK
@implementation CPCollectionView (CPCoding)
- (void)awakeFromCib
{
[super awakeFromCib];
var prototypeView = [_itemPrototype view];
if (prototypeView && (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()) || CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero())))
{
var item = _itemPrototype;
if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
_minItemSize = [prototypeView frameSize];
else if (CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
_maxItemSize = [prototypeView frameSize];
}
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
_items = [];
_content = [];
_cachedItems = [];
_itemSize = CGSizeMakeZero();
_minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey];
_maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey];
@@ -1029,11 +1358,7 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK
[self setBackgroundColors:[aCoder decodeObjectForKey:CPCollectionViewBackgroundColorsKey]];
_tileWidth = -1.0;
_selectionIndexes = [CPIndexSet indexSet];
_allowsEmptySelection = YES;
[self _init];
}
return self;
+26 -1
View File
@@ -22,13 +22,38 @@
@import "CPViewController.j"
/*!
Represents an object inside a CPCollectionView.
*/
@implementation CPCollectionViewItem : CPViewController
{
BOOL _isSelected;
CPData _cachedArchive;
}
- (id)copy
{
var cibName = [self cibName],
copy;
if (cibName)
{
copy = [[[self class] alloc] initWithCibName:cibName bundle:[self cibBundle]];
}
else
{
if (!_cachedArchive)
_cachedArchive = [CPKeyedArchiver archivedDataWithRootObject:self];
copy = [CPKeyedUnarchiver unarchiveObjectWithData:_cachedArchive];
// copy connections
}
[copy setRepresentedObject:[self representedObject]];
[copy setSelected:_isSelected];
return copy;
}
// Setting the Represented Object
@@ -0,0 +1,264 @@
/*
* AppController.j
* CPCollectionViewNibTest
*
* Created by You on November 28, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
//@import "CPCollectionView.j"
CPLogRegister(CPLogConsole);
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
@outlet CPCollectionView collectionView @accessors;
@outlet InternalProtoypeItem prototypeItemInternal;
@outlet ExternalProtoypeItem prototypeItemExternal;
@outlet CPTableView tableView;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
[self willChangeValueForKey:@"minItemWidth"];
[self willChangeValueForKey:@"minItemHeight"];
[collectionView setMinItemSize:CGSizeMake(100, 100)];
[self didChangeValueForKey:@"minItemWidth"];
[self didChangeValueForKey:@"minItemHeight"];
[self willChangeValueForKey:@"maxItemWidth"];
[self willChangeValueForKey:@"maxItemHeight"];
[collectionView setMaxItemSize:CGSizeMake(200, 150)];
[self didChangeValueForKey:@"maxItemWidth"];
[self didChangeValueForKey:@"maxItemHeight"];
[collectionView registerForDraggedTypes:[@"DragType"]];
//[theWindow setFullPlatformWindow:YES];
}
- (IBAction)setPrototypeItem:(id)sender
{
var prototypeItem = [[sender selectedItem] tag] ? prototypeItemExternal : prototypeItemInternal;
[collectionView setItemPrototype:prototypeItem];
}
- (void)setMinItemWidth:(CPInteger)aWidth
{
var size = CGSizeMakeCopy([collectionView minItemSize]);
size.width = aWidth;
[collectionView setMinItemSize:size];
}
- (CPInteger)minItemWidth
{
return [collectionView minItemSize].width;
}
- (void)setMinItemHeight:(CPInteger)aHeight
{
var size = CGSizeMakeCopy([collectionView minItemSize]);
size.height = aHeight;
[collectionView setMinItemSize:size];
}
- (CPInteger)minItemHeight
{
return [collectionView minItemSize].height;
}
- (void)setMaxItemWidth:(CPInteger)aWidth
{
var size = CGSizeMakeCopy([collectionView maxItemSize]);
size.width = aWidth;
[collectionView setMaxItemSize:size];
}
- (CPInteger)maxItemWidth
{
return [collectionView maxItemSize].width;
}
- (void)setMaxItemHeight:(CPInteger)aHeight
{
var size = CGSizeMakeCopy([collectionView maxItemSize]);
size.height = aHeight;
[collectionView setMaxItemSize:size];
}
- (CPInteger)maxItemHeight
{
return [collectionView maxItemSize].height;
}
/*
DELEGATE METHODS
*/
- (CPData)collectionView:(CPCollectionView)aCollectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType
{
return indices;
}
- (CPView)collectionView:(CPCollectionView)aCollectionView draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset
{
return [aCollectionView draggingViewForItemsAtIndexes:indexes withEvent:event offset:dragImageOffset];
}
- (CPArray)collectionView:(CPCollectionView)aCollectionView dragTypesForItemsAtIndexes:(CPIndexSet)indices
{
return [@"DragType"];
}
- (BOOL)collectionView:(CPCollectionView)aCollectionView canDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent
{
return YES;
}
/*
- (BOOL)collectionView:(CPCollectionView)aCollectionView writeItemsAtIndexes:(CPIndexSet)indexes toPasteboard:(CPPasteboard)pboard
{
return YES;
}
*/
- (CPDragOperation)collectionView:(CPCollectionView)aCollectionView validateDrop:(id)draggingInfo proposedIndex:(Function)proposedIndexRef dropOperation:(CPInteger)collectionViewDropOperation
{
var pboard = [draggingInfo draggingPasteboard],
dragIndex = [[pboard dataForType:@"DragType"] firstIndex],
proposedIndex = proposedIndexRef();
if (proposedIndex == dragIndex || proposedIndex == dragIndex + 1)
return CPDragOperationNone;
return CPDragOperationMove;
}
- (BOOL)collectionView:(CPCollectionView)aCollectionView acceptDrop:(id)draggingInfo index:(CPInteger)proposedIndex dropOperation:(CPInteger)collectionViewDropOperation
{
var pboard = [draggingInfo draggingPasteboard],
dragIndexes = [pboard dataForType:@"DragType"];
[[aCollectionView content] moveIndexes:dragIndexes toIndex:proposedIndex];
[aCollectionView reloadContent];
[tableView reloadData];
return YES;
}
@end
@implementation InternalProtoypeItem: CPCollectionViewItem
{
@outlet CPTextField textField;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
textField = [aCoder decodeObjectForKey:@"TextField"];
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeConditionalObject:textField forKey:@"TextField"];
}
- (void)setRepresentedObject:(id)anObject
{
[super setRepresentedObject:anObject];
[textField setStringValue:[anObject objectForKey:@"value"]];
[[self view] setColor:[anObject objectForKey:@"color"]];
}
@end
@implementation ExternalProtoypeItem: CPCollectionViewItem
{
}
- (void)setRepresentedObject:(id)anObject
{
[super setRepresentedObject:anObject];
[[self view] setColor:[anObject objectForKey:@"color"]];
}
@end
var keyCode = 0;
@implementation ArrayController : CPArrayController
{
}
- (void)newObject
{
return [CPDictionary dictionaryWithObjectsAndKeys:(String.fromCharCode(65 + keyCode++)), @"value", [CPColor randomColor], @"color"];
}
@end
@implementation ColorView : CPView
{
CPColor color @accessors;
}
- (void)setColor:(CPColor)aColor
{
color = aColor;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(CGRect)aRect
{
if (!color)
color = [CPColor grayColor];
var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSetFillColor(context, color);
CGContextFillRect(context, aRect);
}
@end
@implementation CPArray (MoveIndexes)
- (void)moveIndexes:(CPIndexSet)indexes toIndex:(int)insertIndex
{
var aboveCount = 0,
object,
removeIndex;
var index = [indexes lastIndex];
while (index != CPNotFound)
{
if (index >= insertIndex)
{
removeIndex = index + aboveCount;
aboveCount ++;
}
else
{
removeIndex = index;
insertIndex --;
}
object = [self objectAtIndex:removeIndex];
[self removeObjectAtIndex:removeIndex];
[self insertObject:object atIndex:insertIndex];
index = [indexes indexLessThanIndex:index];
}
}
@end
@@ -0,0 +1,10 @@
<?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>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>CPCollectionViewNibTest</string>
</dict>
</plist>
@@ -0,0 +1,94 @@
/*
* Jakefile
* CPCollectionViewNibTest
*
* Created by You on November 28, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("CPCollectionViewNibTest", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "CPCollectionViewNibTest.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPCollectionViewNibTest");
task.setIdentifier("com.yourcompany.CPCollectionViewNibTest");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPCollectionViewNibTest");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["CPCollectionViewNibTest"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "CPCollectionViewNibTest", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "CPCollectionViewNibTest", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "CPCollectionViewNibTest"));
OS.system(["press", "-f", FILE.join("Build", "Release", "CPCollectionViewNibTest"), FILE.join("Build", "Deployment", "CPCollectionViewNibTest")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "CPCollectionViewNibTest"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPCollectionViewNibTest"), FILE.join("Build", "Desktop", "CPCollectionViewNibTest", "CPCollectionViewNibTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "CPCollectionViewNibTest", "CPCollectionViewNibTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPCollectionViewNibTest"));
print("----------------------------");
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,298 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11G63</string>
<string key="IBDocument.InterfaceBuilderVersion">2844</string>
<string key="IBDocument.AppKitVersion">1138.51</string>
<string key="IBDocument.HIToolboxVersion">569.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">2844</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSCustomObject</string>
<string>NSCustomView</string>
<string>NSTextField</string>
<string>NSTextFieldCell</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">NSCollectionViewItem</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="1005">
<reference key="NSNextResponder"/>
<int key="NSvFlags">303</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSTextField" id="167825784">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">311</int>
<string key="NSFrame">{{44, 4}, {82, 13}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="589750618">
<int key="NSCellFlags">68157504</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">selected !</string>
<object class="NSFont" key="NSSupport" id="792037410">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:1535</string>
<reference key="NSControlView" ref="167825784"/>
<object class="NSColor" key="NSBackgroundColor" id="48019285">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="581683701">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
</object>
</object>
<object class="NSTextField" id="169792613">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">271</int>
<string key="NSFrame">{{39, 70}, {87, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="667750628"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="791687302">
<int key="NSCellFlags">68157504</int>
<int key="NSCellFlags2">138413056</int>
<string key="NSContents">External</string>
<reference key="NSSupport" ref="792037410"/>
<string key="NSCellIdentifier">_NS:1535</string>
<reference key="NSControlView" ref="169792613"/>
<reference key="NSBackgroundColor" ref="48019285"/>
<object class="NSColor" key="NSTextColor" id="132551368">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
</object>
<object class="NSTextField" id="667750628">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">319</int>
<string key="NSFrame">{{48, 27}, {69, 39}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="167825784"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="484930569">
<int key="NSCellFlags">342884417</int>
<int key="NSCellFlags2">138413056</int>
<string key="NSContents">T</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">32</double>
<int key="NSfFlags">16</int>
</object>
<string key="NSCellIdentifier">_NS:1535</string>
<reference key="NSControlView" ref="667750628"/>
<bool key="NSDrawsBackground">YES</bool>
<reference key="NSBackgroundColor" ref="581683701"/>
<reference key="NSTextColor" ref="132551368"/>
</object>
</object>
</array>
<string key="NSFrameSize">{165, 94}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="169792613"/>
<string key="NSClassName">ColorView</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1005"/>
</object>
<int key="connectionID">16</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: representedObject.value</string>
<reference key="source" ref="667750628"/>
<reference key="destination" ref="1001"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="667750628"/>
<reference key="NSDestination" ref="1001"/>
<string key="NSLabel">value: representedObject.value</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">representedObject.value</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">39</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">hidden: selected</string>
<reference key="source" ref="167825784"/>
<reference key="destination" ref="1001"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="167825784"/>
<reference key="NSDestination" ref="1001"/>
<string key="NSLabel">hidden: selected</string>
<string key="NSBinding">hidden</string>
<string key="NSKeyPath">selected</string>
<dictionary key="NSOptions">
<integer value="0" key="NSNoSelectionPlaceholder"/>
<integer value="0" key="NSNullPlaceholder"/>
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">72</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="1005"/>
<array class="NSMutableArray" key="children">
<reference ref="667750628"/>
<reference ref="169792613"/>
<reference ref="167825784"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">28</int>
<reference key="object" ref="667750628"/>
<array class="NSMutableArray" key="children">
<reference ref="484930569"/>
</array>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">29</int>
<reference key="object" ref="484930569"/>
<reference key="parent" ref="667750628"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">32</int>
<reference key="object" ref="169792613"/>
<array class="NSMutableArray" key="children">
<reference ref="791687302"/>
</array>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">33</int>
<reference key="object" ref="791687302"/>
<reference key="parent" ref="169792613"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">43</int>
<reference key="object" ref="167825784"/>
<array class="NSMutableArray" key="children">
<reference ref="589750618"/>
</array>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">44</int>
<reference key="object" ref="589750618"/>
<reference key="parent" ref="167825784"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="1.IBNSViewMetadataLastInspectedTranslatesAutoresizingMaskIntoConstraints"/>
<boolean value="NO" key="1.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="28.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="32.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="33.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="43.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="44.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">72</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">ColorView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/ColorView.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,107 @@
<!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
CPCollectionViewNibTest
Created by You on November 28, 2012.
Copyright 2012, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, 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>CPCollectionViewNibTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" 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 supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_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);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</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 CPCollectionViewNibTest...</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>
@@ -0,0 +1,77 @@
<!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
CPCollectionViewNibTest
Created by You on November 28, 2012.
Copyright 2012, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, 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>CPCollectionViewNibTest</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 CPCollectionViewNibTest...</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>
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPCollectionViewNibTest
*
* Created by You on November 28, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}