62 CPControlSize _controlSize;
64 BOOL _isIndeterminate;
65 CPProgressIndicatorStyle _style;
69 BOOL _isDisplayedWhenStoppedSet;
70 BOOL _isDisplayedWhenStopped;
86 [bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleMini.gif"]
size:CGSizeMake(16.0, 16.0)]];
88 [bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleSmall.gif"]
size:CGSizeMake(32.0, 32.0)]];
90 [bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"]
size:CGSizeMake(64.0, 64.0)]];
92 CPProgressIndicatorBezelBorderViewPool = [];
97 for (; start <= end; ++start)
99 CPProgressIndicatorBezelBorderViewPool[start] = [];
100 CPProgressIndicatorBezelBorderViewPool[start][CPMiniControlSize] = [];
101 CPProgressIndicatorBezelBorderViewPool[start][CPSmallControlSize] = [];
102 CPProgressIndicatorBezelBorderViewPool[start][CPRegularControlSize] = [];
120 CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle],
121 CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle],
122 CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle],
123 CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle]
126 for (var i = 0, count = prefixes.length; i < count; i++)
128 var prefix = prefixes[i];
135 - (id)initWithFrame:(CGRect)aFrame
147 _isDisplayedWhenStoppedSet = NO;
161 - (void)setUsesThreadedAnimation:(BOOL)aFlag
169 - (void)startAnimation:(
id)aSender
173 [
self _hideOrDisplay];
180 - (void)stopAnimation:(
id)aSender
184 [
self _hideOrDisplay];
190 - (BOOL)usesThreadedAnimation
200 - (void)incrementBy:(
double)aValue
208 - (void)setDoubleValue:(
double)aValue
210 _doubleValue = MIN(MAX(aValue, _minValue), _maxValue);
218 - (double)doubleValue
227 - (void)setMinValue:(
double)aValue
244 - (void)setMaxValue:(
double)aValue
262 - (void)setControlSize:(CPControlSize)aControlSize
264 if (_controlSize == aControlSize)
267 _controlSize = aControlSize;
275 - (CPControlSize)controlSize
283 - (void)setControlTint:(CPControlTint)aControlTint
290 - (CPControlTint)controlTint
298 - (void)setBezeled:(BOOL)isBezeled
314 - (void)setIndeterminate:(BOOL)isIndeterminate
316 if (_isIndeterminate == isIndeterminate)
319 _isIndeterminate = isIndeterminate;
327 - (BOOL)isIndeterminate
329 return _isIndeterminate;
336 - (void)setStyle:(CPProgressIndicatorStyle)aStyle
338 if (_style == aStyle)
352 [
self setFrameSize:[[CPProgressIndicatorSpinningStyleColors[_controlSize] patternImage] size]];
354 [
self setFrameSize:CGSizeMake(CGRectGetWidth([
self frame]), CPProgressIndicatorStyleSizes[
355 CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle] + _CPControlIdentifierForControlSize(_controlSize)][0].height)];
363 - (void)setDisplayedWhenStopped:(BOOL)isDisplayedWhenStopped
365 if (_isDisplayedWhenStoppedSet && _isDisplayedWhenStopped == isDisplayedWhenStopped)
368 _isDisplayedWhenStoppedSet = YES;
370 _isDisplayedWhenStopped = isDisplayedWhenStopped;
372 [
self _hideOrDisplay];
378 - (BOOL)isDisplayedWhenStopped
380 if (_isDisplayedWhenStoppedSet)
381 return _isDisplayedWhenStopped;
390 - (void)_hideOrDisplay
392 [
self setHidden:!_isAnimating && ![
self isDisplayedWhenStopped]];
395 - (void)setFrameSize:(CGSize)aSize
412 [barView setBackgroundColor:_CPControlThreePartImagePattern(
414 CPProgressIndicatorStyleSizes,
415 CPProgressIndicatorClassName,
417 CPProgressIndicatorStyleIdentifiers[_style],
418 _CPControlIdentifierForControlSize(_controlSize))];
423 return [[
CPView alloc] initWithFrame:_CGRectMakeZero()];
426 - (CGRect)rectForEphemeralSubviewNamed:(
CPString)aViewName
430 var
width = CGRectGetWidth([
self bounds]),
431 barWidth = width * ((_doubleValue - _minValue) / (_maxValue - _minValue));
433 if (barWidth > 0.0 && barWidth < 4.0)
436 return _CGRectMake(0, 0, barWidth, 16.0);
443 - (void)updateBackgroundColor
460 CPProgressIndicatorStyleSizes,
461 CPProgressIndicatorClassName,
463 CPProgressIndicatorStyleIdentifiers[_style],
464 _CPControlIdentifierForControlSize(_controlSize))];
480 if (
self = [super initWithCoder:aCoder])
482 _minValue = [aCoder decodeObjectForKey:@"_minValue"];
483 _maxValue = [aCoder decodeObjectForKey:@"_maxValue"];
484 _doubleValue = [aCoder decodeObjectForKey:@"_doubleValue"];
485 _controlSize = [aCoder decodeObjectForKey:@"_controlSize"];
486 _isIndeterminate = [aCoder decodeObjectForKey:@"_isIndeterminate"];
487 _style = [aCoder decodeIntForKey:@"_style"];
488 _isAnimating = [aCoder decodeObjectForKey:@"_isAnimating"];
489 _isDisplayedWhenStoppedSet = [aCoder decodeObjectForKey:@"_isDisplayedWhenStoppedSet"];
490 _isDisplayedWhenStopped = [aCoder decodeObjectForKey:@"_isDisplayedWhenStopped"];
507 [aCoder encodeObject:_minValue forKey:@"_minValue"];
508 [aCoder encodeObject:_maxValue forKey:@"_maxValue"];
509 [aCoder encodeObject:_doubleValue forKey:@"_doubleValue"];
510 [aCoder encodeObject:_controlSize forKey:@"_controlSize"];
511 [aCoder encodeObject:_isIndeterminate forKey:@"_isIndeterminate"];
512 [aCoder encodeInt:_style forKey:@"_style"];
513 [aCoder encodeObject:_isAnimating forKey:@"_isAnimating"];
514 [aCoder encodeObject:_isDisplayedWhenStoppedSet forKey:@"_isDisplayedWhenStoppedSet"];
515 [aCoder encodeObject:_isDisplayedWhenStopped forKey:@"_isDisplayedWhenStopped"];