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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| //------------------------------------------------------------------------------
//------------------------------------------------------------------------------
procedure TFrmEasySearchSejourModule.DBGridSearchSejourDrawDataCell(
Sender: TObject; const Rect: TRect; Field: TField;
State: TGridDrawState);
// Fonctione Interne -------------------------------------------------------
function GetPourcentColor(Pourcent: Integer): TColor;
begin
case Pourcent of // BVR
0..9 : Result := $0000FF;// ClRed;
10..19 : Result := $0033FF;
20..29 : Result := $0066FF;
30..39 : Result := $0099FF;
40..49 : Result := $00CCFF;
50..59 : Result := $00FFFF;// ClYellow
60..69 : Result := $00FFCC;
70..79 : Result := $00FF99;
80..89 : Result := $00FF66;
90..99 : Result := $00FF33;
100 : Result := $00FF00;// ClLime;
else Result := $FF0000;// ClBlue;
end;
end;
// Fonctione Interne -------------------------------------------------------
function InvertColor(AColor: TColor): TColor;
type
TRVBColor = record
case integer of
1: (
cR, cV, cB, cS: Byte;
);
2: (
Color: TColor;
);
end;
var
RVBResult: TRVBColor;
begin
RVBResult.Color := AColor;
RVBResult.cR := $FF - RVBResult.cR;
RVBResult.cV := $FF - RVBResult.cV;
RVBResult.cB := $FF - RVBResult.cB;
Result := RVBResult.Color;
end;
var
CopyRect, RectEnVar: TRect;
ADrawString: String;
TextBmp: TBitmap;
x, y: Integer;
begin
if Assigned(Field) then begin
if Field.FieldName = GRID_FIELD_NAME[egfInterventionPrevueRealisee] then begin
// Efface la Zone
DBGridSearchSejour.Canvas.Brush.Color := clWindow;
DBGridSearchSejour.Canvas.FillRect(Rect);
if not Field.IsNull then begin
if Field.AsInteger > 0 then begin
DBGridSearchSejour.Canvas.Brush.Color := GetPourcentColor(Field.AsInteger);
CopyRect := Rect;
CopyRect.Right := CopyRect.Left + Round((CopyRect.Right - CopyRect.Left) * Field.AsInteger / 100);
DBGridSearchSejour.Canvas.FillRect(CopyRect);
CopyRect := Rect;
ADrawString := Field.AsString +' %';
TextBmp := TBitmap.Create();
try
TextBmp.Width := Rect.Right - Rect.Left;
TextBmp.Height := Rect.Bottom - Rect.Top;
RectEnVar := Types.Rect(0, 2, TextBmp.Width, TextBmp.Height-2);
TextBmp.Canvas.Font.Color := clBlack;
Windows.DrawText(TextBmp.Canvas.Handle,
PChar(ADrawString),
Length(ADrawString),
RectEnVar,
DT_CENTER+DT_VCENTER);
for x := 0 to TextBmp.Width-1 do begin
for y := 0 to TextBmp.Height-1 do begin
if TextBmp.Canvas.Pixels[x, y] = clBlack then begin
TextBmp.Canvas.Pixels[x, y] := InvertColor(DBGridSearchSejour.Canvas.Pixels[Rect.Left+x, Rect.Top+y]);
end else begin
TextBmp.Canvas.Pixels[x, y] := DBGridSearchSejour.Canvas.Pixels[Rect.Left+x, Rect.Top+y];
end;
end;
end;
Windows.BitBlt(DBGridSearchSejour.Canvas.Handle,
Rect.Left, Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top,
TextBmp.Canvas.Handle,
0, 0,
SRCCOPY);
finally
TextBmp.Free();
end;
end;
end;
end;
end;
end; |
Partager