1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
//-----------------------------------------------------------------------------------------------------
// Draw a Horizontal gradient (degrade)
//-----------------------------------------------------------------------------------------------------
procedure GradHorizontal(Canvas:TCanvas; Rect:TRect; FromColor, ToColor:TColor) ;
var
x,deltaX : integer;
dr,dg,db : int64;
r1,r2,g1,g2,b1,b2:Byte;
R,G,B:Byte;
cnt:integer;
begin
deltaX := Rect.Right-Rect.Left;
if (deltaX<2) then exit;
if (Rect.Bottom-Rect.top)<2 then exit;
R1 := GetRValue(FromColor) ;
G1 := GetGValue(FromColor) ;
B1 := GetBValue(FromColor) ;
R2 := GetRValue(ToColor) ;
G2 := GetGValue(ToColor) ;
B2 := GetBValue(ToColor) ;
dr := (R2-R1);
dg := (G2-G1);
db := (B2-B1);
cnt := 0;
for X := Rect.Left to Rect.Right do
begin
R := R1 + ((dr * cnt) div deltaX);
G := G1 + ((dg * cnt) div deltaX);
B := B1 + ((db * cnt) div deltaX);
Canvas.Pen.Color := RGB(R,G,B) ;
Canvas.MoveTo(X,Rect.Top) ;
Canvas.LineTo(X,Rect.Bottom) ;
inc(cnt) ;
end;
end;
//-----------------------------------------------------------------------------------------------------
procedure LB_DrawItem(LB:TListBox;Index: Integer;Rect: TRect; State: TOwnerDrawState);
begin
// Selected line
if (odSelected in state)then
begin
Gradhorizontal(Lb.Canvas,rect,$00906040,clwhite); // ==> NON ! PLANTE du système
end else
// Not selected line
Begin
Gradhorizontal(Lb.Canvas,rect,RGB(203,225,252),RGB(125,165,224));
End;
end; |
Partager