- Inherits from:
- NSView : NSResponder : NSObject
- Conforms to:
- NSCoding
- (NSResponder)
- NSObject (NSObject)
Declared in:
- AppKit/NSProgressIndicator.h
An application displays a progress indicator to show that a lengthy task is under way. Some progress indicators do nothing more than spin to show that the application is busy, while others show the percentage of the task that has been completed. NSProgressIndicator provides both types of display:
NSProgressIndicator is a subclass of NSView. To display a progress indicator, your application creates a window and adds the progress indicator as a subview of the window's content view or any subview. You can create a progress indicator programmatically and initialize it. However, you normally use Interface Builder to create and initialize a progress indicator and to install it in an application view.
For an indeterminate progress indicator, you invoke startAnimation: to start the animation (the spinning of the barber pole) and stopAnimation: when the task is complete. By default, the delay between animation steps is one twelfth of a second (5.0/60.0). You can change the animation delay by invoking setAnimationDelay:. Setting the delay to a double value larger than the default value will slow the animation, while setting the delay to a smaller value will speed it up.
Instead of invoking startAnimation: and stopAnimation:, you can control an indeterminate progress indicator directly by sending the animate: message. Each time you invoke animate:, the animation advances by one step. You can speed up or slow down the animation by varying how often you invoke animate:. Like other views, a progress indicator redisplays itself on each pass through the event loop, if needed. To ensure immediate redrawing, however, you can invoke the displayIfNeeded method (inherited from NSView) each time you invoke animate:.
By default, a progress indicator is indeterminate. Your can specify a determinate progress indicator when you set up the view with Interface Builder, or you can use code like the following to change the default value programmatically:
[myProgressIndicatorView setIndeterminate:FALSE];
For a determinate progress indicator, you invoke the incrementBy: method to advance the progress bar. By default, a determinate progress indicator goes from 0.0 to 100.0. You can increment by any amount, but if you vary the increment too widely, progress may appear uneven or jerky. You typically choose an increment value that evenly divides 100.0. For example, you might invoke incrementBy: 50 times, incrementing by 2.0 each time, to draw the complete progress bar. To modify the default range of 0.0 to 100.0, you can invoke setMinValue: to modify the minimum value and setMaxValue: to modify the maximum value.
After each invocation of incrementBy:, you can invoke the displayIfNeeded method to ensure immediate redrawing.
You can display progress indicators of different sizes by varying the frame size. However, the default size is designed to provide the best results. By default, a progress indicator is drawn with a bezeled frame, but you can use the setBezeled: method to modify the bezeled-frame setting.
A progress indicator is drawn with colors based on the user's current color scheme. When the user changes the color scheme, the color of the progress indicator changes automatically to match the new scheme.
- Animating the progress indicator
- - animate:
- - animationDelay
- - setAnimationDelay:
- - setUsesThreadedAnimation:
- - startAnimation:
- - stopAnimation:
- - usesThreadedAnimation
- Advancing the progress bar
- - incrementBy:
- - setDoubleValue:
- - doubleValue
- - setMinValue:
- - minValue
- - setMaxValue:
- - maxValue
- Setting the appearance
- - setBezeled:
- - isBezeled
- - setIndeterminate:
- - isIndeterminate
- (void)animate:(id)sender
The animate: method only invalidates the progress indicator so it will be redrawn the next time through the event loop. To ensure immediate redrawing, invoke the displayIfNeeded method.
See Also: - animationDelay, - setAnimationDelay:
- (NSTimeInterval)animationDelay
See Also: - animate:
- (double)doubleValue
See Also: - incrementBy:, - setDoubleValue:
- (void)incrementBy:(double)delta
See Also: - doubleValue
- (BOOL)isBezeled
YES
if
the receiver's frame has a three-dimensional bezel.See Also: - setBezeled:
- (BOOL)isIndeterminate
YES
if
the receiver is indeterminate. An indeterminate
progress indicator displays a "barber pole" that spins until
the task is complete. A determinate progress indicator draws a three-dimensional bar
from left to right as the task progresses.See Also: - setIndeterminate:
- (double)maxValue
See Also: - minValue, - setMaxValue:
- (double)minValue
See Also: - maxValue, - setMinValue:
- (void)setAnimationDelay:(NSTimeInterval)delay
- (void)setBezeled:(BOOL)flag
See Also: - isBezeled
- (void)setDoubleValue:(double)doubleValue
See Also: - doubleValue, - incrementBy:, - setMaxValue:, - setMinValue:
- (void)setIndeterminate:(BOOL)flag
See Also: - isIndeterminate
- (void)setMaxValue:(double)newMaximum
See Also: - maxValue
- (void)setMinValue:(double)newMinimum
See Also: - minValue
- (void)setUsesThreadedAnimation:(BOOL)flag
See Also: - usesThreadedAnimation
- (void)startAnimation:(id)sender
See Also: - animationDelay, - stopAnimation:
- (void)stopAnimation:(id)sender
See Also: - animationDelay, - startAnimation:
- (BOOL)usesThreadedAnimation
See Also: - setUsesThreadedAnimation: