mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 02:39:45 +02:00
LCL aligning: no longer forgets to call DoAutoSize after aligning
git-svn-id: trunk@9762 -
This commit is contained in:
parent
bb6be8d3c7
commit
5c7c30f966
@ -1361,7 +1361,7 @@ begin
|
||||
if (Result<>'') and FilenameIsAbsolute(Result) then begin
|
||||
// fully specified target filename
|
||||
end else if Result<>'' then begin
|
||||
// TargetFilename is relative to project directory
|
||||
// TargetFilename is relative to main source file
|
||||
Result:=AppendPathDelim(ExtractFilePath(MainSourceFileName))+Result;
|
||||
end else begin
|
||||
// calculate output directory
|
||||
|
@ -196,10 +196,11 @@ function GetExecutableExt(TargetOS: string): string;
|
||||
begin
|
||||
if TargetOS='' then
|
||||
TargetOS:=GetDefaultTargetOS;
|
||||
if CompareText(copy(TargetOS,1,3), 'win') = 0 then
|
||||
Result:='.exe'
|
||||
if (CompareText(copy(TargetOS,1,3), 'win') = 0)
|
||||
or (CompareText(copy(TargetOS,1,3), 'dos') = 0) then
|
||||
Result:='.exe'
|
||||
else
|
||||
Result:='';
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function GetLibraryExt(TargetOS: string): string;
|
||||
@ -207,11 +208,11 @@ begin
|
||||
if TargetOS='' then
|
||||
TargetOS:=GetDefaultTargetOS;
|
||||
if CompareText(copy(TargetOS,1,3), 'win') = 0 then
|
||||
Result:='.dll'
|
||||
Result:='.dll'
|
||||
else if CompareText(TargetOS, 'darwin') = 0 then
|
||||
Result:='.dylib'
|
||||
Result:='.dylib'
|
||||
else
|
||||
Result:='';
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function GetDefaultTargetCPU: string;
|
||||
|
@ -940,11 +940,11 @@ type
|
||||
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: integer); virtual;
|
||||
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); virtual;
|
||||
procedure ChangeScale(Multiplier, Divider: Integer); dynamic;
|
||||
Function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; virtual;
|
||||
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; virtual;
|
||||
procedure SetAlignedBounds(aLeft, aTop, aWidth, aHeight: integer); virtual;
|
||||
Function GetClientOrigin: TPoint; virtual;
|
||||
Function GetClientRect: TRect; virtual;
|
||||
Function GetScrolledClientRect: TRect; virtual;
|
||||
function GetClientOrigin: TPoint; virtual;
|
||||
function GetClientRect: TRect; virtual;
|
||||
function GetScrolledClientRect: TRect; virtual;
|
||||
function GetClientScrollOffset: TPoint; virtual;
|
||||
function GetControlOrigin: TPoint; virtual;
|
||||
protected
|
||||
@ -2124,6 +2124,7 @@ procedure AdjustBorderSpace(var RemainingClientRect, CurBorderSpace: TRect;
|
||||
const Space: TRect);
|
||||
|
||||
function DbgS(a: TAnchorKind): string; overload;
|
||||
function DbgS(Anchors: TAnchors): string; overload;
|
||||
|
||||
// register (called by the package initialization in design mode)
|
||||
procedure Register;
|
||||
@ -2214,6 +2215,20 @@ begin
|
||||
Result:=AnchorNames[a];
|
||||
end;
|
||||
|
||||
function DbgS(Anchors: TAnchors): string;
|
||||
var
|
||||
a: TAnchorKind;
|
||||
begin
|
||||
Result:='';
|
||||
for a:=Low(TAnchorKind) to High(TAnchorKind) do begin
|
||||
if a in Anchors then begin
|
||||
if Result<>'' then Result:=Result+',';
|
||||
Result:=Result+AnchorNames[a];
|
||||
end;
|
||||
end;
|
||||
Result:='['+Result+']';
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
RecreateWnd
|
||||
This function was originally member of TWincontrol. From a VCL point of view
|
||||
|
@ -276,7 +276,7 @@ begin
|
||||
FShortCut := ShortCut(Char2VK(ParseStr[AccelIndex]), [ssCtrl]);
|
||||
TWSButtonClass(WidgetSetClass).SetShortCut(Self, OldShortCut, FShortCut);
|
||||
end;
|
||||
DoAutoSize;
|
||||
AdjustSize;
|
||||
end;
|
||||
|
||||
function TCustomButton.ChildClassAllowed(ChildClass: TClass): boolean;
|
||||
|
@ -33,21 +33,21 @@
|
||||
Calls DoAutoSize smart.
|
||||
During loading and handle creation the calls are delayed.
|
||||
|
||||
This method do the same as TWinControl.DoAutoSize at the beginning.
|
||||
This method does the same as TWinControl.DoAutoSize at the beginning.
|
||||
But since DoAutoSize is commonly overriden by existing Delphi components,
|
||||
they do not all tests, which can result in too much overhead. To reduce this
|
||||
the LCL calls AdjustSize instead.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.Adjustsize;
|
||||
begin
|
||||
If not AutoSizeCanStart then exit;
|
||||
if AutoSizeDelayed then begin
|
||||
if (not AutoSizeCanStart) or AutoSizeDelayed then begin
|
||||
//debugln('TControl.AdjustSize AutoSizeDelayed ',DbgSName(Self));
|
||||
Include(FControlFlags,cfAutoSizeNeeded);
|
||||
exit;
|
||||
end;
|
||||
//debugln('TControl.AdjustSize DoAutoSize ',DbgSName(Self));
|
||||
DoAutoSize;
|
||||
Exclude(FControlFlags,cfAutoSizeNeeded);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -365,7 +365,7 @@ begin
|
||||
TWinControl(Self).DisableAlign;
|
||||
try
|
||||
// resize parents client area
|
||||
If Parent <> nil then
|
||||
if Parent <> nil then
|
||||
Parent.AdjustSize;
|
||||
if UpdatePosSizeChanged then exit;
|
||||
// notify before autosizing
|
||||
@ -385,6 +385,8 @@ begin
|
||||
// (this will autosize the childs)
|
||||
if Self is TWinControl then
|
||||
TWinControl(Self).EnableAlign;
|
||||
// autosize self
|
||||
AdjustSize;
|
||||
end;
|
||||
finally
|
||||
dec(FSizeLock);
|
||||
@ -404,6 +406,7 @@ begin
|
||||
Resize;
|
||||
CheckOnChangeBounds;
|
||||
// for delphi compatibility send size/move messages
|
||||
UpdatePosSizeChanged;
|
||||
SendMoveSizeMessages(SizeChanged,PosChanged);
|
||||
end;
|
||||
end;
|
||||
@ -2546,9 +2549,10 @@ var
|
||||
OldAlign: TAlign;
|
||||
begin
|
||||
if FAlign = Value then exit;
|
||||
//DebugLn('TControl.SetAlign ',Name,':',ClassName,' Old=',AlignNames[FAlign],' New=',AlignNames[Value]);
|
||||
//DebugLn(['TControl.SetAlign ',DbgSName(Self),' Old=',AlignNames[FAlign],' New=',AlignNames[Value],' ',Anchors<>AnchorAlign[FAlign]]);
|
||||
OldAlign:=FAlign;
|
||||
FAlign := Value;
|
||||
Exclude(FControlFlags,cfLastAlignedBoundsValid);
|
||||
// if anchors were on default then change them to new default
|
||||
// This is done for Delphi compatibility.
|
||||
if (Anchors=AnchorAlign[OldAlign]) and (Anchors<>AnchorAlign[FAlign]) then
|
||||
@ -2564,6 +2568,7 @@ procedure TControl.SetAnchors(const AValue: TAnchors);
|
||||
begin
|
||||
if Anchors=AValue then exit;
|
||||
FAnchors:=AValue;
|
||||
Exclude(FControlFlags,cfLastAlignedBoundsValid);
|
||||
RequestAlign;
|
||||
end;
|
||||
|
||||
@ -3764,7 +3769,7 @@ end;
|
||||
undefined values will be replaced by the current width and height.
|
||||
|
||||
WithThemeSpace: If true, adds space for stacking. For example: TRadioButton
|
||||
has a minimum size. But for staking multiple TRadioButtons there should be
|
||||
has a minimum size. But for stacking multiple TRadioButtons there should be
|
||||
some space around. This space is theme dependent, so it passed parameter to
|
||||
the widgetset.
|
||||
|
||||
|
@ -68,7 +68,7 @@ begin
|
||||
result:=(pos(#10,s)>0) or (pos(#13,s)>0);
|
||||
end;
|
||||
|
||||
Procedure TCustomLabel.DoAutoSize;
|
||||
procedure TCustomLabel.DoAutoSize;
|
||||
var
|
||||
NewWidth, NewHeight: integer;
|
||||
CurAnchors: TAnchors;
|
||||
@ -84,7 +84,7 @@ begin
|
||||
AutoSizing := True;
|
||||
try
|
||||
CalcSize(NewWidth, NewHeight);
|
||||
//debugln('TCustomLabel.DoAutoSize ',dbgs(Left),' ',dbgs(Top),' ',dbgs(NewWidth),' ',dbgs(NewHeight));
|
||||
//debugln('TCustomLabel.DoAutoSize Nice ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h',dbgs(NewHeight));
|
||||
CurAnchors:=[];
|
||||
if Align in [alLeft,alRight,alBottom,alTop,alClient] then
|
||||
CurAnchors:=AnchorAlign[Align];
|
||||
@ -94,13 +94,14 @@ begin
|
||||
if CurAnchors*[akTop,akBottom]=[akTop,akBottom] then
|
||||
NewHeight:=Height;
|
||||
|
||||
//debugln('TCustomLabel.DoAutoSize Anchored ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight));
|
||||
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
|
||||
finally
|
||||
AutoSizing := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TCustomLabel.SetAlignment(Value : TAlignment);
|
||||
procedure TCustomLabel.SetAlignment(Value : TAlignment);
|
||||
begin
|
||||
//debugln('TCustomLabel.SetAlignment Old=',dbgs(ord(Alignment)),' New=',dbgs(ord(Value)),' csLoading=',dbgs(csLoading in ComponentState));
|
||||
if FAlignment <> Value then begin
|
||||
|
@ -170,10 +170,10 @@ function TrimFilename(const AFilename: string): string;
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
l:=length(TheFilename);
|
||||
// check heading spaces
|
||||
if TheFilename[1]=' ' then exit;
|
||||
// check trailing spaces
|
||||
l:=length(TheFilename);
|
||||
if TheFilename[l]=' ' then exit;
|
||||
i:=1;
|
||||
while i<=l do begin
|
||||
|
@ -1067,7 +1067,7 @@ var
|
||||
CurBaseBounds: TRect;
|
||||
NewRight: Integer;
|
||||
NewBottom: Integer;
|
||||
var
|
||||
|
||||
MinWidth: Integer;
|
||||
MaxWidth: Integer;
|
||||
MinHeight: Integer;
|
||||
@ -1080,6 +1080,8 @@ var
|
||||
AnchorSideCache: array[TAnchorKind] of integer;
|
||||
CurAnchors: TAnchors;
|
||||
CurAlignAnchors: TAnchors;
|
||||
OldBounds: TRect;
|
||||
NewBounds: TRect;
|
||||
|
||||
function ConstraintWidth(NewWidth: integer): Integer;
|
||||
begin
|
||||
@ -1158,7 +1160,7 @@ var
|
||||
|
||||
begin
|
||||
{$IFDEF CHECK_POSITION}
|
||||
if CheckPosition(Control) then
|
||||
//if CheckPosition(Control) then
|
||||
with Control do
|
||||
DebugLn('[TWinControl.AlignControls.DoPosition] A Control=',Name,':',ClassName,' ',dbgs(Left),',',dbgs(Top),',',dbgs(Width),',',dbgs(Height),' recalculate the anchors=',dbgs(Control.Anchors <> AnchorAlign[AAlign]),' Align=',AlignNames[AAlign]);
|
||||
{$ENDIF}
|
||||
@ -1451,8 +1453,11 @@ var
|
||||
{$ENDIF}
|
||||
// lock the base bounds, so that the new automatic bounds do not override
|
||||
// the user settings
|
||||
BoundsMutated:=true;
|
||||
OldBounds:=Control.BoundsRect;
|
||||
Control.SetAlignedBounds(NewLeft, NewTop, NewWidth, NewHeight);
|
||||
//DebugLn(['DoPosition ',DbgSName(Control),' ',cfAutoSizeNeeded in Control.FControlFlags]);
|
||||
NewBounds:=Control.BoundsRect;
|
||||
BoundsMutated:=not CompareRect(@OldBounds,@NewBounds);
|
||||
// Sometimes SetBounds change the bounds. For example due to constraints.
|
||||
// update the new bounds
|
||||
with Control do
|
||||
@ -1686,8 +1691,14 @@ begin
|
||||
finally
|
||||
Exclude(FWinControlFlags,wcfAligningControls);
|
||||
end;
|
||||
|
||||
if Showing then AdjustSize;
|
||||
// let childs autosize themselves
|
||||
for i:=0 to ControlCount-1 do begin
|
||||
ChildControl:=Controls[i];
|
||||
if cfAutoSizeNeeded in ChildControl.FControlFlags then begin
|
||||
//DebugLn(['TWinControl.AlignControls AdjustSize: ',DbgSName(ChildControl),' ',(not ChildControl.AutoSizeCanStart),' ',ChildControl.AutoSizeDelayed]);
|
||||
ChildControl.AdjustSize;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWinControl.DoAlignChildControls(TheAlign: TAlign; AControl: TControl;
|
||||
@ -1830,8 +1841,7 @@ begin
|
||||
{$IFDEF VerboseAutoSize}
|
||||
debugln('TWinControl.DoAutoSize ',DbgSName(Self));
|
||||
{$ENDIF}
|
||||
If not AutoSizeCanStart then exit;
|
||||
if AutoSizeDelayed then begin
|
||||
if (not AutoSizeCanStart) or AutoSizeDelayed then begin
|
||||
Include(FControlFlags,cfAutoSizeNeeded);
|
||||
exit;
|
||||
end;
|
||||
|
@ -824,10 +824,10 @@ begin
|
||||
NeighbourList:=FindPageNeighbours(Layout,NeighbourControl,AnchorControls);
|
||||
try
|
||||
NeighbourControl.Parent.DisableAlign;
|
||||
if AnchorControls[akLeft]=nil then ;
|
||||
// TODO: create a PageControl and two pages. And move the neigbbours onto
|
||||
// one page and Control to the other page.
|
||||
|
||||
|
||||
finally
|
||||
NeighbourList.Free;
|
||||
NeighbourControl.Parent.EnableAlign;
|
||||
|
Loading…
Reference in New Issue
Block a user