home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / Pict2Ascii 1.03 / Panes / CMemoryIndicator.cp < prev    next >
Encoding:
Text File  |  1997-05-29  |  2.0 KB  |  65 lines  |  [TEXT/CWIE]

  1. // =================================================================================
  2. //    CMemoryIndicator.cp                        ©1997 BB's Team inc. All rights reserved
  3. // =================================================================================
  4. #include "CMemoryIndicator.h"
  5. #include "PLConstants.h"
  6. #include <LString.h>
  7.  
  8. // ---------------------------------------------------------------------------------
  9. //        • Stream ctor
  10. // ---------------------------------------------------------------------------------
  11. CMemoryIndicator::CMemoryIndicator (LStream *inStream)
  12.     : CGreyCaption (inStream)
  13.     , mFree (0)
  14.     , mIntro ("\p")
  15. {}
  16.  
  17.  
  18. // ---------------------------------------------------------------------------------
  19. //        • CreateMemoryIndicatorStream [static]
  20. // ---------------------------------------------------------------------------------
  21. CMemoryIndicator *
  22. CMemoryIndicator::CreateMemoryIndicatorStream (LStream *inStream)
  23. {
  24.     return new CMemoryIndicator (inStream);
  25. }
  26.  
  27.  
  28. // ---------------------------------------------------------------------------------
  29. //        • FinishCreateSelf
  30. // ---------------------------------------------------------------------------------
  31. void CMemoryIndicator::FinishCreateSelf (void)
  32. {
  33.     // get the introductory text from PPob
  34.     GetDescriptor (mIntro);
  35.  
  36.     // Force initialization of the caption
  37.     SpendTime ();
  38.  
  39.     StartIdling();
  40. }
  41.  
  42.  
  43. // ---------------------------------------------------------------------------------
  44. //        • SpendTime
  45. // ---------------------------------------------------------------------------------
  46. void CMemoryIndicator::SpendTime (void)
  47. {
  48.     EventRecord    lostEvent;
  49.     SpendTime (lostEvent);
  50. }
  51.  
  52.  
  53. // ---------------------------------------------------------------------------------
  54. //        • SpendTime
  55. // ---------------------------------------------------------------------------------
  56. void CMemoryIndicator::SpendTime (const EventRecord &)
  57. {
  58.     Int32 theFreeMem = ::FreeMem() / 1024;
  59.     if (theFreeMem != mFree) {
  60.         mFree = theFreeMem;
  61.         LStr255 theUnit (rSTR, kKb);
  62.         SetDescriptor (mIntro + LStr255(mFree) + theUnit);
  63.     }
  64. }
  65.