LCL, reworked how the printer obtains it's default canvas class

git-svn-id: trunk@24483 -
This commit is contained in:
jesus 2010-04-07 07:09:23 +00:00
parent ff08093f2f
commit 6a922e35dd
3 changed files with 35 additions and 26 deletions

View File

@ -697,11 +697,6 @@ begin
end;
end;
function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
begin
Result:=CupsCanvasClass;
end;
//Override this methode for assign an
//file name at Canvas
procedure TCUPSPrinter.DoBeginDoc;
@ -1186,6 +1181,11 @@ begin
end;
end;
function TCUPSPrinter.DoGetDefaultCanvasClass: TPrinterCanvasRef;
begin
Result := TPostscriptPrinterCanvas;
end;
function TCUPSPrinter.GetPrinterType: TPrinterType;
Var i : Integer;
begin

View File

@ -104,8 +104,6 @@ type
procedure DebugPPD;
{$ENDIF}
protected
function GetCanvasRef : TPrinterCanvasRef; override;
procedure DoBeginDoc; override;
procedure DoEndDoc(aAborted : Boolean); override;
@ -125,6 +123,7 @@ type
function DoGetPaperRect(aName : string;
var aPaperRc: TPaperRect): Integer; override;
function DoGetPrinterState: TPrinterState; override;
function DoGetDefaultCanvasClass: TPrinterCanvasRef; override;
function GetPrinterType : TPrinterType; override;
function GetCanPrint : Boolean; override;
@ -165,7 +164,3 @@ type
procedure MergeOptions(const AOptions:Pcups_option_t; const n:Integer);
property CupsPPD:Pppd_file_t read fcupsPPD;
end;
Var
CupsCanvasClass : TFilePrinterCanvasClass = TPostscriptPrinterCanvas;

View File

@ -196,9 +196,11 @@ type
//fCapabilities: TPrinterCapabilities;
fPaperSize : TPaperSize;
fRawMode : Boolean;
fCanvasClass : TPrinterCanvasRef;
function GetCanvas: TCanvas;
procedure CheckPrinting(Value: Boolean);
function GetCanvasClass: TPrinterCanvasRef;
function GetCopies: Integer;
function GetFonts: TStrings;
function GetOrientation: TPrinterOrientation;
@ -207,6 +209,7 @@ type
function GetPaperSize: TPaperSize;
function GetPrinterIndex: integer;
function GetPrinters: TStrings;
procedure SetCanvasClass(const AValue: TPrinterCanvasRef);
procedure SetCopies(AValue: Integer);
procedure SetOrientation(const AValue: TPrinterOrientation);
procedure SetPrinterIndex(AValue: integer);
@ -214,8 +217,6 @@ type
protected
procedure SelectCurrentPrinterOrDefault;
function GetCanvasRef : TPrinterCanvasRef; virtual;
procedure DoBeginDoc; virtual;
procedure DoNewPage; virtual;
procedure DoEndDoc(aAborded : Boolean); virtual;
@ -245,6 +246,7 @@ type
procedure CheckRawMode(const Value: boolean; Msg:string='');
procedure RawModeChanging; virtual;
procedure PrinterSelected; virtual;
function DoGetDefaultCanvasClass: TPrinterCanvasRef; virtual;
public
constructor Create; virtual;
destructor Destroy; override;
@ -267,6 +269,7 @@ type
property FileName: string read FFileName write FFileName;
property Fonts: TStrings read GetFonts;
property Canvas: TCanvas read GetCanvas;
property CanvasClass: TPrinterCanvasRef read GetCanvasClass write SetCanvasClass;
property PageHeight: Integer read GetPageHeight;
property PageWidth: Integer read GetPageWidth;
property PageNumber : Integer read fPageNumber;
@ -483,10 +486,10 @@ begin
if not Assigned(fCanvas) then
begin
if not Assigned(GetCanvasRef) then
raise Exception.Create('TCanvas not defined.');
if not Assigned(CanvasClass) then
raise Exception.Create('Canvas Class not defined.');
fCanvas:=GetCanvasRef.Create(Self);
fCanvas:=CanvasClass.Create(Self);
end;
Result:=fCanvas;
@ -504,6 +507,17 @@ begin
end;
end;
function TPrinter.GetCanvasClass: TPrinterCanvasRef;
begin
if FRawMode then
result := nil
else
if FCanvasClass=nil then
Result := DoGetDefaultCanvasClass
else
Result := FCanvasClass;
end;
procedure TPrinter.CheckRawMode(const Value:boolean; msg:string ='');
begin
if FRawMode<>Value then
@ -526,6 +540,11 @@ procedure TPrinter.PrinterSelected;
begin
end;
function TPrinter.DoGetDefaultCanvasClass: TPrinterCanvasRef;
begin
result := TPrinterCanvas;
end;
//Get current copies number
function TPrinter.GetCopies: Integer;
Var i : Integer;
@ -604,6 +623,11 @@ begin
end;
end;
procedure TPrinter.SetCanvasClass(const AValue: TPrinterCanvasRef);
begin
FCanvasClass := AValue;
end;
//Return XDPI
function TPrinter.GetXDPI: Integer;
begin
@ -670,16 +694,6 @@ begin
PrinterIndex:=0;
end;
//Specify here the Canvas class used by your TPrinter object
function TPrinter.GetCanvasRef: TPrinterCanvasRef;
begin
if FRawMode then
result := nil
else
Result:=TPrinterCanvas;
end;
procedure TPrinter.DoBeginDoc;
begin
//Override this methode