synedit: fixed SetTopLine ScrollWindowEx delta, bug #8479

git-svn-id: trunk@14321 -
This commit is contained in:
mattias 2008-02-29 17:23:01 +00:00
parent ab2ebe4ec9
commit 3339383d3f
2 changed files with 16 additions and 6 deletions

View File

@ -26,10 +26,10 @@
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="CodeTools"/>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
<PackageName Value="CodeTools"/>
</Item2>
</RequiredPackages>
<Units Count="2">

View File

@ -5602,6 +5602,9 @@ end;
procedure TCustomSynEdit.SetTopLine(Value: Integer);
var
Delta: Integer;
{$ifdef SYN_LAZARUS}
OldTopLine: LongInt;
{$ENDIF}
begin
// don't use MinMax here, it will fail in design mode (Lines.Count is zero,
// but the painting code relies on TopLine >= 1)
@ -5611,13 +5614,12 @@ begin
Value := Min(Value, Lines.Count + 1 - fLinesInWindow);
Value := Max(Value, 1);
if Value <> TopLine then begin
Delta := TopLine - Value;
{$ifdef SYN_LAZARUS}
OldTopLine:=TopLine;
fTopLine := Value;
UpdateScrollBars;
Delta := TopLine - OldTopLine;
if Abs(Delta) < fLinesInWindow then
{$ifndef SYN_LAZARUS}
ScrollWindow(Handle, 0, fTextHeight * Delta, nil, nil);
{$else}
begin
// TODO: SW_SMOOTHSCROLL --> can't get it work
if not ScrollWindowEx(Handle, 0, fTextHeight * Delta, nil, nil, 0, nil,
@ -5627,6 +5629,14 @@ begin
Invalidate;
end;
end
{$else}
Delta := TopLine - Value;
fTopLine := Value;
UpdateScrollBars;
if Abs(Delta) < fLinesInWindow then
begin
ScrollWindow(Handle, 0, fTextHeight * Delta, nil, nil);
end
{$endif}
else
Invalidate;