[Lazarus] Examples of CairoCanvas usage

Petr Kristan petr.kristan at epos.cz
Tue Feb 10 10:40:50 CET 2015


On Tue, Feb 10, 2015 at 10:43:34AM +0200, Juha Manninen wrote:
> On Tue, Feb 10, 2015 at 9:14 AM, Petr Kristan <petr.kristan at epos.cz> wrote:
> > My commandline program version must be linked with gtk in linux.
> > I use this construction:
> >
> > WidgetSet := TGtk2WidgetSet.Create;
> > DrawingRoutine;
> > FreeAndNil(WidgetSet);
> 
> How to use the WidgetSet?
> Can you please test with TextOut(), and maybe send a simple example
> program or application. I still have not found any.
> I would be happy to add an "example" directory below
> components\cairocanvas if you want.

Here is an linux working example:

{$mode objfpc}{$H+}
uses
  Classes, SysUtils, Gtk2Int, InterfaceBase, CairoCanvas,
GdkCairoCanvas, Printers;
var
  c: TFilePrinterCanvas;
begin
  WidgetSet := TGtk2WidgetSet.Create;
  c := TCairoPdfCanvas.Create(nil);
  c.OutputFileName := '/tmp/a.pdf';
  c.XDPI := 75;
  c.YDPI := 75;
  c.PaperWidth := 100;
  c.PaperHeight := 100;
  c.Font.Name := 'Arial';
  c.Font.Height := 12;
  c.TextOut(0, 0, 'Hello word');
  FreeAndNil(c);
  FreeAndNil(WidgetSet);
end.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401    Czech Republic (Eastern Europe)
fax: +420 461101481




More information about the Lazarus mailing list