Main Page | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

DownAndOutView Class Reference

#import <DownAndOutView.h>

Collaboration diagram for DownAndOutView:

Collaboration graph
[legend]
List of all members.

Detailed Description

As a ScreenSaverView, DownAndOutView is the root class of the DownAndOut[tm] screen saver.

It is responsible for drawing the saver content, and for maintaining the state machine that brings the saver through the logout countdown, through application shutdown, to logout.

Definition at line 39 of file DownAndOutView.h.

Public Member Functions

(float) - clockRadius
 Getter of the clock-radius property.
(void) - setClockRadius:
 Setter for the clock-radius property.
(void) - setDeadlineForSeconds: [implementation]
 Sets the deadline object, signifying when logout is to begin, for a given number of seconds in the future.
(void) - resetClock [implementation]
 Return the clock to the set time-to-logout.
(id) - initWithFrame:isPreview: [implementation]
 Designated initializer, inherited from ScreenSaverView.
(void) - dealloc [implementation]
 Unremarkable deallocator.
(void) - fillTextImageWithSeconds: [implementation]
 Compose the image for the textual portion of the screen-saver content, given a countdown time.
(void) - fillTextImageWithString: [implementation]
 Compose the image for the textual portion of the screen-saver content from a string.
(NSRect) - addedImageRect [implementation]
 Calculate the size and placement of an image added to the content.
(void) - startAnimation [implementation]
 Beginning of the animation cycle.
(void) - stopAnimation [implementation]
 Stop the animation timer.
(void) - drawPieCenter:proportion:radius:color: [implementation]
 Draw a circle filled clockwise by a given proportion.
(void) - fillPieImageInner:outer: [implementation]
 Draw the clock-like device with given inner and outer proportions.
(void) - drawRect: [implementation]
 Draw the screen-saver content to the screen.
(void) - animateOneFrame [implementation]
 Advance the screen-saver animation by one frame; manage logout tasks.
(BOOL) - hasConfigureSheet [implementation]
 Affirms that DownAndOut[tm] has a configuration sheet.
(NSWindow *) - configureSheet [implementation]
 Returns the configuration sheet for DownAndOut[tm].

Protected Attributes

NSDate * deadline
 when application shutdown is to begin
DownAndOutControllercontroller
 controls the configuration panel, manages logout tasks
NSRect contentRect
 size of the nonblack content drawn by this view
NSPoint velocity
 random delta of content position between frames
DOState state
 what task is being done (countdown, quitting, logout...)
NSImage * pieImage
 the stylized-clock subimage of the content
NSImage * textImage
 the textual subimage of the content
int secondsLeft
 rounded-down countdown, in seconds
float clockRadius
 radius of stylized clock, determines size of content


Member Function Documentation

- (NSRect) addedImageRect   [implementation]
 

Calculate the size and placement of an image added to the content.

It goes on the left end of the content, is the size of the image if that is no taller than the content; otherwise it is the content height, and proportionally wide. If there is no added image, the returned rectangle is of no width.

Return values:
NSRect a rectangle into which to draw the added image.

Definition at line 147 of file DownAndOutView.m.

References DownAndOutController::addedImage, contentRect, and controller.

Referenced by drawRect:, and startAnimation.

- (void) animateOneFrame   [implementation]
 

Advance the screen-saver animation by one frame; manage logout tasks.

initWithFrame:isPreview: sets the animation interval to 0.05 seconds.

  • When the countdown is in effect, makes sure the clock and text are updated and the content moves around (if desired).
  • When the countdown expires, calls for application quits, a ten-second pause, application kills, and then logout.

This method overrides animateOneFrame in ScreenSaverView, which is a no-op. It does no drawing, but does update the NSImages that are the only things drawRect: puts on the screen.

Definition at line 308 of file DownAndOutView.m.

References contentRect, controller, DAApplication::countApplications, deadline, fillPieImageInner:outer:, fillTextImageWithSeconds:, fillTextImageWithString:, DownAndOutController::killApplications, DownAndOutController::logOut, DownAndOutController::makeTouchFile, DownAndOutController::quitApplications, resetClock, secondsLeft, setDeadlineForSeconds:, state, and velocity.

- (float) clockRadius  
 

Getter of the clock-radius property.

This property determines the size, in pixels, of the content image. The height of the image is twice the radius; the width is three more than seven times the radius (from which you may infer that the text is allotted five radii in width by two in height).

Return values:
float the radius of the clock, in pixels

Referenced by initWithFrame:isPreview:, and setClockRadius:.

- (NSWindow *) configureSheet   [implementation]
 

Returns the configuration sheet for DownAndOut[tm].

Loads DownAndOut.nib from the saver's bundle, and makes the DownAndOutController the owner of the NIB. Overrides the do-nothing method in ScreenSaverView.

Return values:
NSWindow configuration panel for DownAndOut

Definition at line 396 of file DownAndOutView.m.

References controller, and DownAndOutController::panel.

- (void) drawPieCenter: (NSPoint)  center
proportion: (float)  proportion
radius: (float)  radius
color: (NSColor *)  color
  [implementation]
 

Draw a circle filled clockwise by a given proportion.

