mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 08:12:39 +02:00
Printers: Adjust increment for mm/Inch in Unix PageSetup dialog. Issue #33427, patch from AlexeyT.
git-svn-id: trunk@57533 -
This commit is contained in:
parent
45f8bcef97
commit
f745a6b395
@ -86,16 +86,10 @@ function TPageSetupDialog.DoExecute: Boolean;
|
||||
var
|
||||
Dlg: TDlgPageSetup;
|
||||
NDigits, NScale: integer;
|
||||
NInc: double;
|
||||
begin
|
||||
Dlg:= TDlgPageSetup.Create(nil);
|
||||
try
|
||||
Dlg.SetControls(
|
||||
not (psoDisablePagePainting in Options),
|
||||
not (psoDisableMargins in Options),
|
||||
not (psoDisablePaper in Options),
|
||||
not (psoDisableOrientation in Options)
|
||||
);
|
||||
|
||||
if Title<>'' then
|
||||
Dlg.Caption:= Title
|
||||
else
|
||||
@ -107,6 +101,7 @@ begin
|
||||
with Dlg.frmPageSetup.gpMargins do
|
||||
Caption:= Caption+' (inches)';
|
||||
NDigits:= 2;
|
||||
NInc:= 0.01;
|
||||
// according to MSDN, WinAPI margin rect needs values in 1/1000 of inches,
|
||||
// or in 1/100 on mm.
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646842(v=vs.85).aspx
|
||||
@ -118,9 +113,18 @@ begin
|
||||
with Dlg.frmPageSetup.gpMargins do
|
||||
Caption:= Caption+' (mm)';
|
||||
NDigits:= 0;
|
||||
NInc:= 1.0;
|
||||
NScale:= 100;
|
||||
end;
|
||||
|
||||
//must be after setting UnitInches
|
||||
Dlg.SetControls(
|
||||
not (psoDisablePagePainting in Options),
|
||||
not (psoDisableMargins in Options),
|
||||
not (psoDisablePaper in Options),
|
||||
not (psoDisableOrientation in Options)
|
||||
);
|
||||
|
||||
Dlg.frmPageSetup.txtLeft.DecimalPlaces:= NDigits;
|
||||
Dlg.frmPageSetup.txtTop.DecimalPlaces:= NDigits;
|
||||
Dlg.frmPageSetup.txtRight.DecimalPlaces:= NDigits;
|
||||
@ -137,6 +141,11 @@ begin
|
||||
Dlg.frmPageSetup.txtRight.MinValue:= FMinMarginRight/NScale;
|
||||
Dlg.frmPageSetup.txtBottom.MinValue:= FMinMarginBottom/NScale;
|
||||
|
||||
Dlg.frmPageSetup.txtLeft.Increment:= NInc;
|
||||
Dlg.frmPageSetup.txtTop.Increment:= NInc;
|
||||
Dlg.frmPageSetup.txtRight.Increment:= NInc;
|
||||
Dlg.frmPageSetup.txtBottom.Increment:= NInc;
|
||||
|
||||
Result:= Dlg.ShowModal=mrOk;
|
||||
if Result then
|
||||
begin
|
||||
@ -144,6 +153,9 @@ begin
|
||||
FMarginTop:= Round(Dlg.frmPageSetup.txtTop.Value*NScale);
|
||||
FMarginRight:= Round(Dlg.frmPageSetup.txtRight.Value*NScale);
|
||||
FMarginBottom:= Round(Dlg.frmPageSetup.txtBottom.Value*NScale);
|
||||
|
||||
FPageWidth:= Round(Dlg.frmPageSetup.CurPageWidth*NScale);
|
||||
FPageHeight:= Round(Dlg.frmPageSetup.CurPageHeight*NScale);
|
||||
end;
|
||||
finally
|
||||
Dlg.Free;
|
||||
|
@ -64,8 +64,11 @@ type
|
||||
EnableMargins: boolean;
|
||||
EnablePapers: boolean;
|
||||
EnableOrientation: boolean;
|
||||
function NToInches: double;
|
||||
public
|
||||
UnitInches: boolean;
|
||||
CurPageWidth: double;
|
||||
CurPageHeight: double;
|
||||
procedure Initialize(AEnablePreview, AEnableMargins, AEnablePapers,
|
||||
AEnableOrientation: boolean);
|
||||
procedure UpdatePageSize;
|
||||
@ -77,6 +80,14 @@ implementation
|
||||
|
||||
{ TframePageSetup }
|
||||
|
||||
function TframePageSetup.NToInches: double;
|
||||
begin
|
||||
if UnitInches then
|
||||
Result:= 1
|
||||
else
|
||||
Result:= 1/25.4;
|
||||
end;
|
||||
|
||||
procedure TframePageSetup.pbPreviewPaint(Sender: TObject);
|
||||
procedure DrawMargin(AIndex: Integer; ASize: Integer);
|
||||
begin
|
||||
@ -104,17 +115,10 @@ procedure TframePageSetup.pbPreviewPaint(Sender: TObject);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
var
|
||||
NToInches: double;
|
||||
begin
|
||||
if not EnablePreview then
|
||||
exit;
|
||||
|
||||
if UnitInches then
|
||||
NToInches:= 1
|
||||
else
|
||||
NToInches:= 1/10/2.54;
|
||||
|
||||
with pbPreview do
|
||||
begin
|
||||
Canvas.Pen.Color := clBlack;
|
||||
@ -220,6 +224,9 @@ begin
|
||||
FHardMargins.Right := Round(FFactorX * (Physicalrect.Right-WorkRect.Right) * FZoom);
|
||||
FHardMargins.Top := Round(FFactorY * (WorkRect.Top-PhysicalRect.Top) * FZoom);
|
||||
FHardMargins.Bottom := Round(FFactorY * (PhysicalRect.Bottom-WorkRect.Bottom) * FZoom);
|
||||
|
||||
CurPageWidth := (PhysicalRect.Right-PhysicalRect.Left)/Printer.XDPI/NToInches;
|
||||
CurPageHeight := (PhysicalRect.Bottom-PhysicalRect.Top)/Printer.YDPI/NToInches;
|
||||
end;
|
||||
|
||||
{$IFDEF DebugCUPS}
|
||||
|
Loading…
Reference in New Issue
Block a user