mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Refs #1700. Use more macros.
This commit is contained in:
+29
-28
@@ -20,6 +20,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#import "../Foundation/CPRange.h"
|
||||
#import "../Foundation/Ref.h"
|
||||
|
||||
@import <Foundation/CPArray.j>
|
||||
@@ -154,11 +155,11 @@ var HORIZONTAL_MARGIN = 2;
|
||||
_numberOfColumns = CPNotFound;
|
||||
_numberOfRows = CPNotFound;
|
||||
|
||||
_itemSize = CGSizeMakeZero();
|
||||
_itemSize = _CGSizeMakeZero();
|
||||
|
||||
_selectionIndexes = [CPIndexSet indexSet];
|
||||
|
||||
_storedFrameSize = CGSizeMakeZero();
|
||||
_storedFrameSize = _CGSizeMakeZero();
|
||||
|
||||
_needsMinMaxItemSizeUpdate = YES;
|
||||
_uniformSubviewsResizing = NO;
|
||||
@@ -511,7 +512,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
{
|
||||
var width = aSuperviewSize.width,
|
||||
height = aSuperviewSize.height,
|
||||
itemSize = CGSizeMakeCopy(_minItemSize),
|
||||
itemSize = _CGSizeMakeCopy(_minItemSize),
|
||||
maxItemSizeWidth = _maxItemSize.width,
|
||||
maxItemSizeHeight = _maxItemSize.height,
|
||||
itemsCount = [_items count],
|
||||
@@ -569,7 +570,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
if (idx >= displayCount)
|
||||
{
|
||||
[view setFrameOrigin:CGPointMake(-anItemSize.width, -anItemSize.height)];
|
||||
[view setFrameOrigin:_CGPointMake(-anItemSize.width, -anItemSize.height)];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,7 +580,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
y += _verticalMargin + anItemSize.height;
|
||||
}
|
||||
|
||||
[view setFrameOrigin:CGPointMake(x, y)];
|
||||
[view setFrameOrigin:_CGPointMake(x, y)];
|
||||
[view setFrameSize:anItemSize];
|
||||
|
||||
x += anItemSize.width + _horizontalMargin;
|
||||
@@ -682,12 +683,12 @@ var HORIZONTAL_MARGIN = 2;
|
||||
if (aSize === nil || aSize === undefined)
|
||||
[CPException raise:CPInvalidArgumentException reason:"Invalid value provided for minimum size"];
|
||||
|
||||
if (CGSizeEqualToSize(_minItemSize, aSize))
|
||||
if (_CGSizeEqualToSize(_minItemSize, aSize))
|
||||
return;
|
||||
|
||||
_minItemSize = CGSizeMakeCopy(aSize);
|
||||
_minItemSize = _CGSizeMakeCopy(aSize);
|
||||
|
||||
if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
|
||||
if (_CGSizeEqualToSize(_minItemSize, _CGSizeMakeZero()))
|
||||
_needsMinMaxItemSizeUpdate = YES;
|
||||
|
||||
[self tile];
|
||||
@@ -707,10 +708,10 @@ var HORIZONTAL_MARGIN = 2;
|
||||
*/
|
||||
- (void)setMaxItemSize:(CGSize)aSize
|
||||
{
|
||||
if (CGSizeEqualToSize(_maxItemSize, aSize))
|
||||
if (_CGSizeEqualToSize(_maxItemSize, aSize))
|
||||
return;
|
||||
|
||||
_maxItemSize = CGSizeMakeCopy(aSize);
|
||||
_maxItemSize = _CGSizeMakeCopy(aSize);
|
||||
|
||||
// if (_maxItemSize.width == 0 || _maxItemSize.height == 0)
|
||||
// _needsMinMaxItemSizeUpdate = YES;
|
||||
@@ -782,9 +783,9 @@ var HORIZONTAL_MARGIN = 2;
|
||||
newSelectedRange = nil;
|
||||
|
||||
if (index < firstSelectedIndex)
|
||||
newSelectedRange = CPMakeRange(index, (firstSelectedIndex - index) + 1);
|
||||
newSelectedRange = _CPMakeRange(index, (firstSelectedIndex - index) + 1);
|
||||
else
|
||||
newSelectedRange = CPMakeRange(firstSelectedIndex, (index - firstSelectedIndex) + 1);
|
||||
newSelectedRange = _CPMakeRange(firstSelectedIndex, (index - firstSelectedIndex) + 1);
|
||||
|
||||
indexes = [[self selectionIndexes] copy];
|
||||
[indexes addIndexesInRange:newSelectedRange];
|
||||
@@ -936,9 +937,9 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
// Create and position the drop indicator view.
|
||||
if (!_dropView)
|
||||
_dropView = [[_CPCollectionViewDropIndicator alloc] initWithFrame:CGRectMake(-8, -8, 0, 0)];
|
||||
_dropView = [[_CPCollectionViewDropIndicator alloc] initWithFrame:_CGRectMake(-8, -8, 0, 0)];
|
||||
|
||||
[_dropView setFrameSize:CGSizeMake(10, _itemSize.height + _verticalMargin)];
|
||||
[_dropView setFrameSize:_CGSizeMake(10, _itemSize.height + _verticalMargin)];
|
||||
[self addSubview:_dropView];
|
||||
|
||||
var locationInWindow = [anEvent locationInWindow],
|
||||
@@ -965,14 +966,14 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:dragTypes owner:self];
|
||||
|
||||
var dragImageOffset = CGSizeMakeZero(),
|
||||
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);
|
||||
dragPoint = _CGPointMake(dragLocation.x - _itemSize.width / 2 , dragLocation.y - _itemSize.height / 2);
|
||||
|
||||
[self dragView:view
|
||||
at:dragPoint
|
||||
@@ -1103,10 +1104,10 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
_currentDragOperation = dragOperation;
|
||||
|
||||
var frameOrigin,
|
||||
dropviewFrameWidth = CGRectGetWidth([_dropView frame]);
|
||||
dropviewFrameWidth = _CGRectGetWidth([_dropView frame]);
|
||||
|
||||
if (_currentDropIndex == -1 || _currentDragOperation == CPDragOperationNone)
|
||||
frameOrigin = CGPointMake(-dropviewFrameWidth, 0);
|
||||
frameOrigin = _CGPointMake(-dropviewFrameWidth, 0);
|
||||
else
|
||||
{
|
||||
var offset;
|
||||
@@ -1123,7 +1124,7 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
|
||||
var rect = [self frameForItemAtIndex:dropIndex];
|
||||
|
||||
frameOrigin = CGPointMake(CGRectGetMaxX(rect) + offset, rect.origin.y - _verticalMargin);
|
||||
frameOrigin = _CGPointMake(_CGRectGetMaxX(rect) + offset, rect.origin.y - _verticalMargin);
|
||||
}
|
||||
|
||||
[_dropView setFrameOrigin:frameOrigin];
|
||||
@@ -1170,8 +1171,8 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
width = CGRectGetWidth(aRect),
|
||||
circleRect = CGRectMake(1, 1, width - 2, width - 2);
|
||||
width = _CGRectGetWidth(aRect),
|
||||
circleRect = _CGRectMake(1, 1, width - 2, width - 2);
|
||||
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"4886ca"]);
|
||||
CGContextSetFillColor(context, [CPColor whiteColor]);
|
||||
@@ -1183,8 +1184,8 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
CGContextStrokeEllipseInRect(context, circleRect);
|
||||
//then draw the line
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, FLOOR(width / 2), CGRectGetMinY(aRect) + width);
|
||||
CGContextAddLineToPoint(context, FLOOR(width / 2), CGRectGetHeight(aRect));
|
||||
CGContextMoveToPoint(context, FLOOR(width / 2), _CGRectGetMinY(aRect) + width);
|
||||
CGContextAddLineToPoint(context, FLOOR(width / 2), _CGRectGetHeight(aRect));
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
@@ -1205,9 +1206,9 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
|
||||
// if the direction is backward (-1) check with the bottom anchor
|
||||
if (aDirection === -1)
|
||||
[indexes addIndexesInRange:CPMakeRange(anIndex, bottomAnchor - anIndex + 1)];
|
||||
[indexes addIndexesInRange:_CPMakeRange(anIndex, bottomAnchor - anIndex + 1)];
|
||||
else
|
||||
[indexes addIndexesInRange:CPMakeRange(topAnchor, anIndex - topAnchor + 1)];
|
||||
[indexes addIndexesInRange:_CPMakeRange(topAnchor, anIndex - topAnchor + 1)];
|
||||
}
|
||||
else
|
||||
indexes = [CPIndexSet indexSetWithIndex:anIndex];
|
||||
@@ -1220,7 +1221,7 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
{
|
||||
var frame = [self frameForItemsAtIndexes:[self selectionIndexes]];
|
||||
|
||||
if (!CGRectIsNull(frame))
|
||||
if (!_CGRectIsNull(frame))
|
||||
[self scrollRectToVisible:frame];
|
||||
}
|
||||
|
||||
@@ -1368,10 +1369,10 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
if (!CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
|
||||
if (!_CGSizeEqualToSize(_minItemSize, _CGSizeMakeZero()))
|
||||
[aCoder encodeSize:_minItemSize forKey:CPCollectionViewMinItemSizeKey];
|
||||
|
||||
if (!CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
|
||||
if (!_CGSizeEqualToSize(_maxItemSize, _CGSizeMakeZero()))
|
||||
[aCoder encodeSize:_maxItemSize forKey:CPCollectionViewMaxItemSizeKey];
|
||||
|
||||
[aCoder encodeInt:_maxNumberOfRows forKey:CPCollectionViewMaxNumberOfRowsKey];
|
||||
|
||||
Reference in New Issue
Block a user