Printers: Show correct paper names and "source" list in Unix PageSetup dialog. Issue #33427, patch from AlexeyT.

git-svn-id: trunk@57547 -
This commit is contained in:
juha 2018-03-22 08:51:24 +00:00
parent 085dd5ef9f
commit bc26b5cd5f
2 changed files with 20 additions and 5 deletions

View File

@ -88,6 +88,11 @@ var
NDigits, NScale: integer; NDigits, NScale: integer;
NInc: double; NInc: double;
begin begin
// w/o SetPrinter, list of paper names is different
// (Letter / US Letter, EnvMonarch / Envelope Monarch),
// and list of sources is empty
Printer.SetPrinter(Printer.Printers[Printer.PrinterIndex]);
Dlg:= TDlgPageSetup.Create(nil); Dlg:= TDlgPageSetup.Create(nil);
try try
if Title<>'' then if Title<>'' then
@ -166,6 +171,8 @@ begin
Dlg.frmPageSetup.txtRight.Increment:= NInc; Dlg.frmPageSetup.txtRight.Increment:= NInc;
Dlg.frmPageSetup.txtBottom.Increment:= NInc; Dlg.frmPageSetup.txtBottom.Increment:= NInc;
Dlg.frmPageSetup.UpdatePageSize;
Result:= Dlg.ShowModal=mrOk; Result:= Dlg.ShowModal=mrOk;
if Result then if Result then
begin begin

View File

@ -62,7 +62,6 @@ type
FFactorX, FFactorY, FZoom: Double; FFactorX, FFactorY, FZoom: Double;
function NToInches: double; function NToInches: double;
procedure RotateMargins(AOrder: boolean); procedure RotateMargins(AOrder: boolean);
procedure UpdateMaxValues;
public public
UnitInches: boolean; UnitInches: boolean;
EnablePreview: boolean; EnablePreview: boolean;
@ -74,6 +73,7 @@ type
procedure Initialize(AEnablePreview, AEnableMargins, AEnablePapers, procedure Initialize(AEnablePreview, AEnableMargins, AEnablePapers,
AEnableOrientation: boolean); AEnableOrientation: boolean);
procedure UpdatePageSize; procedure UpdatePageSize;
procedure UpdateMaxValues;
procedure SetDefaultMinMargins; procedure SetDefaultMinMargins;
end; end;
@ -265,13 +265,21 @@ begin
end; end;
procedure TframePageSetup.UpdateMaxValues; procedure TframePageSetup.UpdateMaxValues;
procedure DoSetMax(Ctl: TFloatSpinEdit; Value: double);
begin
if Ctl.MinValue > Value then
Ctl.MinValue := Value;
Ctl.MaxValue := Value;
end;
const const
cMul = 0.45; // max margin is almost 1/2 of page size cMul = 0.45; // max margin is almost 1/2 of page size
begin begin
txtLeft.MaxValue := CurPageWidth * cMul; DoSetMax(txtLeft, CurPageWidth * cMul);
txtRight.MaxValue := CurPageWidth * cMul; DoSetMax(txtRight, CurPageWidth * cMul);
txtTop.MaxValue := CurPageHeight * cMul; DoSetMax(txtTop, CurPageHeight * cMul);
txtBottom.MaxValue := CurPageHeight * cMul; DoSetMax(txtBottom, CurPageHeight * cMul);
end; end;
procedure TframePageSetup.Initialize(AEnablePreview, AEnableMargins, AEnablePapers, procedure TframePageSetup.Initialize(AEnablePreview, AEnableMargins, AEnablePapers,