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 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| procedure GradientFillRect(Canvas: TCanvas; Rect: TRect; BeginClr, EndClr: TColor);
var
ColorRect : TRect;
Height, Width : Integer;
FromR, FromG, FromB : Integer;
DiffR, DiffG, DiffB : Integer;
R, G, B : Byte;
I : Integer;
begin
FromR := GetRValue(BeginClr);
FromG := GetGValue(BeginClr);
FromB := GetBValue(BeginClr);
DiffR := GetRValue(EndClr) - FromR;
DiffG := GetGValue(EndClr) - FromG;
DiffB := GetBValue(EndClr) - FromB;
Height := Rect.Bottom-Rect.Top;
Width := Rect.Right-Rect.Left;
ColorRect.Top:= Rect.Top;
ColorRect.Bottom := Rect.Bottom;
for I := 0 to 255 do
begin
ColorRect.Left := Rect.Left + Muldv(I ,Width, 256);
ColorRect.Right:= Rect.Left + Muldv(I+1,Width, 256);
R := FromR + Muldv(I, DiffR, 255);
G := FromG + Muldv(I, DiffG, 255);
B := FromB + Muldv(I, DiffB, 255);
Canvas.Brush.Color := RGB(R, G, B);
Canvas.FillRect(ColorRect);
end;
end;
procedure DrawEclTab(GradientFil : boolean;Canvas: TCanvas; R: TRect; S: String; Index : integer; Images : TImageList; TabColordeb,TabColorfin : TColor);
const
D = 5;
var
H: HRgn;
PrevMode : Integer;
begin
with Canvas do
begin
brush.Color := TabColordeb;
Pen.Color := clWhite;
pen.Width := 3;
H := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
SelectClipRgn(Handle, H);
RoundRect(R.Left, R.Top, R.Right, R.Bottom + 50, D, D);
SelectClipRgn(Handle, 0);
DeleteObject(H);
Pen.Color := clgray;
OffsetRect(R, 1, 1);
H := CreateRectRgn(R.Right -D div 2, R.Top, R.Right, R.Bottom);
SelectClipRgn(Handle, H);
RoundRect(R.Left, R.Top, R.Right, R.Bottom + 50, D, D);
SelectClipRgn(Handle, 0);
DeleteObject(H);
InflateRect(R, -2, -2);
if GradientFil Then
GradientFillRect(Canvas,R,TabColordeb,TabColorFin);
PrevMode := SetBkMode(handle, TRANSPARENT);
DrawText(handle,Pchar(S),Length(S),R,DT_CENTER or DT_VCENTER or DT_SINGLELINE);
SetBkMode(handle, PrevMode);
if assigned(Images) Then
Images.Draw(Canvas,R.Left + 4,R.Top,Index);
end;
end; |
Partager