home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dho.zip / DHO / SRC / SOURCE.ZIP / prgress.cc < prev    next >
C/C++ Source or Header  |  1995-08-27  |  2KB  |  119 lines

  1. /****************************************/
  2. /*    Developer Helper Object Set       */
  3. /*  (C) 1994-95 Thomas E. Bednarz, Jr.  */
  4. /*     All rights reserved              */
  5. /***************************************/
  6.  
  7. /* $Id: prgress.cc 1.4 1995/08/26 22:51:59 teb Exp $ */
  8.  
  9.  
  10. #include<prgress.h>
  11.  
  12.  
  13. //---------------------------------------------------
  14. //   TProgressBar
  15. TProgressBar::TProgressBar(ULONG id, TWinBase *parent, 
  16.                           ULONG x, ULONG y, ULONG cx, ULONG cy):
  17.    TWindow(id, parent)
  18. {
  19.    this->x = x;
  20.    this->y = y;
  21.    this->cx = cx;
  22.    this->cy = cy;
  23.    perDone = 0;
  24.    bg = CLR_DARKGRAY;
  25.    fg = CLR_BLUE;
  26.    brdr = CLR_WHITE;
  27. }
  28.  
  29.  
  30. //---------------------------------------------------
  31. //  ~TProgressBar
  32. TProgressBar::~TProgressBar()
  33. {
  34.  
  35. }
  36.       
  37.  
  38.  
  39. //---------------------------------------------------
  40. //  init
  41. BOOL TProgressBar::init()
  42. {
  43.    if (TWindow::init())
  44.    {
  45.       setWindowPosition(x,y);
  46.       setWindowSize(cx, cy);
  47.       enableUpdate(TRUE);
  48.    }
  49.    return FALSE;
  50. }
  51.  
  52.  
  53.  
  54. //---------------------------------------------------
  55. //  paintWindow
  56. void TProgressBar::paintWindow(HPS ps, RECTL rcl)
  57. {
  58.    RECTL rctl, area;
  59.    float diff;
  60.    area = rcl;
  61.  
  62.    WinFillRect(ps, &area, bg);
  63.    WinDrawBorder(ps, &rcl, 2, 2, brdr, fg, 0);
  64.  
  65.    area.xLeft+=5;
  66.    area.xRight-=5;
  67.    area.yTop-=5;
  68.    area.yBottom+=5;
  69.  
  70.    diff = area.xRight - area.xLeft;
  71.    diff = (diff * (perDone*.01));
  72.    area.xRight = area.xLeft + diff;
  73.  
  74.  
  75.    WinFillRect(ps, &area, fg);
  76. }
  77.  
  78.  
  79. //---------------------------------------------------
  80. //    setPercentDone
  81. void TProgressBar::setPercentDone(LONG percent)
  82. {
  83.    perDone = percent;
  84.    forceUpdate();
  85. }
  86.  
  87.  
  88. //---------------------------------------------------
  89. //   getPercentDone
  90. ULONG TProgressBar::getPercentDone()
  91. {
  92.    return perDone;
  93. }
  94.  
  95.  
  96. //---------------------------------------------------
  97. //   setBackground
  98. void TProgressBar::setBackground(ULONG clr_index)
  99. {
  100.   bg = clr_index;
  101. }
  102.  
  103.  
  104. //---------------------------------------------------
  105. //   setForeground
  106. void TProgressBar::setForeground(ULONG clr_index)
  107. {
  108.    fg = clr_index;
  109. }
  110.  
  111.  
  112. //---------------------------------------------------
  113. //   setBorder
  114. void TProgressBar::setBorder(ULONG clr_index)
  115. {
  116.    brdr = clr_index;
  117. }
  118.  
  119.