home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / LED.PAK / LEDWIND.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.7 KB  |  77 lines

  1. //----------------------------------------------------------------------------
  2. // LED Window to Display Numbers
  3. //
  4. //  ledwind.h
  5. //
  6. // Chris Hewitt, 100036,133 
  7. //
  8. // Displays red LEDs on a black background. The chiseled surrounding is
  9. // optional and is designed to fit on a GRAY background. Setting bSurround
  10. // to TRUE adds 2 pixels to height and width. Height is 24, width is 13 *
  11. // number of digits (not counting the surround).
  12. //
  13. // If bClock is TRUE, the LEDWindow becomes an HH:MM:SS clock, and
  14. // lLEDValue should be a time variable (seconds since 1st Jan 1970,
  15. // or, to be more exact, seconds since -05:00 on 0th Jan 1970!), just
  16. // feed it a time value, or, for an elapsed time counter, a number.
  17. //
  18. // The maximum size of an LEDWindow is 10 Digits.
  19. //
  20. // StarTimer and StopTimer may be used to make the LED register
  21. // time intervals between 1 and 60 seconds. The LED will be incremented
  22. // by one for each interval.
  23. //
  24. // The Bitmaps led0.bmp thru led9.bmp must be declared in the resource
  25. // file as LED0Bmp, LED1Bmp etc. (see example).
  26. //
  27. //----------------------------------------------------------------------------
  28. #if !defined (LEDWIND_H)
  29. #define LEDWIND_H
  30.  
  31. #if !defined(OWL_WINDOW_H)
  32. # include <owl/window.h>
  33. #endif
  34. class _EXPCLASS TBitmap;
  35. class _EXPCLASS TLedDigit;
  36.  
  37. class TLedWindow : public TWindow
  38. {
  39.   public:
  40.     TLedWindow(TWindow* parent, int x, int y, int digits, bool surround, 
  41.                bool clock, long value);
  42.    ~TLedWindow();
  43.  
  44.     void SetupWindow();
  45.  
  46.     void DisplayNumber(long value);
  47.     bool StartTimer(int interval);
  48.     void StopTimer();
  49.  
  50.     long       LedValue;        // The Current Value of this LED window
  51.     
  52.   protected:
  53.     void UpdateLeds();
  54.     void Paint(TDC& dc, bool erase, TRect& rect);
  55.     void EvTimer(uint);
  56.   
  57.     TBitmap*   LedBmp[11];      // Bitmaps for LED numbers (0 - 9 + :)
  58.     bool       Beveled;         // True if led frame is beveled
  59.     int        MaxDigits;       // Maximum Number of Digits
  60.     int        DigitStart;      // Start location of LED Digits in Window
  61.     int        Row, Col;        // The parent window offset of LED Window
  62.     TLedDigit* Led[10];         // Handle array for LED Digit Children
  63.  
  64.     bool       TimerActive;     // Switch indicating if this is a timer
  65.     int        TimerInterval;   // The current Timer interval
  66.     bool       ClockWindow;     // True if this is a Clock
  67.     long       ClockWork;       // Used to store altered time values
  68.     struct tm* tmLedValue;      // Time Struct for Clock Windows
  69.       
  70.     // Note: LedDigits are right to left: *Led[0] (and OldDigit[0]) is
  71.     //       the right-most (ones) digit.
  72.  
  73.   DECLARE_RESPONSE_TABLE(TLedWindow);
  74. };
  75.  
  76. #endif
  77.