home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / include / MotifApp / Clock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-17  |  2.0 KB  |  61 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ///////////////////////////////////////////////////////////////
  22. // Clock.h
  23. ///////////////////////////////////////////////////////////////
  24. #ifndef CLOCK_H
  25. #define CLOCK_H
  26. #include "UIComponent.h"
  27.  
  28. class Clock : public UIComponent {
  29.     
  30.   private:
  31.     
  32.     int          _delta;     // The time between ticks
  33.     XtIntervalId _id;        // Xt Timeout identifier
  34.     
  35.     virtual void timeout();  // Called every delta milliseconds
  36.     virtual void speedChanged ( int ); // Called if the user moves 
  37.     // the speed control
  38.     //  Xt Callbacks
  39.     
  40.     static void timeoutCallback ( XtPointer, XtIntervalId * );
  41.     static void speedChangedCallback ( Widget, XtPointer, XtPointer );
  42.     
  43.   protected:
  44.     
  45.     virtual void tick() = 0;  // Hook for derived classes
  46.     
  47.   public:
  48.     
  49.     Clock ( Widget, char *, 
  50.        int,             // Minimum speed, in frames per second
  51.        int );           // Maximum speed, in frames per second
  52.     ~Clock ();
  53.     
  54.     void stop();    // Stop the clock
  55.     void pulse();   // Make the clock tick once
  56.     void start();   // Start or restart the clock
  57.     
  58.     virtual const char *const className() { return ( "Clock" ); }
  59. };
  60. #endif
  61.