2007-09-16 01:02:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-03-28 21:33:07 +00:00
|
|
|
* Copyright (c) 2007-2008 Transmission authors and contributors
|
2007-09-16 01:02:06 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#import "CTGradientAdditions.h"
|
|
|
|
|
|
|
|
@implementation CTGradient (ProgressBar)
|
|
|
|
|
2008-06-24 19:36:25 +00:00
|
|
|
+ (CTGradient *) progressGradientForRed: (float) redComponent green: (float) greenComponent blue: (float) blueComponent
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
CTGradientElement color1;
|
2008-06-30 01:56:17 +00:00
|
|
|
color1.red = redComponent;
|
|
|
|
color1.green = greenComponent;
|
|
|
|
color1.blue = blueComponent;
|
2008-06-24 03:59:34 +00:00
|
|
|
color1.alpha = 1.0;
|
|
|
|
color1.position = 0.0;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
CTGradientElement color2;
|
2008-06-30 01:56:17 +00:00
|
|
|
color2.red = redComponent * 0.95;
|
|
|
|
color2.green = greenComponent * 0.95;
|
|
|
|
color2.blue = blueComponent * 0.95;
|
2008-06-24 03:59:34 +00:00
|
|
|
color2.alpha = 1.0;
|
2008-05-29 21:50:16 +00:00
|
|
|
color2.position = 0.5;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
CTGradientElement color3;
|
2008-06-30 01:56:17 +00:00
|
|
|
color3.red = redComponent * 0.85;
|
|
|
|
color3.green = greenComponent * 0.85;
|
|
|
|
color3.blue = blueComponent * 0.85;
|
2008-06-24 03:59:34 +00:00
|
|
|
color3.alpha = 1.0;
|
2008-05-29 21:50:16 +00:00
|
|
|
color3.position = 0.5;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
CTGradientElement color4;
|
2008-06-24 04:16:46 +00:00
|
|
|
color4.red = redComponent;
|
|
|
|
color4.green = greenComponent;
|
|
|
|
color4.blue = blueComponent;
|
2008-06-24 03:59:34 +00:00
|
|
|
color4.alpha = 1.0;
|
|
|
|
color4.position = 1.0;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2008-06-24 03:59:34 +00:00
|
|
|
CTGradient * newInstance = [[[self class] alloc] init];
|
2008-06-24 19:36:25 +00:00
|
|
|
[newInstance addElement: &color1];
|
|
|
|
[newInstance addElement: &color2];
|
|
|
|
[newInstance addElement: &color3];
|
|
|
|
[newInstance addElement: &color4];
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
return [newInstance autorelease];
|
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressWhiteGradient = nil;
|
2008-06-24 03:59:34 +00:00
|
|
|
+ (CTGradient *)progressWhiteGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressWhiteGradient)
|
|
|
|
fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95] retain];
|
|
|
|
return fProgressWhiteGradient;
|
2008-06-24 03:59:34 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressGrayGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressGrayGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressGrayGradient)
|
|
|
|
fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7] retain];
|
|
|
|
return fProgressGrayGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressLightGrayGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressLightGrayGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressLightGrayGradient)
|
|
|
|
fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87] retain];
|
|
|
|
return fProgressLightGrayGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressBlueGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressBlueGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressBlueGradient)
|
2008-06-30 01:56:17 +00:00
|
|
|
fProgressBlueGradient = [[[self class] progressGradientForRed: 0.35 green: 0.67 blue: 0.98] retain];
|
2008-06-25 05:01:04 +00:00
|
|
|
return fProgressBlueGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressDarkBlueGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressDarkBlueGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressDarkBlueGradient)
|
|
|
|
fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776] retain];
|
|
|
|
return fProgressDarkBlueGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressGreenGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressGreenGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressGreenGradient)
|
2008-06-30 01:56:17 +00:00
|
|
|
fProgressGreenGradient = [[[self class] progressGradientForRed: 0.44 green: 0.89 blue: 0.40] retain];
|
2008-06-25 05:01:04 +00:00
|
|
|
return fProgressGreenGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressLightGreenGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressLightGreenGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressLightGreenGradient)
|
2008-06-30 01:56:17 +00:00
|
|
|
fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.62 green: 0.99 blue: 0.58] retain];
|
2008-06-25 05:01:04 +00:00
|
|
|
return fProgressLightGreenGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressDarkGreenGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressDarkGreenGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressDarkGreenGradient)
|
|
|
|
fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639] retain];
|
|
|
|
return fProgressDarkGreenGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressRedGradient = nil;
|
2007-11-11 21:45:27 +00:00
|
|
|
+ (CTGradient *)progressRedGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressRedGradient)
|
|
|
|
fProgressRedGradient = [[[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451] retain];
|
|
|
|
return fProgressRedGradient;
|
2007-11-11 21:45:27 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 05:01:04 +00:00
|
|
|
CTGradient * fProgressYellowGradient = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
+ (CTGradient *)progressYellowGradient
|
|
|
|
{
|
2008-06-25 05:01:04 +00:00
|
|
|
if (!fProgressYellowGradient)
|
|
|
|
fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243] retain];
|
|
|
|
return fProgressYellowGradient;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|