lcl: various TControlScrollBar, TScollingWinControl fixes:

- fix scrollbar visibility when AutoScroll = False, scrollbars must appear if visible = True and range > page (with help of patch of Sven Barth, issue #0014279)
  - fix class definition (no need to handle writing of properties using stored modifier - fpc bug was fixed long ago)

git-svn-id: trunk@21501 -
This commit is contained in:
paul 2009-08-31 14:54:29 +00:00
parent 44dde07254
commit 9ce421e78e
3 changed files with 17 additions and 38 deletions

View File

@ -91,7 +91,7 @@ type
FPage: TScrollBarInc;
FPosition: Integer;
FRange: Integer;
FSmooth : Boolean;
FSmooth: Boolean;
FVisible: Boolean;
FOldScrollInfo: TScrollInfo;
FOldScrollInfoValid: Boolean;
@ -108,8 +108,6 @@ type
function GetSmooth: Boolean; virtual;
function GetVisible: Boolean; virtual;
function HandleAllocated: boolean; virtual;
function SmoothIsStored: boolean; virtual;
function VisibleIsStored: boolean; virtual;
procedure AutoCalcRange; virtual;
procedure ControlUpdateScrollBars; virtual;
procedure ScrollHandler(var Message: TLMScroll);
@ -134,17 +132,16 @@ type
function ScrollPos: Integer; virtual;
property Kind: TScrollBarKind read FKind;
function GetOtherScrollBar: TControlScrollBar;
property Size: integer read GetSize write SetSize stored false;
property Size: integer read GetSize write SetSize stored False;
published
property Increment: TScrollBarInc read GetIncrement write SetIncrement default 8;
property Page: TScrollBarInc read GetPage write SetPage default 80;
property Smooth : Boolean read GetSmooth write SetSmooth stored SmoothIsStored;
property Smooth: Boolean read GetSmooth write SetSmooth default False;
property Position: Integer read GetPosition write SetPosition default 0;
property Range: Integer read GetRange write SetRange default 0;
property Visible: Boolean read GetVisible write SetVisible stored VisibleIsStored;
property Visible: Boolean read GetVisible write SetVisible default True;
end;
{ TScrollingWinControl }
TScrollingWinControl = class(TCustomControl)

View File

@ -91,11 +91,6 @@ begin
end;
end;
function TControlScrollBar.SmoothIsStored: boolean;
begin
Result := FSmooth;
end;
function TControlScrollBar.GetIncrement: TScrollBarInc;
begin
Result := FIncrement;
@ -171,11 +166,6 @@ begin
ControlUpdateScrollBars;
end;
function TControlScrollBar.VisibleIsStored: boolean;
begin
Result := FVisible;
end;
function TControlScrollBar.GetSize: integer;
var
KindID: integer;
@ -211,7 +201,7 @@ end;
procedure TControlScrollBar.SetSize(const AValue: integer);
begin
raise EScrollBar.Create('[TControlScrollBar.SetPage] Size is readonly');
raise EScrollBar.Create('[TControlScrollBar.SetSize] Size is readonly');
end;
procedure TControlScrollBar.SetVisible(const Value: Boolean);
@ -300,6 +290,7 @@ end;
procedure TControlScrollBar.UpdateScrollBar;
var
ScrollInfo: TScrollInfo;
NewVisible: Boolean;
begin
if HandleAllocated and (FControl is TScrollingWinControl) then
begin
@ -317,10 +308,11 @@ begin
FOldScrollInfoValid := True;
SetScrollInfo(FControl.Handle, IntfBarKind[Kind], ScrollInfo, FVisible);
end;
if FOldHandleVisible <> FVisible then
NewVisible := Visible and (ScrollInfo.nMax - ScrollInfo.nPage > 0);
if FOldHandleVisible <> NewVisible then
begin
FOldHandleVisible := FVisible;
ShowScrollBar(FControl.Handle, IntfBarKind[Kind], FVisible);
FOldHandleVisible := NewVisible;
ShowScrollBar(FControl.Handle, IntfBarKind[Kind], NewVisible);
end;
{$IFDEF VerboseScrollingWinControl}
if DebugCondition then
@ -427,8 +419,9 @@ begin
FIncrement := 8;
FPosition := 0;
FRange := 0;
FSmooth := false;
FVisible := false;
FSmooth := False;
FVisible := True;
FOldHandleVisible := True;
end;
procedure TControlScrollBar.Assign(Source: TPersistent);

View File

@ -139,7 +139,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean;
CurMax: Integer;
OldVisible: Boolean;
begin
OldVisible:=p_Bar.FVisible;
OldVisible := p_Bar.FVisible;
if p_Bar.Kind = sbVertical then
CurMax := ClientHeight
else
@ -157,7 +157,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean;
var
NewPage: Integer;
begin
Result := false;
Result := False;
// page
NewPage := Max(1,Min(ClientWidth - 1, High(HorzScrollbar.FPage)));
if NewPage <> HorzScrollbar.FPage then
@ -190,20 +190,9 @@ begin
FIsUpdating := True;
try
if AutoScroll then
begin
ComputeScrollbars; // page, autorange, visible
FVertScrollbar.UpdateScrollbar;
FHorzScrollbar.UpdateScrollbar;
end
else
begin
// If AutoScroll is false, then the scrollbars are always invisible
if HandleAllocated then
begin
ShowScrollBar(Handle, SB_HORZ, False);
ShowScrollBar(Handle, SB_VERT, False);
end;
end;
FVertScrollbar.UpdateScrollbar;
FHorzScrollbar.UpdateScrollbar;
finally
FIsUpdating := False;
end;