mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-06 07:22:34 +01:00
TAChart: Add TATools unit. Move TChartZoomDragTool there.
git-svn-id: trunk@24277 -
This commit is contained in:
parent
130b0d9d2d
commit
3dc68f371a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2143,6 +2143,7 @@ components/tachart/taseries.pas svneol=native#text/plain
|
||||
components/tachart/taserieseditor.lfm svneol=native#text/plain
|
||||
components/tachart/taserieseditor.pas svneol=native#text/plain
|
||||
components/tachart/tasources.pas svneol=native#text/pascal
|
||||
components/tachart/tatools.pas svneol=native#text/pascal
|
||||
components/tachart/tatypes.pas svneol=native#text/plain
|
||||
components/tachart/tchart.png -text svneol=unset#images/png
|
||||
components/tachart/tdbchartsource.png -text
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
for details about the copyright.
|
||||
"/>
|
||||
<Version Major="1"/>
|
||||
<Files Count="10">
|
||||
<Files Count="11">
|
||||
<Item1>
|
||||
<Filename Value="taseries.pas"/>
|
||||
<UnitName Value="TASeries"/>
|
||||
@ -65,6 +65,10 @@
|
||||
<Filename Value="tachartaxis.pas"/>
|
||||
<UnitName Value="TAChartAxis"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
<Filename Value="tatools.pas"/>
|
||||
<UnitName Value="TATools"/>
|
||||
</Item11>
|
||||
</Files>
|
||||
<LazDoc Paths="$(LazarusDir)/components/tachart/fpdoc/"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
|
||||
@ -8,7 +8,8 @@ interface
|
||||
|
||||
uses
|
||||
TASeries, TAGraph, TAChartUtils, TASeriesEditor, TATypes, TASources,
|
||||
TADbSource, TACustomSeries, TALegend, TAChartAxis, LazarusPackageIntf;
|
||||
TADbSource, TACustomSeries, TALegend, TAChartAxis, TATools,
|
||||
LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -124,17 +124,6 @@ type
|
||||
property Shift: TShiftState read FShift write FShift;
|
||||
end;
|
||||
|
||||
{ TChartZoomDragTool }
|
||||
|
||||
TChartZoomDragTool = class(TChartTool)
|
||||
private
|
||||
FSelectionRect: TRect;
|
||||
public
|
||||
procedure MouseDown(APoint: TPoint); override;
|
||||
procedure MouseMove(APoint: TPoint); override;
|
||||
procedure MouseUp(APoint: TPoint); override;
|
||||
end;
|
||||
|
||||
TChartToolEventId = (evidMouseDown, evidMouseMove, evidMouseUp);
|
||||
|
||||
{ TChartToolset }
|
||||
@ -351,6 +340,7 @@ procedure RegisterSeriesClass(ASeriesClass: TSeriesClass; const ACaption: string
|
||||
|
||||
var
|
||||
SeriesClassRegistry: TStringList;
|
||||
OnInitBuiltinTools: procedure (AToolset: TChartToolset);
|
||||
|
||||
implementation
|
||||
|
||||
@ -435,7 +425,8 @@ begin
|
||||
FMargins := TChartMargins.Create(Self);
|
||||
|
||||
FBuiltinToolset := TChartToolset.Create(Self);
|
||||
TChartZoomDragTool.Create(FBuiltinToolset.Tools).Shift := [ssLeft];
|
||||
if Assigned(OnInitBuiltinTools) then
|
||||
OnInitBuiltinTools(FBuiltinToolset);
|
||||
FActiveToolIndex := -1;
|
||||
end;
|
||||
|
||||
@ -1357,35 +1348,6 @@ begin
|
||||
Result := Tools.Items[AIndex] as TChartTool;
|
||||
end;
|
||||
|
||||
{ TChartZoomDragTool }
|
||||
|
||||
procedure TChartZoomDragTool.MouseDown(APoint: TPoint);
|
||||
begin
|
||||
Activate;
|
||||
with APoint do
|
||||
FSelectionRect := Rect(X, Y, X, Y);
|
||||
end;
|
||||
|
||||
procedure TChartZoomDragTool.MouseMove(APoint: TPoint);
|
||||
begin
|
||||
if not IsActive then exit;
|
||||
PrepareXorPen(Chart.Canvas);
|
||||
Chart.Canvas.Rectangle(FSelectionRect);
|
||||
FSelectionRect.BottomRight := APoint;
|
||||
Chart.Canvas.Rectangle(FSelectionRect);
|
||||
end;
|
||||
|
||||
procedure TChartZoomDragTool.MouseUp(APoint: TPoint);
|
||||
begin
|
||||
Unused(APoint);
|
||||
Deactivate;
|
||||
with Chart do begin
|
||||
PrepareXorPen(Canvas);
|
||||
Canvas.Rectangle(FSelectionRect);
|
||||
ZoomToRect(FSelectionRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SkipObsoleteChartProperties;
|
||||
const
|
||||
MIRRORX_NOTE = 'Obsolete, use BottomAxis.Invert instead';
|
||||
|
||||
84
components/tachart/tatools.pas
Normal file
84
components/tachart/tatools.pas
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
Authors: Alexander Klenin
|
||||
|
||||
}
|
||||
|
||||
unit TATools;
|
||||
|
||||
interface
|
||||
|
||||
{$H+}
|
||||
|
||||
uses
|
||||
Types,
|
||||
TAGraph;
|
||||
|
||||
{ TChartZoomDragTool }
|
||||
|
||||
type
|
||||
TChartZoomDragTool = class(TChartTool)
|
||||
private
|
||||
FSelectionRect: TRect;
|
||||
public
|
||||
procedure MouseDown(APoint: TPoint); override;
|
||||
procedure MouseMove(APoint: TPoint); override;
|
||||
procedure MouseUp(APoint: TPoint); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Classes, TAChartUtils;
|
||||
|
||||
procedure InitBuitlinTools(AToolset: TChartToolset);
|
||||
begin
|
||||
TChartZoomDragTool.Create((AToolset as TChartToolset).Tools).Shift := [ssLeft];
|
||||
end;
|
||||
|
||||
{ TChartZoomDragTool }
|
||||
|
||||
procedure TChartZoomDragTool.MouseDown(APoint: TPoint);
|
||||
begin
|
||||
Activate;
|
||||
with APoint do
|
||||
FSelectionRect := Rect(X, Y, X, Y);
|
||||
end;
|
||||
|
||||
procedure TChartZoomDragTool.MouseMove(APoint: TPoint);
|
||||
begin
|
||||
if not IsActive then exit;
|
||||
PrepareXorPen(Chart.Canvas);
|
||||
Chart.Canvas.Rectangle(FSelectionRect);
|
||||
FSelectionRect.BottomRight := APoint;
|
||||
Chart.Canvas.Rectangle(FSelectionRect);
|
||||
end;
|
||||
|
||||
procedure TChartZoomDragTool.MouseUp(APoint: TPoint);
|
||||
begin
|
||||
Unused(APoint);
|
||||
Deactivate;
|
||||
with Chart do begin
|
||||
PrepareXorPen(Canvas);
|
||||
Canvas.Rectangle(FSelectionRect);
|
||||
ZoomToRect(FSelectionRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
OnInitBuiltinTools := @InitBuitlinTools;
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user