. , Delphi 1, THeaderSections , . , , !
:
procedure TCustomHeaderControl.FlipChildren(AllLevels: Boolean);
var
Loop, FirstWidth, LastWidth: Integer;
ASectionsList: THeaderSections;
begin
if HandleAllocated and
(Sections.Count > 0) then
begin
{ Get the true width of the last section }
LastWidth := ClientWidth;
FirstWidth := Sections[0].Width;
for Loop := 0 to Sections.Count - 2 do Dec(LastWidth, Sections[Loop].Width);
{ Flip 'em }
ASectionsList := THeaderSections.Create(Self);
try
for Loop := 0 to Sections.Count - 1 do with ASectionsList.Add do
Assign(Self.Sections[Loop]);
for Loop := 0 to Sections.Count - 1 do
Sections[Loop].Assign(ASectionsList[Sections.Count - Loop - 1]);
finally
ASectionsList.Free;
end;
{ Set the width of the last Section }
if Sections.Count > 1 then
begin
Sections[Sections.Count-1].Width := FirstWidth;
Sections[0].Width := LastWidth;
end;
UpdateSections;
end;
end;
, , . , . .
, . , . THeaderSections , THeaderSections - . , ASectionsList.Add SectionsList!
,
for Loop := 0 to Sections.Count - 1 do with ASectionsList.Add do
Assign(Self.Sections[Loop]);
, Sections.Count , ASectionsList.Count - . ,
for Loop := 0 to Sections.Count - 1 do
Sections[Loop].Assign(ASectionsList[Sections.Count - Loop - 1]);
ASectionsList[Sections.Count - Loop - 1] .
. . , , , . , :
type
THeaderControl = class(Vcl.ComCtrls.THeaderControl)
public
procedure FlipChildren(AllLevels: Boolean); override;
end;
procedure THeaderControl.FlipChildren(AllLevels: Boolean);
var
Index, Count: Integer;
Widths: TArray<Integer>;
begin
Count := Sections.Count;
if Count>1 then
begin
SetLength(Widths, Count);
for Index := 0 to Count-2 do
Widths[Index] := Sections[Index].Width;
Widths[Count-1] := ClientWidth;
for Index := 0 to Count-2 do
dec(Widths[Count-1], Widths[Index]);
Sections.BeginUpdate;
try
for Index := 0 to Sections.Count-1 do
Sections[Index].Width := Widths[Count-Index-1];
finally
Sections.EndUpdate;
end;
end;
end;
.