mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 21:56:00 +02:00
LCL: use AdjustClientRect for AnchorSides
git-svn-id: trunk@25515 -
This commit is contained in:
parent
35b96c9265
commit
75cd574d96
@ -1588,7 +1588,8 @@ type
|
|||||||
wcfRealizingBounds,
|
wcfRealizingBounds,
|
||||||
wcfBoundsRealized, // bounds were sent to the interface
|
wcfBoundsRealized, // bounds were sent to the interface
|
||||||
wcfUpdateShowing,
|
wcfUpdateShowing,
|
||||||
wcfHandleVisible
|
wcfHandleVisible,
|
||||||
|
wcfAdjustedLogicalClientRectValid
|
||||||
);
|
);
|
||||||
TWinControlFlags = set of TWinControlFlag;
|
TWinControlFlags = set of TWinControlFlag;
|
||||||
|
|
||||||
@ -1625,6 +1626,7 @@ type
|
|||||||
FBorderStyle: TBorderStyle;
|
FBorderStyle: TBorderStyle;
|
||||||
FBrush: TBrush;
|
FBrush: TBrush;
|
||||||
FAdjustClientRectRealized: TRect;
|
FAdjustClientRectRealized: TRect;
|
||||||
|
FAdjustClientRect: TRect; // valid if wcfAdjustClientRectValid
|
||||||
FChildSizing: TControlChildSizing;
|
FChildSizing: TControlChildSizing;
|
||||||
FControls: TFPList; // the child controls
|
FControls: TFPList; // the child controls
|
||||||
FOnGetDockCaption: TGetDockCaptionEvent;
|
FOnGetDockCaption: TGetDockCaptionEvent;
|
||||||
@ -1685,6 +1687,7 @@ type
|
|||||||
FWinControlFlags: TWinControlFlags;
|
FWinControlFlags: TWinControlFlags;
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
procedure AdjustClientRect(var ARect: TRect); virtual;
|
procedure AdjustClientRect(var ARect: TRect); virtual;
|
||||||
|
procedure GetAdjustedLogicalClientRect(out ARect: TRect);
|
||||||
procedure CreateControlAlignList(TheAlign: TAlign;
|
procedure CreateControlAlignList(TheAlign: TAlign;
|
||||||
AlignList: TFPList; StartControl: TControl);
|
AlignList: TFPList; StartControl: TControl);
|
||||||
procedure AlignControls(AControl: TControl;
|
procedure AlignControls(AControl: TControl;
|
||||||
@ -3399,6 +3402,9 @@ end;
|
|||||||
|
|
||||||
procedure TAnchorSide.GetSidePosition(out ReferenceControl: TControl;
|
procedure TAnchorSide.GetSidePosition(out ReferenceControl: TControl;
|
||||||
out ReferenceSide: TAnchorSideReference; out Position: Integer);
|
out ReferenceSide: TAnchorSideReference; out Position: Integer);
|
||||||
|
var
|
||||||
|
ParentRect: TRect;
|
||||||
|
ParentRectValid: boolean;
|
||||||
|
|
||||||
procedure RaiseInvalidSide;
|
procedure RaiseInvalidSide;
|
||||||
begin
|
begin
|
||||||
@ -3417,6 +3423,20 @@ procedure TAnchorSide.GetSidePosition(out ReferenceControl: TControl;
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetParentSidePos(Side: TAnchorKind): integer;
|
||||||
|
begin
|
||||||
|
if not ParentRectValid then begin
|
||||||
|
FOwner.Parent.GetAdjustedLogicalClientRect(ParentRect);
|
||||||
|
ParentRectValid:=true;
|
||||||
|
end;
|
||||||
|
case Side of
|
||||||
|
akTop: Result:=ParentRect.Top;
|
||||||
|
akLeft: Result:=ParentRect.Left;
|
||||||
|
akRight: Result:=ParentRect.Right;
|
||||||
|
akBottom: Result:=ParentRect.Bottom;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
NextReferenceSide: TAnchorSide;
|
NextReferenceSide: TAnchorSide;
|
||||||
ChainLength: Integer;
|
ChainLength: Integer;
|
||||||
@ -3436,6 +3456,7 @@ begin
|
|||||||
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition OwnerParent=nil']);
|
//if CheckPosition(Owner) then DebugLn(['TAnchorSide.GetSidePosition OwnerParent=nil']);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
ParentRectValid:=false;
|
||||||
ChainLength:=0;
|
ChainLength:=0;
|
||||||
MaxChainLength:=OwnerParent.ControlCount;
|
MaxChainLength:=OwnerParent.ControlCount;
|
||||||
Found:=false;
|
Found:=false;
|
||||||
@ -3480,7 +3501,7 @@ begin
|
|||||||
if Kind in [akLeft,akRight] then begin
|
if Kind in [akLeft,akRight] then begin
|
||||||
// anchor to left side of ReferenceControl
|
// anchor to left side of ReferenceControl
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
Position:=0
|
Position:=GetParentSidePos(akLeft)
|
||||||
else
|
else
|
||||||
Position:=ReferenceControl.Left;
|
Position:=ReferenceControl.Left;
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
@ -3500,7 +3521,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
// anchor to top side of ReferenceControl
|
// anchor to top side of ReferenceControl
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
Position:=0
|
Position:=GetParentSidePos(akTop)
|
||||||
else
|
else
|
||||||
Position:=ReferenceControl.Top;
|
Position:=ReferenceControl.Top;
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
@ -3523,7 +3544,7 @@ begin
|
|||||||
if Kind in [akLeft,akRight] then begin
|
if Kind in [akLeft,akRight] then begin
|
||||||
// anchor to right side of ReferenceControl
|
// anchor to right side of ReferenceControl
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
Position:=OwnerParent.GetLogicalClientRect.Right
|
Position:=GetParentSidePos(akRight)
|
||||||
else
|
else
|
||||||
Position:=ReferenceControl.Left+ReferenceControl.Width;
|
Position:=ReferenceControl.Left+ReferenceControl.Width;
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
@ -3543,7 +3564,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
// anchor to bottom side of ReferenceControl
|
// anchor to bottom side of ReferenceControl
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
Position:=OwnerParent.GetLogicalClientRect.Bottom
|
Position:=GetParentSidePos(akBottom)
|
||||||
else
|
else
|
||||||
Position:=ReferenceControl.Top+ReferenceControl.Height;
|
Position:=ReferenceControl.Top+ReferenceControl.Height;
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
@ -3566,7 +3587,7 @@ begin
|
|||||||
if Kind in [akLeft,akRight] then begin
|
if Kind in [akLeft,akRight] then begin
|
||||||
// center horizontally
|
// center horizontally
|
||||||
if ReferenceControl=OwnerParent then
|
if ReferenceControl=OwnerParent then
|
||||||
Position:=OwnerParent.ClientWidth div 2
|
Position:=GetParentSidePos(akRight)-GetParentSidePos(akLeft)
|
||||||
else
|
else
|
||||||
Position:=ReferenceControl.Left+(ReferenceControl.Width div 2);
|
Position:=ReferenceControl.Left+(ReferenceControl.Width div 2);
|
||||||
if Kind=akLeft then
|
if Kind=akLeft then
|
||||||
|
@ -4679,6 +4679,8 @@ begin
|
|||||||
while AControl<>nil do begin
|
while AControl<>nil do begin
|
||||||
Exclude(AControl.FControlFlags,cfPreferredSizeValid);
|
Exclude(AControl.FControlFlags,cfPreferredSizeValid);
|
||||||
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
|
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
|
||||||
|
if AControl is TWinControl then
|
||||||
|
Exclude(TWinControl(AControl).FWinControlFlags,wcfAdjustedLogicalClientRectValid);
|
||||||
if not AControl.IsControlVisible then break;
|
if not AControl.IsControlVisible then break;
|
||||||
AControl:=AControl.Parent;
|
AControl:=AControl.Parent;
|
||||||
end;
|
end;
|
||||||
|
@ -2377,6 +2377,16 @@ begin
|
|||||||
// It's called often, so don't put expensive code here, or cache the result
|
// It's called often, so don't put expensive code here, or cache the result
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TWinControl.GetAdjustedLogicalClientRect(out ARect: TRect);
|
||||||
|
begin
|
||||||
|
if not (wcfAdjustedLogicalClientRectValid in FWinControlFlags) then begin
|
||||||
|
FAdjustClientRect:=GetLogicalClientRect;
|
||||||
|
AdjustClientRect(FAdjustClientRect);
|
||||||
|
Include(FWinControlFlags,wcfAdjustedLogicalClientRectValid);
|
||||||
|
end;
|
||||||
|
ARect:=FAdjustClientRect;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
TWinControl CreateControlAlignList
|
TWinControl CreateControlAlignList
|
||||||
|
|
||||||
@ -3197,6 +3207,8 @@ begin
|
|||||||
AControl:=Controls[i];
|
AControl:=Controls[i];
|
||||||
Exclude(AControl.FControlFlags,cfPreferredSizeValid);
|
Exclude(AControl.FControlFlags,cfPreferredSizeValid);
|
||||||
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
|
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
|
||||||
|
if AControl is TWinControl then
|
||||||
|
Exclude(TWinControl(AControl).FWinControlFlags,wcfAdjustedLogicalClientRectValid);
|
||||||
if AControl is TWinControl then
|
if AControl is TWinControl then
|
||||||
TWinControl(AControl).InvalidatePreferredChildSizes;
|
TWinControl(AControl).InvalidatePreferredChildSizes;
|
||||||
end;
|
end;
|
||||||
@ -3621,6 +3633,7 @@ begin
|
|||||||
//DumpStack;
|
//DumpStack;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
Exclude(FWinControlFlags,wcfAdjustedLogicalClientRectValid);
|
||||||
Include(FWinControlFlags,wcfClientRectNeedsUpdate);
|
Include(FWinControlFlags,wcfClientRectNeedsUpdate);
|
||||||
|
|
||||||
if WithChildControls then begin
|
if WithChildControls then begin
|
||||||
@ -3842,6 +3855,7 @@ function TWinControl.GetClientRect: TRect;
|
|||||||
DebugLn(['StoreClientRect ',DbgSName(Self),' ',FClientWidth,',',FClientHeight,' HandleAllocated=',HandleAllocated,' wcfBoundsRealized=',wcfBoundsRealized in FWinControlFlags]);
|
DebugLn(['StoreClientRect ',DbgSName(Self),' ',FClientWidth,',',FClientHeight,' HandleAllocated=',HandleAllocated,' wcfBoundsRealized=',wcfBoundsRealized in FWinControlFlags]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FAdjustClientRectRealized:=Rect(0,0,0,0);
|
FAdjustClientRectRealized:=Rect(0,0,0,0);
|
||||||
|
Exclude(FWinControlFlags,wcfAdjustedLogicalClientRectValid);
|
||||||
end;
|
end;
|
||||||
Exclude(FWinControlFlags,wcfClientRectNeedsUpdate);
|
Exclude(FWinControlFlags,wcfClientRectNeedsUpdate);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user