mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 15:36:03 +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
|
var
|
||||||
Dlg: TDlgPageSetup;
|
Dlg: TDlgPageSetup;
|
||||||
NDigits, NScale: integer;
|
NDigits, NScale: integer;
|
||||||
|
NInc: double;
|
||||||
begin
|
begin
|
||||||
Dlg:= TDlgPageSetup.Create(nil);
|
Dlg:= TDlgPageSetup.Create(nil);
|
||||||
try
|
try
|
||||||
Dlg.SetControls(
|
|
||||||
not (psoDisablePagePainting in Options),
|
|
||||||
not (psoDisableMargins in Options),
|
|
||||||
not (psoDisablePaper in Options),
|
|
||||||
not (psoDisableOrientation in Options)
|
|
||||||
);
|
|
||||||
|
|
||||||
if Title<>'' then
|
if Title<>'' then
|
||||||
Dlg.Caption:= Title
|
Dlg.Caption:= Title
|
||||||
else
|
else
|
||||||
@ -107,6 +101,7 @@ begin
|
|||||||
with Dlg.frmPageSetup.gpMargins do
|
with Dlg.frmPageSetup.gpMargins do
|
||||||
Caption:= Caption+' (inches)';
|
Caption:= Caption+' (inches)';
|
||||||
NDigits:= 2;
|
NDigits:= 2;
|
||||||
|
NInc:= 0.01;
|
||||||
// according to MSDN, WinAPI margin rect needs values in 1/1000 of inches,
|
// according to MSDN, WinAPI margin rect needs values in 1/1000 of inches,
|
||||||
// or in 1/100 on mm.
|
// or in 1/100 on mm.
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646842(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646842(v=vs.85).aspx
|
||||||
@ -118,9 +113,18 @@ begin
|
|||||||
with Dlg.frmPageSetup.gpMargins do
|
with Dlg.frmPageSetup.gpMargins do
|
||||||
Caption:= Caption+' (mm)';
|
Caption:= Caption+' (mm)';
|
||||||
NDigits:= 0;
|
NDigits:= 0;
|
||||||
|
NInc:= 1.0;
|
||||||
NScale:= 100;
|
NScale:= 100;
|
||||||
end;
|
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.txtLeft.DecimalPlaces:= NDigits;
|
||||||
Dlg.frmPageSetup.txtTop.DecimalPlaces:= NDigits;
|
Dlg.frmPageSetup.txtTop.DecimalPlaces:= NDigits;
|
||||||
Dlg.frmPageSetup.txtRight.DecimalPlaces:= NDigits;
|
Dlg.frmPageSetup.txtRight.DecimalPlaces:= NDigits;
|
||||||
@ -137,6 +141,11 @@ begin
|
|||||||
Dlg.frmPageSetup.txtRight.MinValue:= FMinMarginRight/NScale;
|
Dlg.frmPageSetup.txtRight.MinValue:= FMinMarginRight/NScale;
|
||||||
Dlg.frmPageSetup.txtBottom.MinValue:= FMinMarginBottom/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;
|
Result:= Dlg.ShowModal=mrOk;
|
||||||
if Result then
|
if Result then
|
||||||
begin
|
begin
|
||||||
@ -144,6 +153,9 @@ begin
|
|||||||
FMarginTop:= Round(Dlg.frmPageSetup.txtTop.Value*NScale);
|
FMarginTop:= Round(Dlg.frmPageSetup.txtTop.Value*NScale);
|
||||||
FMarginRight:= Round(Dlg.frmPageSetup.txtRight.Value*NScale);
|
FMarginRight:= Round(Dlg.frmPageSetup.txtRight.Value*NScale);
|
||||||
FMarginBottom:= Round(Dlg.frmPageSetup.txtBottom.Value*NScale);
|
FMarginBottom:= Round(Dlg.frmPageSetup.txtBottom.Value*NScale);
|
||||||
|
|
||||||
|
FPageWidth:= Round(Dlg.frmPageSetup.CurPageWidth*NScale);
|
||||||
|
FPageHeight:= Round(Dlg.frmPageSetup.CurPageHeight*NScale);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Dlg.Free;
|
Dlg.Free;
|
||||||
|
@ -64,8 +64,11 @@ type
|
|||||||
EnableMargins: boolean;
|
EnableMargins: boolean;
|
||||||
EnablePapers: boolean;
|
EnablePapers: boolean;
|
||||||
EnableOrientation: boolean;
|
EnableOrientation: boolean;
|
||||||
|
function NToInches: double;
|
||||||
public
|
public
|
||||||
UnitInches: boolean;
|
UnitInches: boolean;
|
||||||
|
CurPageWidth: double;
|
||||||
|
CurPageHeight: double;
|
||||||
procedure Initialize(AEnablePreview, AEnableMargins, AEnablePapers,
|
procedure Initialize(AEnablePreview, AEnableMargins, AEnablePapers,
|
||||||
AEnableOrientation: boolean);
|
AEnableOrientation: boolean);
|
||||||
procedure UpdatePageSize;
|
procedure UpdatePageSize;
|
||||||
@ -77,6 +80,14 @@ implementation
|
|||||||
|
|
||||||
{ TframePageSetup }
|
{ TframePageSetup }
|
||||||
|
|
||||||
|
function TframePageSetup.NToInches: double;
|
||||||
|
begin
|
||||||
|
if UnitInches then
|
||||||
|
Result:= 1
|
||||||
|
else
|
||||||
|
Result:= 1/25.4;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TframePageSetup.pbPreviewPaint(Sender: TObject);
|
procedure TframePageSetup.pbPreviewPaint(Sender: TObject);
|
||||||
procedure DrawMargin(AIndex: Integer; ASize: Integer);
|
procedure DrawMargin(AIndex: Integer; ASize: Integer);
|
||||||
begin
|
begin
|
||||||
@ -104,17 +115,10 @@ procedure TframePageSetup.pbPreviewPaint(Sender: TObject);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
var
|
|
||||||
NToInches: double;
|
|
||||||
begin
|
begin
|
||||||
if not EnablePreview then
|
if not EnablePreview then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if UnitInches then
|
|
||||||
NToInches:= 1
|
|
||||||
else
|
|
||||||
NToInches:= 1/10/2.54;
|
|
||||||
|
|
||||||
with pbPreview do
|
with pbPreview do
|
||||||
begin
|
begin
|
||||||
Canvas.Pen.Color := clBlack;
|
Canvas.Pen.Color := clBlack;
|
||||||
@ -220,6 +224,9 @@ begin
|
|||||||
FHardMargins.Right := Round(FFactorX * (Physicalrect.Right-WorkRect.Right) * FZoom);
|
FHardMargins.Right := Round(FFactorX * (Physicalrect.Right-WorkRect.Right) * FZoom);
|
||||||
FHardMargins.Top := Round(FFactorY * (WorkRect.Top-PhysicalRect.Top) * FZoom);
|
FHardMargins.Top := Round(FFactorY * (WorkRect.Top-PhysicalRect.Top) * FZoom);
|
||||||
FHardMargins.Bottom := Round(FFactorY * (PhysicalRect.Bottom-WorkRect.Bottom) * 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;
|
end;
|
||||||
|
|
||||||
{$IFDEF DebugCUPS}
|
{$IFDEF DebugCUPS}
|
||||||
|
Loading…
Reference in New Issue
Block a user