-
Notifications
You must be signed in to change notification settings - Fork 10
/
RikScrollerArrowCell.m
88 lines (85 loc) · 3.92 KB
/
RikScrollerArrowCell.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
#include <AppKit/AppKit.h>
#include "RikScrollerArrowCell.h"
#include "Rik.h"
@implementation RikScrollerArrowCell
- (void) setArrowType: (RikScrollerArrowType) t
{
scroller_arrow_type = t;
}
- (void) drawBezelWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
GSThemeControlState buttonState = [self themeControlState];
NSBezierPath * path = [self pathForFrame: cellFrame];
[(Rik*)[GSTheme theme] drawPathButton: path
in: self
state: buttonState];
}
- (NSBezierPath*) pathForFrame: (NSRect)cellFrame
{
CGFloat r = 3;
cellFrame = NSInsetRect(cellFrame, 1, 1);
cellFrame.origin.x += 0.5;
cellFrame.origin.y += 0.5;
NSRect innerRect = NSInsetRect(cellFrame, r, r);
NSBezierPath* path = [NSBezierPath bezierPath];
switch(scroller_arrow_type)
{
case RikScrollerArrowLeft:
cellFrame.origin.x += 1.0;
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMinY(innerRect))
radius: r
startAngle: 180
endAngle: 270];
[path lineToPoint: NSMakePoint(NSMaxX(cellFrame), NSMinY(cellFrame))];
[path lineToPoint: NSMakePoint(NSMaxX(cellFrame), NSMaxY(cellFrame))];
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMaxY(innerRect))
radius: r
startAngle: 90
endAngle: 180];
[path closePath];
break;
case RikScrollerArrowRight:
cellFrame.origin.x -= 1.0;
[path moveToPoint: NSMakePoint(NSMinX(cellFrame), NSMinY(cellFrame))];
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMinY(innerRect))
radius: r
startAngle: 270
endAngle: 360];
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMaxY(innerRect))
radius: r
startAngle: 0
endAngle: 90];
[path lineToPoint: NSMakePoint(NSMinX(cellFrame), NSMaxY(cellFrame))];
break;
case RikScrollerArrowDown:
cellFrame.origin.y -= 1.0;
[path moveToPoint: NSMakePoint(NSMinX(cellFrame), NSMinY(cellFrame))];
[path moveToPoint: NSMakePoint(NSMaxX(cellFrame), NSMinY(cellFrame))];
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMaxY(innerRect))
radius: r
startAngle: 0
endAngle: 90];
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMaxY(innerRect))
radius: r
startAngle: 90
endAngle: 180];
[path lineToPoint: NSMakePoint(NSMinX(cellFrame), NSMinY(cellFrame))];
break;
case RikScrollerArrowUp:
cellFrame.origin.y += 1.0;
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMinY(innerRect))
radius: r
startAngle: 180
endAngle: 270];
[path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMinY(innerRect))
radius: r
startAngle: 270
endAngle: 360];
[path lineToPoint: NSMakePoint(NSMaxX(cellFrame), NSMaxY(cellFrame))];
[path lineToPoint: NSMakePoint(NSMinX(cellFrame), NSMaxY(cellFrame))];
[path closePath];
break;
}
return path;
}
@end