home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / LProgressIndicator & Friends / LProgressIndicator / LProgressIndicator.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  2.7 KB  |  144 lines  |  [TEXT/CWIE]

  1. #pragma once
  2. /*
  3.     File:        LProgessIndicator.h
  4.  
  5.     Contains:    Abstract base class for the display of progress
  6.                 to the user.
  7.                 
  8.     Version:    2.1
  9.  
  10.     Author:        Chris K. Thomas, ckt@best.com
  11.     
  12.     Copyright:    ©1995 Chris K. Thomas.  All Rights Reserved.
  13. */
  14.  
  15. #include "PP_Types.h"
  16.  
  17. enum ETaskType
  18. {
  19.     task_Measured,    //we know the end max value for the task for which
  20.                     //we are indicating status.
  21.     
  22.     task_Indeterminate    //we don't know the max value
  23. };
  24.  
  25. class LProgressIndicator
  26. {
  27.  
  28. protected:
  29.     ETaskType    mTaskType;
  30.     SInt32        mMinValue, mMaxValue;    // * start and end value
  31.     SInt32        mCurValue;                // * current value
  32.     
  33. public:
  34.  
  35.     //
  36.     // * instance
  37.     //
  38.                 LProgressIndicator();
  39.                 LProgressIndicator(ETaskType inTaskType, SInt32 inMin, SInt32 inMax, SInt32 inValue);
  40.     virtual        ~LProgressIndicator();
  41.     
  42.     //
  43.     // * incrementing
  44.     //
  45.     void             CompletedThisMuchMore(SInt32 inThisMuch);// * relative to current value
  46.     void             CompletedThisMuch(SInt32);                // * absolute - replaces current value
  47.     virtual void    ValueChanged();                            // * subclasses override this one;
  48.                                                 //   it's called when the curValue changes.
  49.     
  50.     //
  51.     // * accessors
  52.     //
  53.     inline void SetValues(SInt32 inMin, SInt32 inMax, SInt32 inValue);
  54.     inline void SetCurrentValue(SInt32 inCurValue);    // equivalent to CompletedThisMuch()
  55.     inline void SetMinValue(SInt32 inMinValue);
  56.     inline void SetMaxValue(SInt32 inMaxValue);
  57.     
  58.     inline SInt32        GetCurrentValue();
  59.     inline SInt32        GetMinValue();
  60.     inline SInt32        GetMaxValue();
  61.     
  62.     inline virtual void            SetTaskType(ETaskType inType);
  63.     inline virtual ETaskType    GetTaskType();
  64.     
  65.     friend class LProgressIndicatorProxy;
  66. };
  67.  
  68.  
  69. inline void
  70. LProgressIndicator::SetValues(SInt32 inMin, SInt32 inMax, SInt32 inValue)
  71. {
  72.     mMinValue = inMin;
  73.     mMaxValue = inMax;
  74.     mCurValue = inValue;
  75.     
  76.     //
  77.     // CompletedThisMuch calls ValueChanged, but we also need
  78.     // to call it when only the min and max have changed
  79.     //
  80.     
  81.     if(inValue != mCurValue)
  82.         CompletedThisMuch(inValue);
  83.     else
  84.         ValueChanged();
  85. }
  86.  
  87. inline void
  88. LProgressIndicator::SetCurrentValue(SInt32 inCurValue)
  89. {
  90.     if(inCurValue != mCurValue)
  91.         CompletedThisMuch(inCurValue);
  92. }
  93.  
  94. inline void
  95. LProgressIndicator::SetMinValue(SInt32 inMinValue)
  96. {
  97.     if(mMinValue != inMinValue)
  98.     {
  99.         mMinValue = inMinValue;
  100.         ValueChanged();
  101.     }
  102. }
  103.  
  104. inline void
  105. LProgressIndicator::SetMaxValue(SInt32 inMaxValue)
  106. {
  107.     if(mMaxValue != inMaxValue)
  108.     {
  109.         mMaxValue = inMaxValue;
  110.         ValueChanged();
  111.     }
  112. }
  113.  
  114. inline void
  115. LProgressIndicator::SetTaskType(ETaskType inType)
  116. {
  117.     mTaskType = inType;
  118. }
  119.  
  120. inline SInt32
  121. LProgressIndicator::GetCurrentValue()
  122. {
  123.     return mCurValue;
  124. }
  125.  
  126. inline SInt32
  127. LProgressIndicator::GetMinValue()
  128. {
  129.     return mMinValue;
  130. }
  131.  
  132. inline SInt32
  133. LProgressIndicator::GetMaxValue()
  134. {
  135.     return mMaxValue;
  136. }
  137.  
  138. inline ETaskType
  139. LProgressIndicator::GetTaskType()
  140. {
  141.     return mTaskType;
  142. }
  143.  
  144.