Printers4Lazarus: implemented TPrintDialog PageRange under Carbon

git-svn-id: trunk@13279 -
This commit is contained in:
tombo 2007-12-11 17:03:23 +00:00
parent 46ca875004
commit 48c79a27ca

View File

@ -44,8 +44,8 @@ function TPrintDialog.Execute: Boolean;
var
CarbonPrinter: TCarbonPrinter;
DialogSettings: PMPrintSettings;
V: UInt32;
PFrom, PTo: Integer;
U, V: UInt32;
PMin, PMax, PFrom, PTo: Integer;
begin
Result := False;
// TODO: Options, Title
@ -64,33 +64,45 @@ begin
OSError(PMSetCollate(DialogSettings, Collate), Self, SExecute, 'PMSetCollate');
OSError(PMSetCopies(DialogSettings, Copies, False), Self, SExecute, 'PMSetCopies');
OSError(PMSetPageRange(DialogSettings, MinPage, MaxPage),
Self, SExecute, 'PMSetPageRange');
PFrom := Max(FromPage, MinPage);
OSError(PMSetFirstPage(DialogSettings, PFrom, False), Self, SExecute, 'PMSetFirstPage');
PTo := Max(PFrom, Min(ToPage, MaxPage));
OSError(PMSetLastPage(DialogSettings, PTo, False), Self, SExecute, 'PMSetLastPage');
PMin := MinPage;
PMax := Max(PMin, MaxPage);
PFrom := Min(Max(FromPage, PMin), PMax);
PTo := Max(PFrom, Min(ToPage, PMax));
OSError(PMSetPageRange(DialogSettings, PMin, PMax),
Self, SExecute, 'PMSetPageRange');
if PrintRange <> prAllPages then
begin
OSError(PMSetFirstPage(DialogSettings, PFrom, False), Self, SExecute, 'PMSetFirstPage');
OSError(PMSetLastPage(DialogSettings, PTo, False), Self, SExecute, 'PMSetLastPage');
end;
if OSError(PMSessionPrintDialog(CarbonPrinter.PrintSession, DialogSettings, CarbonPrinter.PageFormat, Result),
Self, SExecute, 'PMSessionPrintDialog') then Exit;
if Result then
begin
PrintRange := prSelection;
OSError(PMGetCollate(DialogSettings, Collate), Self, SExecute, 'PMGetCollate');
V := Copies;
OSError(PMGetCopies(DialogSettings, V), Self, SExecute, 'PMGetCopies');
Copies := V;
V := FromPage;
OSError(PMGetFirstPage(DialogSettings, V), Self, SExecute, 'PMGetFirstPage');
FromPage := V;
V := ToPage;
OSError(PMGetLastPage(DialogSettings, V), Self, SExecute, 'PMGetLastPage');
ToPage := V;
if V > $FFFF then
begin
PrintRange := prAllPages;
FromPage := PMin;
ToPage := PMax;
end
else
begin
PrintRange := prSelection;
ToPage := V;
OSError(PMGetFirstPage(DialogSettings, V), Self, SExecute, 'PMGetFirstPage');
FromPage := V;
end;
if OSError(PMCopyPrintSettings(DialogSettings, CarbonPrinter.PrintSettings),
Self, SExecute, 'PMCopyPrintSettings') then Exit;