LCL: Move procedure UpdateAlignIndex from TControl to TWinControl because it deals with its private var FAlignOrder. Suggested by taazz.

git-svn-id: trunk@58449 -
This commit is contained in:
juha 2018-07-06 21:06:59 +00:00
parent 9733fa84ab
commit 65bf99f425
3 changed files with 21 additions and 25 deletions

View File

@ -1303,7 +1303,6 @@ type
procedure ScaleConstraints(Multiplier, Divider: Integer);
procedure ChangeScale(Multiplier, Divider: Integer); virtual;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; virtual;
procedure UpdateAlignIndex;
procedure SetBiDiMode(AValue: TBiDiMode); virtual;
procedure SetParentBiDiMode(AValue: Boolean); virtual;
function IsAParentAligning: boolean;
@ -2048,14 +2047,15 @@ type
procedure Remove(AControl: TControl);
procedure AlignNonAlignedControls(ListOfControls: TFPList;
var BoundsModified: Boolean);
procedure CreateControlAlignList(TheAlign: TAlign;
AlignList: TFPList; StartControl: TControl);
procedure UpdateAlignIndex(aChild: TControl);
protected
FDoubleBuffered: Boolean;
FWinControlFlags: TWinControlFlags;
class procedure WSRegisterClass; override;
procedure AdjustClientRect(var ARect: TRect); virtual;
procedure GetAdjustedLogicalClientRect(out ARect: TRect);
procedure CreateControlAlignList(TheAlign: TAlign;
AlignList: TFPList; StartControl: TControl);
procedure AlignControls(AControl: TControl;
var RemainingClientRect: TRect); virtual;
function CustomAlignInsertBefore(AControl1, AControl2: TControl): Boolean; virtual;

View File

@ -652,8 +652,8 @@ begin
' KeepBase=',KeepBase]);
//if (Parent=nil) and (Left>0) and (ALeft=0) then DumpStack; // This can happen if the interface has not yet moved the window and for some reason something applies the interface coords back to the LCL
{$ENDIF}
if not KeepBase then
UpdateAlignIndex;
if Assigned(Parent) and not KeepBase then
Parent.UpdateAlignIndex(Self);
// constraint the size
DoConstrainedResize(ALeft, ATop, AWidth, AHeight);
@ -1805,25 +1805,6 @@ begin
Result := True;
end;
{------------------------------------------------------------------------------
TControl UpdateAlignIndex
Move this control to position 0 of Parent.FAlignOrder
------------------------------------------------------------------------------}
procedure TControl.UpdateAlignIndex;
var
i: Integer;
begin
if Parent=nil then exit;
if Parent.FAlignOrder=nil then
Parent.FAlignOrder:=TFPList.Create;
i:=Parent.FAlignOrder.IndexOf(Self);
if i<0 then
Parent.FAlignOrder.Insert(0,Self)
else
Parent.FAlignOrder.Move(i,0);
end;
{------------------------------------------------------------------------------
TControl Dragging
------------------------------------------------------------------------------}

View File

@ -2530,6 +2530,20 @@ begin
end;
end;
procedure TWinControl.UpdateAlignIndex(aChild: TControl);
// Move child control to position 0 of FAlignOrder
var
i: Integer;
begin
if FAlignOrder=nil then
FAlignOrder:=TFPList.Create;
i:=FAlignOrder.IndexOf(aChild);
if i<0 then
FAlignOrder.Insert(0,aChild)
else
FAlignOrder.Move(i,0);
end;
{------------------------------------------------------------------------------
TWinControl AlignControls
@ -6322,7 +6336,8 @@ begin
AControl.ValidateContainer(Self);
Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(True));
Insert(AControl,Index);
AControl.UpdateAlignIndex;
Assert(AControl.Parent = Self, 'TWinControl.InsertControl: AControl.Parent <> Self');
UpdateAlignIndex(AControl);
if not (csReading in AControl.ComponentState) then
begin
AControl.Perform(CM_PARENTCOLORCHANGED, 0, 0);