home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / timer.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  2KB  |  69 lines

  1.  
  2.  
  3. #ifndef _timer_h_ /* Thu Oct 13 16:22:48 1994 */
  4. #define _timer_h_
  5.  
  6.  
  7.  
  8. #if defined(__GNUC__)
  9. #pragma interface
  10. #endif
  11.  
  12.  
  13. #include "base/binding.h"
  14. #include "base/map.h"
  15.  
  16. // This is a  class that provides a simple timer service.  The Start method
  17. // (for {\it any\/} Timer instance) can only be
  18. // called {\it after\/} the main window has been displayed.
  19.  
  20. class CL_EXPORT UI_Timer: public CL_Object {
  21.  
  22. public:
  23.     UI_Timer (const CL_AbstractBinding& bnd);
  24.     // Construct a Timer object which will execute the given binding
  25.     // whenever the timer expires.
  26.  
  27.     ~UI_Timer ();
  28.     // Destructor: stop the timer.
  29.     
  30.     bool Start (long msecs);
  31.     // Start the timer. After this method is called, the timer repeatedly
  32.     // executes its binding every {\tt msecs} milliseconds.
  33.     //
  34.     // This method returns TRUE if successful, FALSE if the system's timer
  35.     // resource is not available.  This method can only be
  36.     // called {\it after\/} the main window has been displayed.
  37.     
  38.     bool Stop ();
  39.     // Stop the timer, and do not execute the binding any more.
  40.  
  41.     bool IsRunning () const { return _running;};
  42.  
  43. protected:
  44.     CL_AbstractBinding* _bind;
  45.     ulong               _id;
  46.     long                _msecs;
  47.     bool                _running;
  48.     
  49. public:
  50.  
  51. #if defined(__MS_WINDOWS__)
  52.     void DoAlarm ();
  53.     // MS-Windows-specific. For YACL internal use only.
  54.  
  55. #elif defined(__X_MOTIF__)
  56.     static void DoAlarm (void*, ulong*);
  57.     // X-windows specific. For YACL internal use only.
  58.     
  59. #elif defined (__OS2__)
  60.     static void DoAlarm (ulong timerId);
  61.  
  62. protected:
  63.     static CL_IntPtrMap _TimerMap;
  64. #endif
  65. };
  66.  
  67.  
  68. #endif /* _timer_h_ */
  69.