TAChart: Improved handling of system colors by AggPas drawer.

This commit is contained in:
wp_xyz 2023-03-09 10:15:28 +01:00
parent ef093fa2b7
commit 3812d79837
4 changed files with 25 additions and 9 deletions
components/tachart

View File

@ -223,7 +223,7 @@ end;
procedure TAggPasDrawer.PrepareSimplePen(AColor: TChartColor);
begin
with FCanvas.Pen do begin
FPColor := ApplyTransparency(ChartColorToFPColor(ColorOrMono(AColor)));
FPColor := ApplyTransparency(FChartColorToFPColorFunc(ColorOrMono(AColor)));
Style := psSolid;
Mode := pmCopy;
Width := 1;
@ -277,7 +277,7 @@ end;
procedure TAggPasDrawer.SetBrushColor(AColor: TChartColor);
begin
FCanvas.Brush.FPColor :=
ApplyTransparency(ChartColorToFPColor(ColorOrMono(AColor)));
ApplyTransparency(FChartColorToFPColorFunc(ColorOrMono(AColor)));
end;
procedure TAggPasDrawer.SetBrushParams(
@ -318,7 +318,7 @@ end;
procedure TAggPasDrawer.SetPenColor(AColor: TChartColor);
begin
FCanvas.Pen.FPColor := ApplyTransparency(ChartColorToFPColor(ColorOrMono(AColor)));
FCanvas.Pen.FPColor := ApplyTransparency(FChartColorToFPColorFunc(ColorOrMono(AColor)));
end;
procedure TAggPasDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor;
@ -326,7 +326,7 @@ procedure TAggPasDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor;
begin
FCanvas.Pen.Style := AStyle;
FCanvas.Pen.Width := AWidth;
FCanvas.Pen.FPColor := ApplyTransparency(ChartColorToFPColor(ColorOrMono(AColor)));
FCanvas.Pen.FPColor := ApplyTransparency(FChartColorToFPColorFunc(ColorOrMono(AColor)));
end;
procedure TAggpasDrawer.SetPenWidth(AWidth: Integer);

View File

@ -86,12 +86,14 @@ object MainForm: TMainForm
BorderSpacing.Around = 6
Color = clMoneyGreen
object ChartPieSeries: TPieSeries
Title = 'Pie'
ZPosition = 1
Source = RandomChartSource
end
object ChartConstantLine: TConstantLine
Pen.Color = clTeal
Pen.Width = 3
Title = 'const'
end
object ChartLineSeries: TLineSeries
Title = 'Line'

View File

@ -10,6 +10,8 @@ unit Main;
{$mode objfpc}{$H+}
{.$DEFINE USE_SYSTEM_COLORS}
interface
uses
@ -53,16 +55,22 @@ implementation
uses
TAChartUtils, TADrawerCanvas;
{$IF DEFINED(LCLGtk2) or DEFINED(LCLGtk3) or DEFINED(LCLQt) or DEFINED(LCLQt5)}
const
FONT_DIR = '/usr/share/fonts/truetype/';
{$ENDIF}
{ TMainForm }
procedure TMainForm.cbAggPasClick(Sender: TObject);
begin
if cbAggPas.Checked then
Chart.GUIConnector := ChartGUIConnectorAggPas
else
begin
Chart.GUIConnector := ChartGUIConnectorAggPas;
{$IFDEF USE_SYSTEM_COLORS}
Chart.Drawer.DoChartColorToFPColor := @ChartColorSysToFPColor;
{$ENDIF}
end else
Chart.GUIConnector := nil;
end;
@ -84,6 +92,11 @@ begin
{$IF DEFINED(LCLGtk2) or DEFINED(LCLGtk3) or DEFINED(LCLQt) or DEFINED(LCLQt5)}
ChartGUIConnectorAggPas.FontDir := FONT_DIR;
{$ENDIF}
{$IFDEF USE_SYSTEM_COLORS}
Chart.Color := clForm;
Chart.BackColor := clWindow;
{$ENDIF}
end;
procedure TMainForm.FormDestroy(Sender: TObject);
@ -103,6 +116,10 @@ begin
Chart.Title.Text.Text := 'AggPas';
d := TAggPasDrawer.Create(FAggCanvas);
d.DoGetFontOrientation := @CanvasGetFontOrientationFunc;
// The next instruction is required if system colors are used
{$IFDEF USE_SYSTEM_COLORS}
d.DoChartColorToFPColor := @ChartColorSysToFPColor;
{$ENDIF}
{$IF DEFINED(LCLGtk2) or DEFINED(LCLGtk3) or DEFINED(LCLQt) or DEFINED(LCLQt5)}
(d as TAggPasDrawer).FontDir := FONT_DIR;
{$ENDIF}

View File

@ -71,9 +71,6 @@
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>