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 106
|
// todo : ajout de l'alignement pour le texte
procedure TColumnHelpers.SetAColumnAsSortable(const Column: TColumn; const HeaderHeight : Single =0 );
var Header : THeader;
HeaderItem : THeaderItem;
agpl : TGridPanelLayout;
aControlItem : TGridPanelLayout.TControlItem;
aLabel : Tlabel;
aPath : Tpath;
begin
Header:= THeader(Self.FindStyleResource('header'));
if Assigned(Header) then begin
HeaderItem:=Header.Items[Column.Index];
HeaderItem.TagString:='Sortable';
if HeaderHeight>HeaderItem.Height then HeaderItem.Height:=HeaderHeight;
HeaderItem.TextSettings.HorzAlign:=TTextAlign.Leading;
agpl:=TGridPanelLayout.Create(Self);
agpl.Parent:=HeaderItem;
agpl.BeginUpdate;
agpl.Align:=TAlignLayout.Right;
agpl.Width:=HeaderItem.Height;
agpl.Height:=HeaderItem.Height;
agpl.ExpandStyle:=TGridPanelLayout.TExpandStyle.AddColumns;
agpl.ColumnCollection.Clear;
with agpl.ColumnCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=50.000000000000000000;
end;
with agpl.ColumnCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=50.000000000000000000;
end;
agpl.RowCollection.Clear;
with agpl.RowCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=40.000000000000000000;
end;
with agpl.RowCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=20.000000000000000000;
end;
with agpl.RowCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=40.000000000000000000;
end;
agpl.ControlCollection.ClearAndResetID;
aLabel:=TLabel.Create(agpl);
aLabel.Name:=Column.name+'ordre';
aLabel.Text:='1';
aLabel.TextSettings.VertAlign := TTextAlign.Center;
aLabel.TextSettings.HorzAlign := TTextAlign.Center;
aLabel.HitTest:=False;
aLabel.Parent:=agpl;
aLabel.Align:=TAlignLayout.Client;
aControlItem:=agpl.ControlCollection.Add;
aControlItem.Control:=aLabel;
aControlItem.Setlocation(0,2);
aPath:=TPath.Create(agpl);
aPath.Name:=Column.Name+'Asc';
aPath.Data.Data:='M8 15H16L12 8';
aPath.Fill.Color:=TAlphaColors.Black;
aPath.Parent:=agpl;
aPath.Align:=TAlignLayout.Client;
aPath.WrapMode:=TpathWrapMode.Stretch;
aControlItem:=agpl.ControlCollection.Add;
aControlItem.SetLocation(1,0);
aControlItem.Control:=aPath;
aPath:=TPath.Create(agpl);
aPath.Name:=column.Name+'NoSort';
aPath.Data.Data:='M12,10A2,2 0 0,0 10,12C10,13.11 10.9,14 12,14C13.11,14 14,13.11 14,12A2,2 0 0,0 12,10Z';
aPath.Fill.Color:=TAlphaColors.Black;
aPath.Parent:=agpl;
aPath.Align:=TAlignLayout.Client;
aPath.WrapMode:=TPathWrapMode.Fit;
aControlItem:=agpl.ControlCollection.Add;
aControlItem.SetLocation(1,1);
aControlItem.Control:=aPath;
aPath:=TPath.Create(agpl);
aPath.Name:=column.Name+'Desc';
aPath.Data.Data:='M8 9H16L12 16';
aPath.Fill.Color:=TAlphaColors.Black;
aPath.WrapMode:=TpathWrapMode.Stretch;
aPath.Parent:=agpl;
aPath.Align:=TAlignLayout.Client;
aControlItem:=agpl.ControlCollection.Add;
aControlItem.SetLocation(1,2);
aControlItem.Control:=aPath;
agpl.EndUpdate;
end;
end; |
Partager