TAChart: Add printing demo

git-svn-id: trunk@29684 -
This commit is contained in:
ask 2011-02-27 09:47:20 +00:00
parent e2d662475a
commit 8e9c8ec810
5 changed files with 275 additions and 0 deletions

4
.gitattributes vendored
View File

@ -2377,6 +2377,10 @@ components/tachart/demo/multi/Main.lfm svneol=native#text/plain
components/tachart/demo/multi/Main.pas svneol=native#text/pascal
components/tachart/demo/multi/multidemo.lpi svneol=native#text/plain
components/tachart/demo/multi/multidemo.lpr svneol=native#text/pascal
components/tachart/demo/print/Main.lfm svneol=native#text/plain
components/tachart/demo/print/Main.pas svneol=native#text/pascal
components/tachart/demo/print/printdemo.lpi svneol=native#text/plain
components/tachart/demo/print/printdemo.lpr svneol=native#text/pascal
components/tachart/demo/radial/main.lfm svneol=native#text/plain
components/tachart/demo/radial/main.pas svneol=native#text/pascal
components/tachart/demo/radial/radialdemo.lpi svneol=native#text/plain

View File

@ -0,0 +1,80 @@
object Form1: TForm1
Left = 368
Height = 310
Top = 269
Width = 398
Caption = 'Form1'
ClientHeight = 310
ClientWidth = 398
LCLVersion = '0.9.31'
object Chart1: TChart
Left = 0
Height = 272
Top = 0
Width = 398
AxisList = <
item
Marks.LabelFont.Height = -13
Marks.Frame.Style = psSolid
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
Marks.LabelFont.Height = -13
end>
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'TAChart'
)
Align = alClient
ParentColor = False
object Chart1LineSeries1: TLineSeries
Source = RandomChartSource1
end
end
object Panel1: TPanel
Left = 0
Height = 38
Top = 272
Width = 398
Align = alBottom
ClientHeight = 38
ClientWidth = 398
TabOrder = 1
object Print: TButton
Left = 8
Height = 25
Top = 6
Width = 75
Caption = 'Print'
OnClick = PrintClick
TabOrder = 0
end
object PrintCanvas: TButton
Left = 96
Height = 25
Top = 6
Width = 115
Caption = 'Print via Canvas'
OnClick = PrintClick
TabOrder = 1
end
end
object RandomChartSource1: TRandomChartSource
PointsNumber = 12
RandSeed = 1730411800
XMax = 5
XMin = -5
YMax = 5
YMin = -5
left = 171
top = 140
end
object PrintDialog1: TPrintDialog
left = 244
top = 56
end
end

View File

@ -0,0 +1,65 @@
unit Main;
{$mode objfpc}{$H+}
interface
uses
Classes, ExtCtrls, PrintersDlgs, StdCtrls, SysUtils, FileUtil, Forms,
Controls, Graphics, Dialogs, TAGraph, TASeries, TASources;
type
{ TForm1 }
TForm1 = class(TForm)
Chart1: TChart;
Chart1LineSeries1: TLineSeries;
Panel1: TPanel;
Print: TButton;
PrintCanvas: TButton;
PrintDialog1: TPrintDialog;
RandomChartSource1: TRandomChartSource;
procedure PrintClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
uses
OSPrinters, TAPrint, Printers;
{$R *.lfm}
{ TForm1 }
procedure TForm1.PrintClick(Sender: TObject);
const
MARGIN = 10;
var
r: TRect;
d: Integer;
begin
if not PrintDialog1.Execute then exit;
Printer.BeginDoc;
try
r := Rect(0, 0, Printer.PageWidth, Printer.PageHeight div 2);
d := r.Right - r.Left;
r.Left += d div MARGIN;
r.Right -= d div MARGIN;
d := r.Bottom - r.Top;
r.Top += d div MARGIN;
r.Bottom -= d div MARGIN;
if Sender = PrintCanvas then
Chart1.PaintOnCanvas(Printer.Canvas, r)
else
Chart1.Draw(TPrinterDrawer.Create(Printer), r);
finally
Printer.EndDoc;
end;
end;
end.

View File

@ -0,0 +1,106 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="4">
<Item1>
<PackageName Value="LCLBase"/>
<MinVersion Major="1" Release="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="Printer4Lazarus"/>
<MinVersion Minor="5" Valid="True"/>
</Item2>
<Item3>
<PackageName Value="TAChartLazarusPkg"/>
<MinVersion Major="1" Valid="True"/>
</Item3>
<Item4>
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="printdemo.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="printdemo"/>
</Unit0>
<Unit1>
<Filename Value="Main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Main"/>
</Unit1>
<Unit2>
<Filename Value="..\..\taprint.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="TAPrint"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="10"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="printdemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,20 @@
program printdemo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, printer4lazarus, tachartlazaruspkg, Main, taprint
{ you can add units after this };
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.