mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-05 02:59:31 +01:00
LCL: added TScrollingWinControl.ScrollInView
git-svn-id: trunk@50355 -
This commit is contained in:
parent
e2b280b59a
commit
dbb4fc55c3
@ -180,6 +180,7 @@ type
|
|||||||
procedure UpdateScrollbars;
|
procedure UpdateScrollbars;
|
||||||
class function GetControlClassDefaultSize: TSize; override;
|
class function GetControlClassDefaultSize: TSize; override;
|
||||||
procedure ScrollBy(DeltaX, DeltaY: Integer); override;
|
procedure ScrollBy(DeltaX, DeltaY: Integer); override;
|
||||||
|
procedure ScrollInView(AControl: TControl);
|
||||||
published
|
published
|
||||||
property HorzScrollBar: TControlScrollBar read FHorzScrollBar write SetHorzScrollBar;
|
property HorzScrollBar: TControlScrollBar read FHorzScrollBar write SetHorzScrollBar;
|
||||||
property VertScrollBar: TControlScrollBar read FVertScrollBar write SetVertScrollBar;
|
property VertScrollBar: TControlScrollBar read FVertScrollBar write SetVertScrollBar;
|
||||||
|
|||||||
@ -257,6 +257,32 @@ begin
|
|||||||
inherited ScrollBy(DeltaX, DeltaY);
|
inherited ScrollBy(DeltaX, DeltaY);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TScrollingWinControl.ScrollInView(AControl: TControl);
|
||||||
|
var
|
||||||
|
xRect: TRect;
|
||||||
|
begin
|
||||||
|
if AControl=nil then
|
||||||
|
Exit;
|
||||||
|
xRect := AControl.BoundsRect;
|
||||||
|
OffsetRect(xRect, -HorzScrollBar.Position, -VertScrollBar.Position);
|
||||||
|
if xRect.Left < 0 then
|
||||||
|
HorzScrollBar.Position := HorzScrollBar.Position + xRect.Left
|
||||||
|
else if xRect.Right > ClientWidth then
|
||||||
|
begin
|
||||||
|
if xRect.Right - xRect.Left > ClientWidth then
|
||||||
|
xRect.Right := xRect.Left + ClientWidth;
|
||||||
|
HorzScrollBar.Position := HorzScrollBar.Position + xRect.Right - ClientWidth;
|
||||||
|
end;
|
||||||
|
if xRect.Top < 0 then
|
||||||
|
VertScrollBar.Position := VertScrollBar.Position + xRect.Top
|
||||||
|
else if xRect.Bottom > ClientHeight then
|
||||||
|
begin
|
||||||
|
if xRect.Bottom - xRect.Top > ClientHeight then
|
||||||
|
xRect.Bottom := xRect.Top + ClientHeight;
|
||||||
|
VertScrollBar.Position := VertScrollBar.Position + xRect.Bottom - ClientHeight;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TScrollingWinControl.ScrollbarHandler(ScrollKind: TScrollBarKind;
|
procedure TScrollingWinControl.ScrollbarHandler(ScrollKind: TScrollBarKind;
|
||||||
OldPosition: Integer);
|
OldPosition: Integer);
|
||||||
begin
|
begin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user