*============Progress.cc progress bar.....

Class ProgBar(f,n) of Rectangle(f,n) Custom
   This.height = 1.06
   This.width = 10
   this.borderstyle = 2
   This.nMax = 0
   This.Interval = 1
   
   PROCEDURE Setup(nMaximum)
   This.nMax = nMaximum
   if this.nMax <= 100
      This.nInterval = 1
   elseif this.nMax <= 1000
      This.nInterval = 5
   elseif this.nMax <= 10000
      This.nInterval = 20
   else
      This.nInterval = 50
   endif
   
   IF type('This.Parent.progdisp') # 'O'
   
      DEFINE RECTANGLE PROGDISP OF This.Parent;
         Property;
         height this.height-.12,;
         width .17,;
         left this.left+.17,;
         Top this.top+.06,;
         Pageno This.Pageno,;
         ColorNormal "R/R",;
         BorderStyle 0

   endif
   
   PROCEDURE UPDATE(nNum)
   This.nCurrNum = nNum
   This.TestNum = round(this.nCurrnum/this.nInterval,3)

 
   if this.testnum == int(this.testnum)
      This.Parent.Progdisp.visible = .t.
      Local nDecimalDone,nWidth
      nDecimalDone = round(this.nCurrNum/this.nMax,2)
      nWidth = this.width-.35
      if (nDecimaldone*nWidth) > (This.width-.35)
         This.Parent.Progdisp.Width = (This.Width-.35)
      else
         This.Parent.Progdisp.Width = (nDecimalDone*nWidth)
      endif
   endif

   PROCEDURE RESET
   This.Parent.Progdisp.Width = .17

endclass