LCL: AutoSize=true, no childs, no content, consider AdjustClientRect

git-svn-id: trunk@24440 -
This commit is contained in:
mattias 2010-04-05 18:08:52 +00:00
parent 4df6b8b4c4
commit c89fa706ff
2 changed files with 15 additions and 6 deletions

View File

@ -40,7 +40,7 @@ interface
{$ENDIF}
uses
Classes, SysUtils, TypInfo, LCLStrConsts, LCLType, AvgLvlTree,
Classes, SysUtils, TypInfo, types, LCLStrConsts, LCLType, AvgLvlTree,
LCLProc, GraphType, Graphics, LMessages, LCLIntf, InterfaceBase, ImgList,
UTrace, PropertyStorage, Menus, ActnList, LCLClasses, LResources;

View File

@ -7780,10 +7780,11 @@ var
Layout: TAutoSizeCtrlData;
NewClientWidth: Integer;
NewClientHeight: Integer;
OldClientRect: TRect;
CurClientRect: TRect;
NewWidth: Integer;
NewHeight: Integer;
NewMoveLeft, NewMoveRight: integer;
AdjustedClientRect: TRect;
begin
inherited CalculatePreferredSize(PreferredWidth,PreferredHeight,WithThemeSpace);
@ -7796,6 +7797,15 @@ begin
inc(PreferredHeight,BorderSpacing.InnerBorder*2);
end;
// check AdjustClientRect
CurClientRect:=Rect(0,0,1000,1000);
AdjustedClientRect:=CurClientRect;
AdjustClientRect(AdjustedClientRect);
PreferredWidth:=Max(PreferredWidth,
AdjustedClientRect.Left+CurClientRect.Right-AdjustedClientRect.Right);
PreferredHeight:=Max(PreferredHeight,
AdjustedClientRect.Top+CurClientRect.Bottom-AdjustedClientRect.Bottom);
if ControlCount>0 then begin
// get the size requirements for the child controls
@ -7810,10 +7820,9 @@ begin
end;
// add the control border around the client area
OldClientRect := GetClientRect;
NewWidth:=Width-OldClientRect.Right+NewClientWidth;
NewHeight:=Height-OldClientRect.Bottom+NewClientHeight;
CurClientRect := GetClientRect;
NewWidth:=Width-CurClientRect.Right+NewClientWidth;
NewHeight:=Height-CurClientRect.Bottom+NewClientHeight;
{$IF defined(VerboseAutoSize) or defined(VerboseAllAutoSize)}
debugln(['TWinControl.CalculatePreferredSize ',DbgSName(Self),
' HandleAllocated=',HandleAllocated,