mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:19:22 +02:00
change formatting of controlscrollbar.inc (since nobody from devels were against)
git-svn-id: trunk@12326 -
This commit is contained in:
parent
dde8cbb08a
commit
38c4cf597b
@ -16,22 +16,29 @@
|
||||
}
|
||||
|
||||
const
|
||||
IntfBarKind: array[TScrollBarKind] of Integer = (SB_HORZ,SB_VERT);
|
||||
IntfBarKind: array[TScrollBarKind] of Integer =
|
||||
(
|
||||
SB_HORZ,
|
||||
SB_VERT
|
||||
);
|
||||
|
||||
procedure TControlScrollBar.SetPosition(const Value: Integer);
|
||||
var
|
||||
OldPosition: Integer;
|
||||
begin
|
||||
if Value < 0 then begin
|
||||
if Value < 0 then
|
||||
begin
|
||||
SetPosition(0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
If ControlAutoScroll then begin
|
||||
if ControlAutoScroll then
|
||||
begin
|
||||
if FAutoRange < 0 then
|
||||
AutoCalcRange;
|
||||
|
||||
if Value > FAutoRange then begin
|
||||
if Value > FAutoRange then
|
||||
begin
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if Kind=sbHorizontal then
|
||||
DebugLn(['TControlScrollBar.SetPosition FAutoRange Value=',Value,' > AutoRange=',FAutoRange]);
|
||||
@ -41,9 +48,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if Value>Range then begin
|
||||
if Value > Range then
|
||||
begin
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if Kind=sbHorizontal then
|
||||
if Kind = sbHorizontal then
|
||||
DebugLn(['TControlScrollBar.SetPosition Range Value=',Value,' > Range=',Range]);
|
||||
{$ENDIF}
|
||||
SetPosition(Range);
|
||||
@ -51,23 +59,24 @@ begin
|
||||
end;
|
||||
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if Kind=sbHorizontal then
|
||||
if Kind = sbHorizontal then
|
||||
DebugLn(['TControlScrollBar.SetPosition Value=',Value,' FPosition=',FPosition]);
|
||||
{$ENDIF}
|
||||
if Value=FPosition then exit;
|
||||
if Value = FPosition then
|
||||
exit;
|
||||
|
||||
// scroll content of FControl
|
||||
OldPosition:=FPosition;
|
||||
OldPosition := FPosition;
|
||||
FPosition := Value;
|
||||
if FControl is TScrollingWinControl then
|
||||
TScrollingWinControl(FControl).ScrollbarHandler(Kind, OldPosition);
|
||||
|
||||
// check that the new position is also set on the scrollbar
|
||||
if HandleAllocated
|
||||
and (GetScrollPos(ControlHandle, IntfBarKind[Kind]) <> FPosition) then begin
|
||||
if HandleAllocated and (GetScrollPos(ControlHandle, IntfBarKind[Kind]) <> FPosition) then
|
||||
begin
|
||||
InvalidateScollInfo;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if Kind=sbHorizontal then
|
||||
if Kind = sbHorizontal then
|
||||
DebugLn(['TControlScrollBar.SetPosition FPosition=',FPosition]);
|
||||
{$ENDIF}
|
||||
SetScrollPos(ControlHandle, IntfBarKind[Kind], FPosition, Visible);
|
||||
@ -76,107 +85,117 @@ end;
|
||||
|
||||
function TControlScrollBar.SmoothIsStored: boolean;
|
||||
begin
|
||||
Result:=FSmooth;
|
||||
Result := FSmooth;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetIncrement: TScrollBarInc;
|
||||
begin
|
||||
Result:=FIncrement;
|
||||
Result := FIncrement;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetPage: TScrollBarInc;
|
||||
var ScrollInfo: TScrollInfo;
|
||||
var
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then begin
|
||||
ScrollInfo.fMask:=SIF_PAGE;
|
||||
GetScrollInfo(ControlHandle,IntfBarKind[Kind],ScrollInfo);
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then
|
||||
begin
|
||||
ScrollInfo.fMask := SIF_PAGE;
|
||||
GetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo);
|
||||
InvalidateScollInfo;
|
||||
FPage:=ScrollInfo.nPage;
|
||||
FPage := ScrollInfo.nPage;
|
||||
end;
|
||||
Result:=FPage;
|
||||
Result := FPage;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetPosition: Integer;
|
||||
var ScrollInfo: TScrollInfo;
|
||||
var
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then begin
|
||||
ScrollInfo.fMask:=SIF_POS;
|
||||
GetScrollInfo(ControlHandle,IntfBarKind[Kind],ScrollInfo);
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then
|
||||
begin
|
||||
ScrollInfo.fMask := SIF_POS;
|
||||
GetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo);
|
||||
InvalidateScollInfo;
|
||||
FPosition:=ScrollInfo.nPos;
|
||||
FPosition := ScrollInfo.nPos;
|
||||
end;
|
||||
Result:=FPosition;
|
||||
Result := FPosition;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetRange: Integer;
|
||||
var ScrollInfo: TScrollInfo;
|
||||
var
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then begin
|
||||
ScrollInfo.fMask:=SIF_Range+SIF_Page;
|
||||
GetScrollInfo(ControlHandle,IntfBarKind[Kind],ScrollInfo);
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then
|
||||
begin
|
||||
ScrollInfo.fMask := SIF_Range + SIF_Page;
|
||||
GetScrollInfo(ControlHandle, IntfBarKind[Kind], ScrollInfo);
|
||||
InvalidateScollInfo;
|
||||
FRange:=ScrollInfo.nMax-ScrollInfo.nMin-integer(ScrollInfo.nPage);
|
||||
FRange := ScrollInfo.nMax - ScrollInfo.nMin - integer(ScrollInfo.nPage);
|
||||
end;
|
||||
Result:=FRange;
|
||||
Result := FRange;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetSmooth: Boolean;
|
||||
begin
|
||||
Result:=FSmooth;
|
||||
Result := FSmooth;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetVisible: Boolean;
|
||||
begin
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then begin
|
||||
if HandleAllocated and (not (FControl is TScrollingWinControl)) then
|
||||
begin
|
||||
InvalidateScollInfo;
|
||||
FVisible:=GetScrollbarVisible(Controlhandle,IntfBarKind[Kind]);
|
||||
FVisible := GetScrollbarVisible(Controlhandle, IntfBarKind[Kind]);
|
||||
end;
|
||||
Result:=FVisible;
|
||||
Result := FVisible;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetIncrement(const AValue: TScrollBarInc);
|
||||
begin
|
||||
// This value is only used by the ScrollHandler procedure
|
||||
FIncrement:=AValue;
|
||||
FIncrement := AValue;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetPage(const AValue: TScrollBarInc);
|
||||
begin
|
||||
if FPage=AValue then exit;
|
||||
FPage:=AValue;
|
||||
if FPage = AValue then exit;
|
||||
FPage := AValue;
|
||||
ControlUpdateScrollBars;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.VisibleIsStored: boolean;
|
||||
begin
|
||||
Result:=FVisible;
|
||||
Result := FVisible;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetSize: integer;
|
||||
var
|
||||
KindID: integer;
|
||||
begin
|
||||
if Kind=sbHorizontal then
|
||||
KindID:=SM_CYHSCROLL
|
||||
if Kind = sbHorizontal then
|
||||
KindID := SM_CYHSCROLL
|
||||
else
|
||||
KindID:=SM_CXVSCROLL;
|
||||
if HandleAllocated then begin
|
||||
Result:=LCLIntf.GetScrollBarSize(ControlHandle,KindID);
|
||||
KindID := SM_CXVSCROLL;
|
||||
if HandleAllocated then
|
||||
begin
|
||||
Result := LCLIntf.GetScrollBarSize(ControlHandle,KindID);
|
||||
InvalidateScollInfo;
|
||||
end else
|
||||
Result:=GetSystemMetrics(KindID);
|
||||
Result := GetSystemMetrics(KindID);
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetRange(const Value: Integer);
|
||||
begin
|
||||
If Value < 0 then begin
|
||||
if Value < 0 then
|
||||
begin
|
||||
Range := 0;
|
||||
exit;
|
||||
end;
|
||||
if FRange=Value then exit;
|
||||
if FRange = Value then
|
||||
exit;
|
||||
FRange := Value;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if Kind=sbHorizontal then
|
||||
if Kind = sbHorizontal then
|
||||
DebugLn(['TControlScrollBar.SetRange ',Self,' fRange=',FRange]);
|
||||
{$ENDIF}
|
||||
ControlUpdateScrollBars;
|
||||
@ -184,12 +203,13 @@ end;
|
||||
|
||||
procedure TControlScrollBar.SetSize(const AValue: integer);
|
||||
begin
|
||||
Raise EScrollBar.Create('[TControlScrollBar.SetPage] Size is readonly');
|
||||
raise EScrollBar.Create('[TControlScrollBar.SetPage] Size is readonly');
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.SetVisible(const Value: Boolean);
|
||||
begin
|
||||
if FVisible = Value then exit;
|
||||
if FVisible = Value then
|
||||
exit;
|
||||
FVisible := Value;
|
||||
ControlUpdateScrollBars;
|
||||
end;
|
||||
@ -204,14 +224,15 @@ procedure TControlScrollBar.AutoCalcRange;
|
||||
|
||||
procedure AutoCalcVRange;
|
||||
var
|
||||
I : Integer;
|
||||
TmpRange : Longint;
|
||||
I: Integer;
|
||||
TmpRange: Longint;
|
||||
begin
|
||||
TmpRange := 0;
|
||||
For I := 0 to FControl.ControlCount - 1 do
|
||||
With FControl.Controls[I] do
|
||||
if IsControlVisible then begin
|
||||
If (Align = alTop) or (Align = alNone) then
|
||||
if IsControlVisible then
|
||||
begin
|
||||
if (Align = alTop) or (Align = alNone) then
|
||||
TmpRange := Max(TmpRange, Top + Height);
|
||||
end;
|
||||
Range := TmpRange;
|
||||
@ -227,8 +248,10 @@ procedure TControlScrollBar.AutoCalcRange;
|
||||
for i := 0 to FControl.ControlCount - 1 do
|
||||
begin
|
||||
c := FControl.Controls[I];
|
||||
if not C.IsControlVisible then Continue;
|
||||
if (c.Align <> alLeft) and (c.Align <> alNone) then Continue;
|
||||
if not C.IsControlVisible then
|
||||
Continue;
|
||||
if (c.Align <> alLeft) and (c.Align <> alNone) then
|
||||
Continue;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
DebugLn(['AutoCalcHRange ',DbgSName(c),' Left=',c.Left]);
|
||||
{$ENDIF}
|
||||
@ -238,7 +261,8 @@ procedure TControlScrollBar.AutoCalcRange;
|
||||
end;
|
||||
|
||||
begin
|
||||
if ControlAutoScroll then begin
|
||||
if ControlAutoScroll then
|
||||
begin
|
||||
FVisible := True;
|
||||
if Kind = sbVertical then
|
||||
AutoCalcVRange
|
||||
@ -251,8 +275,8 @@ procedure TControlScrollBar.UpdateScrollBar;
|
||||
var
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
if HandleAllocated
|
||||
and (FControl is TScrollingWinControl) then begin
|
||||
if HandleAllocated and (FControl is TScrollingWinControl) then
|
||||
begin
|
||||
FillChar(ScrollInfo,SizeOf(ScrollInfo),0);
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.fMask := SIF_ALL;
|
||||
@ -261,15 +285,14 @@ begin
|
||||
ScrollInfo.nPos := FPosition;
|
||||
ScrollInfo.nPage := FPage;
|
||||
ScrollInfo.nTrackPos := FPosition;
|
||||
if (not FOldScrollInfoValid)
|
||||
or (not CompareMem(@ScrollInfo,@FOldScrollInfo,SizeOf(TScrollInfo))) then
|
||||
if (not FOldScrollInfoValid) or (not CompareMem(@ScrollInfo,@FOldScrollInfo,SizeOf(TScrollInfo))) then
|
||||
begin
|
||||
FOldScrollInfo:=ScrollInfo;
|
||||
FOldScrollInfoValid:=true;
|
||||
FOldScrollInfoValid := true;
|
||||
SetScrollInfo(FControl.Handle, IntfBarKind[Kind], ScrollInfo, FVisible);
|
||||
end;
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
if Kind=sbHorizontal then
|
||||
if Kind = sbHorizontal then
|
||||
DebugLn(['TControlScrollBar.UpdateScrollBar ',DbgSName(FControl),' ',DbgSName(Self),' FVisible=',FVisible,' Range=',FRange,' FPosition=',FPosition,' FPage=',FPage,' FAutoRange=',FAutoRange]);
|
||||
{$ENDIF}
|
||||
end;
|
||||
@ -292,16 +315,16 @@ end;
|
||||
function TControlScrollBar.ControlAutoScroll: boolean;
|
||||
begin
|
||||
if FControl is TScrollingWinControl then
|
||||
Result:=TScrollingWinControl(FControl).AutoScroll
|
||||
Result := TScrollingWinControl(FControl).AutoScroll
|
||||
else
|
||||
Result:=false;
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.ScrollHandler(var Message: TLMScroll);
|
||||
var
|
||||
NewPos: Longint;
|
||||
begin
|
||||
If (csDesigning in FControl.ComponentState) then
|
||||
if (csDesigning in FControl.ComponentState) then
|
||||
exit; //prevent wierdness in IDE.
|
||||
|
||||
NewPos := FPosition;
|
||||
@ -326,28 +349,32 @@ begin
|
||||
{$IFDEF VerboseScrollingWinControl}
|
||||
DebugLn(['TControlScrollBar.ScrollHandler Message.ScrollCode=',Message.ScrollCode,' FPosition=',FPosition,' NewPos=',NewPos,' Range=',Range]);
|
||||
{$ENDIF}
|
||||
if NewPos < 0 then NewPos := 0;
|
||||
if NewPos > Range then NewPos := Range;
|
||||
if NewPos < 0 then
|
||||
NewPos := 0;
|
||||
if NewPos > FRange then
|
||||
NewPos := FRange;
|
||||
InvalidateScollInfo;
|
||||
SetPosition(NewPos);
|
||||
end;
|
||||
|
||||
procedure TControlScrollBar.ControlUpdateScrollBars;
|
||||
begin
|
||||
if ([csLoading,csDestroying]*FControl.ComponentState<>[]) then exit;
|
||||
if not HandleAllocated then exit;
|
||||
if ([csLoading, csDestroying] * FControl.ComponentState <> []) then
|
||||
exit;
|
||||
if not HandleAllocated then
|
||||
exit;
|
||||
if FControl is TScrollingWinControl then
|
||||
TScrollingWinControl(FControl).UpdateScrollBars;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.HandleAllocated: boolean;
|
||||
begin
|
||||
Result:=(FControl<>nil) and (FControl.HandleAllocated);
|
||||
Result := (FControl<>nil) and (FControl.HandleAllocated);
|
||||
end;
|
||||
|
||||
function TControlScrollBar.ControlHandle: HWnd;
|
||||
begin
|
||||
Result:=FControl.Handle;
|
||||
Result := FControl.Handle;
|
||||
end;
|
||||
|
||||
constructor TControlScrollBar.Create(AControl: TWinControl;
|
||||
@ -366,8 +393,10 @@ end;
|
||||
|
||||
procedure TControlScrollBar.Assign(Source: TPersistent);
|
||||
begin
|
||||
If Source is TControlScrollBar then begin
|
||||
With Source as TControlScrollBar do begin
|
||||
if Source is TControlScrollBar then
|
||||
begin
|
||||
with Source as TControlScrollBar do
|
||||
begin
|
||||
Self.Increment := Increment;
|
||||
Self.Position := Position;
|
||||
Self.Range := Range;
|
||||
@ -389,29 +418,29 @@ end;
|
||||
function TControlScrollBar.ScrollPos: Integer;
|
||||
begin
|
||||
if Visible then
|
||||
Result:=Position
|
||||
Result := Position
|
||||
else
|
||||
Result:=0;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetOtherScrollBar: TControlScrollBar;
|
||||
begin
|
||||
if Kind=sbVertical then
|
||||
Result:=GetHorzScrollBar
|
||||
if Kind = sbVertical then
|
||||
Result := GetHorzScrollBar
|
||||
else
|
||||
Result:=GetVertSCrollbar;
|
||||
Result := GetVertSCrollbar;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetHorzScrollBar: TControlScrollBar;
|
||||
begin
|
||||
if FControl is TScrollingWinControl then
|
||||
Result:=TScrollingWinControl(FControl).HorzScrollBar;
|
||||
Result := TScrollingWinControl(FControl).HorzScrollBar;
|
||||
end;
|
||||
|
||||
function TControlScrollBar.GetVertScrollBar: TControlScrollBar;
|
||||
begin
|
||||
if FControl is TScrollingWinControl then
|
||||
Result:=TScrollingWinControl(FControl).VertScrollBar;
|
||||
Result := TScrollingWinControl(FControl).VertScrollBar;
|
||||
end;
|
||||
|
||||
// included by forms.pp
|
||||
|
Loading…
Reference in New Issue
Block a user