Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
danielctull committed Feb 20, 2011
2 parents a40a16a + cdcebdf commit 0b51824
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 36 deletions.
12 changes: 6 additions & 6 deletions DTGridView.h
Expand Up @@ -96,8 +96,8 @@ struct DTOutset {

NSInteger numberOfRows;

NSInteger rowIndexOfSelectedCell;
NSInteger columnIndexOfSelectedCell;
NSUInteger rowIndexOfSelectedCell;
NSUInteger columnIndexOfSelectedCell;

NSTimer *decelerationTimer;
NSTimer *draggingTimer;
Expand Down Expand Up @@ -160,7 +160,7 @@ struct DTOutset {
@param columnIndex The index of the column of the wanted cell.
@return The grid view cell of the grid or nil if the cell is not visible or the indexes is out of range.
*/
- (DTGridViewCell *)cellForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex;
- (DTGridViewCell *)cellForRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex;

/*!
@abstract A constant that identifies a relative position in the receiving table view (top, middle, bottom) for row when scrolling concludes. See “Table View Scroll Position” a descriptions of valid constants.
Expand All @@ -169,9 +169,9 @@ struct DTOutset {
@param position The position the cell should be in once scrolled to.
@param animated If this
*/
- (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated;
- (void)scrollViewToRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated;

- (void)selectRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated;
- (void)selectRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated;

/*!
@abstract This method should be used by subclasses to know when the grid did appear on screen.
Expand Down Expand Up @@ -221,4 +221,4 @@ The grid view object requesting this information.
- (NSInteger)spacingBetweenRowsInGridView:(DTGridView *)gridView;
- (NSInteger)spacingBetweenColumnsInGridView:(DTGridView *)gridView;

@end
@end
39 changes: 19 additions & 20 deletions DTGridView.m
Expand Up @@ -13,7 +13,7 @@


@interface DTGridViewCellInfo : NSObject <DTGridViewCellInfoProtocol> {
NSInteger xPosition, yPosition;
NSUInteger xPosition, yPosition;
CGRect frame;
CGFloat x, y, width, height;
}
Expand All @@ -34,7 +34,7 @@ - (void)checkViews;
- (void)initialiseViews;
- (void)fireEdgeScroll;
- (void)checkNewRowStartingWithCellInfo:(NSObject<DTGridViewCellInfoProtocol> *)info goingUp:(BOOL)goingUp;
- (NSObject<DTGridViewCellInfoProtocol> *)cellInfoForRow:(NSInteger)row column:(NSInteger)col;
- (NSObject<DTGridViewCellInfoProtocol> *)cellInfoForRow:(NSUInteger)row column:(NSUInteger)col;
- (void)checkRow:(NSInteger)row column:(NSInteger)col goingLeft:(BOOL)goingLeft;


Expand Down Expand Up @@ -140,7 +140,7 @@ - (void)reloadData {

- (void)drawRect:(CGRect)rect {

oldContentOffset = CGPointMake(0.0, 0.0);
oldContentOffset = CGPointMake(0.0f, 0.0f);

//hasLoadedData = NO;

Expand Down Expand Up @@ -380,7 +380,7 @@ - (void)loadData {
CGFloat x;

if (i == 0) {
y = 0.0;
y = 0.0f;
//info.frame.origin.y = 0.0;
} else {
DTGridViewCellInfo *previousCellRow = [[cellInfoArrayRows objectAtIndex:i-1] objectAtIndex:0];
Expand All @@ -391,7 +391,7 @@ - (void)loadData {
}

if (j == 0) {
x = 0.0;
x = 0.0f;
} else {
DTGridViewCellInfo *previousCellRow = [cellInfoArrayCols objectAtIndex:j-1];
x = previousCellRow.frame.origin.x + previousCellRow.frame.size.width;
Expand Down Expand Up @@ -478,19 +478,20 @@ - (void)checkViews {

for (DTGridViewCellInfo *info in orderedCells) {

if (isGoingLeft){
if (info.xPosition > 0 && info.frame.origin.x > self.contentOffset.x)
if (isGoingLeft) {
if (info.xPosition > 0 && info.frame.origin.x > self.contentOffset.x) {
if (![leftRightCells objectForKey:[NSString stringWithFormat:@"%i", info.yPosition]])
[leftRightCells setObject:info forKey:[NSString stringWithFormat:@"%i", info.yPosition]];
else if ([[leftRightCells objectForKey:[NSString stringWithFormat:@"%i", info.yPosition]] xPosition] > info.xPosition)
[leftRightCells setObject:info forKey:[NSString stringWithFormat:@"%i", info.yPosition]];
}
} else if (isGoingRight) {
if ([[self.gridCells objectAtIndex:info.yPosition] count] - 1 > info.xPosition && info.frame.origin.x + info.frame.size.width < self.contentOffset.x + self.frame.size.width)
if ([[self.gridCells objectAtIndex:info.yPosition] count] - 1 > info.xPosition && info.frame.origin.x + info.frame.size.width < self.contentOffset.x + self.frame.size.width) {
if (![leftRightCells objectForKey:[NSString stringWithFormat:@"%i", info.yPosition]])
[leftRightCells setObject:info forKey:[NSString stringWithFormat:@"%i", info.yPosition]];
else if ([[leftRightCells objectForKey:[NSString stringWithFormat:@"%i", info.yPosition]] xPosition] < info.xPosition)
[leftRightCells setObject:info forKey:[NSString stringWithFormat:@"%i", info.yPosition]];
}
}

if (![self cellInfoShouldBeOnShow:info])
Expand Down Expand Up @@ -523,7 +524,7 @@ - (void)checkViews {

- (void)initialiseViews {

for (NSInteger i = 0; i < [cellInfoForCellsOnScreen count]; i++) {
for (NSUInteger i = 0; i < [cellInfoForCellsOnScreen count]; i++) {

DTGridViewCellInfo *info = [cellInfoForCellsOnScreen objectAtIndex:i];

Expand All @@ -532,11 +533,11 @@ - (void)initialiseViews {

}

for (NSInteger i = 0; i < [gridCells count]; i++) {
for (NSUInteger i = 0; i < [gridCells count]; i++) {

NSMutableArray *row = [gridCells objectAtIndex:i];

for (NSInteger j = 0; j < [row count]; j++) {
for (NSUInteger j = 0; j < [row count]; j++) {

id object = [row objectAtIndex:j];

Expand Down Expand Up @@ -570,9 +571,7 @@ - (void)checkRow:(NSInteger)row column:(NSInteger)col goingLeft:(BOOL)goingLeft
}
}

- (NSObject<DTGridViewCellInfoProtocol> *)cellInfoForRow:(NSInteger)row column:(NSInteger)col {

if (row < 0 || col < 0) return nil;
- (NSObject<DTGridViewCellInfoProtocol> *)cellInfoForRow:(NSUInteger)row column:(NSUInteger)col {

if ([self.gridCells count] <= row) return nil;

Expand Down Expand Up @@ -646,7 +645,7 @@ - (DTGridViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier {
return nil;
}

- (DTGridViewCell *)cellForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex {
- (DTGridViewCell *)cellForRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex {

for (UIView *v in self.subviews) {
if ([v isKindOfClass:[DTGridViewCell class]]) {
Expand All @@ -659,7 +658,7 @@ - (DTGridViewCell *)cellForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex
return nil;
}

- (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated {
- (void)scrollViewToRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated {

CGFloat xPos = 0, yPos = 0;

Expand Down Expand Up @@ -743,12 +742,12 @@ - (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scroll
if (xPos > self.contentSize.width - self.frame.size.width)
xPos = self.contentSize.width - self.frame.size.width;
else if (xPos < 0)
xPos = 0.0;
xPos = 0.0f;

if (yPos > self.contentSize.height - self.frame.size.height)
yPos = self.contentSize.height - self.frame.size.height;
else if (yPos < 0)
yPos = 0.0;
yPos = 0.0f;

[self scrollRectToVisible:CGRectMake(xPos, yPos, self.frame.size.width, self.frame.size.height) animated:animated];

Expand All @@ -761,7 +760,7 @@ - (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scroll

}

- (void)selectRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated {
- (void)selectRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated {

for (UIView *v in self.subviews) {
if ([v isKindOfClass:[DTGridViewCell class]]) {
Expand Down
2 changes: 1 addition & 1 deletion DTGridViewCell.h
Expand Up @@ -18,7 +18,7 @@
*/
@interface DTGridViewCell : UIView <DTGridViewCellInfoProtocol> {

NSInteger xPosition, yPosition;
NSUInteger xPosition, yPosition;
NSString *identifier;

BOOL selected;
Expand Down
2 changes: 1 addition & 1 deletion DTGridViewCellInfoProtocol.h
Expand Up @@ -7,6 +7,6 @@
//

@protocol DTGridViewCellInfoProtocol
@property (nonatomic, assign) NSInteger xPosition, yPosition;
@property (nonatomic, assign) NSUInteger xPosition, yPosition;
@property (nonatomic, assign) CGRect frame;
@end
6 changes: 3 additions & 3 deletions DTGridViewController.m
Expand Up @@ -35,14 +35,14 @@ - (void)dealloc {
- (NSInteger)numberOfRowsInGridView:(DTGridView *)gridView {
return 0;
}
- (NSInteger)numberOfColumnsInGridView:(DTGridView *)gridView forRowWithIndex:(NSInteger)index {
- (NSInteger)numberOfColumnsInGridView:(DTGridView *)gridView forRowWithIndex:(NSInteger)theIndex {
return 0;
}
- (CGFloat)gridView:(DTGridView *)gridView heightForRow:(NSInteger)rowIndex {
return 0.0;
return 0.0f;
}
- (CGFloat)gridView:(DTGridView *)gridView widthForCellAtRow:(NSInteger)rowIndex column:(NSInteger)columnIndex {
return 0.0;
return 0.0f;
}
- (DTGridViewCell *)gridView:(DTGridView *)gridView viewForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion DTInfiniteGridView/DTInfiniteGridView.m
Expand Up @@ -121,4 +121,4 @@ - (void)layoutSubviews {
[super layoutSubviews];
}

@end
@end
4 changes: 2 additions & 2 deletions DTSnapGridView/DTLabelsSnapGridViewCell.m
Expand Up @@ -46,10 +46,10 @@ - (void)drawRect:(CGRect)rect {
NSInteger halfHeight = (NSInteger)(self.frame.size.height/2.0);

CGSize labelSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font];
self.titleLabel.frame = CGRectMake(0.0, halfHeight-labelSize.height, labelSize.width, labelSize.height);
self.titleLabel.frame = CGRectMake(0.0f, halfHeight-labelSize.height, labelSize.width, labelSize.height);

labelSize = [self.subtitleLabel.text sizeWithFont:self.subtitleLabel.font];
self.subtitleLabel.frame = CGRectMake(0.0, halfHeight+1.0, labelSize.width, labelSize.height);
self.subtitleLabel.frame = CGRectMake(0.0f, halfHeight+1.0f, labelSize.width, labelSize.height);

[self addSubview:self.titleLabel];
[self addSubview:self.subtitleLabel];
Expand Down
2 changes: 1 addition & 1 deletion DTSnapGridView/DTSnapGridView.m
Expand Up @@ -44,7 +44,7 @@ - (void)didEndMoving {
}

- (CGFloat)findWidthForRow:(NSInteger)row column:(NSInteger)column {
NSInteger w = (NSInteger)self.frame.size.width/3;
NSInteger w = (NSInteger)self.frame.size.width/3.0f;
return (CGFloat)w;
}

Expand Down
2 changes: 1 addition & 1 deletion DTSnapGridView/DTSnapGridViewCell.h
Expand Up @@ -17,4 +17,4 @@

@property (nonatomic, assign) CGFloat slideAmount;

@end
@end

0 comments on commit 0b51824

Please sign in to comment.