File: Main.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (94 lines) | stat: -rw-r--r-- 2,089 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
unit Main;

{$mode objfpc}{$H+}

interface

uses
  Classes, ExtCtrls, StdCtrls, SysUtils, FileUtil, Forms, Controls,
  Graphics, FPCanvas, Dialogs, Agg_LCL, TAGraph, TAGUIConnectorAggPas, TASeries,
  TASources, TADrawerAggPas, TADrawUtils;

type

  { TForm1 }

  TForm1 = class(TForm)
    Chart1: TChart;
    Chart1AreaSeries1: TAreaSeries;
    Chart1BarSeries1: TBarSeries;
    Chart1ConstantLine1: TConstantLine;
    Chart1LineSeries1: TLineSeries;
    Chart1PieSeries1: TPieSeries;
    cbAggPas: TCheckBox;
    ChartGUIConnectorAggPas1: TChartGUIConnectorAggPas;
    PaintBox1: TPaintBox;
    Panel1: TPanel;
    RandomChartSource1: TRandomChartSource;
    procedure cbAggPasClick(Sender: TObject);
    procedure Chart1AfterPaint(ASender: TChart);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
  private
    FAggCanvas: TAggLCLCanvas;
    FBmp: TBitmap;
  end;

var
  Form1: TForm1; 

implementation

{$R *.lfm}

uses
  TAChartUtils, TADrawerCanvas;

{ TForm1 }

procedure TForm1.cbAggPasClick(Sender: TObject);
begin
  if cbAggPas.Checked then
    Chart1.GUIConnector := ChartGUIConnectorAggPas1
  else
    Chart1.GUIConnector := nil;
end;

procedure TForm1.Chart1AfterPaint(ASender: TChart);
begin
  Unused(ASender);
  PaintBox1.Invalidate;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FBmp := TBitmap.Create;
  FAggCanvas := TAggLCLCanvas.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FAggCanvas.Free;
  FBmp.Free;
end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  d: IChartDrawer;
begin
  FAggCanvas.Width := PaintBox1.Width;
  FAggCanvas.Height := PaintBox1.Height;
  Chart1.DisableRedrawing;
  Chart1.Title.Text.Text := 'AggPas';
  d := TAggPasDrawer.Create(FAggCanvas);
  d.DoGetFontOrientation := @CanvasGetFontOrientationFunc;
  Chart1.Draw(d, PaintBox1.Canvas.ClipRect);
  Chart1.Title.Text.Text := 'Standard';
  Chart1.EnableRedrawing;
  FBmp.LoadFromIntfImage(FAggCanvas.Image.IntfImg);
  PaintBox1.Canvas.Draw(0, 0, FBmp);
end;

end.