LCL now uses ClientWidth/Height, when Width/Height is not specified in lfm

git-svn-id: trunk@9530 -
This commit is contained in:
mattias 2006-06-30 14:27:08 +00:00
parent 2c02361d4d
commit 187e308562
2 changed files with 37 additions and 6 deletions

View File

@ -730,6 +730,10 @@ type
TControlFlag = ( TControlFlag = (
cfRequestAlignNeeded, cfRequestAlignNeeded,
cfAutoSizeNeeded, cfAutoSizeNeeded,
cfLeftLoaded, // cfLeftLoaded is set, when 'Left' is set during loading.
cfTopLoaded,
cfWidthLoaded,
cfHeightLoaded,
cfClientWidthLoaded, cfClientWidthLoaded,
cfClientHeightLoaded, cfClientHeightLoaded,
cfLastAlignedBoundsValid, cfLastAlignedBoundsValid,

View File

@ -2436,12 +2436,33 @@ begin
end; end;
procedure TControl.Loaded; procedure TControl.Loaded;
var
UseClientWidthForWidth: boolean;
UseClientHeightForHeight: boolean;
NewWidth: LongInt;
NewHeight: LongInt;
begin begin
inherited Loaded; inherited Loaded;
{DebugLn('TControl.Loaded A ',Name,':',ClassName,
' CW=',DbgS(cfClientWidthLoaded in FControlFlags),'=',DbgS(FLoadedClientSize.X), {DebugLn(['TControl.Loaded A ',DbgSName(Self),
' CH=',DbgS(cfClientHeightLoaded in FControlFlags),'=',DbgS(FLoadedClientSize.Y), ' LoadedClientWidth=',cfClientWidthLoaded in FControlFlags,'=',FLoadedClientSize.X,
'');} ' LoadedClientHeight=',cfClientHeightLoaded in FControlFlags,'=',FLoadedClientSize.Y,
' LoadedBounds=',DbgS(FReadBounds),
'']);}
UseClientWidthForWidth:=(not (cfWidthLoaded in FControlFlags))
and (cfClientWidthLoaded in FControlFlags);
UseClientHeightForHeight:=(not (cfHeightLoaded in FControlFlags))
and (cfClientHeightLoaded in FControlFlags);
if UseClientWidthForWidth or UseClientHeightForHeight then begin
DebugLn(['TControl.Loaded ',DbgSName(Self),' Note: Width and/or Height were not set during loading, using ClientWidth/ClientHeight']);
NewWidth:=Width;
if UseClientWidthForWidth then
NewWidth:=FLoadedClientSize.X;
NewHeight:=Height;
if UseClientHeightForHeight then
NewHeight:=FLoadedClientSize.Y;
SetBoundsKeepBase(Left,Top,NewWidth,NewHeight);
end;
if Assigned(Parent) then begin if Assigned(Parent) then begin
if ParentColor then begin if ParentColor then begin
@ -2684,6 +2705,7 @@ begin
if csLoading in ComponentState then begin if csLoading in ComponentState then begin
inc(FReadBounds.Right,Value-FReadBounds.Left); inc(FReadBounds.Right,Value-FReadBounds.Left);
FReadBounds.Left:=Value; FReadBounds.Left:=Value;
Include(FControlFlags,cfLeftLoaded);
end; end;
SetBounds(Value, FTop, FWidth, FHeight); SetBounds(Value, FTop, FWidth, FHeight);
end; end;
@ -2699,6 +2721,7 @@ begin
if csLoading in ComponentState then begin if csLoading in ComponentState then begin
inc(FReadBounds.Bottom,Value-FReadBounds.Top); inc(FReadBounds.Bottom,Value-FReadBounds.Top);
FReadBounds.Top:=Value; FReadBounds.Top:=Value;
Include(FControlFlags,cfTopLoaded);
end; end;
SetBounds(FLeft, Value, FWidth, FHeight); SetBounds(FLeft, Value, FWidth, FHeight);
end; end;
@ -2725,8 +2748,10 @@ begin
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
DebugLn('[TControl.SetWidth] ',Name,':',ClassName,' ',dbgs(Value)); DebugLn('[TControl.SetWidth] ',Name,':',ClassName,' ',dbgs(Value));
{$ENDIF} {$ENDIF}
if csLoading in ComponentState then if csLoading in ComponentState then begin
FReadBounds.Right:=FReadBounds.Left+Value; FReadBounds.Right:=FReadBounds.Left+Value;
Include(FControlFlags,cfWidthLoaded);
end;
if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then
CheckDesignBounds; CheckDesignBounds;
SetBounds(FLeft, FTop, Max(0,Value), FHeight); SetBounds(FLeft, FTop, Max(0,Value), FHeight);
@ -2754,8 +2779,10 @@ begin
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
DebugLn('[TControl.SetHeight] ',Name,':',ClassName,' ',dbgs(Value)); DebugLn('[TControl.SetHeight] ',Name,':',ClassName,' ',dbgs(Value));
{$ENDIF} {$ENDIF}
if csLoading in ComponentState then if csLoading in ComponentState then begin
FReadBounds.Bottom:=FReadBounds.Top+Value; FReadBounds.Bottom:=FReadBounds.Top+Value;
Include(FControlFlags,cfHeightLoaded);
end;
if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then if [csDesigning,csDestroying,csLoading]*ComponentState=[csDesigning] then
CheckDesignBounds; CheckDesignBounds;
SetBounds(FLeft, FTop, FWidth, Max(0,Value)); SetBounds(FLeft, FTop, FWidth, Max(0,Value));