-
Notifications
You must be signed in to change notification settings - Fork 0
/
EBGrid.h
37 lines (31 loc) · 1.23 KB
/
EBGrid.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
#import <Foundation/Foundation.h>
#import <EBFoundation/EBFoundation.h>
#if EBTargetOSX
#import <ApplicationServices/ApplicationServices.h>
#elif EBTargetIOS
#import <CoreGraphics/CoreGraphics.h>
#endif
typedef struct
{
CGFloat leftBorder;
CGFloat rightBorder;
CGFloat topBorder;
CGFloat bottomBorder;
CGSize cellSize;
CGSize cellSpacing;
} EBGridOptions;
typedef struct
{
EBGridOptions gridOptions;
CGFloat containerWidth;
NSUInteger elementCount;
} EBGridInfo;
EBGridOptions EBGridOptionsMake(CGFloat leftBorder, CGFloat rightBorder, CGFloat topBorder, CGFloat bottomBorder, CGSize cellSize, CGSize cellSpacing);
NSUInteger EBGridColumnCount(EBGridInfo gridInfo);
NSUInteger EBGridRowCount(EBGridInfo gridInfo);
CGSize EBGridContainerSize(EBGridInfo gridInfo);
CGRect EBGridRectForCellIndex(EBGridInfo gridInfo, NSUInteger cellIndex);
/* Returned cell indexes are not bounded by elementCount! */
NSIndexSet *EBGridCellIndexesForRect(EBGridInfo gridInfo, CGRect rect);
NSRange EBGridCellIndexRangeForRect(EBGridInfo gridInfo, CGRect rect);
BOOL EBGridMinMaxCellIndexesForRect(EBGridInfo gridInfo, CGRect rect, NSUInteger *outMinXIndex, NSUInteger *outMaxXIndex, NSUInteger *outMinYIndex, NSUInteger *outMaxYIndex);