forked from kwerle/ssh-tunnel-manager
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TunnelsTableView.m
executable file
·46 lines (40 loc) · 1.41 KB
/
TunnelsTableView.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
#import "TunnelsTableView.h"
@implementation TunnelsTableView
- (id)initWithCoder:(NSCoder*)coder{
self = [ super initWithCoder: coder ];
[ self setSelectionActive: YES ];
return self;
}
- (void)setSelectionActive:(BOOL)state
{
selectionActive = state;
}
- (void)highlightSelectionInClipRect:(NSRect)clipRect
{
NSColor *evenColor = [NSColor colorWithCalibratedRed:0.929 green:0.953 blue:0.996 alpha:1.0];
NSColor *oddColor = [NSColor whiteColor];
float rowHeight = [self rowHeight] + [self intercellSpacing].height;
NSRect visibleRect = [self visibleRect];
NSRect highlightRect;
highlightRect.origin = NSMakePoint(NSMinX(visibleRect), (int)(NSMinY(clipRect)/rowHeight)*rowHeight);
highlightRect.size = NSMakeSize(NSWidth(visibleRect), rowHeight - [self intercellSpacing].height);
while (NSMinY(highlightRect) < NSMaxY(clipRect))
{
NSRect clippedHighlightRect = NSIntersectionRect(highlightRect, clipRect);
int row = (int)((NSMinY(highlightRect)+rowHeight/2.0)/rowHeight);
NSColor *rowColor = (0 == row % 2) ? evenColor : oddColor;
[rowColor set];
NSRectFill(clippedHighlightRect);
highlightRect.origin.y += rowHeight;
}
if (selectionActive)
[super highlightSelectionInClipRect: clipRect]; // call superclass's behavior
}
- (NSColor *)_highlightColorForCell:(NSCell *)cell;
{
if (selectionActive)
return [ NSColor yellowColor ];
else
return nil;
}
@end