From 48c79a27ca6e22369cde9c57774ca7408bf6d823 Mon Sep 17 00:00:00 2001 From: tombo Date: Tue, 11 Dec 2007 17:03:23 +0000 Subject: [PATCH] Printers4Lazarus: implemented TPrintDialog PageRange under Carbon git-svn-id: trunk@13279 - --- .../printers/carbon/carbonprndialogs.inc | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/components/printers/carbon/carbonprndialogs.inc b/components/printers/carbon/carbonprndialogs.inc index 20ecbcebc4..a55e755839 100644 --- a/components/printers/carbon/carbonprndialogs.inc +++ b/components/printers/carbon/carbonprndialogs.inc @@ -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;