CSortAnimator Members

Constructor/Destructor

CSortAnimator( )
virtual ~CSortAnimator( )

Methods

General

long GetSize(void)
Returns the current number of bars. Necessary to establish sort-program loop-limits.

long Draw(CDC *Mydc, const CRect& rcBounds, const CRect& rcInvalid)
Draws the current state of the animation. Must be called periodically to update the display. The parameters are the same as those passed to the OnDraw function of an ActiveX control. rcInvalid is not used. Current font is used for drawing text. Bars are drawn using the current drawing units of the device context. (Usually pixels.) Returns 0 if there is nothing to draw (no bars, temps or text). Returns 1 otherwise.

COLORREF GetColor(ColorType Color)
Changes an enumerated color (Red, Blue, ...) into a COLORREF suitable for drawing. Used by the Draw function.


Bar Manipulation

long SetBarCount(long Bars)
Sets the current number of bars, allocates arrays, and initializes them. Normally called during initialization. Returns zero if the Bars parameter is negative or zero, one otherwise.

long Randomize(void)
Sorts the bars into random order. Normally called to begin a sort. Returns zero if there are no bars, one otherwise.

long Initialize(void)
Sorts bars into ascending sequence. Called to test algorithms on pre-sorted arrays. Returns zero if there are no bars, one otherwise.

long SetBarColor(long BarNumber,ColorType Color)
Called to change the color of a single bar. Called to flash colors during the animation. Returns zero if bar index is invalid, one otherwise.

long BarSize(long Bar)
Returns the value of the specified bar, or zero if index is invalid. Used to save or test specific values during a sort. Does not affect bar position or color. Values are always in the range from 0 to Size-1.

long operator[](long x)
Functionally equivalent to BarSize. Allows sort algorithms to be developed in a more "natural" way.

long SwapBars(long BarA,long BarB)
Exchanges the values and colors of the two specified bars. Does nothing if indices are invalid. Returns zero if indices are invalid, one otherwise.

long MoveTempToBar(long TempID, long Bar)
Moves specified temp location to specified bar. Both color and value are moved. Temp color is set to "None". Does nothing if indices are invalid. Returns zero if indices are invalid, one otherwise.

long MoveBarToTemp(long Bar,long TempID)
Moves the specified bar to the specified temp location. Both color and value are moved. Bar color is set to "None". Does nothing if indices are invalid. Returns zero if indices are invalid, one otherwise.


Temp Manipulation

long SetTempCount(long NewTempCount)
Sets the TempCount variable, allocates arrays, and initializes them. Returns zero if NewTempCount is negative or zero, one otherwise.

long TempSize(long TempID)
Returns the value of the specified temp location, or zero if the index is invalid.

long SetTempColor(long TempID,ColorType Color)
Sets the color of the specified temp. Does nothing if index is invalid. Returns zero if index is invalid, one otherwise.

long GetTempCount(void)
Returns the current number of temp locations. Superfluous, since TempCount is public.


Text-Line Manipulation

long SetLineCount(long NewLineCount)
Sets the LineCount variable, allocates arrays, and initializes them. Returns zero if NewLineCount is negative or zero, one otherwise.

long SetText(long LineNumber,LPCSTR NewText)
Sets the value of the indexed text line. Does nothing if index is invalid. Returns zero if index is invalid, one otherwise.

long HighLightLine(long LineNumber)
Causes indexed line to be drawn in red. Does nothing if index is invalid. Returns zero if index is invalid, one otherwise.

long RemoveHighLight(long LineNumber)
Causes indexed line to be drawn in black. Does nothing if index is invalid. Returns zero if index is invalid, one otherwise.

Data Members


Bar Specifications

long Size
Number of bars. DO NOT set this value directly. Use SetBarCount instead. Initialized to zero.

ColorType * Colors
An array giving the color of each bar. The color "None" means bar is invisible. Array elements initialized to "Red", variable initialized to NULL. Array elements may be set directly, but this is not recommended.

long * Values
An array giving the value of each bar. DO NOT modify these values directly. Values must be unique and must be in the range 0 through Size-1. Each location is initialized to  its index, variable initialized to NULL.


Drawing Parameters

long BarIncrement
The increment that is added to each bar to determine its height (in pixels). The height of bar number i is calculated as MinBarHeight+(Values[i]*BarIncrement). Initialized to 10. May be set directly.

long MinBarHeight
The height of the shortest bar in pixels. Initialized to 20. May be set directly.

long BarWidth
The width of each bar in pixels. Initialized to 10. May be set directly.


Temp Specifications

long TempCount
Number of temporary locations at upper left of window. DO NOT modify this value directly. Use SetTempCount instead. Initialized to zero.

ColorType * TempColors
An array giving the current color of each temporary location. Color "None" means bar is invisible. Array elements initialized to "None", variable initialized to NULL Array elements may be set directly, but this is not recommended.

long * Temps
An array containing the value stored in each temporary location. Array elements initialized to zero, variable initialized to NULL. Array elements MUST NOT be set directly.


Text Line Specifications

long LineCount
Number of text lines. DO NOT set this variable directly. Use SetLineCount instead. Initialized to zero.

long * HighLights
An array containing High-Light information for each line of text. Zero causes text to be draw in black, non-zero causes it to be drawn in red. Elements are initialized to zero, variable initialized to NULL. Array elements may be set directly, but this is not recommended.

CString * TextLines
An array containing the text of each text line. Array elements initialized to Empty, variable initialized to NULL. Array elements may be set directly, but this is not recommended.