home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / LED.PAK / LEDWIND.TXT < prev    next >
Encoding:
Text File  |  1997-05-06  |  4.5 KB  |  167 lines

  1.  
  2. Definition of Class LEDDigit
  3.  
  4. LEDDigit is derived from TWindow, and represents an LED Digit within 
  5. a LEDWindow object.
  6.  
  7.  
  8. Data Member:
  9.  
  10. HBITMAP hCurrentLEDBmp;
  11.  
  12.   hCurrentLEDBmp is a handle to a bitmap resource which contains the
  13.   bitmap of the LED digit that is currently displayed by this LEDDigit
  14.   object.
  15.  
  16.  
  17. Member functions:
  18.  
  19. constructor    
  20.  
  21.   LEDDigit( PTWindowsObject AParent, int DigitXLoc, BOOL bSurround,
  22.         HBITMAP hLEDBmp );
  23.  
  24.   Constructs a LEDDigit object within the parent window (AParent),
  25.   at X offset DigitXLoc. If bSurround is TRUE, the X and Y locations
  26.   of this object within the parent are modified to account for the
  27.   pixels used by the surround (DigitXLoc also changes). hLEDBmp is
  28.   the handle of the initial LED bitmap to be displayed by this object.
  29.  
  30. UpdateDigit
  31.  
  32.   void UpdateDigit( HBITMAP hLEDBmp );
  33.  
  34.   Updates the current LED bitmap to be displayed (hLEDBmp). 
  35.  
  36. Paint
  37.  
  38.   virtual void Paint( HDC PaintDC, PAINTSTRUCT _FAR &PaintInfo );
  39.  
  40.   Paints (with a BitBlt) the current digit in the LEDDigit window.
  41.  
  42. ----------------------------------------------------------------------------
  43.  
  44. Definition of Class LEDWindow
  45.  
  46. Data Members:
  47.  
  48. HBITMAP hLEDBmp[11];    
  49.  
  50.   An array of handles for the bitmaps of the LED digits 0 - 9 and :.
  51.  
  52. BOOL bTimerActive;    
  53.  
  54.   If TRUE, a timer has been started for the window, and Tick will be
  55.   called every nTimerInterval seconds.
  56.  
  57. BOOL bSurroundExists;
  58.  
  59.   If TRUE, a chisled surround is required by this LEDWindow.
  60.  
  61. BOOL bClockWindow;
  62.  
  63.   If TRUE, this is an HH:MM:SS clock. In which case the LEDWindow is
  64.   8 digits long and is displayed using localtime to convert from date
  65.   (seconds since 1 Jan 1970) to HH:MM:SS.
  66.  
  67. BOOL bLEDCreated; 
  68.  
  69.   A first-time switch used by the constructor to tell SetUpLEDs not to
  70.   bother to invalidate the LEDDigits this time. 
  71.  
  72. LONG lLEDValue;        
  73.  
  74.   The current value of this LEDWindow, either a LONG integer, or a time
  75.   (which equates to LONG).
  76.  
  77. struct tm *tmLEDValue;
  78.  
  79.   Time structure used to format times into HH:MM:SS for display.
  80.  
  81. int  nOldDigit[10];
  82.  
  83.   The 'old' contents of the various LED digits, used by SetUpLEDS to
  84.   determine which LEDs to invalidate for display.
  85.  
  86. int  nMaxDigits;
  87.  
  88.   The maximum number of digits that this LEDWindow can display. There is
  89.   no supression of leading zeros in an LEDWindow, so nMaxDigits is also
  90.   the actual number of digits displayed.
  91.  
  92. int  nTimerInterval;
  93.  
  94.   The time in seconds between Ticks (WM_TIMER messages) for this LEDWindow.
  95.   Must be 0 (no timer) or between 1 and 60. No sub-second times are catered
  96.   for.
  97.  
  98. int  nDigitStart;
  99.  
  100.   The start (X) location of digits within this LEDWindow.
  101.  
  102. int  nRow, nCol;
  103.  
  104.   The row and column offset of this LEDWindow within the parent window.
  105.  
  106. LEDDigit *hLED[10];
  107.  
  108.   An array of handles to the LEDDigit objects which are children of this
  109.   LEDWindow.
  110.   Note: LEDDigits are right to left: *hLED[0] (and nOldDigit[0]) is
  111.         the right-most (ones) digit.
  112.  
  113.  
  114. Member functions:
  115.  
  116. constructor    
  117.  
  118.   LEDWindow( PTWindowsObject AParent, int x, int y,
  119.         int nDigits, BOOL bSurround, BOOL bClock, LONG lValue );
  120.  
  121.   Creates an LEDWindow within parent AParent at row x, column y. The
  122.   LED has nDigits numerals. If bSurround is true, a chiseled surround
  123.   is drawn around the number. If bClock is TRUE, the LED is an HH:MM:SS
  124.   clock. lValue contains the time or number to be displayed by this LED.
  125.  
  126. destructor
  127.  
  128.   ~LEDWindow( void );
  129.  
  130.   Cleans up by destroying the bitmaps loaded in the constructor.
  131.  
  132. void GetWindowClass(WNDCLASS& AWndClass);
  133.  
  134.   Modifies the standard TWindow class definition to include a GRAY
  135.   background.
  136.  
  137. void DisplayNumber( LONG lValue );
  138.  
  139.   Displays lValue in the LED. If bClock is true, adds 18000 to lValue
  140.   if it is less than 1 'day' (86400 seconds) to prepare it for processing
  141.   by the localtime function.
  142.  
  143. BOOL StartTimer( int nInterval );
  144.  
  145.   Starts a windows timer for the LEDWindow with an interval of nInterval
  146.   seconds.
  147.  
  148. void StopTimer( void );
  149.  
  150.   Stops a timer for a LEDWindow (if one is active).
  151.  
  152. void SetupLEDs( void );
  153.  
  154.   Decides which LEDs must be changes to reflect an updated lLEDValue.
  155.   Selects the appropriate bitmap and passes it to the LEDDigit.
  156.  
  157. virtual void Tick( RTMessage Msg ) = [WM_TIMER];
  158.  
  159.   Called once for every WM_TIMER message sent to his LEDWindow. Adds one
  160.   to lLEDValue for each tick.
  161.  
  162. virtual void Paint(HDC PaintDC, PAINTSTRUCT&);
  163.  
  164.   Paints the LEDWindow surround (if required).
  165.  
  166. ----------------------------------------------------------------------------
  167.