forked from AlessandroSangiuliano/rik.theme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rik+Table.m
121 lines (101 loc) · 3.97 KB
/
Rik+Table.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#import "Rik.h"
#import "Rik+Drawings.h"
@interface Rik(RikTable)
@end
@implementation Rik(RikTable)
typedef enum {
GSTabSelectedLeft,
GSTabSelectedRight,
GSTabSelectedToUnSelectedJunction,
GSTabSelectedFill,
GSTabUnSelectedLeft,
GSTabUnSelectedRight,
GSTabUnSelectedToSelectedJunction,
GSTabUnSelectedJunction,
GSTabUnSelectedFill,
GSTabBackgroundFill
} GSTabPart;
- (NSRect) tableHeaderCellDrawingRectForBounds: (NSRect)theRect
{
NSSize borderSize;
// This adjustment must match the drawn border
borderSize = NSMakeSize(0, 0);
return NSInsetRect(theRect, borderSize.width, borderSize.height);
}
- (NSColor *) tableHeaderTextColorForState: (GSThemeControlState)state
{
NSColor *color;
if (state == GSThemeHighlightedState)
color = [NSColor controlTextColor];
else
color = [NSColor controlTextColor];
return color;
}
- (void) drawTableCornerView: (NSView*)cornerView
withClip: (NSRect)aRect
{
NSRect divide;
NSRect rect;
if ([cornerView isFlipped])
{
NSDivideRect(aRect, ÷, &rect, 1.0, NSMaxYEdge);
}
else
{
NSDivideRect(aRect, ÷, &rect, 1.0, NSMinYEdge);
}
NSColor * basecolor = [[NSColor controlBackgroundColor] shadowWithLevel: 0.1];
NSGradient* buttonBackgroundGradient = [self _bezelGradientWithColor: basecolor];
[buttonBackgroundGradient drawInRect: rect angle: -90];
NSBezierPath* linesPath = [NSBezierPath bezierPath];
[linesPath setLineWidth: 1];
[linesPath moveToPoint: NSMakePoint(rect.origin.x, NSMinY(rect))];
[linesPath lineToPoint: NSMakePoint(rect.origin.x + rect.size.width, NSMinY(rect))];
[linesPath moveToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect))];
[linesPath lineToPoint: NSMakePoint(rect.origin.x + rect.size.width, NSMaxY(rect))];
NSColor * strokeColor = [NSColor colorWithCalibratedRed: 0.70
green: 0.70
blue: 0.70
alpha: 1.0];
[strokeColor setStroke];
[linesPath stroke];
}
- (void) drawTableHeaderCell: (NSTableHeaderCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)controlView
state: (GSThemeControlState)state
{
NSRect rect;
// Leave a 1pt thick horizontal line underneath the header
if (![controlView isFlipped])
{
cellFrame.origin.y++;
}
//cellFrame.size.height--;
NSColor * basecolor;
if (state == GSThemeHighlightedState)
{
basecolor = [NSColor selectedControlColor];
}
else
{
basecolor = [[NSColor controlBackgroundColor] shadowWithLevel: 0.1];
}
NSGradient* buttonBackgroundGradient = [self _bezelGradientWithColor: basecolor];
[buttonBackgroundGradient drawInRect: cellFrame angle: -90];
NSBezierPath* linesPath = [NSBezierPath bezierPath];
[linesPath setLineWidth: 1];
[linesPath moveToPoint: NSMakePoint(cellFrame.origin.x-0.5, NSMinY(cellFrame) + 5)];
[linesPath lineToPoint: NSMakePoint(cellFrame.origin.x-0.5, NSMaxY(cellFrame) - 5)];
[linesPath moveToPoint: NSMakePoint(cellFrame.origin.x, NSMinY(cellFrame))];
[linesPath lineToPoint: NSMakePoint(cellFrame.origin.x + cellFrame.size.width, NSMinY(cellFrame))];
[linesPath moveToPoint: NSMakePoint(cellFrame.origin.x, NSMaxY(cellFrame))];
[linesPath lineToPoint: NSMakePoint(cellFrame.origin.x + cellFrame.size.width, NSMaxY(cellFrame))];
NSColor * strokeColor = [NSColor colorWithCalibratedRed: 0.70
green: 0.70
blue: 0.70
alpha: 1.0];
[strokeColor setStroke];
[linesPath stroke];
}
@end