forked from ttscoff/nv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDFView.m
59 lines (50 loc) · 1.08 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
//
// 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 {
NSRect bounds = [self bounds];
bounds.origin.x -=2.0f;
bounds.origin.y +=1.0f;
bounds.size.width +=4.0f;
[vColor set];
NSFrameRect(bounds);
}
- (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