Merged revision(s) 49760 #8804bbadce, 49763-49764 #66468c8af8-#66468c8af8 from trunk:

LazReport: lrCodeReport RunReport procedure now takes an argument for optionally showing the report after run
........
LazReport, lrCodeReport: add missing layout text property, from Frans van Leeuwen, issue #28609
........
LazReport, lrCodeReport: sample for testing text layout
........

git-svn-id: branches/fixes_1_4@49831 -
This commit is contained in:
maxim 2015-09-15 21:02:29 +00:00
parent 9165a16427
commit 5cb533ff16
2 changed files with 35 additions and 5 deletions

View File

@ -108,7 +108,7 @@ type
procedure SetPaper(ASize: integer; AOr: TPrinterOrientation = poPortrait;
AWidth: integer = 0; AHeight: integer = 0);
procedure SetRatio(X, Y: double);
procedure RunReport;
procedure RunReport(aShowPreview: boolean = true);
procedure SetFont(AName: string; ASize: integer; AStyle: TFontStyles = []);
procedure NewLine(i: word = 1);
procedure NewPage;
@ -257,11 +257,12 @@ begin
YRatio := Y;
end;
procedure TlrCodeReport.RunReport;
procedure TlrCodeReport.RunReport(aShowPreview: boolean = true);
begin
if Assigned(OnBeginReport) then
OnBeginReport(Self);
Report.ShowReport;
if aShowPreview then
Report.ShowReport;
end;
procedure TlrCodeReport.SetFont(AName: string; ASize: integer;
@ -585,6 +586,7 @@ begin
AText.Font.Style := Style.FontStyle;
AText.Alignment := Style.Alignment;
AText.Layout := Style.Layout;
AText.Memo.Add(Text);
AText.CalcGaps;

View File

@ -57,7 +57,7 @@ begin
with CodeReport1 do
begin
Report.Clear; // reset report
CodeReport1BeginReport(CodeReport1); // execute code
RunReport(false); // execute code
Report.PrepareReport;
Report.ExportTo(TfrTNPDFExportFilter, SaveDialog1.FileName);
end;
@ -68,7 +68,7 @@ begin
with CodeReport1 do
begin
Report.Clear; // reset report
CodeReport1BeginReport(CodeReport1); // execute code
RunReport(false); // execute code
Report.PrepareReport;
Report.PrintPreparedReport('', 1); // empty string print all the pages
// '1-5' print pages from 1 to 5
@ -140,6 +140,34 @@ begin
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);
// Layout
x := Cursor.YBottom + 5;
BoxText.FillColor := clSilver;
BoxText.Line.LColor := clGreen;
BoxText.FontColor := clRed;
BoxText.Layout := tlTop;
BoxText.Alignment := taLeftJustify;
DrawText(20, x, 50, 15, 'TopLeft', BoxText);
BoxText.Alignment := taCenter;
DrawText(70, x, 50, 15, 'TopCenter', BoxText);
BoxText.Alignment := taRightJustify;
DrawText(120, x, 50, 15, 'TopRight', BoxText);
x := Cursor.YBottom;
BoxText.Layout := tlCenter;
BoxText.Alignment := taLeftJustify;
DrawText(20, x, 50, 15, 'CenterLeft', BoxText);
BoxText.Alignment := taCenter;
DrawText(70, x, 50, 15, 'CenterCenter', BoxText);
BoxText.Alignment := taRightJustify;
DrawText(120, x, 50, 15, 'CenterRight', BoxText);
x := Cursor.YBottom;
BoxText.Layout := tlBottom;
BoxText.Alignment := taLeftJustify;
DrawText(20, x, 50, 15, 'BottomLeft', BoxText);
BoxText.Alignment := taCenter;
DrawText(70, x, 50, 15, 'BottomCenter', BoxText);
BoxText.Alignment := taRightJustify;
DrawText(120, x, 50, 15, 'BottomRight', BoxText);
LineStyle.LColor := clMaroon;
LineStyle.LWidth := 1;