$INCLUDE "QARROW.INC"
TYPE QArrow EXTENDS QCANVAS
Bevel AS LONG
Orientation AS LONG
State AS LONG
ArrowColorNormal AS LONG
ArrowColorHot AS LONG
ArrowColorDown AS LONG
ArrowColorDisabled AS LONG
OffTimer AS QTIMER
FUNCTION MidColor(Color1 AS LONG,Color2 AS LONG,tone AS SINGLE) AS LONG
DIM Red1 AS LONG
DIM Green1 AS LONG
DIM Blue1 AS LONG
DIM Red2 AS LONG
DIM Green2 AS LONG
DIM Blue2 AS LONG
DIM RedMid AS LONG
DIM GreenMid AS LONG
DIM BlueMid AS LONG
Blue1 = SHR(Color1 AND &HFF0000) 16
Green1 = SHR(Color1 AND &HFF00) 8
Red1 = (Color1 AND &HFF)
Blue2= SHR (Color2 AND &HFF0000) 16
Green2= SHR (Color2 AND &HFF00) 8
Red2= (Color2 AND &HFF)
RedMid=(Red1*(1-tone)+Red2*tone) AND &HFF
GreenMid=(Green1*(1-tone)+Green2*tone) AND &HFF
BlueMid=(Blue1*(1-tone)+Blue2*tone) AND &HFF
QArrow.MidColor=RedMid OR (SHL GreenMid 8) OR (SHL BlueMid 16 )
END FUNCTION
SUB DrawComponent
DIM BevelColorHilight AS LONG
DIM BevelColorShadow AS LONG
DIM nowColor AS LONG
IF QArrow.Enabled = False THEN
QArrow.State = -1
END IF
SELECT CASE QArrow.State
CASE asNormal
nowColor = QArrow.ArrowColorNormal
CASE asHot
nowColor = QArrow.ArrowColorHot
CASE asDown
nowColor = QArrow.ArrowColorDown
CASE ELSE
nowColor = QArrow.ArrowColorDisabled
END SELECT
IF QArrow.Bevel=True THEN
BevelColorHilight=QArrow.MidColor(nowColor,&HFFFFFF,0.7)
BevelColorShadow=QArrow.MidColor(nowColor,0,0.5)
IF QArrow.State=asDown THEN
SWAP BevelColorHilight,BevelColorShadow
END IF
END IF
SELECT CASE QArrow.Orientation
CASE aoPointE
QArrow.line (0,0,QArrow.Width,QArrow.Height/2,nowColor)
QArrow.line (0,QArrow.Height-1,QArrow.Width,QArrow.Height/2-1,nowColor)
QArrow.Paint QArrow.Width / 2, QArrow.Height / 2, nowColor, nowColor
IF QArrow.Bevel=True THEN
QArrow.line (0,0,QArrow.Width,QArrow.Height/2,BevelColorShadow)
QArrow.line (0,QArrow.Height-1,QArrow.Width,QArrow.Height/2-1,BevelColorShadow)
QArrow.line (0,0,0,QArrow.Height,BevelColorHilight)
END IF
CASE aoPointW
QArrow.line (QArrow.Width-1,0,-1,QArrow.Height/2,nowColor)
QArrow.line (QArrow.Width-1,QArrow.Height-1,-1,QArrow.Height/2-1,nowColor)
QArrow.Paint QArrow.Width / 2, QArrow.Height / 2, nowColor, nowColor
IF QArrow.Bevel=True THEN
QArrow.line (QArrow.Width-1,0,-1,QArrow.Height/2,BevelColorHilight)
QArrow.line (QArrow.Width-1,QArrow.Height-1,-1,QArrow.Height/2-1,BevelColorShadow)
QArrow.line (QArrow.Width-1,0,QArrow.Width-1,QArrow.Height,BevelColorShadow)
END IF
CASE aoPointN
QArrow.line (0,QArrow.Height-1,QArrow.Width/2,-1,nowColor)
QArrow.line (QArrow.Width-1,QArrow.Height-1,QArrow.Width/2-1,-1,nowColor)
QArrow.line (0,QArrow.Height-1,QArrow.Width-1,QArrow.Height-1,nowColor)
QArrow.Paint QArrow.Width / 2, QArrow.Height / 2, nowColor, nowColor
IF QArrow.Bevel=True THEN
QArrow.line (0,QArrow.Height-1,QArrow.Width/2,-1,BevelColorHilight)
QArrow.line (QArrow.Width-1,QArrow.Height-1,QArrow.Width/2-1,-1,BevelColorShadow)
QArrow.line (0,QArrow.Height-1,QArrow.Width-1,QArrow.Height-1,BevelColorShadow)
END IF
CASE aoPointS
QArrow.line (0,0,QArrow.Width/2,QArrow.Height,nowColor)
QArrow.line (QArrow.Width-1,0,QArrow.Width/2-1,QArrow.Height,nowColor)
QArrow.Paint QArrow.Width / 2, QArrow.Height / 2, nowColor, nowColor
IF QArrow.Bevel=True THEN
QArrow.line (0,0,QArrow.Width/2,QArrow.Height,BevelColorShadow)
QArrow.line (QArrow.Width-1,0,QArrow.Width/2-1,QArrow.Height,BevelColorShadow)
QArrow.line (1,0,QArrow.Width-1,0,BevelColorHilight)
END IF
END SELECT
END SUB
SUB Refresh
IF QArrow.Enabled = True THEN
QArrow.State = asNormal
END IF
QArrow.DrawComponent
END SUB
FUNCTION IsInside(x, y, x1, y1, x2, y2) AS LONG
QArrow.IsInside = False
IF x >= x1 AND x <= x2 THEN
IF y1 >= 0 AND y <= y2 THEN
QArrow.IsInside = True
END IF
END IF
END FUNCTION
EVENT OffTimer.OnTimer
IF QArrow.IsInside(MOUSEX, MOUSEY, 0, 0, QArrow.Width, QArrow.Height) = False THEN
QArrow.State = asNormal
QArrow.DrawComponent
QArrow.OffTimer.Enabled = False
END IF
END EVENT
EVENT OnPaint
QArrow.DrawComponent
END EVENT
EVENT OnMouseDown
IF QArrow.State <> asDown THEN
QArrow.State = asDown
QArrow.DrawComponent
END IF
END EVENT
EVENT OnMouseUp
IF QArrow.State = asDown THEN
QArrow.State = asHot
QArrow.DrawComponent
END IF
END EVENT
EVENT OnMouseMove
IF QArrow.IsInside(MOUSEX, MOUSEY, 0, 0, QArrow.Width, QArrow.Height) = False THEN
ELSE
IF QArrow.State <> asHot AND QArrow.State <> asDown THEN
QArrow.State = asHot
QArrow.DrawComponent
QArrow.OffTimer.Enabled = True
END IF
END IF
END EVENT
CONSTRUCTOR
Bevel=True
State = asNormal
Orientation = aoPointE
ArrowColorNormal = &HB0E0
ArrowColorHot = &HD0F0
ArrowColorDown = &HF0
ArrowColorDisabled = &H999999
Width = 25
Height = 50
OffTimer.Enabled = False
OffTimer.Interval = 50
END CONSTRUCTOR
END TYPE
|
|