-
Notifications
You must be signed in to change notification settings - Fork 0
/
ITBevelView.m
81 lines (64 loc) · 2.9 KB
/
ITBevelView.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
#import "ITBevelView.h"
@implementation ITBevelView
- (id)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) {
_bevelDepth = 5;
[self setAutoresizesSubviews:NO];
}
return self;
}
- (id)initWithCoder:(NSCoder *)coder {
if ((self = [super initWithCoder:coder])) {
_bevelDepth = 5;
[self setAutoresizesSubviews:NO];
}
return self;
}
- (int)bevelDepth {
return _bevelDepth;
}
- (void)setBevelDepth:(int)newDepth {
_bevelDepth = newDepth;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)aRect {
NSRect frameRect = [self convertRect:[self frame] fromView:[self superview]];
NSRect innerRect = NSMakeRect((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth), (frameRect.size.width - (_bevelDepth * 2)), (frameRect.size.height - (_bevelDepth * 2)));
NSBezierPath *leftEdge = [NSBezierPath bezierPath];
NSBezierPath *topEdge = [NSBezierPath bezierPath];
NSBezierPath *rightEdge = [NSBezierPath bezierPath];
NSBezierPath *bottomEdge = [NSBezierPath bezierPath];
[[[self subviews] objectAtIndex:0] setFrame:innerRect];
[leftEdge moveToPoint:frameRect.origin];
[leftEdge lineToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)];
[leftEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth))];
[leftEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth))];
[topEdge moveToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)];
[topEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)];
[topEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth))];
[topEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth))];
[rightEdge moveToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)];
[rightEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)];
[rightEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth))];
[rightEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), _bevelDepth)];
[bottomEdge moveToPoint:frameRect.origin];
[bottomEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)];
[bottomEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), _bevelDepth)];
[bottomEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth))];
[[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set];
[leftEdge fill];
[[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] set];
[topEdge fill];
[[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set];
[rightEdge fill];
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.6] set];
[bottomEdge fill];
[[[self subviews] objectAtIndex:0] setNeedsDisplay:YES];
}
- (BOOL)mouseDownCanMoveWindow {
return NO;
}
- (void)dealloc {
[super dealloc];
}
@end