forked from jerrykrinock/ClassesObjC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSSYAutoHeightTableView.m
61 lines (47 loc) · 1.62 KB
/
SSYAutoHeightTableView.m
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
#import "SSYAutoHeightTableView.h"
@class SSYAutoHeightBox ;
@implementation SSYAutoHeightTableView
#ifdef j
- (NSRect)frame {
CGFloat headerHeight = NSHeight([[self headerView] frame]) ;
NSInteger nRows = [self numberOfRows] ;
CGFloat rowsHeight = nRows * [self rowHeight] ;
CGFloat gapsHeight = (nRows-1) * [self intercellSpacing].height ;
CGFloat height = headerHeight + rowsHeight + gapsHeight ;
NSRect frame_ = [super frame] ;
frame_.size.height = height ;
return frame_ ;
}
#endif
- (void)noteHeightOfRowsWithIndexesChanged:(NSIndexSet *)indexSet {
}
- (void)viewWillDraw {
// Perform some operations before recursing for descendants.
// Now recurse to handle all our descendants.
// Overrides must call up to super like this.
[super viewWillDraw];
// Perform some operations that might depend on descendants
// already having had a chance to update.
NSTableHeaderView* headerView = [self headerView] ;
CGFloat headerHeight ;
if (headerView) {
headerHeight = NSHeight([headerView frame]) ;
}
else {
headerHeight = 0.0 ;
}
NSInteger nRows = [self numberOfRows] ;
CGFloat rowsHeight = nRows * [self rowHeight] ;
CGFloat gapsHeight = (nRows-1) * [self intercellSpacing].height ;
CGFloat height = headerHeight + rowsHeight + gapsHeight ;
NSRect frame = [self frame] ;
frame.size.height = height ;
[self setFrame:frame] ;
CGFloat width = frame.size.width ;
NSScrollView* enclosingScrollView = [self enclosingScrollView] ;
frame = [enclosingScrollView frame] ;
frame.size.width = width + 2.0 ;
frame.size.height = height + 2.0 ;
[enclosingScrollView setFrame:frame] ;
}
@end