-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBottomView.m
executable file
·80 lines (65 loc) · 1.74 KB
/
BottomView.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
//
// BottomView.m
//
// Created by Vagrod on 5/8/10.
// Copyright 2010 Home. All rights reserved.
//
#import "BottomView.h"
@implementation BottomView
@synthesize startingColor;
@synthesize endingColor;
@synthesize angle;
- (id)initWithFrame:(NSRect)frame;
{
if (self = [super initWithFrame:frame]) {
NSColor * clrFrom = [NSColor windowFrameColor];
double r = [[clrFrom
colorUsingColorSpaceName:@"NSDeviceRGBColorSpace"] redComponent];
double g = [[clrFrom
colorUsingColorSpaceName:@"NSDeviceRGBColorSpace"] greenComponent];
double b = [[clrFrom
colorUsingColorSpaceName:@"NSDeviceRGBColorSpace"] blueComponent];
[self setStartingColor:[NSColor colorWithCalibratedRed:r green:g blue:b alpha:1.0]];
[self setEndingColor:[NSColor colorWithCalibratedRed:r green:g blue:b alpha:0.0]];
[self setAngle:270];
}
return self;
}
- (BOOL) isFlipped{
return YES;
}
- (void)drawRect:(NSRect)rect;
{
if (endingColor == nil || [startingColor isEqual:endingColor]) {
// Fill view with a standard background color
[startingColor set];
NSRectFill(rect);
}
else {
// Fill view with a top-down gradient
// from startingColor to endingColor
NSGradient* aGradient = [[[NSGradient alloc]
initWithStartingColor:startingColor
endingColor:endingColor] autorelease];
[aGradient drawInRect:[self bounds] angle:angle];
}
}
- (void)setStartingColor:(NSColor *)newColor;
{
[startingColor autorelease];
startingColor = [newColor retain];
[self setNeedsDisplay:YES];
}
- (void)setEndingColor:(NSColor *)newColor;
{
[endingColor autorelease];
endingColor = [newColor retain];
[self setNeedsDisplay:YES];
}
- (void)dealloc;
{
[self setStartingColor:nil];
[self setEndingColor:nil];
[super dealloc];
}
@end