home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / misc / xref_v1.1.lha / XRef / Tools / lib / gauge.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  1.8 KB  |  81 lines

  1. /*
  2. ** $PROJECT: xrefsupport.lib
  3. **
  4. ** $VER: gauge.c 1.1 (07.09.94)
  5. **
  6. ** by
  7. **
  8. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  9. **
  10. ** (C) Copyright 1994
  11. ** All Rights Reserved !
  12. **
  13. ** $HISTORY:
  14. **
  15. ** 07.09.94 : 001.001 :  initial
  16. */
  17.  
  18. #include "/source/def.h"
  19.  
  20. #include "xrefsupport.h"
  21.  
  22. void draw_gauge(struct Gauge *gauge,ULONG actual,ULONG maximal)
  23. {
  24.    if(maximal == 0)
  25.    {
  26.       EraseRect(gauge->RPort,gauge->Left  ,gauge->Top,
  27.                              gauge->Right ,gauge->Bottom);
  28.       gauge->LastPixel = gauge->Left;
  29.    } else
  30.    {
  31.       ULONG pixel = (gauge->Right - gauge->Left) * actual / maximal;
  32.  
  33.       pixel += gauge->Left;
  34.  
  35.       if(pixel > gauge->LastPixel)
  36.       {
  37.          SetDrMd(gauge->RPort,JAM1);
  38.          SetAPen(gauge->RPort,gauge->FillPen);
  39.          RectFill(gauge->RPort,gauge->LastPixel,gauge->Top,
  40.                                pixel           ,gauge->Bottom);
  41.          gauge->LastPixel = pixel;
  42.       }
  43.    }
  44. }
  45.  
  46. void draw_gaugeinit(struct Window *win,struct Gauge *gauge,UBYTE shinepen,UBYTE shadowpen)
  47. {
  48.    struct RastPort *rp = win->RPort;
  49.  
  50.    UWORD left   = gauge->Left;
  51.    UWORD top    = gauge->Top;
  52.    UWORD right  = gauge->Right;
  53.    UWORD bottom = gauge->Bottom;
  54.  
  55.    gauge->RPort  = rp;
  56.  
  57.    SetDrMd(rp,JAM1);
  58.  
  59.    SetAPen(rp,shinepen);
  60.    Move(rp,right     ,top       );
  61.    Draw(rp,left      ,top       );
  62.    Draw(rp,left      ,bottom    );
  63.    Move(rp,left + 1  ,bottom - 1);
  64.    Draw(rp,left + 1  ,top       );
  65.  
  66.    SetAPen(rp,shadowpen);
  67.  
  68.    Move(rp,right     ,top       );
  69.    Draw(rp,right     ,bottom    );
  70.    Draw(rp,left  + 1 ,bottom    );
  71.    Move(rp,right - 1 ,bottom    );
  72.    Draw(rp,right - 1 ,top    + 1);
  73.  
  74.    gauge->Left   += 2;
  75.    gauge->Right  -= 2;
  76.    gauge->Top    += 1;
  77.    gauge->Bottom -= 1;
  78.    gauge->LastPixel = gauge->Left;
  79. }
  80.  
  81.