mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-28 16:11:57 +01:00
TAChart/TChartExtentLink: Automatically sync chart sides when the axis title size changes.
git-svn-id: trunk@64917 -
This commit is contained in:
parent
f1e4528ce3
commit
9abd98a3ea
@ -12,6 +12,8 @@ type
|
||||
strict private
|
||||
FChart: TChart;
|
||||
FListener: TListener;
|
||||
FClipRectListener: TListener;
|
||||
procedure OnClipRectChanged(ASender: TObject);
|
||||
procedure OnExtentChanged(ASender: TObject);
|
||||
procedure SetChart(AValue: TChart);
|
||||
protected
|
||||
@ -51,6 +53,7 @@ type
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure AddChart(AChart: TChart);
|
||||
procedure SyncSides(AChart: TChart); virtual;
|
||||
procedure SyncWith(AChart: TChart);
|
||||
published
|
||||
property AlignMissingAxes: Boolean read FAlignMissingAxes write FAlignMissingAxes default true;
|
||||
@ -97,11 +100,13 @@ constructor TLinkedChart.Create(ACollection: TCollection);
|
||||
begin
|
||||
inherited Create(ACollection);
|
||||
FListener := TListener.Create(@FChart, @OnExtentChanged);
|
||||
FClipRectListener := TListener.Create(@FChart, @OnClipRectChanged);
|
||||
end;
|
||||
|
||||
destructor TLinkedChart.Destroy;
|
||||
begin
|
||||
FreeAndNil(FListener);
|
||||
FreeAndNil(FClipRectListener);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -112,6 +117,12 @@ begin
|
||||
Result += ' -> ' + Chart.Name;
|
||||
end;
|
||||
|
||||
procedure TLinkedChart.OnClipRectChanged(ASender: TObject);
|
||||
begin
|
||||
Unused(ASender);
|
||||
(Collection.Owner as TChartExtentLink).SyncSides(Chart);
|
||||
end;
|
||||
|
||||
procedure TLinkedChart.OnExtentChanged(ASender: TObject);
|
||||
begin
|
||||
Unused(ASender);
|
||||
@ -122,10 +133,18 @@ procedure TLinkedChart.SetChart(AValue: TChart);
|
||||
begin
|
||||
if FChart = AValue then exit;
|
||||
if Chart <> nil then
|
||||
begin
|
||||
Chart.ExtentBroadcaster.Unsubscribe(FListener);
|
||||
Chart.ClipRectBroadcaster.Unsubscribe(FClipRectListener);
|
||||
end;
|
||||
|
||||
FChart := AValue;
|
||||
|
||||
if Chart <> nil then
|
||||
begin
|
||||
Chart.ExtentBroadcaster.Subscribe(FListener);
|
||||
Chart.ClipRectBroadcaster.Subscribe(FClipRectListener);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TChartExtentLink }
|
||||
@ -215,7 +234,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
WriteLn;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -226,6 +244,12 @@ begin
|
||||
DoAlignSides;
|
||||
end;
|
||||
|
||||
procedure TChartExtentLink.SyncSides(AChart: TChart);
|
||||
begin
|
||||
Unused(AChart);
|
||||
DoAlignSides;
|
||||
end;
|
||||
|
||||
procedure TChartExtentLink.SyncWith(AChart: TChart);
|
||||
|
||||
function CombineXY(const AX, AY: TDoubleRect): TDoubleRect;
|
||||
|
||||
@ -225,6 +225,7 @@ type
|
||||
FActiveToolIndex: Integer;
|
||||
FAutoFocus: Boolean;
|
||||
FBroadcaster: TBroadcaster;
|
||||
FClipRectBroadcaster: TBroadcaster;
|
||||
FBuiltinToolset: TBasicChartToolset;
|
||||
FClipRect: TRect;
|
||||
FCurrentExtent: TDoubleRect;
|
||||
@ -384,6 +385,7 @@ type
|
||||
property ChartHeight: Integer read GetChartHeight;
|
||||
property ChartWidth: Integer read GetChartWidth;
|
||||
property ClipRect: TRect read FClipRect;
|
||||
property ClipRectBroadcaster: TBroadcaster read FClipRectBroadcaster;
|
||||
property CurrentExtent: TDoubleRect read FCurrentExtent;
|
||||
property ExtentBroadcaster: TBroadcaster read FExtentBroadcaster;
|
||||
property FullExtentBroadcaster: TBroadcaster read FFullExtentBroadcaster;
|
||||
@ -708,6 +710,7 @@ begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
FBroadcaster := TBroadcaster.Create;
|
||||
FClipRectBroadcaster := TBroadcaster.Create;
|
||||
FExtentBroadcaster := TBroadcaster.Create;
|
||||
FFullExtentBroadcaster := TBroadcaster.Create;
|
||||
FAllowZoom := true;
|
||||
@ -791,6 +794,7 @@ begin
|
||||
FreeAndNil(FMarginsExternal);
|
||||
FreeAndNil(FBuiltinToolset);
|
||||
FreeAndNil(FBroadcaster);
|
||||
FreeAndNil(FClipRectBroadcaster);
|
||||
FreeAndNil(FExtentBroadcaster);
|
||||
FreeAndNil(FFullExtentBroadcaster);
|
||||
FreeAndNil(FDefaultGUIConnector);
|
||||
@ -1014,6 +1018,8 @@ begin
|
||||
FPrevLogicalExtent := FLogicalExtent;
|
||||
end;
|
||||
|
||||
FClipRectBroadcaster.Broadcast(Self);
|
||||
|
||||
// Undo changes made by the drawer (mainly for printing). The user may print
|
||||
// something else after the chart and, for example, would not expect the font
|
||||
// to be rotated (Fix for issue #0027163) or the pen to be in xor mode.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user