home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Containers / ActiveXApp / CActiveXPeriodical.cpp < prev    next >
Encoding:
Text File  |  1996-11-26  |  2.5 KB  |  89 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CActiveXPeriodical.cpp     ©1996 Microsoft Corporation. All rights reserved.
  3. // ===========================================================================
  4.  
  5. #include <Platform.h>
  6. #include "CActiveXPeriodical.h"
  7. #include "CActiveXScheduler.h"
  8.  
  9. CActiveXPeriodical*    CActiveXPeriodical::sActiveXPeriodical = NULL;
  10.  
  11. #pragma mark === CActiveXPeriodical::Construction & Destruction ===
  12.  
  13. // ---------------------------------------------------------------------------
  14. //        • CActiveXPeriodical::CActiveXPeriodical
  15. // ---------------------------------------------------------------------------
  16. //    Default Constructor
  17.  
  18. CActiveXPeriodical::CActiveXPeriodical(void)
  19. {
  20.     mIsIdling = false;
  21.     mIsRepeating = false;
  22. }
  23.  
  24.  
  25. #pragma mark === CActiveXPeriodical::LPerodical ===
  26.  
  27. // ---------------------------------------------------------------------------
  28. //        • CActiveXPeriodical::SpendTime()
  29. // ---------------------------------------------------------------------------
  30. //
  31.  
  32. void
  33. CActiveXPeriodical::SpendTime(const EventRecord &inMacEvent)
  34. {
  35.     CActiveXScheduler*    Scheduler = CActiveXScheduler::GetActiveXScheduler();
  36.  
  37.     if (Scheduler)
  38.         Scheduler->Idle(inMacEvent.what == nullEvent);
  39. }
  40.  
  41.  
  42. #pragma mark === CActiveXPeriodical::CActiveXScheduler ===
  43.  
  44. // ---------------------------------------------------------------------------
  45. //        • CActiveXPeriodical::UpdatePeriodical() [ static ]
  46. // ---------------------------------------------------------------------------
  47. //
  48.  
  49. void
  50. CActiveXPeriodical::UpdatePeriodical(void)
  51. {
  52.     if (!sActiveXPeriodical)
  53.         sActiveXPeriodical = new CActiveXPeriodical;
  54.  
  55.     if (sActiveXPeriodical)
  56.     {
  57.         Boolean8    HasIdlers = false;
  58.         Boolean8    HasRepeaters = false;
  59.         CActiveXScheduler*    Scheduler = CActiveXScheduler::GetActiveXScheduler();
  60.  
  61.         if (Scheduler)
  62.         {
  63.             HasIdlers = Scheduler->HasNullEventItems();
  64.             HasRepeaters = Scheduler->HasAllEventItems();
  65.         }
  66.  
  67.         if (sActiveXPeriodical->mIsIdling && !HasIdlers)
  68.         {
  69.             sActiveXPeriodical->mIsIdling = false;
  70.             sActiveXPeriodical->StopIdling();
  71.         }
  72.         else if (!sActiveXPeriodical->mIsIdling && HasIdlers)
  73.         {
  74.             sActiveXPeriodical->mIsIdling = true;
  75.             sActiveXPeriodical->StartIdling();
  76.         }
  77.  
  78.         if (sActiveXPeriodical->mIsRepeating && !HasRepeaters)
  79.         {
  80.             sActiveXPeriodical->mIsRepeating = false;
  81.             sActiveXPeriodical->StopRepeating();
  82.         }
  83.         else if (!sActiveXPeriodical->mIsRepeating && HasRepeaters)
  84.         {
  85.             sActiveXPeriodical->mIsRepeating = true;
  86.             sActiveXPeriodical->StartRepeating();
  87.         }
  88.     }
  89. }