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
| procedure TfPrinc.cStringGridDrawCell(Sender: TObject; Col, Row: Integer;
Rect: TRect; State: TGridDrawState);
var
Decale : Integer;
begin
with cStringGrid.Canvas do begin
{-------- Choisit les couleurs --------}
if Row= 0 then begin
Brush.Color:= clBtnFace; // Couleur du fond
Font.Style:= []; // Style du caractère
Font.Color:= clBlack; // Couleur du caractère
end else begin
case Col of
0: begin
Brush.Color:= clYellow;
Font.Style:= [];
Font.Color:= clBlack;
end;
1: begin
Brush.Color:= clWindow;
Font.Style:= [];
Font.Color:= clBlack;
end;
2: begin
Brush.Color:= clBlue;
Font.Style:= [];
Font.Color:= clWhite;
end;
3: begin
Brush.Color:= clTeal;
Font.Style:= [];
Font.Color:= clWhite;
end;
4: begin
Brush.Color:= clRed;
Font.Style:= [fsBold];
Font.Color:= clYellow;
end;
end;
end;
{-------- Si cette case est en sélection --------}
if (gdSelected in State) then begin
Brush.Color:= clHighlight;
Font.Style:= [fsBold];
Font.Color:= clHighlightText;
end;
{-------- Choisit l'alignement --------}
FillRect(Rect);
Decale:= (cStringGrid.ColWidths[Col] - TextWidth(cStringGrid.Cells[Col,Row])) div 2;
if (Row = 0) or (Col = 4) then
TextOut(Rect.Left + Decale, Rect.Top + 4, cStringGrid.Cells[Col, Row]) // Centrer
else if Col in [2,3] then
TextOut(Rect.Left + ((Decale * 2)- 2), Rect.Top + 4, cStringGrid.Cells[Col,Row]) // A droite
else
TextOut(Rect.Left + 2 , Rect.Top + 4, cStringGrid.Cells[col,Row]); // A Gauche
end;
{------------------------------------------------------------------------------}
{ OnDrawCell est appeler à chaque fois qu'il faut dessine une case }
{------------------------------------------------------------------------------}
{ Col représente la colonne de la case à dessine }
{ Row représente la ligne de la case à dessine }
{ Rect contient les valeurs nous permetant de dessiner au bon endroit }
{ State nous indique si cette case est "Selected", "Focused" ou "Fixed" }
{------------------------------------------------------------------------------}
end; |
Partager