[fpc-pascal] Using the FPCanvas unit (in fpGUI)

Michael Van Canneyt michael at freepascal.org
Sat May 5 22:51:16 CEST 2007



On Fri, 4 May 2007, Graeme Geldenhuys wrote:

> Hi,
> 
> If I wanted to start using the FPCanvas unit as a set of base classes
> for fpGUI (my custom drawn widget set), what do I need to do, or
> implement.  Is there any documentation on that unit.
> 
> Take the Font class as an example.  Looking at the TFPCustomFont
> class.  I guess I would need to create a descendant class (TFFont in
> this case) and then override the abstract methods (in this case
> virtual or some reason) for each supported painting backend (GDI, X11)
> to create the correct resources.
> 
> TFFont = class(TFPCustomFont)
>  ...<snip>...
>  protected
>    procedure DoAllocateResources; override;
>    procedure DoDeAllocateResources; override;
>   ...<snip>...
> end;
> 
> 
> Am I understanding this correctly?

Yes.

> Is this what the FPCanvas unit is meant for?  Acting as a base class
> for an actual implementation?

Absolutely. The idea is that all graphic routines base themselves
on TFPCustomCanvas, so that any drawing routine works on all canvases.

There are currently 2 implementations: TImageCanvas which draws on a bitmap,
and TPostScriptCanvase which creates a postscript file. What concerns the latter,
one day it should be 'merged' (as in 'take the best of the 2') with the pscanvas
in Lazarus. The resulting canvas can be independent of Lazarus, and can be distributed
with FPC, so fpGUI and other frameworks can also benefit from it. 

Obviously, there is also the Lazarus canvas, which is also a descendent of TFPCustomCanvas.

Michael.



More information about the fpc-pascal mailing list