From 5cb533ff16049d7bc8a9a71f4b34624adab07ddc Mon Sep 17 00:00:00 2001 From: maxim Date: Tue, 15 Sep 2015 21:02:29 +0000 Subject: [PATCH] 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 - --- .../addons/lrcodereport/lr_codereport.pas | 8 +++-- .../addons/lrcodereport/sample/main.pas | 32 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/components/lazreport/source/addons/lrcodereport/lr_codereport.pas b/components/lazreport/source/addons/lrcodereport/lr_codereport.pas index 5799d34514..18c83fb202 100644 --- a/components/lazreport/source/addons/lrcodereport/lr_codereport.pas +++ b/components/lazreport/source/addons/lrcodereport/lr_codereport.pas @@ -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; diff --git a/components/lazreport/source/addons/lrcodereport/sample/main.pas b/components/lazreport/source/addons/lrcodereport/sample/main.pas index 5909fffc2a..dcf9a49eb2 100644 --- a/components/lazreport/source/addons/lrcodereport/sample/main.pas +++ b/components/lazreport/source/addons/lrcodereport/sample/main.pas @@ -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;