[Lazarus] TCairoCanvas integration

Michael Van Canneyt michael at freepascal.org
Thu Mar 11 14:23:15 CET 2010



On Thu, 11 Mar 2010, petr.kristan at epos.cz wrote:

> On Wed, Mar 10, 2010 at 03:22:31PM +0100, petr.kristan at epos.cz wrote:
>> Hi.
>>
>> Main work on TCairoCanvas = class(TPrinterCanvas) is almost done.
>>
>> My question is how to integrate it into LCL?
>> IMHO user should have a choice which TPrinterCanvas implementation use.
>> Now in TCUPSPrinter is hard coded TPostscriptPrinterCanvas:
>>
>> function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
>> begin
>>   Result:=TPostscriptPrinterCanvas;
>> end;
>>
>> Petr
>>
> Nobody here, who can halp me to integrate TCairoCanvas into LCL?
>
> Were in LCL directory structure place cairocanvas.pas (depends only on
> libcairo) and gdkcairocanvas.pas (depends extra on libgdk).
>
> How should programer select which implementation of TPrinterCanvas will
> be created in TPrinter.GetCanvas.
>
> Now TCUPSPrinter implementation use hard coded TPostscriptPrinterCanvas
> and needs access to TPostscriptPrinterCanvas(Canvas).OutputFileName.
> My TCairoCanvas implementation has the same needs.
>
> I do not want to waste my time if comunity do not have an interest to
> include CairoCanvas into lcl.

I think you should create an abstract TFilePrinterCanvas descendent of
TPrinterCanvas (with the needed FileName property) and define a variable

Type
   TFilePrinterCanvas = Class of TFilePrinterCanvas;

Var
   CupsCanvasClass : TFilePrinterCanvas = TPostscriptPrinterCanvas;

which the programmer can set, if so desired. then the
TCUPSPrinter.GetCanvasRef
implementation checks the CupsCanvasClass variable. If it is set,
it uses the class defined there, and if not, it uses
TPostscriptPrinterCanvas.

Michael.




More information about the Lazarus mailing list