EDActivityIndicator


Inherits From:
NSView
Declared In:
EDActivityIndicator.h


Class Description

An application displays an activity indicator to show that some lengthy task is underway. This task is happening in the background and does not prevent the user from interacting with the application. EDActivityIndiciator uses an animation of two small arrows chasing each other, much like the ones in Mail and OmniWeb. The images used for the animation can be changed on a per-class basis by overriding the animation class method.


Instance Variables

struct EDAIFlags flags;
NSColor *bgColor;
id target;
SEL action;
float xpos;
NSTimer *animationTimer;

flagsAll instance variables are private.
bgColor
target
action
xpos
animationTimer


Method Types

Animation image
+ animation
Changing the indicator's appearance
- setBackgroundColor:
- backgroundColor
- setDrawsBackground:
- drawsBackground
Setting and getting the indicator's attributes
- setHidesOnLoad:
- hidesOnLoad
- setIsHidden:
- isHidden
- setFrameRate:
- frameRate
Setting target and action
- setTarget:
- target
- setAction:
- action
Managing the animation
- step:
- startAnimation:
- stopAnimation:
Drawing and highlighting the activity indicator
- highlight:


Class Methods

animation

+ (NSImage *)animation

Returns all frames of the animation in one NSImage. Frames are assumed to be squares and arranged in a row from left to right. Consequently, if the size of the frames is s x s and the animation contains n frames the image must be s x (s * n) in size.

This method must be efficient as it is called frequently.


Instance Methods

action

- (SEL)action

Returns the receiver's action-message selector.


backgroundColor

- (NSColor *)backgroundColor

Returns the receiver's background color.


drawsBackground

- (BOOL)drawsBackground

Returns YES if the receiver draws its background, NO if it doesn't.


frameRate

- (unsigned int)frameRate

Returns the current frame rate for the animation.


hidesOnLoad

- (BOOL)hidesOnLoad

Returns YES if the receiver automatically hides when the NIB file is loaded.


highlight:

- (void)highlight:(BOOL)flag

If the receiver's highlight status is different from flag, sets that status to flag and, if flag is YES, highlights the the receiver by drawing multiple slightly faded copies of the current frame's image around the image.


isHidden

- (BOOL)isHidden

Returns YES if the receiver is hidden when the animation is not running.


setAction:

- (void)setAction:(SEL)aSelector

Sets the selector used for the action message to aSelector.


setBackgroundColor:

- (void)setBackgroundColor:(NSColor *)aColor

Sets the receiver's background color to aColor.


setDrawsBackground:

- (void)setDrawsBackground:(BOOL)flag

Controls whether the receiver draws its background. If flag is YES, the receiver fills its background with the background color; if flag is NO, it doesn't.


setFrameRate:

- (void)setFrameRate:(unsigned int)value

Sets the frame rate for the animation. Frames are changed value times per second whith 255 being the theoretical maximum. The default is 20.


setHidesOnLoad:

- (void)setHidesOnLoad:(BOOL)flag

Controls whether the receiver automatically hides when the NIB file is loaded. This is used so that the receiver can be visible for editing in Interface Builder but hidden when loaded into the applicaton.


setIsHidden:

- (void)setIsHidden:(BOOL)flag

Controls whether the receiver is hidden when the animation is not running. The default is YES.


setTarget:

- (void)setTarget:(id)anObject

Sets the receiver's target object to anObject.


startAnimation:

- (IBAction)startAnimation:(id)sender

Starts the animation by setting up a timer that sends step: methods in the specified frequency. Note that this means that the "lengty task" can't run in the main application thread as this would block the run loop.


step:

- (IBAction)step:(id)sender

Advances the animation by one step. This method is normally called automatically by the animation timer.


stopAnimation:

- (IBAction)stopAnimation:(id)sender

Stops the animation. Multiple start: invocations do not need to be balanced by an equivalent amount of stop: invocations.


target

- (id)target

Returns the receiver's target object.


Version 2.0 Copyright ©2002 by Erik Doernenburg. All Rights Reserved.