mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 20:36:38 +02:00
TAChart: TDataPointDragTool: Add Origin property and OnDrag event
git-svn-id: trunk@38765 -
This commit is contained in:
parent
b3e693b304
commit
e30d3da819
@ -394,16 +394,25 @@ type
|
|||||||
property GrabRadius: Integer read FGrabRadius write FGrabRadius default 4;
|
property GrabRadius: Integer read FGrabRadius write FGrabRadius default 4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TDataPointDragTool = class;
|
||||||
|
TDataPointDragEvent = procedure (
|
||||||
|
ASender: TDataPointDragTool; var APoint: TPoint) of object;
|
||||||
|
|
||||||
{ TDataPointDragTool }
|
{ TDataPointDragTool }
|
||||||
|
|
||||||
TDataPointDragTool = class(TDataPointTool)
|
TDataPointDragTool = class(TDataPointTool)
|
||||||
|
strict private
|
||||||
|
FOnDrag: TDataPointDragEvent;
|
||||||
|
FOrigin: TPoint;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure MouseDown(APoint: TPoint); override;
|
procedure MouseDown(APoint: TPoint); override;
|
||||||
procedure MouseMove(APoint: TPoint); override;
|
procedure MouseMove(APoint: TPoint); override;
|
||||||
procedure MouseUp(APoint: TPoint); override;
|
procedure MouseUp(APoint: TPoint); override;
|
||||||
|
property Origin: TPoint read FOrigin;
|
||||||
published
|
published
|
||||||
property ActiveCursor default crSizeAll;
|
property ActiveCursor default crSizeAll;
|
||||||
|
property OnDrag: TDataPointDragEvent read FOnDrag write FOnDrag;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDataPointClickTool }
|
{ TDataPointClickTool }
|
||||||
@ -1498,14 +1507,20 @@ procedure TDataPointDragTool.MouseDown(APoint: TPoint);
|
|||||||
begin
|
begin
|
||||||
FindNearestPoint(APoint);
|
FindNearestPoint(APoint);
|
||||||
if FSeries = nil then exit;
|
if FSeries = nil then exit;
|
||||||
|
FOrigin := FChart.GraphToImage(NearestGraphPoint);
|
||||||
Activate;
|
Activate;
|
||||||
Handled;
|
Handled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataPointDragTool.MouseMove(APoint: TPoint);
|
procedure TDataPointDragTool.MouseMove(APoint: TPoint);
|
||||||
begin
|
begin
|
||||||
if FSeries <> nil then
|
if FSeries = nil then exit;
|
||||||
|
if Assigned(OnDrag) then begin
|
||||||
|
OnDrag(Self, APoint);
|
||||||
|
if Toolset.FIsHandled then exit;
|
||||||
|
end;
|
||||||
FSeries.MovePoint(FPointIndex, APoint);
|
FSeries.MovePoint(FPointIndex, APoint);
|
||||||
|
Handled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataPointDragTool.MouseUp(APoint: TPoint);
|
procedure TDataPointDragTool.MouseUp(APoint: TPoint);
|
||||||
|
Loading…
Reference in New Issue
Block a user