#import "TUIScrollView.h"
#import "TUIFastIndexPath.h"
typedef enum {
TUITableViewStylePlain, TUITableViewStyleGrouped, } TUITableViewStyle;
typedef enum {
TUITableViewScrollPositionNone,
TUITableViewScrollPositionTop,
TUITableViewScrollPositionMiddle,
TUITableViewScrollPositionBottom,
TUITableViewScrollPositionToVisible, } TUITableViewScrollPosition;
typedef enum {
TUITableViewInsertionMethodBeforeIndex = NSOrderedAscending,
TUITableViewInsertionMethodAtIndex = NSOrderedSame,
TUITableViewInsertionMethodAfterIndex = NSOrderedDescending
} TUITableViewInsertionMethod;
@class TUITableViewCell;
@protocol TUITableViewDataSource;
@class TUITableView;
@protocol TUITableViewDelegate<NSObject, TUIScrollViewDelegate>
- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
@optional
- (void)tableView:(TUITableView *)tableView willDisplayCell:(TUITableViewCell *)cell forRowAtIndexPath:(TUIFastIndexPath *)indexPath; - (void)tableView:(TUITableView *)tableView didSelectRowAtIndexPath:(TUIFastIndexPath *)indexPath; - (void)tableView:(TUITableView *)tableView didDeselectRowAtIndexPath:(TUIFastIndexPath *)indexPath;
- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event;
- (BOOL)tableView:(TUITableView*)tableView shouldSelectRowAtIndexPath:(TUIFastIndexPath*)indexPath forEvent:(NSEvent*)event; - (NSMenu *)tableView:(TUITableView *)tableView menuForRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event;
- (void)tableViewWillReloadData:(TUITableView *)tableView;
- (void)tableViewDidReloadData:(TUITableView *)tableView;
- (TUIFastIndexPath *)tableView:(TUITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(TUIFastIndexPath *)fromPath toProposedIndexPath:(TUIFastIndexPath *)proposedPath;
@end
@interface TUITableView : TUIScrollView
{
TUITableViewStyle _style;
__unsafe_unretained id <TUITableViewDataSource> _dataSource; NSArray * _sectionInfo;
TUIView * _pullDownView;
TUIView * _headerView;
CGSize _lastSize;
CGFloat _contentHeight;
NSMutableIndexSet * _visibleSectionHeaders;
NSMutableDictionary * _visibleItems;
NSMutableDictionary * _reusableTableCells;
TUIFastIndexPath * _selectedIndexPath;
TUIFastIndexPath * _indexPathShouldBeFirstResponder;
NSInteger _futureMakeFirstResponderToken;
TUIFastIndexPath * _keepVisibleIndexPathForReload;
CGFloat _relativeOffsetForReload;
TUITableViewCell * _dragToReorderCell;
CGPoint _currentDragToReorderLocation;
CGPoint _currentDragToReorderMouseOffset;
TUIFastIndexPath * _currentDragToReorderIndexPath;
TUITableViewInsertionMethod _currentDragToReorderInsertionMethod;
TUIFastIndexPath * _previousDragToReorderIndexPath;
TUITableViewInsertionMethod _previousDragToReorderInsertionMethod;
struct {
unsigned int animateSelectionChanges:1;
unsigned int forceSaveScrollPosition:1;
unsigned int derepeaterEnabled:1;
unsigned int layoutSubviewsReentrancyGuard:1;
unsigned int didFirstLayout:1;
unsigned int dataSourceNumberOfSectionsInTableView:1;
unsigned int delegateTableViewWillDisplayCellForRowAtIndexPath:1;
unsigned int maintainContentOffsetAfterReload:1;
} _tableFlags;
}
- (id)initWithFrame:(CGRect)frame style:(TUITableViewStyle)style;
@property (nonatomic,unsafe_unretained) id <TUITableViewDataSource> dataSource;
@property (nonatomic,unsafe_unretained) id <TUITableViewDelegate> delegate;
@property (readwrite, assign) BOOL animateSelectionChanges;
@property (nonatomic, assign) BOOL maintainContentOffsetAfterReload;
- (void)reloadData;
- (void)reloadDataMaintainingVisibleIndexPath:(TUIFastIndexPath *)indexPath relativeOffset:(CGFloat)relativeOffset;
- (void)reloadLayout;
- (NSInteger)numberOfSections;
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (CGRect)rectForHeaderOfSection:(NSInteger)section;
- (CGRect)rectForSection:(NSInteger)section;
- (CGRect)rectForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
- (NSIndexSet *)indexesOfSectionsInRect:(CGRect)rect;
- (NSIndexSet *)indexesOfSectionHeadersInRect:(CGRect)rect;
- (TUIFastIndexPath *)indexPathForCell:(TUITableViewCell *)cell; - (NSArray *)indexPathsForRowsInRect:(CGRect)rect; - (TUIFastIndexPath *)indexPathForRowAtPoint:(CGPoint)point;
- (TUIFastIndexPath *)indexPathForRowAtVerticalOffset:(CGFloat)offset;
- (NSInteger)indexOfSectionWithHeaderAtPoint:(CGPoint)point;
- (NSInteger)indexOfSectionWithHeaderAtVerticalOffset:(CGFloat)offset;
- (void)enumerateIndexPathsUsingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block;
- (void)enumerateIndexPathsWithOptions:(NSEnumerationOptions)options usingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block;
- (void)enumerateIndexPathsFromIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath withOptions:(NSEnumerationOptions)options usingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block;
- (TUIView *)headerViewForSection:(NSInteger)section;
- (TUITableViewCell *)cellForRowAtIndexPath:(TUIFastIndexPath *)indexPath; - (NSArray *)visibleCells; - (NSArray *)sortedVisibleCells; - (NSArray *)indexPathsForVisibleRows;
- (void)scrollToRowAtIndexPath:(TUIFastIndexPath *)indexPath atScrollPosition:(TUITableViewScrollPosition)scrollPosition animated:(BOOL)animated;
- (TUIFastIndexPath *)indexPathForSelectedRow; - (TUIFastIndexPath *)indexPathForFirstRow;
- (TUIFastIndexPath *)indexPathForLastRow;
- (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition;
- (void)deselectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated;
@property (nonatomic, strong) TUIView *pullDownView;
- (BOOL)pullDownViewIsVisible;
@property (nonatomic, strong) TUIView *headerView;
- (TUITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;
@end
@protocol TUITableViewDataSource<NSObject>
@required
- (NSInteger)tableView:(TUITableView *)table numberOfRowsInSection:(NSInteger)section;
- (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
@optional
- (TUIView *)tableView:(TUITableView *)tableView headerViewForSection:(NSInteger)section;
- (BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(TUIFastIndexPath *)indexPath;
- (void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath;
- (BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(TUIFastIndexPath *)indexPath;
- (void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath;
- (NSInteger)numberOfSectionsInTableView:(TUITableView *)tableView;
@end
@interface NSIndexPath (TUITableView)
+ (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section;
@property(nonatomic,readonly) NSUInteger section;
@property(nonatomic,readonly) NSUInteger row;
@end
#import "TUITableViewCell.h"
#import "TUITableView+Derepeater.h"