Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-05

Using the FPCanvas unit (in fpGUI)

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

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?
Is this what the FPCanvas unit is meant for? Acting as a base class for an actual implementation?

Graeme Geldenhuys There's no place like S34° 03.168' E018° 49.342'

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 22 lines
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.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote 6 lines
> 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.

Thanks Michael. I'm starting work on this now in fpGUI.

Graeme Geldenhuys There's no place like S34° 03.168' E018° 49.342'

Reply by email