forked from overcyn/Enqueue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSTableView+Extensions.m
30 lines (26 loc) · 1.02 KB
/
NSTableView+Extensions.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
#import "NSTableView+Extensions.h"
@implementation NSTableView (Extensions)
- (void)scrollRowToVisiblePretty:(NSInteger)row {
int topRow = row - 3;
if (topRow < 0) {
topRow = 0;
}
int botRow = row + 3;
if (botRow > [self numberOfRows]) {
botRow = [self numberOfRows] - 1;
}
NSRect topRect = [self rectOfRow:topRow];
NSRect botRect = [self rectOfRow:botRow];
[self scrollRectToVisible:NSUnionRect(topRect, botRect)];
}
- (void)PRHighlightTableColumn:(NSTableColumn *)tableColumn ascending:(BOOL)ascending {
for (NSTableColumn *i in [self tableColumns]) {
if (i != tableColumn) {
[[i tableView] setIndicatorImage:nil inTableColumn:i];
}
}
NSImage *indicatorImage = ascending ? [NSImage imageNamed:@"NSAscendingSortIndicator"] : [NSImage imageNamed:@"NSDescendingSortIndicator"];
[[tableColumn tableView] setIndicatorImage:indicatorImage inTableColumn:tableColumn];
[[tableColumn tableView] setHighlightedTableColumn:tableColumn];
}
@end