Headers/SpinCursor.h

/*
    File:       SpinCursor.h
 
    Contains:   TSpinCursor is a simple cursor spinning class.
                SpinCursor.h contains the TSpinCursor class definition.
 
    Written by: Kent Sandvik    
 
    Copyright:  Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/18/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
// Declare label for this header file
#ifndef _SPINCURSOR_
#define _SPINCURSOR_
 
#ifndef _DTSCPLUSLIBRARY_
#include "DTSCPlusLibrary.h"
#endif
 
 
// TOOLBOX INTERFACES
#ifndef __QUICKDRAW__
#include <Quickdraw.h>
#endif
 
#ifndef __RESOURCES__
#include <Resources.h>
#endif
 
#ifndef __MEMORY__
#include <Memory.h>
#endif
 
#ifndef __TOOLUTILS__
#include <ToolUtils.h>
#endif
 
 
// _________________________________________________________________________________________________________ //
//  TSpinCursor Class Interface.
 
class TSpinCursor
// TSpinCursor is a simple cursor spinning/controlling class, that will bind the CURS and 'acur' resources
// specified, and animate the cursor to either direction based on the 'acur' list.
{
public:
    // ENUMS AND TYPEDEFS
    enum EDirection                             // our cursor spinning direction
    {
        kBackwards = -1, kForwards = 1
    };
 
    // CONSTRUCTORS AND DESTRUCTORS
    TSpinCursor(short acurID,                   // the 'acur' resource used
                short SpinDirection = kForwards,// spindirection (default forwards)
                short spinTicks = 60);          // amount of ticks between spins (1 second default)
    virtual~ TSpinCursor();
 
    // MAIN INTERFACE
    virtual void Spin();                        // start spinning
    virtual void SetSpinDirection(EDirection);  // change directions    
    // INTERNAL STRUCTS
    struct AnimationCursRec                     // structure needed to map the 'acur' resource to a data structure
    {
        struct
        {
            unsigned short hasColor:1;          // if true uses color cursors
            unsigned short count:15;            // # of frames in the cursor list
        } information;
        short frame;                            // cursor index list of next cursor frame
        CursHandle nCursors[20];                // list of cursor handles
    };
 
    // FIELDS
protected:CursHandle fCursorHandle;             // reference to our cursor handle
    short fCursorID;                            // ID of the CURS resource
    short fIndex;                               // index to the animated cursor list
    short fSpinDirection;                       // 1 = forward, -1 backwards, 2 skip every 2 framesÉ
    AnimationCursRec * *fCursorList;            // list of cursors we will use
    long fTickCounter;                          // our Tick counter
    short fSpinTicks;                           // amount of ticks between spins
    OSErr fError;                               // latest error
};
 
 
#endif
 
// _________________________________________________________________________________________________________ //
 
 
/*  Change History (most recent last):
  No        Init.   Date        Comment
  1         khs     12/14/92    New file
  2         khs     1/3/93      Cleanup
*/