mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 15:10:22 +02:00
TAChart: Add TChartNavScrollBar component
git-svn-id: trunk@29925 -
This commit is contained in:
parent
a4834c21fa
commit
bed86da6ba
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2422,6 +2422,7 @@ components/tachart/icons/tcalculatedchartsource.png -text svneol=unset#images/pn
|
|||||||
components/tachart/icons/tchart.png -text svneol=unset#images/png
|
components/tachart/icons/tchart.png -text svneol=unset#images/png
|
||||||
components/tachart/icons/tchartaxistransformations.png -text svneol=unset#images/png
|
components/tachart/icons/tchartaxistransformations.png -text svneol=unset#images/png
|
||||||
components/tachart/icons/tchartlegendpanel.png -text
|
components/tachart/icons/tchartlegendpanel.png -text
|
||||||
|
components/tachart/icons/tchartnavscrollbar.png -text
|
||||||
components/tachart/icons/tchartstyles.png -text svneol=unset#images/png
|
components/tachart/icons/tchartstyles.png -text svneol=unset#images/png
|
||||||
components/tachart/icons/tcharttoolset.png -text svneol=unset#images/png
|
components/tachart/icons/tcharttoolset.png -text svneol=unset#images/png
|
||||||
components/tachart/icons/tdatetimeintervalchartsource.png -text svneol=unset#images/png
|
components/tachart/icons/tdatetimeintervalchartsource.png -text svneol=unset#images/png
|
||||||
@ -2446,6 +2447,7 @@ components/tachart/tagraph.pas svneol=native#text/plain
|
|||||||
components/tachart/talegend.pas svneol=native#text/plain
|
components/tachart/talegend.pas svneol=native#text/plain
|
||||||
components/tachart/talegendpanel.pas svneol=native#text/pascal
|
components/tachart/talegendpanel.pas svneol=native#text/pascal
|
||||||
components/tachart/tamultiseries.pas svneol=native#text/pascal
|
components/tachart/tamultiseries.pas svneol=native#text/pascal
|
||||||
|
components/tachart/tanavigation.pas svneol=native#text/pascal
|
||||||
components/tachart/taprint.pas svneol=native#text/pascal
|
components/tachart/taprint.pas svneol=native#text/pascal
|
||||||
components/tachart/taradialseries.pas svneol=native#text/pascal
|
components/tachart/taradialseries.pas svneol=native#text/pascal
|
||||||
components/tachart/taseries.pas svneol=native#text/plain
|
components/tachart/taseries.pas svneol=native#text/plain
|
||||||
|
BIN
components/tachart/icons/tchartnavscrollbar.png
Normal file
BIN
components/tachart/icons/tchartnavscrollbar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 359 B |
@ -28,7 +28,7 @@
|
|||||||
for details about the copyright.
|
for details about the copyright.
|
||||||
"/>
|
"/>
|
||||||
<Version Major="1"/>
|
<Version Major="1"/>
|
||||||
<Files Count="21">
|
<Files Count="22">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="tagraph.pas"/>
|
<Filename Value="tagraph.pas"/>
|
||||||
<HasRegisterProc Value="True"/>
|
<HasRegisterProc Value="True"/>
|
||||||
@ -121,6 +121,11 @@
|
|||||||
<Filename Value="tageometry.pas"/>
|
<Filename Value="tageometry.pas"/>
|
||||||
<UnitName Value="TAGeometry"/>
|
<UnitName Value="TAGeometry"/>
|
||||||
</Item21>
|
</Item21>
|
||||||
|
<Item22>
|
||||||
|
<Filename Value="tanavigation.pas"/>
|
||||||
|
<HasRegisterProc Value="True"/>
|
||||||
|
<UnitName Value="TANavigation"/>
|
||||||
|
</Item22>
|
||||||
</Files>
|
</Files>
|
||||||
<LazDoc Paths="$(LazarusDir)\components\tachart\fpdoc"/>
|
<LazDoc Paths="$(LazarusDir)\components\tachart\fpdoc"/>
|
||||||
<Type Value="RunAndDesignTime"/>
|
<Type Value="RunAndDesignTime"/>
|
||||||
|
@ -10,7 +10,8 @@ uses
|
|||||||
TAGraph, TAChartAxis, TAChartUtils, TACustomSeries, TASources, TADbSource,
|
TAGraph, TAChartAxis, TAChartUtils, TACustomSeries, TASources, TADbSource,
|
||||||
TASeries, TASeriesEditor, TASubcomponentsEditor, TATools, TATransformations,
|
TASeries, TASeriesEditor, TASubcomponentsEditor, TATools, TATransformations,
|
||||||
TATypes, TADrawUtils, TAMultiSeries, TALegend, TAStyles, TAFuncSeries,
|
TATypes, TADrawUtils, TAMultiSeries, TALegend, TAStyles, TAFuncSeries,
|
||||||
TALegendPanel, TARadialSeries, TACustomSource, TAGeometry, LazarusPackageIntf;
|
TALegendPanel, TARadialSeries, TACustomSource, TAGeometry, TANavigation,
|
||||||
|
LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ begin
|
|||||||
RegisterUnit('TATransformations', @TATransformations.Register);
|
RegisterUnit('TATransformations', @TATransformations.Register);
|
||||||
RegisterUnit('TAStyles', @TAStyles.Register);
|
RegisterUnit('TAStyles', @TAStyles.Register);
|
||||||
RegisterUnit('TALegendPanel', @TALegendPanel.Register);
|
RegisterUnit('TALegendPanel', @TALegendPanel.Register);
|
||||||
|
RegisterUnit('TANavigation', @TANavigation.Register);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
@ -58,6 +58,23 @@ LazarusResources.Add('tchartlegendpanel','PNG',[
|
|||||||
+'p'#150'G'#244'3'#7#173'n4'#243#194#193#13#20#153#185#254#246'4'#255#18#233
|
+'p'#150'G'#244'3'#7#173'n4'#243#194#193#13#20#153#185#254#246'4'#255#18#233
|
||||||
+#13#248#238#202'A'#8#175'F'#133#0#0#0#0'IEND'#174'B`'#130
|
+#13#248#238#202'A'#8#175'F'#133#0#0#0#0'IEND'#174'B`'#130
|
||||||
]);
|
]);
|
||||||
|
LazarusResources.Add('tchartnavscrollbar','PNG',[
|
||||||
|
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#3#0#0#0#215#169#205
|
||||||
|
+#202#0#0#0'iPLTE'#0#0#0'ww'#146#239#239#237#254#254#255#0#136'j'#194#192#193
|
||||||
|
+#255'@@'#223#223#219#6#5#1'w'#177'6'#7#6#4'JJ'#255#186#188#201#8#8#6#137#137
|
||||||
|
+#137'zzz'#251#252#255#1#1#1#192#192#192#186#188#183#192#193#198#197#196#204
|
||||||
|
+#194#193#209#200#200#208#201#204#213#189#190#184#185#188#197#244#244#254#251
|
||||||
|
+#251#255#183#184#189#252#251#255#255#255#248#255#255#251#190#192#187#0#0#0
|
||||||
|
+#201#182#11'-'#0#0#0#1'tRNS'#0'@'#230#216'f'#0#0#0#172'IDATx^'#141#208#215#14
|
||||||
|
+#195'0'#8'@'#209#2#30#217#163'{'#175#255#255#200'Bb'#211#184#242'Co^P'#142
|
||||||
|
+#140','#175#254#15#164'0'#165'!'#162#157#4'('#9#176#239'"x'#141'G'#192#162
|
||||||
|
+#202'A'#9#150#203#130#20#224#157#172#162#215#227#180#0#19#160#134'3m'#158'_0'
|
||||||
|
+#198'D'#160#27#173#21#140'a'#10#171#142#151#3'E'#144#159','#206#145'w0'#236
|
||||||
|
+#175';'#5#207#137#8'4'#180#189'/oU'#215','#178'JR(K'#1''''#16#222'*'#5'7'#193
|
||||||
|
+#216'fA'#31#17'~'#210#183#2#139#136#208#12#252#205#163'4C?"'#12'"`'#139#30#1
|
||||||
|
+#185#25#186'VOT'#221#18#184'x'#130#11' '#146'K '#223#7'D'#130#10#200'('#15'3'
|
||||||
|
+'m'#0#0#0#0'IEND'#174'B`'#130
|
||||||
|
]);
|
||||||
LazarusResources.Add('tchartstyles','PNG',[
|
LazarusResources.Add('tchartstyles','PNG',[
|
||||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||||
+#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#0#25'tEXtSoftware'#0'Paint.NET v3.5'
|
+#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#0#25'tEXtSoftware'#0'Paint.NET v3.5'
|
||||||
|
@ -175,6 +175,7 @@ type
|
|||||||
FClipRect: TRect;
|
FClipRect: TRect;
|
||||||
FCurrentExtent: TDoubleRect;
|
FCurrentExtent: TDoubleRect;
|
||||||
FDrawer: IChartDrawer;
|
FDrawer: IChartDrawer;
|
||||||
|
FExtentBroadcaster: TBroadcaster;
|
||||||
FIsZoomed: Boolean;
|
FIsZoomed: Boolean;
|
||||||
FOffset: TDoublePoint; // Coordinates transformation
|
FOffset: TDoublePoint; // Coordinates transformation
|
||||||
FOnExtentChanged: TChartEvent;
|
FOnExtentChanged: TChartEvent;
|
||||||
@ -284,6 +285,7 @@ type
|
|||||||
property ChartWidth: Integer read GetChartWidth;
|
property ChartWidth: Integer read GetChartWidth;
|
||||||
property ClipRect: TRect read FClipRect;
|
property ClipRect: TRect read FClipRect;
|
||||||
property CurrentExtent: TDoubleRect read FCurrentExtent;
|
property CurrentExtent: TDoubleRect read FCurrentExtent;
|
||||||
|
property ExtentBroadcaster: TBroadcaster read FExtentBroadcaster;
|
||||||
property LogicalExtent: TDoubleRect read FLogicalExtent write SetLogicalExtent;
|
property LogicalExtent: TDoubleRect read FLogicalExtent write SetLogicalExtent;
|
||||||
property OnChartPaint: TChartPaintEvent
|
property OnChartPaint: TChartPaintEvent
|
||||||
read FOnChartPaint write SetOnChartPaint; experimental;
|
read FOnChartPaint write SetOnChartPaint; experimental;
|
||||||
@ -505,6 +507,7 @@ begin
|
|||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
|
||||||
FBroadcaster := TBroadcaster.Create;
|
FBroadcaster := TBroadcaster.Create;
|
||||||
|
FExtentBroadcaster := TBroadcaster.Create;
|
||||||
FAllowZoom := true;
|
FAllowZoom := true;
|
||||||
FAxisVisible := true;
|
FAxisVisible := true;
|
||||||
FDrawer := TCanvasDrawer.Create(Canvas);
|
FDrawer := TCanvasDrawer.Create(Canvas);
|
||||||
@ -577,6 +580,7 @@ begin
|
|||||||
FreeAndNil(FMargins);
|
FreeAndNil(FMargins);
|
||||||
FreeAndNil(FBuiltinToolset);
|
FreeAndNil(FBuiltinToolset);
|
||||||
FreeAndNil(FBroadcaster);
|
FreeAndNil(FBroadcaster);
|
||||||
|
FreeAndNil(FExtentBroadcaster);
|
||||||
|
|
||||||
DrawData.DeleteByChart(Self);
|
DrawData.DeleteByChart(Self);
|
||||||
inherited;
|
inherited;
|
||||||
@ -686,6 +690,7 @@ begin
|
|||||||
(FPrevLogicalExtent.a <> FLogicalExtent.a) or
|
(FPrevLogicalExtent.a <> FLogicalExtent.a) or
|
||||||
(FPrevLogicalExtent.b <> FLogicalExtent.b)
|
(FPrevLogicalExtent.b <> FLogicalExtent.b)
|
||||||
then begin
|
then begin
|
||||||
|
FExtentBroadcaster.Broadcast(Self);
|
||||||
if Assigned(OnExtentChanged) then
|
if Assigned(OnExtentChanged) then
|
||||||
OnExtentChanged(Self);
|
OnExtentChanged(Self);
|
||||||
FPrevLogicalExtent := FLogicalExtent;
|
FPrevLogicalExtent := FLogicalExtent;
|
||||||
|
176
components/tachart/tanavigation.pas
Normal file
176
components/tachart/tanavigation.pas
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
{
|
||||||
|
*****************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 TANavigation;
|
||||||
|
|
||||||
|
{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, StdCtrls, TAChartUtils, TAGraph;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TChartNavScrollBar }
|
||||||
|
|
||||||
|
TChartNavScrollBar = class (TCustomScrollBar)
|
||||||
|
private
|
||||||
|
FChart: TChart;
|
||||||
|
FListener: TListener;
|
||||||
|
procedure ChartExtentChanged(ASender: TObject);
|
||||||
|
procedure SetChart(AValue: TChart);
|
||||||
|
protected
|
||||||
|
procedure Scroll(
|
||||||
|
AScrollCode: TScrollCode; var AScrollPos: Integer); override;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
published
|
||||||
|
property Chart: TChart read FChart write SetChart;
|
||||||
|
published
|
||||||
|
property Align;
|
||||||
|
property Anchors;
|
||||||
|
property BidiMode;
|
||||||
|
property BorderSpacing;
|
||||||
|
property Constraints;
|
||||||
|
property DragCursor;
|
||||||
|
property DragKind;
|
||||||
|
property DragMode;
|
||||||
|
property Enabled;
|
||||||
|
property Kind;
|
||||||
|
property LargeChange;
|
||||||
|
property Max;
|
||||||
|
property Min;
|
||||||
|
property PageSize;
|
||||||
|
property ParentBidiMode;
|
||||||
|
property ParentShowHint;
|
||||||
|
property PopupMenu;
|
||||||
|
property Position;
|
||||||
|
property ShowHint;
|
||||||
|
property SmallChange;
|
||||||
|
property TabOrder;
|
||||||
|
property TabStop;
|
||||||
|
property Visible;
|
||||||
|
published
|
||||||
|
property OnChange;
|
||||||
|
property OnContextPopup;
|
||||||
|
property OnDragDrop;
|
||||||
|
property OnDragOver;
|
||||||
|
property OnEndDrag;
|
||||||
|
property OnEnter;
|
||||||
|
property OnExit;
|
||||||
|
property OnKeyDown;
|
||||||
|
property OnKeyPress;
|
||||||
|
property OnKeyUp;
|
||||||
|
property OnScroll;
|
||||||
|
property OnStartDrag;
|
||||||
|
property OnUTF8KeyPress;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
Forms, SysUtils;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
RegisterComponents(CHART_COMPONENT_IDE_PAGE, [TChartNavScrollBar]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TChartNavScrollBar }
|
||||||
|
|
||||||
|
procedure TChartNavScrollBar.ChartExtentChanged(ASender: TObject);
|
||||||
|
var
|
||||||
|
fe, le: TDoubleRect;
|
||||||
|
w: Double;
|
||||||
|
begin
|
||||||
|
if FChart = nil then exit;
|
||||||
|
fe := FChart.GetFullExtent;
|
||||||
|
le := FChart.LogicalExtent;
|
||||||
|
case Kind of
|
||||||
|
sbHorizontal: begin
|
||||||
|
w := fe.b.X - fe.a.X;
|
||||||
|
if w <= 0 then
|
||||||
|
Position := 0
|
||||||
|
else
|
||||||
|
Position := Round(WeightedAverage(Min, Max, (le.a.X - fe.a.X) / w));
|
||||||
|
end;
|
||||||
|
sbVertical: begin
|
||||||
|
w := fe.b.Y - fe.a.Y;
|
||||||
|
if w <= 0 then
|
||||||
|
Position := 0
|
||||||
|
else
|
||||||
|
Position := Round(WeightedAverage(Max, Min, (le.a.Y - fe.a.Y) / w));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TChartNavScrollBar.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FListener := TListener.Create(@FChart, @ChartExtentChanged);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TChartNavScrollBar.Destroy;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FListener);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChartNavScrollBar.Scroll(
|
||||||
|
AScrollCode: TScrollCode; var AScrollPos: Integer);
|
||||||
|
var
|
||||||
|
fe, le: TDoubleRect;
|
||||||
|
d, w: Double;
|
||||||
|
begin
|
||||||
|
inherited Scroll(AScrollCode, AScrollPos);
|
||||||
|
if FChart = nil then exit;
|
||||||
|
w := Max - Min;
|
||||||
|
if w = 0 then exit;
|
||||||
|
fe := FChart.GetFullExtent;
|
||||||
|
le := FChart.LogicalExtent;
|
||||||
|
case Kind of
|
||||||
|
sbHorizontal: begin
|
||||||
|
d := WeightedAverage(fe.a.X, fe.b.X, Position / w);
|
||||||
|
le.b.X += d - le.a.X;
|
||||||
|
le.a.X := d;
|
||||||
|
end;
|
||||||
|
sbVertical: begin
|
||||||
|
d := WeightedAverage(fe.b.Y, fe.a.Y, Position / w);
|
||||||
|
le.b.Y += d - le.a.Y;
|
||||||
|
le.a.Y := d;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
FChart.LogicalExtent := le;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChartNavScrollBar.SetChart(AValue: TChart);
|
||||||
|
begin
|
||||||
|
if FChart = AValue then exit;
|
||||||
|
|
||||||
|
if FListener.IsListening then
|
||||||
|
FChart.ExtentBroadcaster.Unsubscribe(FListener);
|
||||||
|
FChart := AValue;
|
||||||
|
if FChart <> nil then
|
||||||
|
FChart.ExtentBroadcaster.Subscribe(FListener);
|
||||||
|
ChartExtentChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user