forked from ttscoff/nv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DFView.m
68 lines (57 loc) · 1.51 KB
/
DFView.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
//
// DFView.m
// Notation
//
// Created by ElasticThreads on 2/15/11.
//
#import "DFView.h"
#import "AppController.h"
@implementation DFView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
if (!vColor) {
[self setBackgroundColor:[[NSApp delegate] backgrndColor]];
}
// Initialization code here.
}
return self;
}
- (void)dealloc{
[vColor release];
[super dealloc];
}
- (void)drawRect:(NSRect)rect {
[super drawRect:rect];
if (!IsLionOrLater&&([[NSApp delegate]isInFullScreen])){
NSRect bounds = [self bounds];
bounds.origin.x -=2.0f;
bounds.size.width +=4.0f;
NSBezierPath *aPath=[NSBezierPath bezierPath];
[aPath moveToPoint:NSMakePoint(floor(bounds.origin.x), floor(bounds.origin.y))];
[aPath lineToPoint:NSMakePoint(floor(bounds.origin.x+bounds.size.width), floor(bounds.origin.y))];
[aPath setLineWidth:1.0];
[vColor setStroke];
// [[NSColor redColor] setStroke];
[aPath stroke];
}
}
- (void)setBackgroundColor:(NSColor *)inColor{
if (vColor) {
[vColor release];
}
CGFloat fWhite;
fWhite = [[inColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace] whiteComponent];
if (fWhite < 0.75f) {
if (fWhite<0.25f) {
fWhite += 0.22f;
}else {
fWhite += 0.16f;
}
}else {
fWhite -= 0.20f;
}
vColor = [NSColor colorWithCalibratedWhite:fWhite alpha:1.0f];
[vColor retain];
}
@end