-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGradientView.m
More file actions
54 lines (43 loc) · 1 KB
/
GradientView.m
File metadata and controls
54 lines (43 loc) · 1 KB
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
//
// GradientView.m
// Beholder
//
// Created by Danny Espinoza on 9/29/06.
// Copyright 2006 Mesa Dynamics, LLC. All rights reserved.
//
#import "GradientView.h"
@implementation GradientView
- (void)awakeFromNib
{
macVersion = 0;
Gestalt(gestaltSystemVersion, &macVersion);
if(macVersion >= 0x1040) {
NSColor* c1 = [NSColor colorWithCalibratedWhite:.90 alpha:1.0];
NSColor* c2 = [NSColor colorWithCalibratedWhite:.95 alpha:1.0];
gradient = [[CTGradient gradientWithBeginningColor:c1 endingColor:c2] retain];
}
[self setNeedsDisplay:YES];
}
- (void)dealloc
{
if(macVersion >= 0x1040) {
[gradient release];
}
[super dealloc];
}
- (void)drawRect:(NSRect)rect
{
if(macVersion >= 0x1040) {
//CTGradient *aGradient = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:gradient]];
[gradient fillRect:[self frame] angle:90];
}
else {
[[NSColor colorWithCalibratedWhite:.90 alpha:1.0] set];
NSRectFill(rect);
}
}
- (bool)isOpaque
{
return NO;
}
@end