The filled area increases clockwise from straight up. The edge of the unfilled area is stroked in the same color as the filled area, and filled with black.

Parameters:
center NSPoint, the locus of the circle's center
proportion float, [0..1] (pinned) how much of the circle is filled
radius float, the radius of the circle
color NSColor, the color to use for fill and stroke

Definition at line 218 of file DownAndOutView.m.

Referenced by fillPieImageInner:outer:.

- (void) drawRect: (NSRect)  rect   [implementation]
 

Draw the screen-saver content to the screen.

This method fills the screen with black, then composites the added image (if any) and the prepared clock and text images in the animated destination.

Parameters:
rect the area to update.

Definition at line 278 of file DownAndOutView.m.

References DownAndOutController::addedImage, addedImageRect, controller, pieImage, and textImage.

- (void) fillPieImageInner: (float)  inner
outer: (float)  outer
  [implementation]
 

Draw the clock-like device with given inner and outer proportions.

This method knows how to place drawPieCenter:proportion:radius:color: in the clock image, so that the seconds (outer) circle is drawn first, in blue, and the minutes (inner) circle is drawn second, in red. The result is drawn in the pieImage instance variable.

Parameters:
inner proportion of the inner (minutes) circle to fill [0..1]
outer proportion of the outer (seconds) circle to fill [0..1]

Definition at line 259 of file DownAndOutView.m.

References drawPieCenter:proportion:radius:color:, and pieImage.

Referenced by animateOneFrame.

- (void) fillTextImageWithSeconds: (int)  seconds   [implementation]
 

Compose the image for the textual portion of the screen-saver content, given a countdown time.

Passes the given number of seconds to the controller, which has the chosen template, and access to the necessary substitutions. Renders the text in the attributes chosen in setClockRadius: (half-radius Times italic, light gray).

Parameters:
seconds the number of seconds left in the countdown

Definition at line 111 of file DownAndOutView.m.

References controller, DownAndOutController::messageTextForSeconds:, and textImage.

Referenced by animateOneFrame.

- (void) fillTextImageWithString: (NSString *)  aString   [implementation]
 

Compose the image for the textual portion of the screen-saver content from a string.

Renders the string in the attributes chosen in setClockRadius: (half-radius Times italic, light gray).

Parameters:
aString the message to put in the image

Definition at line 130 of file DownAndOutView.m.

References textImage.

Referenced by animateOneFrame.

- (BOOL) hasConfigureSheet   [implementation]
 

Affirms that DownAndOut[tm] has a configuration sheet.

This overrides the default provided in ScreenSaverView.

Return values:
YES indicates that there is a configuration sheet

Definition at line 388 of file DownAndOutView.m.

- (id) initWithFrame: (NSRect)  frame
isPreview: (BOOL)  isPreview
  [implementation]
 

Designated initializer, inherited from ScreenSaverView.

Sets the animation rate to twenty-per-second, and creates a controller object which will load default (or preferred) parameters for the view.

Parameters:
frame the initial frame for the view, in superview coordinates
isPreview whether the view is running in the System Preferences preview.
Return values:
self unless the superclass implementation returns nil.

Definition at line 59 of file DownAndOutView.m.

References clockRadius, controller, and state.

- (void) resetClock   [implementation]
 

Return the clock to the set time-to-logout.

Used when DownAndOut[tm] runs in the System Preferences preview, so that when the countdown timer runs out, it loops back rather than trying to log the user out.

Definition at line 48 of file DownAndOutView.m.

References controller, DownAndOutController::secondsBeforeLogout, and setDeadlineForSeconds:.

Referenced by animateOneFrame, and startAnimation.

- (void) setClockRadius: (float)  newRadius  
 

Setter for the clock-radius property.

The document for the getter method clockRadius explains how this property determines the height and width of the drawn element of the screen-saver content.

Parameters:
newRadius float, the new radius, in pixels, for the clock-like device.
Bug:
This method should check for absurd values for newRadius.
It does no checking at all.

Definition at line 78 of file DownAndOutView.m.

References clockRadius, pieImage, and textImage.

- (void) setDeadlineForSeconds: (int)  seconds   [implementation]
 

Sets the deadline object, signifying when logout is to begin, for a given number of seconds in the future.

Parameters:
seconds the number of seconds in the future to begin logout

Definition at line 39 of file DownAndOutView.m.

References deadline, and secondsLeft.

Referenced by animateOneFrame, and resetClock.

- (void) startAnimation   [implementation]
 

Beginning of the animation cycle.

Inherited from ScreenSaverView, and the super method must be called. Here, if the content moves, we select the initial position and velocity of the content.

Definition at line 177 of file DownAndOutView.m.

References addedImageRect, contentRect, controller, resetClock, and velocity.

- (void) stopAnimation   [implementation]
 

Stop the animation timer.

Inherited from ScreenSaverView, and the super method must be called. This method releases the NSDate that marks the beginning of the logout process.

Definition at line 204 of file DownAndOutView.m.

References deadline.


The documentation for this class was generated from the following files:
Generated on Wed Jan 25 12:04:27 2006 for DownAndOut by  doxygen 1.4.4