You've already forked lazarus-ccr
LazStats: Fix text printer margins to be in mm.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7858 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -49,10 +49,12 @@ uses
|
||||
Globals;
|
||||
|
||||
const
|
||||
LEFT_MARGIN = 200;
|
||||
RIGHT_MARGIN = 200;
|
||||
TOP_MARGIN = 150;
|
||||
BOTTOM_MARGIN = 200;
|
||||
LEFT_MARGIN = 20; // mm
|
||||
RIGHT_MARGIN = 20;
|
||||
TOP_MARGIN = 15;
|
||||
BOTTOM_MARGIN = 20;
|
||||
|
||||
INCH = 25.4; // 1 inch in mm
|
||||
|
||||
|
||||
constructor TReportFrame.Create(AOwner: TComponent);
|
||||
@ -117,13 +119,18 @@ var
|
||||
pageNo: Integer;
|
||||
oldFontSize: Integer;
|
||||
h: Integer;
|
||||
leftMM, rightMM, topMM, bottomMM: Integer;
|
||||
begin
|
||||
with Printer do
|
||||
begin
|
||||
x := LEFT_MARGIN;
|
||||
FPrintY := TOP_MARGIN;
|
||||
xMax := PaperSize.Width - RIGHT_MARGIN;
|
||||
yMax := PaperSize.Height - BOTTOM_MARGIN;
|
||||
leftMM := round(LEFT_MARGIN / INCH * XDpi);
|
||||
rightMM := round(RIGHT_MARGIN / INCH * XDpi);
|
||||
topMM := round(TOP_MARGIN / INCH * YDpi);
|
||||
bottomMM := round(BOTTOM_MARGIN / INCH * YDpi);
|
||||
x := leftMM;
|
||||
FPrintY := topMM;
|
||||
xMax := PaperSize.Width - rightMM;
|
||||
yMax := PaperSize.Height - bottomMM;
|
||||
pageNo := 1;
|
||||
try
|
||||
Canvas.Brush.Style := bsClear; // no text background color
|
||||
@ -133,12 +140,12 @@ begin
|
||||
oldFontSize := Canvas.Font.Size;
|
||||
for i:=0 to ReportMemo.Lines.Count-1 do begin
|
||||
// Print page number
|
||||
if FPrintY = TOP_MARGIN then begin
|
||||
if FPrintY = topMM then begin
|
||||
Canvas.Font.Size := 10;
|
||||
h := Canvas.TextHeight('Page 9') + 4;
|
||||
Canvas.TextOut(x+1, FPrintY, 'Page ' + IntToStr(PageNo));
|
||||
Canvas.Pen.Width := 3;
|
||||
Canvas.Line(LEFT_MARGIN, FPrintY+h, xmax, FPrintY+h);
|
||||
Canvas.Line(leftMM, FPrintY+h, xMax, FPrintY+h);
|
||||
inc(FPrintY, 2*h);
|
||||
Canvas.Font.Size := oldFontSize;
|
||||
end;
|
||||
@ -146,7 +153,7 @@ begin
|
||||
inc(FPrintY, Canvas.TextHeight('Tg'));
|
||||
if FPrintY > yMax then begin
|
||||
NewPage;
|
||||
FPrintY := TOP_MARGIN;
|
||||
FPrintY := topMM;
|
||||
inc(PageNo);
|
||||
end;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user