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

View File

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

View File

@ -139,7 +139,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean;
CurMax: Integer; CurMax: Integer;
OldVisible: Boolean; OldVisible: Boolean;
begin begin
OldVisible:=p_Bar.FVisible; OldVisible := p_Bar.FVisible;
if p_Bar.Kind = sbVertical then if p_Bar.Kind = sbVertical then
CurMax := ClientHeight CurMax := ClientHeight
else else
@ -157,7 +157,7 @@ function TScrollingWinControl.ComputeScrollbars: Boolean;
var var
NewPage: Integer; NewPage: Integer;
begin begin
Result := false; Result := False;
// page // page
NewPage := Max(1,Min(ClientWidth - 1, High(HorzScrollbar.FPage))); NewPage := Max(1,Min(ClientWidth - 1, High(HorzScrollbar.FPage)));
if NewPage <> HorzScrollbar.FPage then if NewPage <> HorzScrollbar.FPage then
@ -190,20 +190,9 @@ begin
FIsUpdating := True; FIsUpdating := True;
try try
if AutoScroll then if AutoScroll then
begin
ComputeScrollbars; // page, autorange, visible ComputeScrollbars; // page, autorange, visible
FVertScrollbar.UpdateScrollbar; FVertScrollbar.UpdateScrollbar;
FHorzScrollbar.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;
finally finally
FIsUpdating := False; FIsUpdating := False;
end; end;