TAChart: Add TPanDragTool.EscapeCancels property

git-svn-id: trunk@38866 -
This commit is contained in:
ask 2012-09-27 15:51:04 +00:00
parent 320655321d
commit 6020e3b6da

View File

@ -302,6 +302,9 @@ type
strict private strict private
FDirections: TPanDirectionSet; FDirections: TPanDirectionSet;
FOrigin: TPoint; FOrigin: TPoint;
FPrev: TPoint;
strict protected
procedure Cancel; override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure MouseDown(APoint: TPoint); override; procedure MouseDown(APoint: TPoint); override;
@ -311,6 +314,7 @@ type
property ActiveCursor default crSizeAll; property ActiveCursor default crSizeAll;
property Directions: TPanDirectionSet property Directions: TPanDirectionSet
read FDirections write FDirections default PAN_DIRECTIONS_ALL; read FDirections write FDirections default PAN_DIRECTIONS_ALL;
property EscapeCancels;
end; end;
{ TPanClickTool } { TPanClickTool }
@ -1323,6 +1327,13 @@ end;
{ TPanDragTool } { TPanDragTool }
procedure TPanDragTool.Cancel;
begin
if not IsActive then exit;
MouseMove(FOrigin);
Deactivate;
end;
constructor TPanDragTool.Create(AOwner: TComponent); constructor TPanDragTool.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
@ -1333,6 +1344,7 @@ procedure TPanDragTool.MouseDown(APoint: TPoint);
begin begin
Activate; Activate;
FOrigin := APoint; FOrigin := APoint;
FPrev := APoint;
Handled; Handled;
end; end;
@ -1340,8 +1352,9 @@ procedure TPanDragTool.MouseMove(APoint: TPoint);
var var
d: TPoint; d: TPoint;
begin begin
d := FOrigin - APoint; if not IsActive then exit;
FOrigin := APoint; d := FPrev - APoint;
FPrev := APoint;
if not (pdLeft in Directions) then d.X := Max(d.X, 0); if not (pdLeft in Directions) then d.X := Max(d.X, 0);
if not (pdRight in Directions) then d.X := Min(d.X, 0); if not (pdRight in Directions) then d.X := Min(d.X, 0);