mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 11:19:40 +02:00
parent
ce953254e7
commit
816204bcbc
@ -628,6 +628,7 @@ begin
|
|||||||
{$IFDEF UseCache}
|
{$IFDEF UseCache}
|
||||||
if aValue=DoGetOrientation then exit;
|
if aValue=DoGetOrientation then exit;
|
||||||
Exclude(FStates,cpsOrientationValid);
|
Exclude(FStates,cpsOrientationValid);
|
||||||
|
Exclude(FStates,cpsPaperRectValid);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
inherited DoSetOrientation(aValue);
|
inherited DoSetOrientation(aValue);
|
||||||
|
|
||||||
@ -701,14 +702,77 @@ begin
|
|||||||
begin
|
begin
|
||||||
fCachePaperRectResult:=1; //CUPS return margins
|
fCachePaperRectResult:=1; //CUPS return margins
|
||||||
|
|
||||||
fCachePaperRect.PhysicalRect.Right:=Trunc(P^.Width);
|
// Margins.
|
||||||
fCachePaperRect.PhysicalRect.Bottom:=Trunc(P^.Length);
|
//
|
||||||
|
// Cups gives dimensions based on postcript language
|
||||||
|
// user space coordinates system which is something like
|
||||||
|
//
|
||||||
|
// +y +--> +x
|
||||||
|
// ^ but our system is |
|
||||||
|
// | v
|
||||||
|
// +--> +x +y
|
||||||
|
//
|
||||||
|
// so values in x are the same, but we need to invert values in y,
|
||||||
|
// the given bottom value is the margin size at the bottom, we need
|
||||||
|
// to re-calc. our bottom offset, and the given top value is offset
|
||||||
|
// top value of imageable area, we need to re-calc. our top offset,
|
||||||
|
// which is the margin size at the top of the page.
|
||||||
|
//
|
||||||
|
// The current implementation assumes that paper is fed short-edge-first
|
||||||
|
// either in portrait orientation, or in landscape orientation.
|
||||||
|
//
|
||||||
|
// In landscape orientation, printable margins should preserved.
|
||||||
|
// It's based on a 90 degree counterclock wise paper rotation
|
||||||
|
//
|
||||||
|
// FEED DIRECTION FEED DIRECTION
|
||||||
|
//
|
||||||
|
// /\ /\
|
||||||
|
// / \ / \
|
||||||
|
// || ||
|
||||||
|
// || ||
|
||||||
|
//
|
||||||
|
// PORTRAIT ORIENTATION LANDSCAPE ORIENTATION
|
||||||
|
//
|
||||||
|
// +-----------------+ +-----------------+
|
||||||
|
// | t | | t |
|
||||||
|
// | +---------+ | | +---------+ |
|
||||||
|
// | | | | | | | |
|
||||||
|
// | | ( ) | | | | v | |
|
||||||
|
// | | | | | | |\ | | |
|
||||||
|
// | l | >--+--< | r | | l | ---+-() | r |
|
||||||
|
// | | | | | | |/ | | |
|
||||||
|
// | | / \ | | | | ^ | |
|
||||||
|
// | | / \ | | | | | |
|
||||||
|
// | +---------+ | | +---------+ |
|
||||||
|
// | | | |
|
||||||
|
// | b | | b |
|
||||||
|
// +-----------------+ +-----------------+
|
||||||
|
//
|
||||||
|
// todo: check meaning of poReverseXXXXX
|
||||||
|
//
|
||||||
|
|
||||||
|
if Orientation in [poPortrait, poReversePortrait] then begin
|
||||||
|
|
||||||
|
fCachePaperRect.PhysicalRect.Right:=Trunc(P^.Width);
|
||||||
|
fCachePaperRect.PhysicalRect.Bottom:=Trunc(P^.Length);
|
||||||
|
|
||||||
|
fCachePaperRect.WorkRect.Left:=Trunc(P^.Left);
|
||||||
|
fCachePaperRect.WorkRect.Right:=Trunc(P^.Right);
|
||||||
|
fCachePaperRect.WorkRect.Top:=Trunc(P^.Length-P^.Top);
|
||||||
|
fCachePaperRect.WorkRect.Bottom:=Trunc(P^.Length-P^.Bottom);
|
||||||
|
|
||||||
|
end else begin
|
||||||
|
|
||||||
|
FCachePaperRect.PhysicalRect.Right:=Trunc(P^.Length);
|
||||||
|
FCachePaperRect.PhysicalRect.Bottom:=Trunc(P^.Width);
|
||||||
|
|
||||||
|
FCachePaperRect.WorkRect.Left:=Trunc(P^.Length-P^.Top);
|
||||||
|
FCachePaperRect.WorkRect.Right:=Trunc(P^.Length-P^.Bottom);
|
||||||
|
FCachePaperRect.WorkRect.Top:=Trunc(P^.Width-P^.Right);
|
||||||
|
FCachePaperRect.WorkRect.Bottom:=Trunc(p^.width - P^.left);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
//Margings
|
|
||||||
fCachePaperRect.WorkRect.Left:=Trunc(P^.Left);
|
|
||||||
fCachePaperRect.WorkRect.Right:=Trunc(P^.Right);
|
|
||||||
fCachePaperRect.WorkRect.Top:=Trunc(P^.Length-P^.Top);
|
|
||||||
fCachePaperRect.WorkRect.Bottom:=Trunc(P^.Length-P^.Bottom);
|
|
||||||
//debugln('TCUPSPrinter.DoGetPaperRect PhysicalRect=',dbgs(fCachePaperRect.PhysicalRect),' WorkRect=',dbgs(fCachePaperRect.WorkRect));
|
//debugln('TCUPSPrinter.DoGetPaperRect PhysicalRect=',dbgs(fCachePaperRect.PhysicalRect),' WorkRect=',dbgs(fCachePaperRect.WorkRect));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -456,7 +456,7 @@ begin
|
|||||||
Left :=Windows.GetDeviceCaps(fDC, PHYSICALOFFSETX);
|
Left :=Windows.GetDeviceCaps(fDC, PHYSICALOFFSETX);
|
||||||
Top :=Windows.GetDeviceCaps(fDC, PHYSICALOFFSETY);
|
Top :=Windows.GetDeviceCaps(fDC, PHYSICALOFFSETY);
|
||||||
Right :=Left + Windows.GetDeviceCaps(fDC, HORZRES);
|
Right :=Left + Windows.GetDeviceCaps(fDC, HORZRES);
|
||||||
Bottom:=Bottom + Windows.GetDeviceCaps(fDC, VERTRES);
|
Bottom:=Top + Windows.GetDeviceCaps(fDC, VERTRES);
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// for other papers return at least the physical size
|
// for other papers return at least the physical size
|
||||||
|
@ -761,43 +761,7 @@ begin
|
|||||||
Margins:=fOwnedPrinter.DoGetPaperRect(aName,TmpPaperRect);
|
Margins:=fOwnedPrinter.DoGetPaperRect(aName,TmpPaperRect);
|
||||||
if Margins>=0 then
|
if Margins>=0 then
|
||||||
begin
|
begin
|
||||||
if fOwnedPrinter.Orientation in [poPortrait,poReversePortrait] then
|
Result := TmpPaperRect;
|
||||||
begin
|
|
||||||
Result.PhysicalRect:=TmpPaperRect.PhysicalRect;
|
|
||||||
|
|
||||||
if Margins=1 then
|
|
||||||
Result.WorkRect:=TmpPaperRect.WorkRect
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Result.WorkRect.Left:=Result.PhysicalRect.Left+TmpPaperRect.WorkRect.Left;
|
|
||||||
Result.WorkRect.Right:=Result.PhysicalRect.Right-TmpPaperRect.WorkRect.Right;
|
|
||||||
Result.WorkRect.Top:=Result.PhysicalRect.Top+TmpPaperRect.WorkRect.Top;
|
|
||||||
Result.WorkRect.Bottom:=Result.PhysicalRect.Bottom-TmpPaperRect.WorkRect.Bottom;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
//If the selected orientation is not normal, reverse
|
|
||||||
//length with width
|
|
||||||
Result.PhysicalRect.Right:=TmpPaperRect.PhysicalRect.Bottom;
|
|
||||||
Result.PhysicalRect.Bottom:=TmpPaperRect.PhysicalRect.Right;
|
|
||||||
|
|
||||||
if Margins=1 then
|
|
||||||
begin
|
|
||||||
Result.WorkRect.Right:=TmpPaperRect.WorkRect.Bottom;
|
|
||||||
Result.WorkRect.Left:=TmpPaperRect.WorkRect.Left;
|
|
||||||
Result.WorkRect.Bottom:=TmpPaperRect.WorkRect.Right;
|
|
||||||
Result.WorkRect.Top:=TmpPaperRect.WorkRect.Top;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
// workrect is margins
|
|
||||||
Result.WorkRect.Left:=Result.PhysicalRect.Left+TmpPaperRect.WorkRect.left;
|
|
||||||
Result.WorkRect.Right:=Result.PhysicalRect.Right-TmpPaperRect.WorkRect.Bottom;
|
|
||||||
Result.WorkRect.Top:=Result.PhysicalRect.Top+TmpPaperRect.WorkRect.top;
|
|
||||||
Result.WorkRect.Bottom:=Result.PhysicalRect.Bottom-TmpPaperRect.WorkRect.right;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
end
|
||||||
else raise EPrinter.Create(Format('The paper "%s" as not definied rect ! ',[aName]));
|
else raise EPrinter.Create(Format('The paper "%s" as not definied rect ! ',[aName]));
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user