Printers: Paint margins etc. in Unix PageSetup dialog. Issue #33427, patch from AlexeyT.

git-svn-id: trunk@57540 -
This commit is contained in:
juha 2018-03-20 16:05:14 +00:00
parent 0081f4daa1
commit eb60bc8c6d

View File

@ -117,49 +117,35 @@ begin
end; end;
procedure TframePageSetup.pbPreviewPaint(Sender: TObject); procedure TframePageSetup.pbPreviewPaint(Sender: TObject);
procedure DrawMargin(AIndex: Integer; ASize: Integer); var
begin R: TRect;
with pbPreview do NLeft, NTop, NRight, NBottom: integer;
case AIndex of
0: // Left
begin
Canvas.MoveTo(ASize, 1);
Canvas.LineTo(ASize, Height-1);
end;
1: //Top
begin
Canvas.MoveTo(1,ASize);
Canvas.LineTo(Width-1, ASize);
end;
2: // Right
begin
Canvas.MoveTo(Width-1-ASize, 1);
Canvas.LineTo(Width-1-ASize,Height-1);
end;
3: // Bottom
begin
Canvas.MoveTo(1,Height-1-Asize);
Canvas.LineTo(Width-1, Height-1-ASize);
end;
end;
end;
begin begin
if not EnablePreview then if not EnablePreview then
exit; exit;
with pbPreview do with pbPreview do
begin begin
Canvas.Pen.Style := psSolid;
Canvas.Pen.Color := clBlack; Canvas.Pen.Color := clBlack;
Canvas.Brush.Color := clWhite; Canvas.Brush.Color := clWhite;
Canvas.Rectangle(0, 0, Width, Height); Canvas.Rectangle(0, 0, Width, Height);
if EnableMargins then if EnableMargins then
begin begin
Canvas.Pen.Color := clHighlight; NLeft := Round(txtLeft.Value * NToInches * Printer.XDPI * FFactorX * FZoom);
DrawMargin(0, Round(txtLeft.Value * NToInches * Printer.XDPI * FFactorX * FZoom) ); //FHardMargins.Left NTop := Round(txtTop.Value * NToInches * Printer.YDPI * FFactorY * FZoom);
DrawMargin(1, Round(txtTop.Value * NToInches * Printer.YDPI * FFactorY * FZoom) ); NRight := Round(txtRight.Value * NToInches * Printer.XDPI * FFactorX * FZoom);
DrawMargin(2, Round(txtRight.Value * NToInches * Printer.XDPI * FFactorX * FZoom) ); NBottom := Round(txtBottom.Value * NToInches * Printer.YDPI * FFactorY * FZoom);
DrawMargin(3, Round(txtBottom.Value * NToInches * Printer.YDPI * FFactorY * FZoom) );
R.Left := NLeft;
R.Top := NTop;
R.Right := Width-1-NRight;
R.Bottom := Height-1-NBottom;
Canvas.Pen.Color := clMedGray;
//Canvas.Pen.Style := psDash; // AT: setting line style don't work, line is solid
Canvas.Rectangle(R);
end; end;
end; end;
end; end;
@ -272,11 +258,13 @@ begin
end; end;
procedure TframePageSetup.UpdateMaxValues; procedure TframePageSetup.UpdateMaxValues;
const
cMul = 0.45; // max margin is almost 1/2 of page size
begin begin
txtLeft.MaxValue := CurPageWidth/2; txtLeft.MaxValue := CurPageWidth * cMul;
txtRight.MaxValue := CurPageWidth/2; txtRight.MaxValue := CurPageWidth * cMul;
txtTop.MaxValue := CurPageHeight/2; txtTop.MaxValue := CurPageHeight * cMul;
txtBottom.MaxValue := CurPageHeight/2; txtBottom.MaxValue := CurPageHeight * cMul;
end; end;
procedure TframePageSetup.Initialize(AEnablePreview, AEnableMargins, AEnablePapers, procedure TframePageSetup.Initialize(AEnablePreview, AEnableMargins, AEnablePapers,