mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 00:40:18 +02:00
LazReport, added TlrCodeReport component and sample, it makes reports at runtime with an easy to use api and it doesn't need the report designer, with small changes, from Julio Jimenez Borreguero
git-svn-id: trunk@37314 -
This commit is contained in:
parent
734def7277
commit
42eb73c8a5
12
.gitattributes
vendored
12
.gitattributes
vendored
@ -1625,6 +1625,18 @@ components/lazreport/source/addons/addfunction/lrAddFunctionLibrary.pas svneol=n
|
||||
components/lazreport/source/addons/addfunction/lr_add_function.lpk svneol=native#text/plain
|
||||
components/lazreport/source/addons/addfunction/lr_add_function.pas svneol=native#text/pascal
|
||||
components/lazreport/source/addons/addfunction/lr_add_function_const.pas svneol=native#text/pascal
|
||||
components/lazreport/source/addons/lrcodereport/lr_codereport.lrs svneol=native#text/plain
|
||||
components/lazreport/source/addons/lrcodereport/lr_codereport.pas svneol=native#text/pascal
|
||||
components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.lpk svneol=native#text/plain
|
||||
components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.pas svneol=native#text/pascal
|
||||
components/lazreport/source/addons/lrcodereport/sample/main.lfm svneol=native#text/plain
|
||||
components/lazreport/source/addons/lrcodereport/sample/main.pas svneol=native#text/pascal
|
||||
components/lazreport/source/addons/lrcodereport/sample/testlrcodereport.ico -text
|
||||
components/lazreport/source/addons/lrcodereport/sample/testlrcodereport.lpi svneol=native#text/plain
|
||||
components/lazreport/source/addons/lrcodereport/sample/testlrcodereport.lpr svneol=native#text/pascal
|
||||
components/lazreport/source/addons/lrcodereport/sample/testlrcodereport.lps svneol=native#text/xml
|
||||
components/lazreport/source/addons/lrcodereport/sample/testlrcodereport.res -text
|
||||
components/lazreport/source/addons/lrcodereport/tlrcodereport.png -text
|
||||
components/lazreport/source/addons/pdfexport/lazreportpdfexport.lpk svneol=native#text/plain
|
||||
components/lazreport/source/addons/pdfexport/lazreportpdfexport.pas svneol=native#text/plain
|
||||
components/lazreport/source/addons/pdfexport/lr_e_pdf.pas svneol=native#text/plain
|
||||
|
@ -0,0 +1,22 @@
|
||||
LazarusResources.Add('tlrcodereport','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
|
||||
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147
|
||||
+#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#220#5#17#19
|
||||
+#2#19'!'#133#247#11#0#0#1#136'IDATH'#199#221'U1k'#194'`'#16'}'#9'N'#197'E'
|
||||
+#167'"8'#20'3'#137' '#168'T'#2']#'#14'bG'#23#145'RHJ7'#23#193#138#147#160'E'
|
||||
+#220#11#173'HK'#23'G'#17#28'B'#226#230' '#14'*'#221'E'#128#187'8y'#29'bClM'
|
||||
+#19'5K'#251#224#131#11#247'%'#239'{'#247#189#187#0''#29#140#241'A'#18'E:'
|
||||
+#245#131'/'#205'&c'#154#148'D'#145'l'#163#213'"'#242'x'#180#24' ""I'#20'i4'
|
||||
+#28#238#28#210#181#143'('#153'HX'#158#244'm0'#192#249'z'#13#16'a'#3#128'5'
|
||||
+#217#183#151'@V'#20#235'ZD'#163#192'd'#2't'#187'`y'#222't'#219#209#10'bD'#184
|
||||
+'u'#187#177#201#229#240#202'q'#168':'#174#192#128#234'/9'#215#225#190'31'#9
|
||||
+#145'}'#130#179'xI'#143'W'#163#154'^2YQ'#144#20#4'-VU<D"'#216'0'#12#234#227
|
||||
+#241'i'#10#140'%'#211'c'#191#31#143#141#6#192#178'@6{'#26#193#142#130'm|'#229
|
||||
+#245'"'#151'N'#3#0#222#3#1#148#15'!X'#141'j'#214#10#12'('#31'z'#201'f65*'#184
|
||||
+'\.q3'#155'iM'#199'q'#168'L'#167#206#216'T'#207#133#195'@'#167#3#176',*'#249
|
||||
+#188#243#10#158#230's<'#23#139' '#0#247#139#5'.'#156'j4='#215#235#161'^'#218
|
||||
+#218#185#221'v'#176#209#190#144'Ji'#203#2'G'#207'"YU'#145#20#4'M'#17#195#28
|
||||
+#214#201#182'fQ('#4#185'P'#0#250'} '#24#180#175#224'N'#146'lU('#236#243#225
|
||||
+':'#147#1#0'tc1|'#152#188#247'cr}'#255'#'#29#131'8'#207'3'#248'7'#248#4#141
|
||||
+','#188'xX'#199#141#161#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
@ -0,0 +1,798 @@
|
||||
{ LR_CodeReport
|
||||
|
||||
Copyright (C) 2012 Julio Jiménez Borreguero
|
||||
Contact: jujibo at gmail dot com
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the same terms as the Lazarus Component Library (LCL)
|
||||
|
||||
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.
|
||||
|
||||
}
|
||||
|
||||
unit LR_CodeReport;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Graphics, LR_Const, LR_Class, ExtCtrls, LR_Shape,
|
||||
LR_BarC, Barcode, Printers;
|
||||
|
||||
type
|
||||
|
||||
TlrPageMargin = record
|
||||
Left, Right, Top, Bottom: double;
|
||||
end;
|
||||
|
||||
TlrCursor = record
|
||||
XTop, YTop, XBottom, YBottom: double;
|
||||
Left, Top: double
|
||||
end;
|
||||
|
||||
TlrLineStyle = record
|
||||
LColor: TColor;
|
||||
LStyle: TfrFrameStyle;
|
||||
LWidth: double;
|
||||
end;
|
||||
|
||||
TlrTextRectStyle = record
|
||||
FontName: string;
|
||||
FontColor: TColor;
|
||||
FontSize: integer;
|
||||
FontStyle: TFontStyles;
|
||||
Angle: integer;
|
||||
FillColor: TColor;
|
||||
Line: TlrLineStyle;
|
||||
BorderLines: TfrFrameBorders; // border lines
|
||||
Alignment: TAlignment;
|
||||
Layout: TTextLayout;
|
||||
Autosize, Stretched, WordBreak, WordWrap: boolean
|
||||
end;
|
||||
|
||||
TlrShapeStyle = record
|
||||
FillColor: TColor;
|
||||
FrameColor: TColor;
|
||||
FrameWith: double;
|
||||
FrameStyle: TfrFrameStyle;
|
||||
ShapeType: TfrShapeType;
|
||||
end;
|
||||
|
||||
TlrBarCodeStyle = record
|
||||
CheckSum: boolean;
|
||||
ShowCode: boolean;
|
||||
BarType: TBarcodeType;
|
||||
Zoom: double;
|
||||
Angle: double;
|
||||
FrameColor: TColor;
|
||||
BorderLines: TfrFrameBorders;
|
||||
FrameWidth: double;
|
||||
CodeFormat: string;
|
||||
end;
|
||||
|
||||
{ TlrCodeReport }
|
||||
|
||||
TlrCodeReport = class(TComponent)
|
||||
private
|
||||
ActivePage: integer;
|
||||
XRatio, YRatio: double;
|
||||
PaperSize, PaperWidth, PaperHeight: integer;
|
||||
PaperOrientation: TPrinterOrientation;
|
||||
//PaperSize: TPaperSize
|
||||
FReport, FOwnedReport: TfrReport;
|
||||
ABitMap: TBitMap;
|
||||
SavedLineStyle: TlrLineStyle;
|
||||
SavedTextRectStyle: TlrTextRectStyle;
|
||||
SavedFrameStyle: TlrTextRectStyle;
|
||||
SavedShapeStyle: TlrShapeStyle;
|
||||
SavedBarCodeStyle: TlrBarCodeStyle;
|
||||
FOnBeginReport: TNotifyEvent;
|
||||
|
||||
|
||||
function GetReport: TfrReport;
|
||||
procedure SetReport(AValue: TfrReport);
|
||||
function TextWidth(AText: string): double;
|
||||
function TextHeight: double;
|
||||
|
||||
public
|
||||
PageMargin: TlrPageMargin;
|
||||
Cursor: TlrCursor;
|
||||
LineStyle: TlrLineStyle;
|
||||
TextRectStyle: TlrTextRectStyle;
|
||||
FrameStyle: TlrTextRectStyle;
|
||||
ShapeStyle: TlrShapeStyle;
|
||||
BarCodeStyle: TlrBarCodeStyle;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure SetPaper(ASize: integer; AOr: TPrinterOrientation = poPortrait;
|
||||
AWidth: integer = 0; AHeight: integer = 0);
|
||||
procedure SetRatio(X, Y: double);
|
||||
procedure RunReport;
|
||||
procedure NewLine(i: word = 1);
|
||||
procedure NewPage;
|
||||
procedure SetActivePage(APage: integer);
|
||||
procedure EnableMillimeters; // set units (x, y, w, h..) in millimeters
|
||||
function GetTextHeight: double;
|
||||
function GetTextWidth(AText: string): double;
|
||||
function GetPageWidth: integer; // returning value in enabled units
|
||||
function GetPageHeight: integer;
|
||||
function GetPageWidthMM: double;
|
||||
function GetPageHeightMM: double;
|
||||
function GetActivePage: integer;
|
||||
|
||||
|
||||
{* Styles *}
|
||||
procedure ResetLineStyle;
|
||||
procedure ResetTextRectStyle;
|
||||
procedure ResetFrameStyle;
|
||||
procedure ResetShapeStyle;
|
||||
procedure ResetBarCodeStyle;
|
||||
procedure SaveTextRectStyle;
|
||||
procedure SaveLineStyle;
|
||||
procedure SaveFrameStyle;
|
||||
procedure SaveShapeStyle;
|
||||
procedure SaveBarCodeStyle;
|
||||
procedure RestoreTextRectStyle;
|
||||
procedure RestoreLineStyle;
|
||||
procedure RestoreFrameStyle;
|
||||
procedure RestoreShapeStyle;
|
||||
procedure RestoreBarCodeStyle;
|
||||
function GetDefaultTextRectStyle: TlrTextRectStyle;
|
||||
function GetDefaultLineStyle: TlrLineStyle;
|
||||
function GetDefaultFrameStyle: TlrTextRectStyle;
|
||||
function GetDefaultShapeStyle: TlrShapeStyle;
|
||||
function GetDefaultBarCodeStyle: TlrBarCodeStyle;
|
||||
|
||||
function PageCount: integer;
|
||||
|
||||
{* Drawing lines and frames*}
|
||||
procedure DrawLine(X, Y, W, H: double; const Style: TlrLineStyle);
|
||||
procedure DrawHLine(X, Y, W: double);
|
||||
procedure DrawVLine(X, Y, H: double);
|
||||
procedure DrawFrame(X, Y, W, H: double; Style: TlrTextRectStyle);
|
||||
procedure DrawFrame(X, Y, W, H: double);
|
||||
|
||||
{* Drawing text *}
|
||||
procedure DrawText(X, Y, W, H: double; Text: string; Style: TlrTextRectStyle);
|
||||
procedure TextOut(AText: string);
|
||||
procedure TextOutLn(AText: string);
|
||||
procedure TextOutXY(X, Y: double; AText: string;
|
||||
Alignment: TAlignment = taLeftJustify);
|
||||
procedure TextOutRectXY(X, Y, W, H: double; AText: string;
|
||||
Alignment: TAlignment = taLeftJustify; Clipping: boolean = True);
|
||||
procedure TextOutXYUp(X, Y: double; AText: string;
|
||||
Alignment: TAlignment = taLeftJustify);
|
||||
|
||||
{* Drawing images *}
|
||||
procedure DrawImage(X, Y, W, H: double; AImage: TImage;
|
||||
ASharedName: string = ''; AStretched: boolean = True;
|
||||
AKeepAspect: boolean = True; ACentered: boolean = False);
|
||||
|
||||
{* Drawing shapes *}
|
||||
procedure DrawShape(X, Y, W, H: double; Style: TlrShapeStyle);
|
||||
procedure DrawRectangle(X, Y, W, H: double);
|
||||
procedure DrawRoundRectangle(X, Y, W, H: double);
|
||||
procedure DrawDiagonalDownRight(X, Y, W, H: double);
|
||||
procedure DrawDiagonalUpRight(X, Y, W, H: double);
|
||||
procedure DrawEllipse(X, Y, W, H: double);
|
||||
procedure DrawTriangle(X, Y, W, H: double);
|
||||
|
||||
{* Drawring BarCode *}
|
||||
procedure DrawBarCode(X, Y, W, H: double; Code: string; Style: TlrBarCodeStyle);
|
||||
published
|
||||
property OnBeginReport: TNotifyEvent read FOnBeginReport write FOnBeginReport;
|
||||
property Report: TfrReport read GetReport write SetReport;
|
||||
end;
|
||||
|
||||
procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
const
|
||||
DPIX = 93 / 1.022; // 91 DPI default (used by lazreport)
|
||||
DPIY = 93 / 1.015;
|
||||
|
||||
|
||||
procedure register;
|
||||
begin
|
||||
RegisterComponents('LazReport',[TLrCodeReport]);
|
||||
end;
|
||||
|
||||
{ TlrCodeReport }
|
||||
|
||||
constructor TlrCodeReport.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
SetRatio(1, 1); // pixels
|
||||
ResetLineStyle;
|
||||
ResetTextRectStyle;
|
||||
ResetFrameStyle;
|
||||
ResetShapeStyle;
|
||||
ResetBarCodeStyle;
|
||||
// Init cursor
|
||||
Cursor.XTop := 0.0;
|
||||
Cursor.YTop := 0.0;
|
||||
Cursor.XBottom := 0.0;
|
||||
Cursor.YBottom := 0.0;
|
||||
// Init margins
|
||||
PageMargin.Left := 0.0;
|
||||
PageMargin.Right := 0.0;
|
||||
PageMargin.Left := 0.0;
|
||||
PageMargin.Right := 0.0;
|
||||
PageMargin.Left := 0;
|
||||
PageMargin.Top := 0;
|
||||
ABitMap := TBitMap.Create; // for canvas stuff
|
||||
// Set default paper
|
||||
PaperSize := 9; // A4 check LR_Prntr for a list
|
||||
PaperWidth := 0;
|
||||
PaperHeight := 0;
|
||||
PaperOrientation := poPortrait;
|
||||
end;
|
||||
|
||||
destructor TlrCodeReport.Destroy;
|
||||
begin
|
||||
// TODO, free only if FReport is owned
|
||||
FOwnedReport.Free;
|
||||
ABitMap.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SetPaper(ASize: integer; AOr: TPrinterOrientation;
|
||||
AWidth: integer; AHeight: integer);
|
||||
begin
|
||||
PaperSize := ASize;
|
||||
PaperWidth := AWidth;
|
||||
PaperHeight := AHeight;
|
||||
PaperOrientation := AOr;
|
||||
// Update current page
|
||||
Report.Pages[ActivePage].ChangePaper(PaperSize, PaperWidth,
|
||||
PaperHeight, PaperOrientation);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SetRatio(X, Y: double);
|
||||
begin
|
||||
XRatio := X;
|
||||
YRatio := Y;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.RunReport;
|
||||
begin
|
||||
NewPage; // Create the first page
|
||||
if Assigned(OnBeginReport) then
|
||||
OnBeginReport(Self);
|
||||
Report.ShowReport;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.NewPage;
|
||||
begin
|
||||
Report.Pages.Add;
|
||||
ActivePage := PageCount - 1;
|
||||
// Set Page Size and orientation
|
||||
Report.Pages[ActivePage].ChangePaper(PaperSize, PaperWidth,
|
||||
PaperHeight, PaperOrientation);
|
||||
// Set initial cursor position
|
||||
Cursor.XTop := PageMargin.Left;
|
||||
Cursor.XBottom := PageMargin.Left;
|
||||
Cursor.YTop := PageMargin.Top;
|
||||
Cursor.YBottom := PageMargin.Top;
|
||||
Cursor.Top := 0;
|
||||
Cursor.Left := 0;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SetActivePage(APage: integer);
|
||||
begin
|
||||
if APage in [1 .. PageCount] then
|
||||
ActivePage := APage - 1
|
||||
else
|
||||
raise Exception.CreateFmt(sErrorOccured, [self.ClassName]);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.EnableMillimeters;
|
||||
begin
|
||||
// Set X and Y axes ratio
|
||||
XRatio := Report.Pages[ActivePage].PrnInfo.Pgw / GetPageWidthMM;
|
||||
YRatio := Report.Pages[ActivePage].PrnInfo.Pgh / GetPageHeightMM;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetTextHeight: double;
|
||||
begin
|
||||
Result := round(TextHeight / XRatio);
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetTextWidth(AText: string): double;
|
||||
begin
|
||||
Result := round(TextWidth(AText) / XRatio);
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetPageWidth: integer;
|
||||
begin
|
||||
Result := round(Report.Pages[ActivePage].PrnInfo.Pgw / XRatio);
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetPageHeight: integer;
|
||||
begin
|
||||
Result := round(Report.Pages[ActivePage].PrnInfo.PgH / YRatio);
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetPageWidthMM: double;
|
||||
begin
|
||||
Result := Report.Pages[ActivePage].PrnInfo.Pgw / DPIX * 25.4; // inches to mm
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetPageHeightMM: double;
|
||||
begin
|
||||
Result := Report.Pages[ActivePage].PrnInfo.PgH / DPIY * 25.4; // inches to mm
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetActivePage: integer;
|
||||
begin
|
||||
Result := ActivePage + 1;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.ResetLineStyle;
|
||||
begin
|
||||
LineStyle := GetDefaultLineStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.ResetTextRectStyle;
|
||||
begin
|
||||
TextRectStyle := GetDefaultTextRectStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.ResetFrameStyle;
|
||||
begin
|
||||
FrameStyle := GetDefaultFrameStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.ResetShapeStyle;
|
||||
begin
|
||||
ShapeStyle := GetDefaultShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.ResetBarCodeStyle;
|
||||
begin
|
||||
BarCodeStyle := GetDefaultBarCodeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SaveTextRectStyle;
|
||||
begin
|
||||
SavedTextRectStyle := TextRectStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SaveLineStyle;
|
||||
begin
|
||||
SavedLineStyle := LineStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SaveFrameStyle;
|
||||
begin
|
||||
SavedFrameStyle := FrameStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SaveShapeStyle;
|
||||
begin
|
||||
SavedShapeStyle := ShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SaveBarCodeStyle;
|
||||
begin
|
||||
SavedBarCodeStyle := BarCodeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.RestoreTextRectStyle;
|
||||
begin
|
||||
TextRectStyle := SavedTextRectStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.RestoreLineStyle;
|
||||
begin
|
||||
LineStyle := SavedLineStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.RestoreFrameStyle;
|
||||
begin
|
||||
FrameStyle := SavedFrameStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.RestoreShapeStyle;
|
||||
begin
|
||||
ShapeStyle := SavedShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.RestoreBarCodeStyle;
|
||||
begin
|
||||
BarCodeStyle := SavedBarCodeStyle;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetDefaultTextRectStyle: TlrTextRectStyle;
|
||||
var
|
||||
Textstyle: TlrTextRectStyle;
|
||||
begin
|
||||
with Textstyle do
|
||||
begin
|
||||
FontName := 'Arial';
|
||||
FontColor := clBlack;
|
||||
FontSize := 8;
|
||||
FontStyle := [];
|
||||
Angle := 0;
|
||||
FillColor := clNone;
|
||||
Line := GetDefaultLineStyle;
|
||||
BorderLines := [];
|
||||
Alignment := taLeftJustify;
|
||||
Layout := tlTop;
|
||||
Autosize := False;
|
||||
Stretched := True;
|
||||
WordBreak := False;
|
||||
WordWrap := False; // cut text
|
||||
end;
|
||||
Result := Textstyle;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetDefaultLineStyle: TlrLineStyle;
|
||||
var
|
||||
Lstyle: TlrLineStyle;
|
||||
begin
|
||||
with Lstyle do
|
||||
begin
|
||||
LWidth := 1.0;
|
||||
LColor := clBlack;
|
||||
LStyle := frsSolid;
|
||||
end;
|
||||
Result := Lstyle;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetDefaultFrameStyle: TlrTextRectStyle;
|
||||
var
|
||||
AFramestyle: TlrTextRectStyle;
|
||||
begin
|
||||
AFramestyle := GetDefaultTextRectStyle;
|
||||
AFramestyle.BorderLines := [frbLeft, frbTop, frbRight, frbBottom];
|
||||
Result := AFramestyle;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetDefaultShapeStyle: TlrShapeStyle;
|
||||
begin
|
||||
with Result do
|
||||
begin
|
||||
FillColor := clNone;
|
||||
FrameColor := clBlack;
|
||||
FrameWith := 1;
|
||||
FrameStyle := frsSolid;
|
||||
ShapeType := frstRectangle;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetDefaultBarCodeStyle: TlrBarCodeStyle;
|
||||
begin
|
||||
Result.CheckSum := True;
|
||||
Result.ShowCode := True;
|
||||
Result.BarType := bcCode39;
|
||||
Result.Zoom := 1.0;
|
||||
Result.Angle := 0;
|
||||
Result.FrameColor := clBlack;
|
||||
Result.BorderLines := [];
|
||||
Result.FrameWidth := 1;
|
||||
Result.CodeFormat := 'BARCODE';
|
||||
end;
|
||||
|
||||
function TlrCodeReport.PageCount: integer;
|
||||
begin
|
||||
Result := Report.Pages.Count;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.TextWidth(AText: string): double;
|
||||
begin
|
||||
ABitMap.Canvas.Font.Name := TextRectStyle.FontName;
|
||||
ABitMap.Canvas.Font.Size := TextRectStyle.FontSize;
|
||||
ABitMap.Canvas.Font.Style := TextRectStyle.FontStyle;
|
||||
Result := ABitMap.Canvas.TextWidth(AText);
|
||||
end;
|
||||
|
||||
function TlrCodeReport.GetReport: TfrReport;
|
||||
begin
|
||||
if FReport=nil then begin
|
||||
if FOwnedReport=nil then
|
||||
FOwnedReport := TFrReport.Create(nil);
|
||||
FReport := FOwnedReport;
|
||||
end;
|
||||
|
||||
result := FReport;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.SetReport(AValue: TfrReport);
|
||||
begin
|
||||
FReport := AValue;
|
||||
end;
|
||||
|
||||
function TlrCodeReport.TextHeight: double;
|
||||
begin
|
||||
ABitMap.Canvas.Font.Name := TextRectStyle.FontName;
|
||||
ABitMap.Canvas.Font.Size := TextRectStyle.FontSize;
|
||||
ABitMap.Canvas.Font.Style := TextRectStyle.FontStyle;
|
||||
Result := ABitMap.Canvas.TextHeight(' '); // assume all glyphs have same height
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawLine(X, Y, W, H: double; const Style: TlrLineStyle);
|
||||
var
|
||||
aLine: TfrLineView;
|
||||
begin
|
||||
aLine := TfrLineView.Create;
|
||||
aLine.CreateUniqueName;
|
||||
aLine.Left := X * XRatio;
|
||||
aLine.Top := Y * YRatio;
|
||||
aLine.Width := W * XRatio;
|
||||
aLine.Height := H * YRatio;
|
||||
aLine.FrameColor := Style.LColor;
|
||||
aLine.FrameWidth := Style.LWidth;
|
||||
aLine.FrameStyle := Style.LStyle;
|
||||
Report.Pages[ActivePage].Objects.Add(aLine);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawHLine(X, Y, W: double);
|
||||
begin
|
||||
DrawLine(X, Y, W, 0, LineStyle);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawVLine(X, Y, H: double);
|
||||
begin
|
||||
DrawLine(X, Y, 0, H, LineStyle);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawFrame(X, Y, W, H: double; Style: TlrTextRectStyle);
|
||||
begin
|
||||
DrawText(X, Y, W, H, '', Style);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawFrame(X, Y, W, H: double);
|
||||
begin
|
||||
DrawText(X, Y, W, H, '', FrameStyle);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawText(X, Y, W, H: double; Text: string;
|
||||
Style: TlrTextRectStyle);
|
||||
var
|
||||
AText: TfrMemoview;
|
||||
ARect: TRect;
|
||||
begin
|
||||
AText := TfrMemoView.Create;
|
||||
AText.CreateUniqueName;
|
||||
AText.Left := X * XRatio;
|
||||
AText.Top := Y * YRatio;
|
||||
AText.Width := W * XRatio;
|
||||
AText.Height := H * YRatio;
|
||||
AText.Angle := Style.Angle;
|
||||
|
||||
AText.AutoSize := Style.Autosize;
|
||||
AText.Stretched := Style.Stretched;
|
||||
AText.WordWrap := Style.WordWrap;
|
||||
AText.WordBreak := Style.WordBreak;
|
||||
|
||||
AText.FrameWidth := Style.Line.LWidth;
|
||||
AText.FrameColor := Style.Line.LColor;
|
||||
AText.FrameStyle := Style.Line.LStyle;
|
||||
|
||||
AText.FillColor := Style.FillColor;
|
||||
AText.Frames := Style.BorderLines;
|
||||
|
||||
AText.Font.Name := Style.FontName;
|
||||
AText.Font.Color := Style.FontColor;
|
||||
AText.Font.Size := Style.FontSize;
|
||||
AText.Font.Style := Style.FontStyle;
|
||||
|
||||
AText.Alignment := Style.Alignment;
|
||||
|
||||
AText.Memo.Add(Text);
|
||||
AText.CalcGaps;
|
||||
ARect := AText.DRect;
|
||||
//AText.Font.Name:= Style.FontName;
|
||||
Report.Pages[ActivePage].Objects.Add(AText);
|
||||
// Update Cursor
|
||||
Cursor.YTop := AText.Top / YRatio; // adjust to ratio used
|
||||
Cursor.XTop := AText.Left / XRatio;
|
||||
Cursor.YBottom := (AText.Top + AText.Height) / YRatio; // adjust to ratio used
|
||||
Cursor.XBottom := (AText.Left + AText.Width) / XRatio;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.TextOut(AText: string);
|
||||
begin
|
||||
DrawText(Cursor.Left + PageMargin.Left, Cursor.Top + PageMargin.Top,
|
||||
TextWidth(AText), TextHeight, AText, TextRectStyle);
|
||||
Cursor.Left += TextWidth(AText) / XRatio;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.TextOutLn(AText: string);
|
||||
var
|
||||
ATop, ATextHeight: double;
|
||||
begin
|
||||
ATextHeight := TextHeight / YRatio;
|
||||
ATop := Cursor.Top + ATextHeight;
|
||||
if ATop >= (GetPageHeight - PageMargin.Bottom - (2*ATextHeight)) then
|
||||
NewPage;
|
||||
TextOut(AText);
|
||||
Cursor.Left := 0;
|
||||
Cursor.Top += ATextHeight;
|
||||
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.TextOutXY(X, Y: double; AText: string; Alignment: TAlignment);
|
||||
var
|
||||
Style: TlrTextRectStyle;
|
||||
Pos: double;
|
||||
begin
|
||||
Style := TextRectStyle;
|
||||
Style.Alignment := Alignment;
|
||||
case Alignment of
|
||||
taLeftJustify: Pos := X;
|
||||
taRightJustify:
|
||||
begin
|
||||
Pos := X - TextWidth(AText);
|
||||
end;
|
||||
taCenter:
|
||||
begin
|
||||
Pos := X - (TextWidth(AText) / 2);
|
||||
end;
|
||||
end;
|
||||
DrawText(Pos, Y, TextWidth(AText), TextHeight, AText, Style);
|
||||
Cursor.Left += TextWidth(AText) / XRatio;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.TextOutRectXY(X, Y, W, H: double; AText: string;
|
||||
Alignment: TAlignment; Clipping: boolean);
|
||||
var
|
||||
Style: TlrTextRectStyle;
|
||||
begin
|
||||
Style := TextRectStyle;
|
||||
Style.Alignment := Alignment;
|
||||
Style.WordWrap := not Clipping;
|
||||
Style.Stretched := True;
|
||||
|
||||
DrawText(X, Y, W, H, AText, Style);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.TextOutXYUp(X, Y: double; AText: string; Alignment: TAlignment);
|
||||
var
|
||||
Style: TlrTextRectStyle;
|
||||
Pos: double;
|
||||
begin
|
||||
Style := TextRectStyle;
|
||||
Style.Alignment := Alignment;
|
||||
Style.Angle := 90;
|
||||
case Alignment of
|
||||
taRightJustify: Pos := Y;
|
||||
taLeftJustify:
|
||||
begin
|
||||
Pos := Y - TextWidth(AText);
|
||||
end;
|
||||
taCenter:
|
||||
begin
|
||||
Pos := Y - (TextWidth(AText) / 2);
|
||||
end;
|
||||
end;
|
||||
DrawText(X, Pos, TextHeight, TextWidth(AText), AText, Style);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawImage(X, Y, W, H: double; AImage: TImage;
|
||||
ASharedName: string; AStretched: boolean; AKeepAspect: boolean; ACentered: boolean);
|
||||
var
|
||||
APicture: TfrPictureView;
|
||||
begin
|
||||
APicture := TfrPictureView.Create;
|
||||
APicture.CreateUniqueName;
|
||||
APicture.Left := X * XRatio;
|
||||
APicture.Top := Y * YRatio;
|
||||
APicture.Width := W * XRatio;
|
||||
APicture.Height := H * YRatio;
|
||||
APicture.SharedName := ASharedName;
|
||||
APicture.Stretched := AStretched;
|
||||
APicture.KeepAspect := AKeepAspect;
|
||||
APicture.Centered := ACentered;
|
||||
APicture.Picture.Assign(AImage.Picture);
|
||||
Report.Pages[ActivePage].Objects.Add(APicture);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawShape(X, Y, W, H: double; Style: TlrShapeStyle);
|
||||
var
|
||||
AShape: TfrShapeView;
|
||||
begin
|
||||
AShape := TfrShapeView.Create;
|
||||
AShape.CreateUniqueName;
|
||||
AShape.Left := X * XRatio;
|
||||
AShape.Top := Y * YRatio;
|
||||
AShape.Width := W * XRatio;
|
||||
AShape.Height := H * YRatio;
|
||||
AShape.FillColor := ShapeStyle.FillColor;
|
||||
AShape.FrameColor := ShapeStyle.FrameColor;
|
||||
AShape.FrameWidth := ShapeStyle.FrameWith;
|
||||
AShape.FrameStyle := ShapeStyle.FrameStyle;
|
||||
AShape.ShapeType := ShapeStyle.ShapeType;
|
||||
Report.Pages[ActivePage].Objects.Add(AShape);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawRectangle(X, Y, W, H: double);
|
||||
begin
|
||||
SaveShapeStyle;
|
||||
ShapeStyle.ShapeType := frstRectangle;
|
||||
DrawShape(X, Y, W, H, ShapeStyle);
|
||||
RestoreShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawRoundRectangle(X, Y, W, H: double);
|
||||
begin
|
||||
SaveShapeStyle;
|
||||
ShapeStyle.ShapeType := frstRoundRect;
|
||||
DrawShape(X, Y, W, H, ShapeStyle);
|
||||
RestoreShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawDiagonalDownRight(X, Y, W, H: double);
|
||||
begin
|
||||
SaveShapeStyle;
|
||||
ShapeStyle.ShapeType := frstDiagonal1;
|
||||
DrawShape(X, Y, W, H, ShapeStyle);
|
||||
RestoreShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawDiagonalUpRight(X, Y, W, H: double);
|
||||
begin
|
||||
SaveShapeStyle;
|
||||
ShapeStyle.ShapeType := frstDiagonal2;
|
||||
DrawShape(X, Y, W, H, ShapeStyle);
|
||||
RestoreShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawEllipse(X, Y, W, H: double);
|
||||
begin
|
||||
SaveShapeStyle;
|
||||
ShapeStyle.ShapeType := frstEllipse;
|
||||
DrawShape(X, Y, W, H, ShapeStyle);
|
||||
RestoreShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawTriangle(X, Y, W, H: double);
|
||||
begin
|
||||
SaveShapeStyle;
|
||||
ShapeStyle.ShapeType := frstTriangle;
|
||||
DrawShape(X, Y, W, H, ShapeStyle);
|
||||
RestoreShapeStyle;
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.DrawBarCode(X, Y, W, H: double; Code: string;
|
||||
Style: TlrBarCodeStyle);
|
||||
var
|
||||
ABarCode: TfrBarCodeView;
|
||||
begin
|
||||
ABarCode := TfrBarCodeView.Create;
|
||||
ABarCode.CreateUniqueName;
|
||||
ABarCode.Left := X * XRatio;
|
||||
ABarCode.Top := Y * YRatio;
|
||||
ABarCode.Width := W * XRatio;
|
||||
ABarCode.Height := H * YRatio;
|
||||
// Bar code
|
||||
ABarCode.Memo.Text := Code;
|
||||
ABarCode.CheckSum := Style.CheckSum;
|
||||
ABarCode.ShowText := Style.ShowCode;
|
||||
ABarCode.BarType := Style.BarType;
|
||||
ABarCode.Zoom := Style.Zoom;
|
||||
ABarCode.Param.cAngle := Style.Angle;
|
||||
ABarCode.FrameColor := Style.FrameColor;
|
||||
ABarCode.Frames := Style.BorderLines;
|
||||
ABarCode.FrameWidth := Style.FrameWidth;
|
||||
ABarCode.FormatStr := Style.CodeFormat;
|
||||
Report.Pages[ActivePage].Objects.Add(ABarCode);
|
||||
end;
|
||||
|
||||
procedure TlrCodeReport.NewLine(i: word);
|
||||
begin
|
||||
for i := 0 to i - 1 do
|
||||
begin
|
||||
TextOutLn('');
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$i lr_codereport.lrs}
|
||||
|
||||
end.
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<Name Value="lr_codereport_pkg"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Files Count="2">
|
||||
<Item1>
|
||||
<Filename Value="lr_codereport.lrs"/>
|
||||
<Type Value="LRS"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="lr_codereport.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="LR_CodeReport"/>
|
||||
</Item2>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="lazreport"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="FCL"/>
|
||||
</Item2>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
@ -0,0 +1,21 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit lr_codereport_pkg;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LR_CodeReport, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('LR_CodeReport', @LR_CodeReport.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('lr_codereport_pkg', @Register);
|
||||
end.
|
2921
components/lazreport/source/addons/lrcodereport/sample/main.lfm
Normal file
2921
components/lazreport/source/addons/lrcodereport/sample/main.lfm
Normal file
File diff suppressed because it is too large
Load Diff
251
components/lazreport/source/addons/lrcodereport/sample/main.pas
Normal file
251
components/lazreport/source/addons/lrcodereport/sample/main.pas
Normal file
@ -0,0 +1,251 @@
|
||||
unit main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LR_Class, LR_Shape, LR_BarC, lr_e_pdf, Forms,
|
||||
Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, LR_CodeReport;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Button1: TButton;
|
||||
frBarCodeObject1: TfrBarCodeObject;
|
||||
frShapeObject1: TfrShapeObject;
|
||||
frTNPDFExport1: TfrTNPDFExport;
|
||||
Image1: TImage;
|
||||
Report: TlrCodeReport;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure ReportBeginReport(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
begin
|
||||
report.RunReport;
|
||||
end;
|
||||
|
||||
procedure TForm1.ReportBeginReport(Sender: TObject);
|
||||
var
|
||||
BoxText: TlrTextRectStyle;
|
||||
n: integer;
|
||||
X: double;
|
||||
begin
|
||||
with Sender as TlrCodeReport do
|
||||
begin
|
||||
// Set paper... 1=Letter 9=A4....
|
||||
//SetPaper(1, poLandscape); // try uncomment this line to test another paper size
|
||||
// Set up a custom style
|
||||
BoxText := GetDefaultTextRectStyle;
|
||||
BoxText.FontName := 'Times';
|
||||
BoxText.FontSize := 12;
|
||||
BoxText.FontStyle := [fsBold, fsItalic];
|
||||
BoxText.FontColor := clBlue;
|
||||
BoxText.FillColor := clYellow;
|
||||
BoxText.Line.LColor := clRed;
|
||||
BoxText.Line.LWidth := 2;
|
||||
BoxText.BorderLines := [frbLeft, frbTop, frbRight, frbBottom];
|
||||
BoxText.Alignment := taRightJustify;
|
||||
//*******************************************************************
|
||||
//SetRatio(1, 1); // working with pixels
|
||||
//NOTE: by default values are in pixels
|
||||
LineStyle.LColor := clBlue;
|
||||
DrawHLine(0, 5, GetPageWidth);
|
||||
DrawVLine(5, 0, GetPageHeight);
|
||||
|
||||
// check values uncomment to try
|
||||
//ShowMessage('Width: ' + FormatFloat('0.00', GetPageWidth) +
|
||||
// 'pixels' + 'Height: ' + FormatFloat('0.00', GetPageHeight) + 'pixels.');
|
||||
|
||||
// working with mm
|
||||
EnableMillimeters; // workign in millimeters
|
||||
|
||||
//// check values uncomment to try
|
||||
//ShowMessage('Width: ' + FormatFloat('0.00', GetPageWidth) +
|
||||
// ' mm.' + 'Height: ' + FormatFloat('0.00', GetPageHeight) + ' mm.');
|
||||
|
||||
// Draw text
|
||||
DrawText(0, 0, GetPageWidth, 10, 'Text example áéóâ € jgÑ€', BoxText);
|
||||
DrawText(0, 15, GetPageWidth, 10, 'Text example áéóâ E jgNE', BoxText);
|
||||
DrawText(0, 30, GetPageWidth, 10, '1234', BoxText);
|
||||
|
||||
// Testing cursor
|
||||
// Set AutoSize
|
||||
BoxText.Autosize := True;
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'Testing cursors', BoxText);
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'next line', BoxText);
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'another line', BoxText);
|
||||
// Align Left
|
||||
BoxText.Alignment := taLeftJustify;
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'Testing cursors', BoxText);
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'next line', BoxText);
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'another line', BoxText);
|
||||
// center it
|
||||
BoxText.FontName := 'Arial';
|
||||
BoxText.Alignment := taCenter;
|
||||
BoxText.Autosize := False;
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'Testing cursors', BoxText);
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'next line', BoxText);
|
||||
DrawText(0, Cursor.YBottom, GetPageWidth, 6, 'another line', BoxText);
|
||||
|
||||
LineStyle.LColor := clMaroon;
|
||||
LineStyle.LWidth := 1;
|
||||
LineStyle.LStyle := frsDashDotDot;
|
||||
DrawHLine(0, 15, GetPageWidth);
|
||||
DrawVLine(15, 0, GetPageHeight);
|
||||
NewPage;
|
||||
LineStyle.LColor := clRed;
|
||||
LineStyle.LStyle := frsDash;
|
||||
DrawHLine(0, 15, GetPageWidth);
|
||||
DrawVLine(15, 0, GetPageHeight);
|
||||
|
||||
NewPage;
|
||||
LineStyle.LColor := clYellow;
|
||||
DrawHLine(0, 15, GetPageWidth);
|
||||
DrawVLine(15, 0, GetPageHeight);
|
||||
|
||||
NewPage;
|
||||
// Testing TextOutRectXY
|
||||
ResetTextRectStyle; // restart default style
|
||||
TextOutRectXY(10, 10, 15, 5, 'This text will be cut');
|
||||
TextRectStyle.FontName := 'Times';
|
||||
TextRectStyle.FontSize := 10;
|
||||
TextRectStyle.FontStyle := [fsBold];
|
||||
TextOutRectXY(10, 50, 15, 45, 'This is a non clipping test', taCenter, False);
|
||||
ResetTextRectStyle;
|
||||
|
||||
// TextOut* testing. write/writeln equivalent
|
||||
NewPage;
|
||||
PageMargin.Top := 10;
|
||||
PageMargin.Bottom := 10;
|
||||
PageMargin.Left := 10;
|
||||
PageMargin.Right := 10;
|
||||
TextOut('World World ');
|
||||
TextOut('World');
|
||||
TextOut('!');
|
||||
TextOut('___');
|
||||
TextOutLn('.');
|
||||
TextOutLn('Hello');
|
||||
TextRectStyle.FontSize := 12;
|
||||
TextOutLn('World - Size 12');
|
||||
TextRectStyle.FontSize := 10;
|
||||
TextOutLn('End! - Size 10');
|
||||
for n := 0 to 250 do
|
||||
begin
|
||||
TextOutLn('Line ' + IntToStr(n));
|
||||
end;
|
||||
NewLine;
|
||||
TextOutLn('1 line below');
|
||||
NewLine(3);
|
||||
TextOutLn('3 lines below');
|
||||
|
||||
NewPage;
|
||||
// Testing TextOutXY
|
||||
TextOutXY(0, 0, 'UL Corner'); // default is left aligned
|
||||
TextOutXY(GetPageWidth, 0, 'UR Corner', taRightJustify);
|
||||
TextOutXY(GetPageWidth / 2, 0, 'Center', taCenter);
|
||||
TextOutXY(GetPageWidth / 2, 13, 'LLLL');
|
||||
TextOutXY(GetPageWidth / 2, 13, 'RRRR', taRightJustify);
|
||||
TextOutXY(0, GetPageHeight - 4, 'LL Corner'); // default is left aligned
|
||||
TextOutXY(GetPageWidth, GetPageHeight - 4, 'LR Corner', taRightJustify);
|
||||
TextOutXY(GetPageWidth / 2, GetPageHeight - 4, 'Center', taCenter);
|
||||
NewPage;
|
||||
|
||||
// Testing rotated up text
|
||||
TextOutXYUp(5, 1, 'Rotated Text UL Corner', taRightJustify);
|
||||
TextOutXYUp(5, GetPageHeight / 2, 'Rotated Text Center', taCenter);
|
||||
TextOutXYUp(5, GetPageHeight - 1, 'Rotated Text LL Corner', taLeftJustify);
|
||||
|
||||
NewPage;
|
||||
// Testing frames
|
||||
DrawFrame(10, 10, 25, 10);
|
||||
FrameStyle.FillColor := clYellow;
|
||||
FrameStyle.Line.LColor := clBlue;
|
||||
DrawFrame(10, 35, 25, 10);
|
||||
FrameStyle.Line.LColor := clNavy;
|
||||
FrameStyle.FillColor := clNavy; // No borders
|
||||
DrawFrame(15, 40, 25, 10);
|
||||
ResetFrameStyle; // start new default style
|
||||
FrameStyle.FillColor := clRed;
|
||||
FrameStyle.Line.LColor := clGreen;
|
||||
FrameStyle.Line.LWidth := 2;
|
||||
FrameStyle.BorderLines := [frbLeft, frbTop, frbBottom]; // no line right side
|
||||
DrawFrame(150, 10, 25, 10);
|
||||
ResetFrameStyle;
|
||||
DrawFrame(10, 100, 24, 10);
|
||||
DrawFrame(34, 100, 24, 10);
|
||||
DrawFrame(58, 100, 24, 10);
|
||||
DrawFrame(82, 100, 24, 10);
|
||||
|
||||
NewPage;
|
||||
// Testing image
|
||||
// using sharedname, this allows us to define one image and reuse it
|
||||
// resulting in less resources usage
|
||||
DrawImage(10, 10, 60, 60, Image1, 'logo1');
|
||||
DrawImage(10, 80, 60, 30, Image1, 'logo1');
|
||||
// keepaspect=false
|
||||
DrawImage(71, 80, 60, 30, Image1, 'logo1', True, False, False);
|
||||
|
||||
NewPage;
|
||||
// Testing shapes
|
||||
DrawShape(10, 10, 50, 20, ShapeStyle); // full power procedure
|
||||
ShapeStyle.FillColor := clYellow;
|
||||
ShapeStyle.FrameColor := clBlue;
|
||||
DrawRectangle(10, 30, 50, 20);
|
||||
DrawRoundRectangle(10, 50, 50, 20);
|
||||
DrawDiagonalDownRight(10, 70, 50, 20);
|
||||
DrawDiagonalUpRight(10, 90, 50, 20);
|
||||
DrawEllipse(10, 110, 50, 20);
|
||||
DrawTriangle(10, 130, 50, 20);
|
||||
|
||||
NewPage;
|
||||
// Testing BarCodes
|
||||
DrawBarCode(10, 10, 0, 15, 'lazarus-123456789', BarCodeStyle); // Default is Code39
|
||||
BarCodeStyle.Angle := 90;
|
||||
DrawBarCode(10, 30, 15, 0, 'lazarus-123456789', BarCodeStyle);
|
||||
ResetBarCodeStyle;
|
||||
BarCodeStyle.BorderLines := [frbLeft, frbTop, frbRight, frbBottom];
|
||||
BarCodeStyle.FrameColor := clYellow;
|
||||
DrawBarCode(10, 90, 0, 15, 'lazarus-123456789', BarCodeStyle);
|
||||
|
||||
// Testing active page change
|
||||
ResetTextRectStyle;
|
||||
TextRectStyle.FontSize := 7;
|
||||
TextRectStyle.FontColor := clDkGray;
|
||||
for n := 1 to PageCount do
|
||||
begin
|
||||
SetActivePage(n); // move to page n
|
||||
if (n mod 2) = 0 then
|
||||
begin
|
||||
X := PageMargin.Left;
|
||||
TextOutXY(X, GetPageHeight - PageMargin.Bottom,
|
||||
Format('Page %d of %d', [GetActivePage, PageCount]), taLeftJustify);
|
||||
end
|
||||
else
|
||||
begin
|
||||
X := GetPageWidth - PageMargin.Right;
|
||||
TextOutXY(X, GetPageHeight - PageMargin.Bottom,
|
||||
Format('Page %d of %d', [GetActivePage, PageCount]), taRightJustify);
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="testlrcodereport"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<MacroValues Count="1">
|
||||
<Macro1 Name="LCLWidgetType" Value="gtk2"/>
|
||||
</MacroValues>
|
||||
<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"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="4">
|
||||
<Item1>
|
||||
<PackageName Value="lr_codereport_pkg"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="lazreportpdfexport"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="lazreport"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item4>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="testlrcodereport.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="testlrcodereport"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="main"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="testlrcodereport"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
<LCLWidgetType Value="gtk2"/>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@ -0,0 +1,21 @@
|
||||
program testlrcodereport;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, lazreportpdfexport, main
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
@ -0,0 +1,232 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectSession>
|
||||
<Version Value="9"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="16">
|
||||
<Unit0>
|
||||
<Filename Value="testlrcodereport.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="testlrcodereport"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<UsageCount Value="46"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="main"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="22"/>
|
||||
<CursorPos X="38" Y="42"/>
|
||||
<UsageCount Value="46"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="lr_codereport.pas"/>
|
||||
<UnitName Value="LR_CodeReport"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="747"/>
|
||||
<CursorPos X="4" Y="779"/>
|
||||
<UsageCount Value="24"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/lr_barc.pas"/>
|
||||
<UnitName Value="LR_BarC"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="260"/>
|
||||
<CursorPos X="29" Y="276"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/barcode.pas"/>
|
||||
<UnitName Value="Barcode"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="177"/>
|
||||
<CursorPos X="3" Y="76"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/lr_class.pas"/>
|
||||
<UnitName Value="LR_Class"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="6973"/>
|
||||
<CursorPos X="1" Y="6987"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/lr_view.pas"/>
|
||||
<ComponentName Value="frPreviewForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="LR_View"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="35"/>
|
||||
<CursorPos X="3" Y="35"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/lr_prntr.pas"/>
|
||||
<UnitName Value="LR_Prntr"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="950"/>
|
||||
<CursorPos X="9" Y="970"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/lr_vers.inc"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="37"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="../../lazarus/lcl/printers.pas"/>
|
||||
<UnitName Value="Printers"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="137"/>
|
||||
<CursorPos X="3" Y="141"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="../../lazarus/components/lazreport/source/lr_const.pas"/>
|
||||
<UnitName Value="LR_Const"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="233"/>
|
||||
<CursorPos X="16" Y="251"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="../../lazarus/lcl/include/rasterimage.inc"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="292"/>
|
||||
<CursorPos X="1" Y="308"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="../../../../lazarus/components/lazreport/source/lr_register.pas"/>
|
||||
<UnitName Value="LR_Register"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="51"/>
|
||||
<CursorPos X="1" Y="83"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="../../../../lazarus/components/lazreport/source/addons/lrcodereport/lr_codereport.pas"/>
|
||||
<UnitName Value="LR_CodeReport"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="60"/>
|
||||
<CursorPos X="30" Y="65"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="../../../../lazarus/components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.pas"/>
|
||||
<UnitName Value="lr_codereport_pkg"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="47" Y="17"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="../../../../lazarus/components/lazreport/source/lr_barc.pas"/>
|
||||
<UnitName Value="LR_BarC"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="43"/>
|
||||
<CursorPos X="3" Y="54"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit15>
|
||||
</Units>
|
||||
<General>
|
||||
<ActiveWindowIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<JumpHistory Count="20" HistoryIndex="19">
|
||||
<Position1>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="98" Column="42" TopLine="91"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="260" Column="55" TopLine="238"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="252" Column="32" TopLine="239"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="259" Column="75" TopLine="236"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="248" Column="16" TopLine="240"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="259" Column="46" TopLine="240"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="173" Column="29" TopLine="158"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="171" Column="38" TopLine="158"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="7" Column="47" TopLine="1"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="98" Column="1" TopLine="79"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="92" Column="14" TopLine="73"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="94" Column="18" TopLine="70"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="27" Column="30" TopLine="10"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="18" Column="12" TopLine="7"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="17" Column="40" TopLine="7"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="41" Column="53" TopLine="28"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="42" Column="53" TopLine="29"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="56" Column="53" TopLine="40"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="26" Column="1" TopLine="6"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="42" Column="1" TopLine="39"/>
|
||||
</Position20>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
</CONFIG>
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 520 B |
Loading…
Reference in New Issue
Block a user