FastReport_FMX_2.8.12/LibD28x64/FMX.Linux.Old.frxPrinter.pas
2024-07-06 22:41:12 +02:00

592 lines
20 KiB
ObjectPascal

{******************************************}
{ }
{ FastReport FMX v2.0 }
{ Printer }
{ }
{ Copyright (c) 1998-2020 }
{ by Alexander Syrykh, }
{ Fast Reports Inc. }
{ }
{******************************************}
unit FMX.Linux.Old.frxPrinter;
interface
{$I fmx.inc}
{$I frx.inc}
uses
System.Classes, System.SysUtils,System.Types, System.UITypes, System.Variants,
FMX.Types, FMX.frxPrinter, FMX.Printer.Linux, FMX.Printer, FMX.frxClass
{$IFDEF DELPHI19}
, FMX.Graphics
{$ENDIF};
type
THackCanvas = class(TCanvas);
THackPrinter = class(TPrinter);
TfrxPrinter = class(TfrxCustomPrinter)
private
FIsFirst: Boolean;
public
constructor Create(const AName, APort: String); override;
destructor Destroy; override;
procedure Init; override;
procedure Abort; override;
procedure BeginDoc; override;
procedure BeginPage; override;
procedure BeginRAWDoc; override;
procedure EndDoc; override;
procedure EndPage; override;
procedure EndRAWDoc; override;
procedure WriteRAWDoc(const buf: AnsiString); override;
procedure SetViewParams(APaperSize: Integer;
APaperWidth, APaperHeight: Extended;
AOrientation: TPrinterOrientation); override;
procedure SetPrintParams(APaperSize: Integer;
APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation;
ABin, ADuplex, ACopies: Integer); override;
procedure PropertiesDlg; override;
function ShowPrintDialog: Boolean; override;
function UpdateDeviceCaps: Boolean;
end;
TfrxPrinters = class(TfrxCustomPrinters)
protected
function GetDefaultPrinter: String; override;
public
constructor Create;
destructor Destroy; override;
procedure FillPrinters; override;
end;
function ActualfrxPrinterClass : TfrxCustomPrintersClass;
implementation
uses
FMX.frxUtils, FMX.frxRes, FMX.frxFMX, FMX.Forms, FMUX.Api;
type
TPaperInfo = {packed} record
Typ: Integer;
Name: String;
X, Y: Integer;
end;
const
PAPERCOUNT = 66;
PaperInfo: array[0..PAPERCOUNT - 1] of TPaperInfo = (
(Typ:1; Name: ''; X:2159; Y:2794),
(Typ:2; Name: ''; X:2159; Y:2794),
(Typ:3; Name: ''; X:2794; Y:4318),
(Typ:4; Name: ''; X:4318; Y:2794),
(Typ:5; Name: ''; X:2159; Y:3556),
(Typ:6; Name: ''; X:1397; Y:2159),
(Typ:7; Name: ''; X:1842; Y:2667),
(Typ:8; Name: ''; X:2970; Y:4200),
(Typ:9; Name: ''; X:2100; Y:2970),
(Typ:10; Name: ''; X:2100; Y:2970),
(Typ:11; Name: ''; X:1480; Y:2100),
(Typ:12; Name: ''; X:2500; Y:3540),
(Typ:13; Name: ''; X:1820; Y:2570),
(Typ:14; Name: ''; X:2159; Y:3302),
(Typ:15; Name: ''; X:2150; Y:2750),
(Typ:16; Name: ''; X:2540; Y:3556),
(Typ:17; Name: ''; X:2794; Y:4318),
(Typ:18; Name: ''; X:2159; Y:2794),
(Typ:19; Name: ''; X:984; Y:2254),
(Typ:20; Name: ''; X:1048; Y:2413),
(Typ:21; Name: ''; X:1143; Y:2635),
(Typ:22; Name: ''; X:1207; Y:2794),
(Typ:23; Name: ''; X:1270; Y:2921),
(Typ:24; Name: ''; X:4318; Y:5588),
(Typ:25; Name: ''; X:5588; Y:8636),
(Typ:26; Name: ''; X:8636; Y:11176),
(Typ:27; Name: ''; X:1100; Y:2200),
(Typ:28; Name: ''; X:1620; Y:2290),
(Typ:29; Name: ''; X:3240; Y:4580),
(Typ:30; Name: ''; X:2290; Y:3240),
(Typ:31; Name: ''; X:1140; Y:1620),
(Typ:32; Name: ''; X:1140; Y:2290),
(Typ:33; Name: ''; X:2500; Y:3530),
(Typ:34; Name: ''; X:1760; Y:2500),
(Typ:35; Name: ''; X:1760; Y:1250),
(Typ:36; Name: ''; X:1100; Y:2300),
(Typ:37; Name: ''; X:984; Y:1905),
(Typ:38; Name: ''; X:920; Y:1651),
(Typ:39; Name: ''; X:3778; Y:2794),
(Typ:40; Name: ''; X:2159; Y:3048),
(Typ:41; Name: ''; X:2159; Y:3302),
(Typ:42; Name: ''; X:2500; Y:3530),
(Typ:43; Name: ''; X:1000; Y:1480),
(Typ:44; Name: ''; X:2286; Y:2794),
(Typ:45; Name: ''; X:2540; Y:2794),
(Typ:46; Name: ''; X:3810; Y:2794),
(Typ:47; Name: ''; X:2200; Y:2200),
(Typ:50; Name: ''; X:2355; Y:3048),
(Typ:51; Name: ''; X:2355; Y:3810),
(Typ:52; Name: ''; X:2969; Y:4572),
(Typ:53; Name: ''; X:2354; Y:3223),
(Typ:54; Name: ''; X:2101; Y:2794),
(Typ:55; Name: ''; X:2100; Y:2970),
(Typ:56; Name: ''; X:2355; Y:3048),
(Typ:57; Name: ''; X:2270; Y:3560),
(Typ:58; Name: ''; X:3050; Y:4870),
(Typ:59; Name: ''; X:2159; Y:3223),
(Typ:60; Name: ''; X:2100; Y:3300),
(Typ:61; Name: ''; X:1480; Y:2100),
(Typ:62; Name: ''; X:1820; Y:2570),
(Typ:63; Name: ''; X:3220; Y:4450),
(Typ:64; Name: ''; X:1740; Y:2350),
(Typ:65; Name: ''; X:2010; Y:2760),
(Typ:66; Name: ''; X:4200; Y:5940),
(Typ:67; Name: ''; X:2970; Y:4200),
(Typ:68; Name: ''; X:3220; Y:4450));
type
TPaperInfoLCL = {packed} record
Name: String;
W, H: Extended;
end;
const
LCLPaperCount = 119;
PtPrIn = 72;
CmPrIn = 2.54;
PtPrCm = PtPrIn/CmPrIn;
PtPrmm = PtPrCm/10;
LCLPaperInfo : array[0..LCLPAPERCOUNT-1] of TPaperInfoLCL =
((Name: 'Letter 8 1/2 x 11 in'; W: 8.5 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Letter Small 8 1/2 x 11 in'; W: 8.5 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Tabloid 11 x 17 in'; W: 11 * PtPrIn; H: 17 * PtPrIn),
(Name: 'Ledger 17 x 11 in'; W: 17 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Legal 8 1/2 x 14 in'; W: 8.5 * PtPrIn; H: 14 * PtPrIn),
(Name: 'Statement 5 1/2 x 8 1/2 in'; W: 5.5 * PtPrIn; H: 8.5 * PtPrIn),
(Name: 'Executive 7 1/4 x 10 1/2 in'; W: 7.25 * PtPrIn; H: 10.5 * PtPrIn),
(Name: 'A3 297 x 420 mm'; W: 297 * PtPrmm; H: 420 * PtPrmm),
(Name: 'A4 210 x 297 mm'; W: 210 * PtPrmm; H: 297 * PtPrmm),
(Name: 'A4 Small 210 x 297 mm'; W: 210 * PtPrmm; H: 297 * PtPrmm),
(Name: 'A5 148 x 210 mm'; W: 148 * PtPrmm; H: 210 * PtPrmm),
(Name: 'B4 (JIS) 250 x 354 mm'; W: 250 * PtPrmm; H: 354 * PtPrmm),
(Name: 'B5 (JIS) 182 x 257 mm'; W: 182 * PtPrmm; H: 257 * PtPrmm),
(Name: 'Folio 8 1/2 x 13 in'; W: 8.5 * PtPrIn; H: 13 * PtPrIn),
(Name: 'Quarto 215 x 275 mm'; W: 215 * PtPrmm; H: 275 * PtPrmm),
(Name: '10x14 in'; W: 10 * PtPrIn; H: 14 * PtPrIn),
(Name: '11x17 in'; W: 11 * PtPrIn; H: 17 * PtPrIn),
(Name: 'Note 8 1/2 x 11 in'; W: 8.5 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Envelope #9 3 7/8 x 8 7/8'; W: 3 * 7 / 8 * PtPrIn; H: 8 * 7 / 8 * PtPrIn),
(Name: 'Envelope #10 4 1/8 x 9 1/2'; W: 3 * 1 / 8 * PtPrIn; H: 9.5 * PtPrIn),
(Name: 'Envelope #11 4 1/2 x 10 3/8'; W: 4.5 * PtPrIn; H: 10 * 3 / 8 * PtPrIn),
(Name: 'Envelope #12 4 3/4 x 11'; W: 4.75 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Envelope #14 5 x 11 1/2'; W: 5 * PtPrIn; H: 11.5 * PtPrIn),
(Name: 'C size sheet 17 x 22 in'; W: 17 * PtPrIn; H: 22 * PtPrIn),
(Name: 'D size sheet 22 x 34 in'; W: 22 * PtPrIn; H: 34 * PtPrIn),
(Name: 'E size sheet 34 x 44 in'; W: 34 * PtPrIn; H: 44 * PtPrIn),
(Name: 'Envelope DL 110 x 220mm'; W: 110 * PtPrmm; H: 220 * PtPrmm),
(Name: 'Envelope C5 162 x 229 mm'; W: 162 * PtPrmm; H: 229 * PtPrmm),
(Name: 'Envelope C3 324 x 458 mm'; W: 324 * PtPrmm; H: 458 * PtPrmm),
(Name: 'Envelope C4 229 x 324 mm'; W: 229 * PtPrmm; H: 324 * PtPrmm),
(Name: 'Envelope C6 114 x 162 mm'; W: 114 * PtPrmm; H: 162 * PtPrmm),
(Name: 'Envelope C65 114 x 229 mm'; W: 114 * PtPrmm; H: 229 * PtPrmm),
(Name: 'Envelope B4 250 x 353 mm'; W: 250 * PtPrmm; H: 353 * PtPrmm),
(Name: 'Envelope B5 176 x 250 mm'; W: 176 * PtPrmm; H: 250 * PtPrmm),
(Name: 'Envelope B6 176 x 125 mm'; W: 176 * PtPrmm; H: 125 * PtPrmm),
(Name: 'Envelope 110 x 230 mm'; W: 110 * PtPrmm; H: 230 * PtPrmm),
(Name: 'Envelope Monarch 3 7/8 x 7 1/2 in'; W: 3 * 7 / 8 * PtPrIn; H: 7.5 * PtPrIn),
(Name: '6 34 Envelope 3 5/8 x 6 1/2 in'; W: 3 * 5 / 8 * PtPrIn; H: 6.5 * PtPrIn),
(Name: 'US Std Fanfold 14 7/8 x 11 in'; W: 14 * 7 / 8 * PtPrIn; H: 11 * PtPrIn),
(Name: 'German Std Fanfold 8 1/2 x 12 in'; W: 8.5 * PtPrIn; H: 12 * PtPrIn),
(Name: 'German Legal Fanfold 8 1/2 x 13 in'; W: 8.5 * PtPrIn; H: 13 * PtPrIn),
(Name: 'B4 (ISO) 250 x 353 mm'; W: 250 * PtPrmm; H: 353 * PtPrmm),
(Name: 'Japanese Postcard 100 x 148 mm'; W: 100 * PtPrmm; H: 148 * PtPrmm),
(Name: '9 x 11 in'; W: 9 * PtPrIn; H: 11 * PtPrIn),
(Name: '10 x 11 in'; W: 10 * PtPrIn; H: 11 * PtPrIn),
(Name: '15 x 11 in'; W: 15 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Envelope Invite 220 x 220 mm'; W: 220 * PtPrmm; H: 220 * PtPrmm),
(Name: 'RESERVED--DO NOT USE'; W: 0; H: 0),
(Name: 'RESERVED--DO NOT USE'; W: 0; H: 0),
(Name: 'Letter Extra 9 \275 x 12 in'; W: 9.275 * PtPrIn; H: 12 * PtPrIn),
(Name: 'Legal Extra 9 \275 x 15 in'; W: 9.275 * PtPrIn; H: 15 * PtPrIn),
(Name: 'Tabloid Extra 11.69 x 18 in'; W: 11.69 * PtPrIn; H: 18 * PtPrIn),
(Name: 'A4 Extra 9.27 x 12.69 in'; W: 9.27 * PtPrIn; H: 12.69 * PtPrIn),
(Name: 'Letter Transverse 8 \275 x 11 in'; W: 8.275 * PtPrIn; H: 11 * PtPrIn),
(Name: 'A4 Transverse 210 x 297 mm'; W: 210 * PtPrmm; H: 297 * PtPrmm),
(Name: 'Letter Extra Transverse 9\275 x 12 in'; W: 9.275 * PtPrIn; H: 12 * PtPrIn),
(Name: 'SuperASuperAA4 227 x 356 mm'; W: 227 * PtPrmm; H: 356 * PtPrmm),
(Name: 'SuperBSuperBA3 305 x 487 mm'; W: 305 * PtPrmm; H: 487 * PtPrmm),
(Name: 'Letter Plus 8.5 x 12.69 in'; W: 8.5 * PtPrIn; H: 12.69 * PtPrIn),
(Name: 'A4 Plus 210 x 330 mm'; W: 210 * PtPrmm; H: 330 * PtPrmm),
(Name: 'A5 Transverse 148 x 210 mm'; W: 148 * PtPrmm; H: 210 * PtPrmm),
(Name: 'B5 (JIS) Transverse 182 x 257 mm'; W: 182 * PtPrmm; H: 257 * PtPrmm),
(Name: 'A3 Extra 322 x 445 mm'; W: 322 * PtPrmm; H: 445 * PtPrmm),
(Name: 'A5 Extra 174 x 235 mm'; W: 174 * PtPrmm; H: 235 * PtPrmm),
(Name: 'B5 (ISO) Extra 201 x 276 mm'; W: 201 * PtPrmm; H: 276 * PtPrmm),
(Name: 'A2 420 x 594 mm'; W: 420 * PtPrmm; H: 594 * PtPrmm),
(Name: 'A3 Transverse 297 x 420 mm'; W: 297 * PtPrmm; H: 420 * PtPrmm),
(Name: 'A3 Extra Transverse 322 x 445 mm'; W: 322 * PtPrmm; H: 445 * PtPrmm),
(Name: 'Japanese Double Postcard 200 x 148 mm'; W: 200 * PtPrmm; H: 148 * PtPrmm),
(Name: 'A6 105 x 148 mm'; W: 105 * PtPrmm; H: 148 * PtPrmm),
(Name: 'Japanese Envelope Kaku #2'; W: 0; H: 0),
(Name: 'Japanese Envelope Kaku #3'; W: 0; H: 0),
(Name: 'Japanese Envelope Chou #3'; W: 0; H: 0),
(Name: 'Japanese Envelope Chou #4'; W: 0; H: 0),
(Name: 'Letter Rotated 11 x 8 1/2 11 in'; W: 11 * PtPrIn; H: 8.5 * PtPrIn),
(Name: 'A3 Rotated 420 x 297 mm'; W: 420 * PtPrmm; H: 297 * PtPrmm),
(Name: 'A4 Rotated 297 x 210 mm'; W: 297 * PtPrmm; H: 210 * PtPrmm),
(Name: 'A5 Rotated 210 x 148 mm'; W: 210 * PtPrmm; H: 148 * PtPrmm),
(Name: 'B4 (JIS) Rotated 364 x 257 mm'; W: 364 * PtPrmm; H: 257 * PtPrmm),
(Name: 'B5 (JIS) Rotated 257 x 182 mm'; W: 257 * PtPrmm; H: 182 * PtPrmm),
(Name: 'Japanese Postcard Rotated 148 x 100 mm'; W: 148 * PtPrmm; H: 100 * PtPrmm),
(Name: 'Double Japanese Postcard Rotated 148 x 200 mm'; W: 148 * PtPrmm; H: 200 * PtPrmm),
(Name: 'A6 Rotated 148 x 105 mm'; W: 148 * PtPrmm; H: 105 * PtPrmm),
(Name: 'Japanese Envelope Kaku #2 Rotated'; W: 0; H: 0),
(Name: 'Japanese Envelope Kaku #3 Rotated'; W: 0; H: 0),
(Name: 'Japanese Envelope Chou #3 Rotated'; W: 0; H: 0),
(Name: 'Japanese Envelope Chou #4 Rotated'; W: 0; H: 0),
(Name: 'B6 (JIS) 128 x 182 mm'; W: 128 * PtPrmm; H: 182 * PtPrmm),
(Name: 'B6 (JIS) Rotated 182 x 128 mm'; W: 182 * PtPrmm; H: 128 * PtPrmm),
(Name: '12 x 11 in'; W: 12 * PtPrIn; H: 11 * PtPrIn),
(Name: 'Japanese Envelope You #4'; W: 0; H: 0),
(Name: 'Japanese Envelope You #4 Rotated'; W: 0; H: 0),
(Name: 'PRC 16K 146 x 215 mm'; W: 146 * PtPrmm; H: 215 * PtPrmm),
(Name: 'PRC 32K 97 x 151 mm'; W: 97 * PtPrmm; H: 151 * PtPrmm),
(Name: 'PRC 32K(Big) 97 x 151 mm'; W: 97 * PtPrmm; H: 151 * PtPrmm),
(Name: 'PRC Envelope #1 102 x 165 mm'; W: 102 * PtPrmm; H: 165 * PtPrmm),
(Name: 'PRC Envelope #2 102 x 176 mm'; W: 102 * PtPrmm; H: 176 * PtPrmm),
(Name: 'PRC Envelope #3 125 x 176 mm'; W: 125 * PtPrmm; H: 176 * PtPrmm),
(Name: 'PRC Envelope #4 110 x 208 mm'; W: 110 * PtPrmm; H: 208 * PtPrmm),
(Name: 'PRC Envelope #5 110 x 220 mm'; W: 110 * PtPrmm; H: 220 * PtPrmm),
(Name: 'PRC Envelope #6 120 x 230 mm'; W: 120 * PtPrmm; H: 230 * PtPrmm),
(Name: 'PRC Envelope #7 160 x 230 mm'; W: 160 * PtPrmm; H: 230 * PtPrmm),
(Name: 'PRC Envelope #8 120 x 309 mm'; W: 120 * PtPrmm; H: 309 * PtPrmm),
(Name: 'PRC Envelope #9 229 x 324 mm'; W: 229 * PtPrmm; H: 324 * PtPrmm),
(Name: 'PRC Envelope #10 324 x 458 mm'; W: 324 * PtPrmm; H: 458 * PtPrmm),
(Name: 'PRC 16K Rotated 215 x 146 mm'; W: 215 * PtPrmm; H: 146 * PtPrmm),
(Name: 'PRC 32K Rotated 151 x 97 mm'; W: 151 * PtPrmm; H: 97 * PtPrmm),
(Name: 'PRC 32K(Big) Rotated 151 x 97 mm'; W: 151 * PtPrmm; H: 97 * PtPrmm),
(Name: 'PRC Envelope #1 Rotated 165 x 102 mm'; W: 165 * PtPrmm; H: 102 * PtPrmm),
(Name: 'PRC Envelope #2 Rotated 176 x 102 mm'; W: 176 * PtPrmm; H: 102 * PtPrmm),
(Name: 'PRC Envelope #3 Rotated 176 x 125 mm'; W: 176 * PtPrmm; H: 125 * PtPrmm),
(Name: 'PRC Envelope #4 Rotated 208 x 110 mm'; W: 208 * PtPrmm; H: 110 * PtPrmm),
(Name: 'PRC Envelope #5 Rotated 220 x 110 mm'; W: 220 * PtPrmm; H: 110 * PtPrmm),
(Name: 'PRC Envelope #6 Rotated 230 x 120 mm'; W: 230 * PtPrmm; H: 120 * PtPrmm),
(Name: 'PRC Envelope #7 Rotated 230 x 160 mm'; W: 230 * PtPrmm; H: 160 * PtPrmm),
(Name: 'PRC Envelope #8 Rotated 309 x 120 mm'; W: 309 * PtPrmm; H: 120 * PtPrmm),
(Name: 'PRC Envelope #9 Rotated 324 x 229 mm'; W: 324 * PtPrmm; H: 229 * PtPrmm),
(Name: 'PRC Envelope #10 Rotated 458 x 324 mm'; W: 458 * PtPrmm; H: 324 * PtPrmm),
(Name: 'Custom size'; W: 0; H: 0));
constructor TfrxPrinter.Create(const AName, APort: String);
begin
inherited Create(AName, APort);
end;
destructor TfrxPrinter.Destroy;
begin
inherited;
end;
procedure TfrxPrinter.Init;
function FindLinuxPaper(w, h: Integer): Integer;
var
I: Integer;
p: TPaperInfo;
lw,lh: Integer;
begin
Result := 0;
for I := 0 to Length(PaperInfo) - 1 do
begin
p := PaperInfo[I];
lw :=p.X;
lh :=p.Y;
if ((w >= lw - 6) and (w <= lw + 6)) and ((h >= lh - 6) and (h <= lh + 6)) then
begin
Result := I;
Break;
end;
end;
end;
procedure FillPapers;
var
i,k: Integer;
fw, fh: Integer;
begin
for I := 0 to PAPERCOUNT - 1 do
begin
fw := PaperInfo[I].X;
fh := PaperInfo[I].Y;
k := FindLinuxPaper(fw, fh);
if k > 0 then
FPapers.AddObject(LCLPaperInfo[i].Name, TObject(PaperInfo[k].Typ));
end;
end;
procedure AssignActivePrinter;
var
i: Integer;
begin
for i := 0 to FMX.Printer.Printer.Count - 1 do
if TPrinterLinux(FMX.Printer.Printer).Printers[i].Device = Name then
TPrinterLinux(FMX.Printer.Printer).ActivePrinter:=
TPrinterLinux(FMX.Printer.Printer).Printers[i];
end;
begin
AssignActivePrinter;
if FInitialized then Exit;
UpdateDeviceCaps;
FDefOrientation := TPrinterLinux(FMX.Printer.Printer).Orientation;
FOrientation := FDefOrientation;
FDefPaper := 256;
FDefBin := 0;
FDefDuplex := 0;
FPaper := FDefPaper;
FDefPaperWidth := FPaperWidth;
FDefPaperHeight := FPaperHeight;
FOrientation := FDefOrientation;
FillPapers;
FBin := -1;
FDuplex := -1;
FInitialized := True;
FBin := -1;
FDuplex := -1;
FInitialized := True;
end;
procedure TfrxPrinter.Abort;
begin
TPrinterLinux(FMX.Printer.Printer).Abort;
end;
procedure TfrxPrinter.BeginDoc;
begin
FPrinting := True;
FCanvas := TPrinterLinux(FMX.Printer.Printer).Canvas;
FIsFirst := True;
if FTitle <> '' then
TPrinterLinux(FMX.Printer.Printer).Title := FTitle
else
TPrinterLinux(FMX.Printer.Printer).Title := 'Fast Report Document';
UpdateDeviceCaps;
TPrinterLinux(FMX.Printer.Printer).BeginDoc;
FCanvas := TPrinterLinux(FMX.Printer.Printer).Canvas;
end;
procedure TfrxPrinter.BeginPage;
begin
inherited;
if not (FIsFirst) then
begin
TPrinterLinux(FMX.Printer.Printer).NewPage;
TPrinterLinux(FMX.Printer.Printer).Canvas.BeginScene;
end;
FIsFirst := False;
end;
procedure TfrxPrinter.EndDoc;
var
LSettings: TFmuxPageSettings;
begin
TPrinterLinux(FMX.Printer.Printer).EndDoc;
FmuxGetPageSettings(LSettings);
FPaperWidth := LSettings.Width * 25.4 / 96;
FPaperHeight := LSettings.Height * 25.4 / 96;
{$IFDEF DELPHI25}
try
if TPrinterLinux(FMX.Printer.Printer).Canvas.BeginSceneCount > 0 then
TPrinterLinux(FMX.Printer.Printer).Canvas.EndScene;
except
end;
{$ELSE}
TPrinterLinux(FMX.Printer.Printer).Canvas.EndScene;
{$ENDIF}
FPrinting := False;
THackPrinter(FMX.Printer.Printer).FPrinting := False;
FBin := -1;
FDuplex := -1;
end;
procedure TfrxPrinter.EndPage;
begin
//todo
end;
procedure TfrxPrinter.BeginRAWDoc;
begin
//todo
end;
procedure TfrxPrinter.EndRAWDoc;
begin
//todo
end;
procedure TfrxPrinter.WriteRAWDoc(const buf: AnsiString);
begin
//todo
end;
procedure TfrxPrinter.SetViewParams(APaperSize: Integer;
APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation);
begin
FPaper := APaperSize;
FOrientation := AOrientation;
if APaperSize <> 256 then
begin
FPaperHeight := LCLPaperInfo[FPaper].H;
FPaperWidth := LCLPaperInfo[FPaper].W;
if not UpdateDeviceCaps then Exit;
end
else
begin
// copy the margins from A4 paper
SetViewParams(DMPAPER_A4, 0, 0, AOrientation);
FPaperHeight := APaperHeight;
FPaperWidth := APaperWidth;
end;
end;
function TfrxPrinter.ShowPrintDialog: Boolean;
begin
Result := False;
end;
procedure TfrxPrinter.SetPrintParams(APaperSize: Integer;
APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation;
ABin, ADuplex, ACopies: Integer);
var
LPaperHeight, LPaperWidth: Double;
begin
{ later fix these values }
FPaper := APaperSize;
if TPrinterLinux(FMX.Printer.Printer).Orientation <> AOrientation then
begin
if FPrinting then
begin
EndDoc;
TPrinterLinux(FMX.Printer.Printer).Orientation := AOrientation;
BeginDoc;
end
else
TPrinterLinux(FMX.Printer.Printer).Orientation := AOrientation;
end;
LPaperHeight := FPaperHeight * FDPI.Y / 96;
LPaperWidth := FPaperWidth * FDPI.X / 96;
{$IFDEF DELPHI18}
TPrinterLinux(FMX.Printer.Printer).Canvas.SetSize(Round(LPaperWidth), Round(LPaperHeight));
{$ELSE}
TPrinterLinux(FMX.Printer.Printer).Canvas.ResizeBuffer(Round(LPaperWidth), Round(LPaperHeight);
{$ENDIF}
FOrientation := AOrientation;
UpdateDeviceCaps;
end;
function TfrxPrinter.UpdateDeviceCaps: Boolean;
var
Idx: Integer;
LSettings: TFmuxPageSettings;
begin
FCanvas := TPrinterLinux(FMX.Printer.Printer).Canvas;
Idx := TPrinterLinux(FMX.Printer.Printer).ActivePrinter.ActiveDPIIndex;
if Idx <> -1 then
begin
FDPI.X := TPrinterLinux(FMX.Printer.Printer).ActivePrinter.DPI[Idx].X;
FDPI.y := TPrinterLinux(FMX.Printer.Printer).ActivePrinter.DPI[Idx].Y;
end
else if TPrinterLinux(FMX.Printer.Printer).ActivePrinter.DPICount > 0 then
begin
FDPI.X := TPrinterLinux(FMX.Printer.Printer).ActivePrinter.DPI[0].X;
FDPI.y := TPrinterLinux(FMX.Printer.Printer).ActivePrinter.DPI[0].Y;
end
else
begin
FDPI := System.Classes.Point(72, 72);
end;
FmuxGetPageSettings(LSettings);
FPaperWidth := LSettings.Width * 25.4 / 96; // DPI / DPI
FPaperHeight := LSettings.Height * 25.4 / 96; // DPI / DPI
FLeftMargin := LSettings.Margins.Left * 25.4 / 96; // mm per Inch / DPI = mm
FTopMargin := LSettings.Margins.Top * 25.4 / 96; // DPI
FRightMargin := LSettings.Margins.Right * 25.4 / 96; // DPI
FBottomMargin := LSettings.Margins.Bottom * 25.4 / 96; // DPI
Result := True;
end;
procedure TfrxPrinter.PropertiesDlg;
begin
end;
{ TfrxPrinters }
constructor TfrxPrinters.Create;
begin
Inherited;
end;
destructor TfrxPrinters.Destroy;
begin
inherited;
end;
function TfrxPrinters.GetDefaultPrinter: String;
begin
Result := TPrinterLinux(FMX.Printer.Printer).ActivePrinter.Device;
end;
procedure TfrxPrinters.FillPrinters;
var
i: Integer;
procedure AddPrinter(ADevice, APort: String);
begin
FPrinterList.Add(TfrxPrinter.Create(ADevice, APort));
FPrinters.Add(ADevice);
end;
begin
Clear;
for i := 0 to TPrinterLinux(FMX.Printer.Printer).Count - 1 do
AddPrinter(FMX.Printer.Printer.Printers[i].Device, TPrinterLinux(FMX.Printer.Printer).Printers[i].Port);
end;
function ActualfrxPrinterClass : TfrxCustomPrintersClass;
begin
Result := TfrxPrinters;
end;
initialization
finalization
end.