mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 15:39:30 +02:00
Printers: Match Windows PageSetupDialog settings with the Unix dialog. Issue #33427, patch from AlexeyT.
git-svn-id: trunk@57517 -
This commit is contained in:
parent
dd8971ca15
commit
2791021ac9
@ -20,38 +20,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetNumber(FromLeft: boolean; s:ansistring; aDefault: Integer): Integer;
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
res: string;
|
|
||||||
begin
|
|
||||||
|
|
||||||
if FromLeft then
|
|
||||||
i := 1
|
|
||||||
else
|
|
||||||
i := Length(s);
|
|
||||||
|
|
||||||
Res := '';
|
|
||||||
while (i>0)and(i<=Length(s)) do
|
|
||||||
begin
|
|
||||||
if s[i] in ['0'..'9'] then begin
|
|
||||||
if Fromleft then
|
|
||||||
Res:=Res+S[i]
|
|
||||||
else
|
|
||||||
Res:=S[i]+Res;
|
|
||||||
end else begin
|
|
||||||
if Res<>'' then
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
if FromLeft then
|
|
||||||
Inc(i)
|
|
||||||
else
|
|
||||||
Dec(i);
|
|
||||||
end;
|
|
||||||
|
|
||||||
Result := StrToIntDef(Res, aDefault);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TPrintDialog }
|
{ TPrintDialog }
|
||||||
|
|
||||||
function TPrintDialog.DoExecute: Boolean;
|
function TPrintDialog.DoExecute: Boolean;
|
||||||
@ -94,15 +62,15 @@ begin
|
|||||||
// simple rules.
|
// simple rules.
|
||||||
i := pos('-', Dlg.edRange.Text);
|
i := pos('-', Dlg.edRange.Text);
|
||||||
if i<>0 then begin
|
if i<>0 then begin
|
||||||
FromPage := GetNumber(False, copy(Dlg.edRange.Text, 1, i-1), FromPage);
|
FromPage := StrToIntDef(Trim(Copy(Dlg.edRange.Text, 1, i-1)), FromPage);
|
||||||
ToPage := GetNumber(True, copy(Dlg.edRange.Text, i+1, 255), ToPage);
|
ToPage := StrToIntDef(Trim(Copy(Dlg.edRange.Text, i+1, MaxInt)), ToPage);
|
||||||
if ToPage<FromPage then begin
|
if ToPage<FromPage then begin
|
||||||
i := ToPage;
|
i := ToPage;
|
||||||
ToPage := FromPage;
|
ToPage := FromPage;
|
||||||
FromPage := i;
|
FromPage := i;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
Self.FromPage := GetNumber(True, copy(Dlg.edRange.Text, i+1, 255), Self.FromPage);
|
Self.FromPage := StrToIntDef(Trim(Dlg.edRange.Text), Self.FromPage);
|
||||||
Self.ToPage := Self.FromPage;
|
Self.ToPage := Self.FromPage;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -95,7 +95,11 @@ begin
|
|||||||
lCustData := 0;
|
lCustData := 0;
|
||||||
Flags := PSD_MARGINS or PSD_ENABLEPAGESETUPHOOK;
|
Flags := PSD_MARGINS or PSD_ENABLEPAGESETUPHOOK;
|
||||||
hWndOwner := GetOwnerHandle(Self);
|
hWndOwner := GetOwnerHandle(Self);
|
||||||
rtMargin := fMargins;
|
// TODO: check that no need to div by 1000 values below
|
||||||
|
rtMargin.Left := MarginLeft;
|
||||||
|
rtMargin.Top := MarginTop;
|
||||||
|
rtMargin.Right := MarginRight;
|
||||||
|
rtMargin.Bottom := MarginBottom;
|
||||||
PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
|
||||||
// Pdev.DevMode has the required size, just copy to the global memory
|
// Pdev.DevMode has the required size, just copy to the global memory
|
||||||
DeviceMode := GLobalAlloc(GHND, PDev.DevModeSize);
|
DeviceMode := GLobalAlloc(GHND, PDev.DevModeSize);
|
||||||
@ -125,10 +129,14 @@ begin
|
|||||||
|
|
||||||
Result:=True;
|
Result:=True;
|
||||||
if (Flags and PSD_INHUNDREDTHSOFMILLIMETERS)>0 then
|
if (Flags and PSD_INHUNDREDTHSOFMILLIMETERS)>0 then
|
||||||
fUnits := unMM
|
fUnits := pmMillimeters
|
||||||
else
|
else
|
||||||
fUnits := unInch;
|
fUnits := pmInches;
|
||||||
fMargins := rtMargin;
|
|
||||||
|
MarginLeft := rtMargin.Left;
|
||||||
|
MarginTop := rtMargin.Top;
|
||||||
|
MarginRight := rtMargin.Right;
|
||||||
|
MarginBottom := rtMargin.Bottom;
|
||||||
|
|
||||||
if lpp.hDevMode <> 0 then
|
if lpp.hDevMode <> 0 then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user