mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 04:19:47 +02:00
lcl: TControlScrollBar.Range:
- manual change of this property should set owner control AutoScroll to False - property should not be stored if owner control AutoScroll = True git-svn-id: trunk@21679 -
This commit is contained in:
parent
32e74e9789
commit
3faec5e74c
13
lcl/forms.pp
13
lcl/forms.pp
@ -97,8 +97,8 @@ type
|
||||
FOldScrollInfoValid: Boolean;
|
||||
protected
|
||||
FControl: TWinControl;
|
||||
function ControlAutoScroll: boolean; virtual;
|
||||
function ControlHandle: HWnd; virtual;
|
||||
function GetAutoScroll: boolean; virtual;
|
||||
function GetIncrement: TScrollBarInc; virtual;
|
||||
function GetPage: TScrollBarInc; virtual;
|
||||
function GetPosition: Integer; virtual;
|
||||
@ -107,16 +107,19 @@ type
|
||||
function GetSmooth: Boolean; virtual;
|
||||
function GetVisible: Boolean; virtual;
|
||||
function HandleAllocated: boolean; virtual;
|
||||
function IsRangeStored: boolean; virtual;
|
||||
procedure AutoCalcRange; virtual;
|
||||
procedure ControlUpdateScrollBars; virtual;
|
||||
procedure InternalSetRange(const AValue: Integer); virtual;
|
||||
procedure ScrollHandler(var Message: TLMScroll);
|
||||
procedure SetAutoScroll(const AValue: Boolean); virtual;
|
||||
procedure SetIncrement(const AValue: TScrollBarInc); virtual;
|
||||
procedure SetPage(const AValue: TScrollBarInc); virtual;
|
||||
procedure SetPosition(const Value: Integer); virtual;
|
||||
procedure SetRange(const Value: Integer); virtual;
|
||||
procedure SetRange(const AValue: Integer); virtual;
|
||||
procedure SetSize(const AValue: integer); virtual;
|
||||
procedure SetSmooth(const Value: Boolean); virtual;
|
||||
procedure SetVisible(const Value: Boolean); virtual;
|
||||
procedure SetSmooth(const AValue: Boolean); virtual;
|
||||
procedure SetVisible(const AValue: Boolean); virtual;
|
||||
procedure UpdateScrollBar; virtual;
|
||||
procedure InvalidateScrollInfo;
|
||||
{$ifdef VerboseScrollingWinControl}
|
||||
@ -137,7 +140,7 @@ type
|
||||
property Page: TScrollBarInc read GetPage write SetPage default 80;
|
||||
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 Range: Integer read GetRange write SetRange stored IsRangeStored default 0;
|
||||
property Visible: Boolean read GetVisible write SetVisible default True;
|
||||
end;
|
||||
|
||||
|
@ -33,7 +33,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
if ControlAutoScroll then
|
||||
if GetAutoScroll then
|
||||
begin
|
||||
if FAutoRange < 0 then
|
||||
AutoCalcRange;
|
||||
@ -182,21 +182,12 @@ begin
|
||||
Result := GetSystemMetrics(KindID);
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetRange(const Value: Integer);
|
||||
procedure TControlScrollBar.SetRange(const AValue: Integer);
|
||||
begin
|
||||
if Value < 0 then
|
||||
begin
|
||||
Range := 0;
|
||||
exit;
|
||||
end;
|
||||
if FRange = Value then
|
||||
exit;
|
||||
FRange := Value;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if DebugCondition then
|
||||
DebugLn(['TControlScrollBar.SetRange ',Self,' fRange=',FRange]);
|
||||
{$ENDIF}
|
||||
ControlUpdateScrollBars;
|
||||
if not (csLoading in FControl.ComponentState) then
|
||||
SetAutoScroll(False);
|
||||
|
||||
InternalSetRange(AValue);
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetSize(const AValue: integer);
|
||||
@ -204,18 +195,18 @@ begin
|
||||
raise EScrollBar.Create('[TControlScrollBar.SetSize] Size is readonly');
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetVisible(const Value: Boolean);
|
||||
procedure TControlScrollBar.SetVisible(const AValue: Boolean);
|
||||
begin
|
||||
if FVisible = Value then
|
||||
exit;
|
||||
FVisible := Value;
|
||||
if FVisible = AValue then
|
||||
Exit;
|
||||
FVisible := AValue;
|
||||
ControlUpdateScrollBars;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetSmooth(const Value: Boolean);
|
||||
procedure TControlScrollBar.SetSmooth(const AValue: Boolean);
|
||||
begin
|
||||
// only used by the ScrollHandler procedure
|
||||
FSmooth := Value;
|
||||
FSmooth := AValue;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.AutoCalcRange;
|
||||
@ -249,7 +240,7 @@ procedure TControlScrollBar.AutoCalcRange;
|
||||
continue;
|
||||
TmpRange := Max(TmpRange, c.Top + c.Height);
|
||||
end;
|
||||
Range := TmpRange;
|
||||
InternalSetRange(TmpRange);
|
||||
end;
|
||||
|
||||
procedure AutoCalcHRange;
|
||||
@ -273,11 +264,11 @@ procedure TControlScrollBar.AutoCalcRange;
|
||||
continue;
|
||||
TmpRange := Max(TmpRange, c.Left + c.Width);
|
||||
end;
|
||||
Range := TmpRange;
|
||||
InternalSetRange(TmpRange);
|
||||
end;
|
||||
|
||||
begin
|
||||
if ControlAutoScroll then
|
||||
if GetAutoScroll then
|
||||
begin
|
||||
FVisible := True;
|
||||
if Kind = sbVertical then
|
||||
@ -339,12 +330,12 @@ begin
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
function TControlScrollBar.ControlAutoScroll: boolean;
|
||||
function TControlScrollBar.GetAutoScroll: boolean;
|
||||
begin
|
||||
if FControl is TScrollingWinControl then
|
||||
Result := TScrollingWinControl(FControl).AutoScroll
|
||||
else
|
||||
Result := false;
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.ScrollHandler(var Message: TLMScroll);
|
||||
@ -385,21 +376,49 @@ begin
|
||||
SetPosition(NewPos);
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetAutoScroll(const AValue: Boolean);
|
||||
begin
|
||||
if FControl is TScrollingWinControl then
|
||||
TScrollingWinControl(FControl).FAutoScroll := False;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.ControlUpdateScrollBars;
|
||||
begin
|
||||
if ([csLoading, csDestroying] * FControl.ComponentState <> []) then
|
||||
exit;
|
||||
Exit;
|
||||
if not HandleAllocated then
|
||||
exit;
|
||||
Exit;
|
||||
if FControl is TScrollingWinControl then
|
||||
TScrollingWinControl(FControl).UpdateScrollBars;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.InternalSetRange(const AValue: Integer);
|
||||
var
|
||||
NewRange: Integer;
|
||||
begin
|
||||
NewRange := AValue;
|
||||
if NewRange < 0 then
|
||||
NewRange := 0;
|
||||
if FRange = NewRange then
|
||||
Exit;
|
||||
FRange := AValue;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if DebugCondition then
|
||||
DebugLn(['TControlScrollBar.SetRange ',Self,' fRange=',FRange]);
|
||||
{$ENDIF}
|
||||
ControlUpdateScrollBars;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.HandleAllocated: boolean;
|
||||
begin
|
||||
Result := (FControl <> nil) and FControl.HandleAllocated;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.IsRangeStored: boolean;
|
||||
begin
|
||||
Result := not GetAutoScroll;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.ControlHandle: HWnd;
|
||||
begin
|
||||
Result := FControl.Handle;
|
||||
|
Loading…
Reference in New Issue
Block a user