From c89fa706ff67c7c9ab1fa6a3f1b4d56b0957e2f6 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 5 Apr 2010 18:08:52 +0000 Subject: [PATCH] LCL: AutoSize=true, no childs, no content, consider AdjustClientRect git-svn-id: trunk@24440 - --- lcl/controls.pp | 2 +- lcl/include/wincontrol.inc | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lcl/controls.pp b/lcl/controls.pp index e0d38f5bec..8c09167ceb 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -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; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 796470010a..178906cb23 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -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,