77 lines
2.3 KiB
ObjectPascal
77 lines
2.3 KiB
ObjectPascal
{******************************************}
|
|
{ }
|
|
{ FastReport FMX v2.0 }
|
|
{ Linux canvas stub classes }
|
|
{ }
|
|
{ Copyright (c) 1998-2021 }
|
|
{ by Fast Reports Inc. }
|
|
{ }
|
|
{******************************************}
|
|
|
|
unit FMX.frxCanvas.Linux;
|
|
|
|
interface
|
|
{$I fmx.inc}
|
|
{$I frx.inc}
|
|
{$SCOPEDENUMS ON}
|
|
|
|
uses
|
|
System.SysUtils, System.Classes, System.Types, System.Math.Vectors, System.UITypes, System.UIConsts, FMX.Types,
|
|
FMX.Graphics, FMX.TextLayout, FMX.Canvas.Linux;
|
|
|
|
type
|
|
TfrxLinuxCanvas = class(TLinuxCanvas)
|
|
private
|
|
FPrinter: TObject;
|
|
protected
|
|
procedure DoSetMatrix(const M: TMatrix); override;
|
|
public
|
|
constructor CreateFromFrxPrinter(const APrinter: TObject);
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses System.Math, FMX.Consts, FMX.frxFMX, FMX.frxPrinter, FMX.frxClass;
|
|
|
|
|
|
{ TfrxLinuxCanvas }
|
|
|
|
constructor TfrxLinuxCanvas.CreateFromFrxPrinter(const APrinter: TObject);
|
|
begin
|
|
if APrinter is TfrxCustomPrinter then
|
|
FPrinter := APrinter;
|
|
inherited CreateFromPrinter(nil);
|
|
end;
|
|
|
|
procedure TfrxLinuxCanvas.DoSetMatrix(const M: TMatrix);
|
|
var
|
|
LMatrix: TMatrix;
|
|
frxPrinter: TfrxCustomPrinter;
|
|
begin
|
|
|
|
if FPrinter <> nil then
|
|
begin
|
|
{ marging converts from MM by using DPI }
|
|
{ scale converts based on PPI = 72 }
|
|
frxPrinter := TfrxCustomPrinter(FPrinter);
|
|
if frxPrinter.Orientation = TPrinterOrientation.poLandscape then
|
|
LMatrix := M * TMatrix.CreateRotation(DegToRad(90)) *
|
|
TMatrix.CreateTranslation(Height, 0) * TMatrix.CreateTranslation
|
|
(frxPrinter.LeftMargin * frxPrinter.DPI.X / frxDefDPIUnits,
|
|
frxPrinter.TopMargin * frxPrinter.DPI.Y / frxDefDPIUnits) * TMatrix.CreateScaling
|
|
(1 / (frxPrinter.DPI.X / frxDefPPIUnits), 1 / (frxPrinter.DPI.Y / frxDefPPIUnits))
|
|
else
|
|
LMatrix := M * TMatrix.CreateTranslation(frxPrinter.LeftMargin * fr01cm *
|
|
frxPrinter.DPI.X / frxDefDPIUnits, frxPrinter.TopMargin * fr01cm * frxPrinter.DPI.Y
|
|
/ frxDefDPIUnits) * TMatrix.CreateScaling(1 / (frxPrinter.DPI.X / frxDefPPIUnits),
|
|
1 / (frxPrinter.DPI.Y / frxDefPPIUnits));
|
|
end;
|
|
inherited DoSetMatrix(LMatrix);
|
|
end;
|
|
|
|
initialization
|
|
TTextLayoutManager.RegisterTextLayout(TLinuxTextLayout, TfrxLinuxCanvas);
|
|
|
|
|
|
end.
|