source: trunk/macosx/ProgressGradients.m @ 8227

Last change on this file since 8227 was 7659, checked in by livings124, 13 years ago

update the Mac code's copyright dates

  • Property svn:keywords set to Date Rev Author Id
File size: 4.9 KB
Line 
1/******************************************************************************
2 * $Id: ProgressGradients.m 7659 2009-01-10 23:37:37Z livings124 $
3 *
4 * Copyright (c) 2007-2009 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "ProgressGradients.h"
26
27@implementation ProgressGradients
28
29+ (NSGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent
30{
31    NSColor * baseColor = [NSColor colorWithCalibratedRed: redComponent green: greenComponent blue: blueComponent alpha: 1.0];
32   
33    NSColor * color2 = [NSColor colorWithCalibratedRed: redComponent * 0.95 green: greenComponent * 0.95 blue: blueComponent * 0.95
34                        alpha: 1.0];
35   
36    NSColor * color3 = [NSColor colorWithCalibratedRed: redComponent * 0.85 green: greenComponent * 0.85 blue: blueComponent * 0.85
37                        alpha: 1.0];
38   
39    NSGradient * progressGradient = [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5,
40                                        baseColor, 1.0, nil];
41    return [progressGradient autorelease];
42}
43
44NSGradient * fProgressWhiteGradient = nil;
45+ (NSGradient *) progressWhiteGradient
46{
47    if (!fProgressWhiteGradient)
48        fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95f green: 0.95f blue: 0.95f] retain];
49    return fProgressWhiteGradient;
50}
51
52NSGradient * fProgressGrayGradient = nil;
53+ (NSGradient *) progressGrayGradient
54{
55    if (!fProgressGrayGradient)
56        fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7f green: 0.7f blue: 0.7f] retain];
57    return fProgressGrayGradient;
58}
59
60NSGradient * fProgressLightGrayGradient = nil;
61+ (NSGradient *) progressLightGrayGradient
62{
63    if (!fProgressLightGrayGradient)
64        fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87f green: 0.87f blue: 0.87f] retain];
65    return fProgressLightGrayGradient;
66}
67
68NSGradient * fProgressBlueGradient = nil;
69+ (NSGradient *) progressBlueGradient
70{
71    if (!fProgressBlueGradient)
72        fProgressBlueGradient = [[[self class] progressGradientForRed: 0.35f green: 0.67f blue: 0.98f] retain];
73    return fProgressBlueGradient;
74}
75
76NSGradient * fProgressDarkBlueGradient = nil;
77+ (NSGradient *) progressDarkBlueGradient
78{
79    if (!fProgressDarkBlueGradient)
80        fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616f green: 0.722f blue: 0.776f] retain];
81    return fProgressDarkBlueGradient;
82}
83
84NSGradient * fProgressGreenGradient = nil;
85+ (NSGradient *) progressGreenGradient
86{
87    if (!fProgressGreenGradient)
88        fProgressGreenGradient = [[[self class] progressGradientForRed: 0.44f green: 0.89f blue: 0.40f] retain];
89    return fProgressGreenGradient;
90}
91
92NSGradient * fProgressLightGreenGradient = nil;
93+ (NSGradient *) progressLightGreenGradient
94{
95    if (!fProgressLightGreenGradient)
96        fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.62f green: 0.99f blue: 0.58f] retain];
97    return fProgressLightGreenGradient;
98}
99
100NSGradient * fProgressDarkGreenGradient = nil;
101+ (NSGradient *) progressDarkGreenGradient
102{
103    if (!fProgressDarkGreenGradient)
104        fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627f green: 0.714f blue: 0.639f] retain];
105    return fProgressDarkGreenGradient;
106}
107
108NSGradient * fProgressRedGradient = nil;
109+ (NSGradient *) progressRedGradient
110{
111    if (!fProgressRedGradient)
112        fProgressRedGradient = [[[self class] progressGradientForRed: 0.902f green: 0.439f blue: 0.451f] retain];
113    return fProgressRedGradient;
114}
115
116NSGradient * fProgressYellowGradient = nil;
117+ (NSGradient *) progressYellowGradient
118{
119    if (!fProgressYellowGradient)
120        fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933f green: 0.890f blue: 0.243f] retain];
121    return fProgressYellowGradient;
122}
123
124@end
Note: See TracBrowser for help on using the repository browser.