forked from camh/CHGridView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHGridView.h
92 lines (73 loc) · 2.89 KB
/
CHGridView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// CHGridView.h
//
// RELEASED UNDER THE MIT LICENSE
//
// Created by Cameron Kenly Hunt on 2/18/10.
// Copyright 2010 Cameron Kenley Hunt All rights reserved.
// http://cameron.io/project/chgridview
//
#import <UIKit/UIKit.h>
#import "CHTileView.h"
#import "CHSectionHeaderView.h"
#import "CHGridLayout.h"
@class CHGridView;
@class CHTileView;
// data source protocol
@protocol CHGridViewDataSource <NSObject>
- (int)numberOfTilesInSection:(int)section GridView:(CHGridView *)gridView;
- (CHTileView *)tileForIndexPath:(CHGridIndexPath)indexPath inGridView:(CHGridView *)gridView;
@optional
- (int)numberOfSectionsInGridView:(CHGridView *)gridView;
- (NSString *)titleForHeaderOfSection:(int)section inGridView:(CHGridView *)gridView;
@end
// delegate protocol
@protocol CHGridViewDelegate <NSObject,UIScrollViewDelegate>
@optional
- (void)selectedTileAtIndexPath:(CHGridIndexPath)indexPath inGridView:(CHGridView *)gridView;
- (void)visibleTilesChangedTo:(int)tiles;
- (CGSize)sizeForTileAtIndex:(CHGridIndexPath)indexPath inGridView:(CHGridView *)gridView;
- (CHSectionHeaderView *)headerViewForSection:(int)section inGridView:(CHGridView *)gridView;
@end
@interface CHGridView : UIScrollView {
CHGridLayout *layout;
UIView *tilesView;
NSMutableArray *visibleTiles;
NSMutableArray *visibleSectionHeaders;
NSMutableArray *reusableTiles;
id<CHGridViewDataSource> dataSource;
int sections;
NSMutableArray *sectionCounts;
int maxReusable;
CHGridIndexPath selectedIndexPath;
BOOL isSlowDevice;
//settable properties
BOOL centerTilesInGrid;
BOOL allowsSelection;
CGSize padding;
float preLoadMultiplier;
float rowHeight;
int perLine;
float sectionTitleHeight;
UIView *gridHeaderView, *gridFooterView;
}
@property (nonatomic, assign) id<CHGridViewDataSource> dataSource;
@property (nonatomic, assign) id<CHGridViewDelegate,UIScrollViewDelegate> delegate;
@property (nonatomic) BOOL centerTilesInGrid;
@property (nonatomic) BOOL allowsSelection;
@property (nonatomic) CGSize padding;
@property (nonatomic) float preLoadMultiplier;
@property (nonatomic) float rowHeight;
@property (nonatomic) int perLine;
@property (nonatomic) float sectionTitleHeight;
@property (nonatomic, retain) IBOutlet UIView *gridHeaderView, *gridFooterView;
- (void)reloadData;
- (void)reloadDataAndLayoutUpdateNeeded:(BOOL)layoutNeeded;
- (CHTileView *)dequeueReusableTileWithIdentifier:(NSString *)identifier;
- (CHTileView *)tileForIndexPath:(CHGridIndexPath)indexPath;
- (CHGridIndexPath)indexPathForPoint:(CGPoint)point;
- (void)scrollToTileAtIndexPath:(CHGridIndexPath)indexPath animated:(BOOL)animated;
- (void)selectTileAtIndexPath:(CHGridIndexPath)indexPath animated:(BOOL)animated;
- (void)deselectTileAtIndexPath:(CHGridIndexPath)indexPath;
- (void)deselectSelectedTile;
@end