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} {$ENDIF}
uses uses
Classes, SysUtils, TypInfo, LCLStrConsts, LCLType, AvgLvlTree, Classes, SysUtils, TypInfo, types, LCLStrConsts, LCLType, AvgLvlTree,
LCLProc, GraphType, Graphics, LMessages, LCLIntf, InterfaceBase, ImgList, LCLProc, GraphType, Graphics, LMessages, LCLIntf, InterfaceBase, ImgList,
UTrace, PropertyStorage, Menus, ActnList, LCLClasses, LResources; UTrace, PropertyStorage, Menus, ActnList, LCLClasses, LResources;

View File

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