home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / TIMERCTL.H < prev    next >
C/C++ Source or Header  |  1994-01-05  |  3KB  |  103 lines

  1. /************************************************************************
  2. **
  3. ** @(#)timerctl.h    01/05/94    Chris Ahlstrom
  4. **
  5. **    C++ Borland/Microsoft
  6. **
  7. *************************************************************************/
  8.  
  9. #if !defined(TIMERCTL_h)                // { TIMERCTL_h
  10. #define TIMERCTL_h
  11.  
  12. #include "timerctl.err"        // TimerError type declaration
  13.  
  14. #define TIMER_IGNORE_COUNT    (-1)
  15.  
  16.  
  17. /************************************************************************
  18. ** class TimerControl
  19. *************************************************************************/
  20.  
  21. class TimerControl
  22. {
  23.     friend void deleteTimer        // deletes one or more linked timers
  24.     (
  25.     TimerControl *timer        // uses the timer->Next member
  26.     );
  27.  
  28. public:                    // constructor & destructor
  29.  
  30.     TimerControl            // constructor
  31.     (
  32.     void *master,            // points to TDeskTop or HWND
  33.     int number = 1,            // ID code for the timer
  34.     unsigned duration = 100,    // minimum duration of timer (msec)
  35.     int count = TIMER_IGNORE_COUNT    // times to allow timer-handling
  36.     );
  37.  
  38.     virtual ~TimerControl();        // destructor
  39.  
  40.     virtual int setupTimer        // sets up the timer
  41.     (
  42.     unsigned duration
  43.     );
  44.     virtual int timerDelay ();        // implements a delay function
  45.     virtual int disableTimer ();    // renders the timer unuseable
  46.     virtual int attach            // links two timers (for lists)
  47.     (
  48.     TimerControl *lasttimer
  49.     );
  50.     TimerControl *next ();        // returns the next pointer
  51.  
  52.     int decrementCount ();        // gives access/control over Count
  53.     int ID;                // ID code of timer
  54.     void *Handle;            // window/desktop handle
  55.  
  56. public:                    // public access functions
  57.  
  58.     const char *getErrorMsg (void);    // pointer to last error message
  59.  
  60.     int isError (void)            // get cheap error status in-line
  61.     {
  62.     return (errorCode != 0);
  63.     }
  64.  
  65. protected:                // internal functions
  66.  
  67.     virtual void setErrorCode        // set errorCode and errorMsg
  68.     (
  69.     int index
  70.     );
  71.     int getErrorCode (void)        // get code (derived objects only)
  72.     {
  73.     return errorCode;
  74.     }
  75.  
  76. protected:                // internal error message fields
  77.  
  78.     /********************************************************************
  79.     ** Callers can call isError() to see if an error occurred.  Some
  80.     ** functions also return error codes.  In either case, if an error
  81.     ** occurs, the caller can get the message by calling
  82.     **
  83.     **        getErrorMsg()
  84.     **
  85.     *********************************************************************/
  86.  
  87.     const char *errorMsg;        // last error message
  88.     const char * const * errorMsgList;    // if used, a list of messages
  89.     const int errorMsgCount;        // the number of messages in list
  90.     int errorCode;            // message to the caller
  91.  
  92.     unsigned Duration;            // duration of timer (ms)
  93.     int Count;                // times to handle the timer
  94.     int Useable;            // is timer working?
  95.     TimerControl *Next;            // pointer to next timer
  96.  
  97. };
  98.  
  99.  
  100.  
  101. #endif                            // } TIMERCTL_h
  102.  
  103.