TAChart: Add TATools unit. Move TChartZoomDragTool there.

git-svn-id: trunk@24277 -
This commit is contained in:
ask 2010-03-29 10:56:12 +00:00
parent 130b0d9d2d
commit 3dc68f371a
5 changed files with 95 additions and 43 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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"/>

View File

@ -8,7 +8,8 @@ interface
uses
TASeries, TAGraph, TAChartUtils, TASeriesEditor, TATypes, TASources,
TADbSource, TACustomSeries, TALegend, TAChartAxis, LazarusPackageIntf;
TADbSource, TACustomSeries, TALegend, TAChartAxis, TATools,
LazarusPackageIntf;
implementation

View File

@ -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';

View 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.