2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSProgressIndicator</title>
|
1999-08-22 10:30:14 +00:00
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Gerrit van Dyk <gerritvd@decimax.com>
|
|
|
|
Date: 1999
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1999-08-22 10:30:14 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
1999-08-22 10:30:14 +00:00
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-10-27 22:21:01 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2007-10-29 21:16:17 +00:00
|
|
|
Lesser General Public License for more details.
|
1999-08-22 10:30:14 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1999-08-22 10:30:14 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
1999-08-22 10:30:14 +00:00
|
|
|
*/
|
|
|
|
|
2002-04-11 23:17:42 +00:00
|
|
|
#include <Foundation/NSTimer.h>
|
2003-06-13 15:01:12 +00:00
|
|
|
#include "AppKit/NSProgressIndicator.h"
|
|
|
|
#include "AppKit/NSGraphics.h"
|
2009-10-27 22:21:01 +00:00
|
|
|
#include "AppKit/NSImage.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
#include "AppKit/NSWindow.h"
|
2006-09-22 11:53:40 +00:00
|
|
|
#include "GNUstepGUI/GSTheme.h"
|
2008-12-02 07:27:14 +00:00
|
|
|
#include "GNUstepGUI/GSNibLoading.h"
|
1999-08-22 10:30:14 +00:00
|
|
|
|
|
|
|
@implementation NSProgressIndicator
|
|
|
|
|
2003-10-30 00:23:23 +00:00
|
|
|
static NSColor *fillColour = nil;
|
2009-10-27 22:21:01 +00:00
|
|
|
#define MaxCount 10
|
|
|
|
static int indeterminateMaxCount = MaxCount;
|
|
|
|
static int spinningMaxCount = MaxCount;
|
|
|
|
static NSColor *indeterminateColors[MaxCount];
|
|
|
|
static NSImage *spinningImages[MaxCount];
|
|
|
|
|
2001-10-06 22:26:28 +00:00
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (self == [NSProgressIndicator class])
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
int i;
|
|
|
|
|
2001-10-06 22:26:28 +00:00
|
|
|
[self setVersion: 1];
|
|
|
|
// FIXME: Should come from defaults and should be reset when defaults change
|
2004-06-07 23:54:25 +00:00
|
|
|
// FIXME: Should probably get the color from the color extension list (see NSToolbar)
|
|
|
|
fillColour = RETAIN([NSColor controlShadowColor]);
|
2009-10-27 22:21:01 +00:00
|
|
|
|
|
|
|
// Load images for indeterminate style
|
|
|
|
for (i = 0; i < MaxCount; i++)
|
|
|
|
{
|
|
|
|
NSString *imgName = [NSString stringWithFormat: @"common_ProgressIndeterminate_%d", i + 1];
|
|
|
|
NSImage *image = [NSImage imageNamed: imgName];
|
|
|
|
|
|
|
|
if (image == nil)
|
|
|
|
{
|
|
|
|
indeterminateMaxCount = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
indeterminateColors[i] = RETAIN([NSColor colorWithPatternImage: image]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load images for spinning style
|
|
|
|
for (i = 0; i < MaxCount; i++)
|
|
|
|
{
|
|
|
|
NSString *imgName = [NSString stringWithFormat: @"common_ProgressSpinning_%d", i + 1];
|
|
|
|
NSImage *image = [NSImage imageNamed: imgName];
|
|
|
|
|
|
|
|
if (image == nil)
|
|
|
|
{
|
|
|
|
spinningMaxCount = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
spinningImages[i] = RETAIN(image);
|
|
|
|
}
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (id)initWithFrame:(NSRect)frameRect
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
self = [super initWithFrame: frameRect];
|
2009-10-27 22:21:01 +00:00
|
|
|
if (!self)
|
|
|
|
return nil;
|
|
|
|
|
2001-10-06 22:26:28 +00:00
|
|
|
_isIndeterminate = YES;
|
|
|
|
_isBezeled = YES;
|
|
|
|
_isVertical = NO;
|
|
|
|
_usesThreadedAnimation = NO;
|
2009-10-27 22:21:01 +00:00
|
|
|
_animationDelay = 5.0 / 60.0; // 1 twelfth a a second
|
2001-10-06 22:26:28 +00:00
|
|
|
_doubleValue = 0.0;
|
|
|
|
_minValue = 0.0;
|
|
|
|
_maxValue = 100.0;
|
2009-10-27 22:21:01 +00:00
|
|
|
_controlTint = NSDefaultControlTint;
|
|
|
|
_controlSize = NSRegularControlSize;
|
|
|
|
[self setStyle: NSProgressIndicatorBarStyle];
|
|
|
|
|
2001-10-06 22:26:28 +00:00
|
|
|
return self;
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
TEST_RELEASE(_timer);
|
|
|
|
[super dealloc];
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
2007-09-10 11:12:44 +00:00
|
|
|
- (BOOL) isFlipped
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (void)animate:(id)sender
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (!_isIndeterminate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_count++;
|
2009-10-27 22:21:01 +00:00
|
|
|
if (((_style == NSProgressIndicatorSpinningStyle) && (_count >= spinningMaxCount))
|
|
|
|
|| ((_style == NSProgressIndicatorBarStyle) && (_count >= indeterminateMaxCount)))
|
2001-10-06 22:26:28 +00:00
|
|
|
_count = 0;
|
|
|
|
|
|
|
|
[self setNeedsDisplay:YES];
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
- (NSTimeInterval)animationDelay
|
|
|
|
{
|
|
|
|
return _animationDelay;
|
|
|
|
}
|
|
|
|
|
2005-06-16 12:34:13 +00:00
|
|
|
- (void)setAnimationDelay:(NSTimeInterval)delay
|
1999-08-22 10:30:14 +00:00
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
_animationDelay = delay;
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)startAnimation:(id)sender
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (!_isIndeterminate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!_usesThreadedAnimation)
|
|
|
|
{
|
|
|
|
ASSIGN(_timer, [NSTimer scheduledTimerWithTimeInterval: _animationDelay
|
2009-10-27 22:21:01 +00:00
|
|
|
target: self
|
|
|
|
selector: @selector(animate:)
|
|
|
|
userInfo: nil
|
|
|
|
repeats: YES]);
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
// FIXME: Not implemented
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_isRunning = YES;
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)stopAnimation:(id)sender
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (!_isIndeterminate || !_isRunning)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!_usesThreadedAnimation)
|
|
|
|
{
|
|
|
|
[_timer invalidate];
|
|
|
|
DESTROY(_timer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
// FIXME: Not implemented
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_isRunning = NO;
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)usesThreadedAnimation
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
return _usesThreadedAnimation;
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setUsesThreadedAnimation:(BOOL)flag
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_usesThreadedAnimation != flag)
|
|
|
|
{
|
|
|
|
BOOL wasRunning = _isRunning;
|
|
|
|
|
|
|
|
if (wasRunning)
|
2009-10-27 22:21:01 +00:00
|
|
|
[self stopAnimation: self];
|
2001-10-06 22:26:28 +00:00
|
|
|
|
|
|
|
_usesThreadedAnimation = flag;
|
|
|
|
|
|
|
|
if (wasRunning)
|
2009-10-27 22:21:01 +00:00
|
|
|
[self startAnimation: self];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)incrementBy:(double)delta
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
_doubleValue += delta;
|
2009-10-27 22:21:01 +00:00
|
|
|
[self setNeedsDisplay: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (double)doubleValue
|
|
|
|
{
|
|
|
|
return _doubleValue;
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDoubleValue:(double)aValue
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_doubleValue != aValue)
|
|
|
|
{
|
|
|
|
_doubleValue = aValue;
|
2009-10-27 22:21:01 +00:00
|
|
|
[self setNeedsDisplay: YES];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
- (double)minValue
|
|
|
|
{
|
|
|
|
return _minValue;
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (void)setMinValue:(double)newMinimum
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_minValue != newMinimum)
|
|
|
|
{
|
|
|
|
_minValue = newMinimum;
|
2009-10-27 22:21:01 +00:00
|
|
|
[self setNeedsDisplay: YES];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
- (double)maxValue
|
|
|
|
{
|
|
|
|
return _maxValue;
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (void)setMaxValue:(double)newMaximum
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_maxValue != newMaximum)
|
|
|
|
{
|
|
|
|
_maxValue = newMaximum;
|
2009-10-27 22:21:01 +00:00
|
|
|
[self setNeedsDisplay: YES];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
- (BOOL)isBezeled
|
|
|
|
{
|
|
|
|
return _isBezeled;
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (void)setBezeled:(BOOL)flag
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_isBezeled != flag)
|
|
|
|
{
|
|
|
|
_isBezeled = flag;
|
2009-10-27 22:21:01 +00:00
|
|
|
[self setNeedsDisplay: YES];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
- (BOOL)isIndeterminate
|
|
|
|
{
|
|
|
|
return _isIndeterminate;
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (void)setIndeterminate:(BOOL)flag
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
_isIndeterminate = flag;
|
1999-08-22 10:30:14 +00:00
|
|
|
// Maybe we need more functionality here when we implement indeterminate
|
2001-10-06 22:26:28 +00:00
|
|
|
if (flag == NO && _isRunning)
|
|
|
|
[self stopAnimation: self];
|
|
|
|
}
|
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
- (BOOL)isDisplayedWhenStopped
|
|
|
|
{
|
|
|
|
return _isDisplayedWhenStopped;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDisplayedWhenStopped:(BOOL)flag
|
|
|
|
{
|
|
|
|
_style = _isDisplayedWhenStopped;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSProgressIndicatorStyle) style
|
|
|
|
{
|
|
|
|
return _style;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setStyle:(NSProgressIndicatorStyle)style
|
|
|
|
{
|
|
|
|
_style = style;
|
|
|
|
_count = 0;
|
|
|
|
[self setDisplayedWhenStopped: (style == NSProgressIndicatorBarStyle)];
|
|
|
|
}
|
|
|
|
|
2001-10-06 22:26:28 +00:00
|
|
|
- (NSControlSize)controlSize
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
return _controlSize;
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setControlSize:(NSControlSize)size
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
_controlSize = size;
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSControlTint)controlTint
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
return _controlTint;
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setControlTint:(NSControlTint)tint
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
_controlTint = tint;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) sizeToFit
|
|
|
|
{
|
|
|
|
// FIXME
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)rect
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
NSRect r;
|
1999-08-22 10:30:14 +00:00
|
|
|
|
|
|
|
// Draw the Bezel
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_isBezeled)
|
|
|
|
{
|
|
|
|
// Calc the inside rect to be drawn
|
2006-09-22 11:53:40 +00:00
|
|
|
r = [[GSTheme theme] drawGrayBezel: _bounds withClip: rect];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
else
|
2009-10-27 22:21:01 +00:00
|
|
|
{
|
|
|
|
r = _bounds;
|
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
|
2009-10-27 22:21:01 +00:00
|
|
|
if (_style == NSProgressIndicatorSpinningStyle)
|
2001-10-06 22:26:28 +00:00
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
NSRect imgBox = {{0,0}, {0,0}};
|
|
|
|
|
|
|
|
imgBox.size = [spinningImages[_count] size];
|
|
|
|
[spinningImages[_count] drawInRect: r
|
|
|
|
fromRect: imgBox
|
|
|
|
operation: NSCompositeSourceOver
|
|
|
|
fraction: 1.0];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
2009-10-27 22:21:01 +00:00
|
|
|
else
|
2001-10-06 22:26:28 +00:00
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
if (_isIndeterminate)
|
|
|
|
{
|
|
|
|
[indeterminateColors[_count] set];
|
|
|
|
NSRectFill(r);
|
|
|
|
}
|
|
|
|
else
|
2001-10-06 22:26:28 +00:00
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
// Draw determinate
|
|
|
|
if (_doubleValue > _minValue)
|
|
|
|
{
|
|
|
|
double val;
|
|
|
|
|
|
|
|
if (_doubleValue > _maxValue)
|
|
|
|
val = _maxValue - _minValue;
|
|
|
|
else
|
|
|
|
val = _doubleValue - _minValue;
|
|
|
|
|
|
|
|
if (_isVertical)
|
|
|
|
r.size.height = NSHeight(r) * (val / (_maxValue - _minValue));
|
|
|
|
else
|
|
|
|
r.size.width = NSWidth(r) * (val / (_maxValue - _minValue));
|
|
|
|
r = NSIntersectionRect(r,rect);
|
|
|
|
if (!NSIsEmptyRect(r))
|
|
|
|
{
|
|
|
|
[fillColour set];
|
|
|
|
NSRectFill(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// It does not seem that Gnustep has a copyWithZone: on NSView, it is private
|
|
|
|
// under openstep
|
|
|
|
|
|
|
|
// NSCopying
|
|
|
|
/* - (id)copyWithZone:(NSZone *)zone
|
|
|
|
{
|
2009-10-27 22:21:01 +00:00
|
|
|
NSProgressIndicator *newInd;
|
1999-08-22 10:30:14 +00:00
|
|
|
|
|
|
|
newInd = [super copyWithZone:zone];
|
2001-10-06 22:26:28 +00:00
|
|
|
[newInd setIndeterminate:_isIndeterminate];
|
|
|
|
[newInd setBezeled:_isBezeled];
|
|
|
|
[newInd setUsesThreadedAnimation:_usesThreadedAnimation];
|
|
|
|
[newInd setAnimimationDelay:_animationDelay];
|
|
|
|
[newInd setDoubleValue:_doubleValue];
|
|
|
|
[newInd setMinValue:_minValue];
|
|
|
|
[newInd setMaxValue:_maxValue];
|
|
|
|
[newInd setVertical:_isVertical];
|
1999-08-22 10:30:14 +00:00
|
|
|
return newInd;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// NSCoding
|
|
|
|
- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder:aCoder];
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([aCoder allowsKeyedCoding])
|
2006-08-12 22:44:56 +00:00
|
|
|
{
|
|
|
|
unsigned long flags = 0;
|
|
|
|
id matrix = AUTORELEASE([[NSPSMatrix alloc] init]);
|
|
|
|
|
|
|
|
[aCoder encodeDouble: _minValue forKey: @"NSMinValue"];
|
|
|
|
[aCoder encodeDouble: _maxValue forKey: @"NSMaxValue"];
|
|
|
|
[aCoder encodeObject: matrix forKey: @"NSDrawMatrix"];
|
|
|
|
|
|
|
|
// add flag values.
|
|
|
|
flags |= (_isIndeterminate)? 2 : 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Hard coded... this value forces it to be a regular-sized,
|
|
|
|
// bar type progress indicator since this is the only type
|
|
|
|
// gnustep supports.
|
|
|
|
//
|
|
|
|
flags |= 8200;
|
|
|
|
[aCoder encodeInt: flags forKey: @"NSpiFlags"];
|
|
|
|
|
|
|
|
// things which Gorm encodes, but IB doesn't care about.
|
|
|
|
[aCoder encodeDouble: _doubleValue forKey: @"GSDoubleValue"];
|
|
|
|
[aCoder encodeBool: _isBezeled forKey: @"GSIsBezeled"];
|
|
|
|
[aCoder encodeBool: _isVertical forKey: @"GSIsVertical"];
|
|
|
|
[aCoder encodeBool: _usesThreadedAnimation forKey: @"GSUsesThreadAnimation"];
|
|
|
|
[aCoder encodeDouble: _animationDelay forKey: @"GSAnimationDelay"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at:&_animationDelay];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(double) at:&_doubleValue];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(double) at:&_minValue];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
|
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithCoder:(NSCoder *)aDecoder
|
|
|
|
{
|
2009-10-28 07:47:14 +00:00
|
|
|
self = [super initWithCoder: aDecoder];
|
|
|
|
if (!self)
|
|
|
|
return nil;
|
|
|
|
|
2004-01-30 19:49:00 +00:00
|
|
|
if ([aDecoder allowsKeyedCoding])
|
|
|
|
{
|
2006-08-12 22:44:56 +00:00
|
|
|
// id matrix = [aDecoder decodeObjectForKey: @"NSDrawMatrix"];
|
2004-01-30 19:49:00 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"NSMaxValue"])
|
|
|
|
{
|
2009-10-28 07:47:14 +00:00
|
|
|
int max = [aDecoder decodeDoubleForKey: @"NSMaxValue"];
|
|
|
|
|
|
|
|
[self setMaxValue: max];
|
|
|
|
}
|
2006-08-12 22:44:56 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"NSMinValue"])
|
|
|
|
{
|
2009-10-28 07:47:14 +00:00
|
|
|
int min = [aDecoder decodeDoubleForKey: @"NSMinValue"];
|
|
|
|
|
|
|
|
[self setMinValue: min];
|
|
|
|
}
|
2004-01-30 19:49:00 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"NSpiFlags"])
|
|
|
|
{
|
2009-10-28 07:47:14 +00:00
|
|
|
int flags = [aDecoder decodeIntForKey: @"NSpiFlags"];
|
|
|
|
|
|
|
|
_isIndeterminate = ((flags & 2) == 2);
|
|
|
|
// ignore the rest, since they are not pertinent to GNUstep.
|
|
|
|
}
|
|
|
|
|
2006-08-12 22:44:56 +00:00
|
|
|
// things which Gorm encodes, but IB doesn't care about.
|
|
|
|
if ([aDecoder containsValueForKey: @"GSDoubleValue"])
|
2009-10-28 07:47:14 +00:00
|
|
|
{
|
|
|
|
_doubleValue = [aDecoder decodeDoubleForKey: @"GSDoubleValue"];
|
|
|
|
}
|
2006-08-12 22:44:56 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"GSIsBezeled"])
|
2009-10-28 07:47:14 +00:00
|
|
|
{
|
|
|
|
_isBezeled = [aDecoder decodeBoolForKey: @"GSIsBezeled"];
|
|
|
|
}
|
2006-08-12 22:44:56 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"GSIsVertical"])
|
2009-10-28 07:47:14 +00:00
|
|
|
{
|
|
|
|
_isVertical = [aDecoder decodeBoolForKey: @"GSIsVertical"];
|
|
|
|
}
|
2006-08-12 22:44:56 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"GSUsesThreadAnimation"])
|
2009-10-28 07:47:14 +00:00
|
|
|
{
|
|
|
|
_usesThreadedAnimation = [aDecoder decodeBoolForKey: @"GSUsesThreadAnimation"];
|
|
|
|
}
|
2006-08-12 22:44:56 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"GSAnimationDelay"])
|
2009-10-28 07:47:14 +00:00
|
|
|
{
|
|
|
|
_animationDelay = [aDecoder decodeDoubleForKey: @"GSAnimationDelay"];
|
|
|
|
}
|
2004-01-30 19:49:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSTimeInterval)
|
2009-10-27 22:21:01 +00:00
|
|
|
at:&_animationDelay];
|
2004-01-30 19:49:00 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(double) at:&_doubleValue];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(double) at:&_minValue];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(double) at:&_maxValue];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
|
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSProgressIndicator (GNUstepExtensions)
|
|
|
|
|
2009-10-28 07:47:14 +00:00
|
|
|
- (BOOL)isVertical
|
|
|
|
{
|
|
|
|
return _isVertical;
|
|
|
|
}
|
|
|
|
|
1999-08-22 10:30:14 +00:00
|
|
|
- (void)setVertical:(BOOL)flag
|
|
|
|
{
|
2001-10-06 22:26:28 +00:00
|
|
|
if (_isVertical != flag)
|
|
|
|
{
|
|
|
|
_isVertical = flag;
|
1999-08-22 10:30:14 +00:00
|
|
|
[self setNeedsDisplay:YES];
|
2001-10-06 22:26:28 +00:00
|
|
|
}
|
1999-08-22 10:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2006-08-12 22:44:56 +00:00
|
|
|
|