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
| unit GrilleUnit;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Rtti,
FMX.Grid.Style, FMX.Grid, FMX.Controls.Presentation, FMX.ScrollBox,
FMX.StdCtrls, System.Skia, FMX.Skia;
type
TForm5 = class(TForm)
Grid1: TGrid;
Column1: TColumn;
Column2: TColumn;
StyleBook1: TStyleBook;
Button1: TButton;
SkSvg1: TSkSvg;
procedure Button1Click(Sender: TObject);
procedure Grid1DrawColumnHeader(Sender: TObject; const Canvas: TCanvas;
const Column: TColumn; const Bounds: TRectF);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form5: TForm5;
implementation
{$R *.fmx}
uses FMX.Header;
procedure TForm5.Button1Click(Sender: TObject);
var
Header: THeader;
begin
Header:= THeader(Grid1.FindStyleResource('header'));
Header.Height := 40;
end;
procedure TForm5.Grid1DrawColumnHeader(Sender: TObject; const Canvas: TCanvas;
const Column: TColumn; const Bounds: TRectF);
var
Header: THeader;
HeaderItem: THeaderItem;
const svg1 = '''
<svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" enable-background="new 0 0 48 48">
<g fill="#D1C4E9">
<path d="M38,7H10C8.9,7,8,7.9,8,9v6c0,1.1,0.9,2,2,2h28c1.1,0,2-0.9,2-2V9C40,7.9,39.1,7,38,7z"/>
<path d="M38,19H10c-1.1,0-2,0.9-2,2v6c0,1.1,0.9,2,2,2h28c1.1,0,2-0.9,2-2v-6C40,19.9,39.1,19,38,19z"/>
<path d="M38,31H10c-1.1,0-2,0.9-2,2v6c0,1.1,0.9,2,2,2h28c1.1,0,2-0.9,2-2v-6C40,31.9,39.1,31,38,31z"/>
</g>
<circle fill="#43A047" cx="38" cy="38" r="10"/>
<polygon fill="#DCEDC8" points="42.5,33.3 36.8,39 34.1,36.3 32,38.5 36.8,43.3 44.6,35.5"/>
</svg>
''';
begin
Header:= THeader(Grid1.FindStyleResource('header'));
if assigned(Header) then HeaderItem:= Header.Items[column.index];
case Column.Index of
0 : begin
if HeaderItem.ComponentCount>1 then HeaderItem.Components[1].Destroy;
with TSKSvg.Create(HeaderItem) do
begin
Margins.Right:=2;
Margins.Top:=1;
Margins.Bottom:=1;
Height:=Header.Height-2;
Width:=Height;
Align:=TalignLayout.Right;
Parent:=HeaderItem;
HeaderItem.TextSettings.HorzAlign := TTextAlign.Leading;
SVG.Source:=svg1;
Width:=Header.Height;
// OnClick:=ClickSort;
end;
end;
1 : begin
end;
end;
end;
end. |
Partager