$IFNDEF TRUE
$DEFINE True 1
$ENDIF
$IFNDEF FALSE
$DEFINE False 0
$ENDIF
$IFNDEF boolean
$DEFINE boolean INTEGER
$ENDIF
TYPE QVuMeter EXTENDS QCANVAS
Max AS INTEGER
Min AS INTEGER
DarkColor AS LONG
LightColor AS LONG
Thickness AS SHORT PROPERTY SET SetThickness
Interval AS SHORT PROPERTY SET SetInterval
Value AS LONG PROPERTY SET SetValue
WITH QVuMeter
PROPERTY SET SetInterval(value AS SHORT)
.Interval=INT(value)
END PROPERTY
PROPERTY SET SetThickness(value AS SHORT)
.Thickness=INT(value)
END PROPERTY
PROPERTY SET SetValue(value AS LONG)
.Value=value
.repaint
END PROPERTY
EVENT OnPaint
DIM y AS SHORT
DIM i AS SHORT
DIM NbLine AS SHORT
DIM NbLight AS SHORT
DIM range AS SHORT
DIM ValMeter AS INTEGER
NbLine=INT(.height/(.thickness+.interval))
range=.Max-.Min
ValMeter=INT(.Value-.Min)
NbLight=INT((NbLine/range)*ValMeter)
y=.height
FOR i=1 TO NbLine
IF i>NbLight THEN
.Fillrect(0,y,.width,y-.thickness,.DarkColor)
ELSE
.Fillrect(0,y,.width,y-.thickness,.LightColor)
END IF
y=y-(.thickness +.interval)
NEXT i
END EVENT
END WITH
CONSTRUCTOR
DarkColor=&h0
LightColor=&hffffff
Min=0
Max=100
Thickness=2
Interval=1
Value=0
END CONSTRUCTOR
END TYPE
|