LCL: TScrollingWincontrol: fixed GetLogicalClientRect - only use Range if bar is visible, use preferredsize if Parent.ChildSizing.Layout<>cclNone

git-svn-id: trunk@25574 -
This commit is contained in:
mattias 2010-05-22 11:52:45 +00:00
parent d18d9a1205
commit cb7c832e25
3 changed files with 32 additions and 8 deletions

View File

@ -137,6 +137,8 @@ type
property Kind: TScrollBarKind read FKind;
function GetOtherScrollBar: TControlScrollBar;
property Size: integer read GetSize write SetSize stored False;
function ClientSizeWithBar: integer; // return for vertical scrollbar the clientwidth with the bar, even if Visible=false
function ClientSizeWithoutBar: integer; // return for vertical scrollbar the clientwidth without the bar, even if Visible=true
published
property Increment: TScrollBarInc read GetIncrement write SetIncrement default 8;
property Page: TScrollBarInc read GetPage write SetPage default 80;
@ -172,7 +174,7 @@ type
OldPosition: Integer); virtual;
procedure SetAutoScroll(Value: Boolean); virtual;
procedure Loaded; override;
property AutoScroll: Boolean read FAutoScroll write SetAutoScroll default False;
property AutoScroll: Boolean read FAutoScroll write SetAutoScroll default False;// auto show/hide scrollbars
public
constructor Create(TheOwner : TComponent); override;
destructor Destroy; override;

View File

@ -231,8 +231,6 @@ procedure TControlScrollBar.AutoCalcRange;
PreferredHeight:=0;
FControl.GetPreferredSize(PreferredWidth,PreferredHeight,true);
//DebugLn(['GetPreferredClientRect ',DbgSName(FControl),' Pref=',PreferredWidth,'x',PreferredHeight]);
dec(PreferredWidth,FControl.Width-FControl.ClientWidth);
dec(PreferredHeight,FControl.Height-FControl.ClientHeight);
if PreferredWidth<0 then PreferredWidth:=0;
if PreferredHeight<0 then PreferredHeight:=0;
end;
@ -245,7 +243,8 @@ procedure TControlScrollBar.AutoCalcRange;
PreferredWidth: Integer;
PreferredHeight: Integer;
begin
if FControl.AutoSize then
if FControl.AutoSize
or ((FControl.Parent<>nil) and (FControl.Parent.ChildSizing.Layout<>cclNone)) then
begin
GetPreferredClientRect(PreferredWidth,PreferredHeight);
TmpRange := PreferredHeight;
@ -261,7 +260,7 @@ procedure TControlScrollBar.AutoCalcRange;
TmpRange := Max(TmpRange, c.Top + c.Height);
end;
end;
//DebugLn(['AutoCalcVRange ',DbgSName(FControl),' Bounds=',dbgs(FControl.BoundsRect),' Client=',dbgs(FControl.ClientRect),' TmpRange=',TmpRange,' pref=',PreferredWidth,'x',PreferredHeight]);
//DebugLn(['AutoCalcVRange ',DbgSName(FControl),' AutoSize=',FControl.AutoSize,' Bounds=',dbgs(FControl.BoundsRect),' Client=',dbgs(FControl.ClientRect),' TmpRange=',TmpRange,' pref=',PreferredWidth,'x',PreferredHeight]);
InternalSetRange(TmpRange);
end;
@ -273,7 +272,8 @@ procedure TControlScrollBar.AutoCalcRange;
PreferredWidth: Integer;
PreferredHeight: Integer;
begin
if FControl.AutoSize then
if FControl.AutoSize
or ((FControl.Parent<>nil) and (FControl.Parent.ChildSizing.Layout<>cclNone)) then
begin
GetPreferredClientRect(PreferredWidth,PreferredHeight);
TmpRange := PreferredWidth;
@ -525,6 +525,26 @@ begin
Result := GetVertSCrollbar;
end;
function TControlScrollBar.ClientSizeWithBar: integer;
begin
if Kind = sbVertical then
Result:=FControl.ClientWidth
else
Result:=FControl.ClientHeight;
if not Visible then
dec(Result,GetSize);
end;
function TControlScrollBar.ClientSizeWithoutBar: integer;
begin
if Kind = sbVertical then
Result:=FControl.ClientWidth
else
Result:=FControl.ClientHeight;
if Visible then
inc(Result,GetSize);
end;
function TControlScrollBar.GetHorzScrollBar: TControlScrollBar;
begin
if FControl is TScrollingWinControl then

View File

@ -57,9 +57,11 @@ begin
{if (FHorzScrollBar.Range>Result.Right)
or (FVertScrollBar.Range>Result.Bottom) then
DebugLn(['TScrollingWinControl.GetLogicalClientRect Client=',ClientWidth,'x',ClientHeight,' Ranges=',FHorzScrollBar.Range,'x',FVertScrollBar.Range]);}
if Assigned(FHorzScrollBar) and (FHorzScrollBar.Range > Result.Right) then
if Assigned(FHorzScrollBar) and FHorzScrollBar.Visible
and (FHorzScrollBar.Range > Result.Right) then
Result.Right := FHorzScrollBar.Range;
if Assigned(FVertScrollBar) and (FVertScrollBar.Range > Result.Bottom) then
if Assigned(FVertScrollBar) and FVertScrollBar.Visible
and (FVertScrollBar.Range > Result.Bottom) then
Result.Bottom := FVertScrollBar.Range;
end;