[cairo] Cairo and FLTK?

Bill Spitzak spitzak at thefoundry.co.uk
Mon Oct 29 05:00:58 PDT 2007

The following code should return a cairo surfact_t that can be used to 
draw into an fltk window. You would call this inside your 
window/widget's draw() function:

/** Fltk cairo create surface function accepting a Window* as input */
cairo_surface_t* fltk::cairo_create_surface(Window* wi) {
   XWindow window = fltk::xid(wi);
   cairo_surface_t* surface =  cairo_xlib_surface_create(xdisplay, window,
				   xvisual->visual, wi->w(), wi->h());
   cairo_xlib_surface_set_size(surface, wi->w(), wi->h());
   return surface;

This function exists in fltk2 but only if it is compiled with the 
configuration USE_CAIRO option.

Kalle Vahlman wrote:
> 2007/10/29, Peter Meier <meier at irt.de>:
>> Hello to everybody!
>> Is there anyone out there who has experience in using cairo with FLTK?
>> Can anyone give me a hint or a short example?
> I don't know FLTK that well, but the basic requirements with
> integration to toolkits is that you can acquire a cairo surface for
> the platform resource (ie. X window usually) which means the toolkit
> API needs to expose this. I didn't see anything like that with a quick
> peek into the API docs, but that of course doesn't mean it's
> impossible.
> You'll also likely need a bit of knowledge about how the drawing model
> goes underneath the hood of the toolkit, as some do double-buffering
> so it's not always self-evident *where* you are drawing for example.
> When you get the platform resource there's all sort of quirks
> (specially with X11) in creating a surface of it, but once past those
> the usual cairo_create()-workflow should work.

Bill Spitzak, Senior Software Engineer
The Foundry, 1 Wardour Street, London, W1D 6PA, UK
Tel: +44 (0)20 7434 0449 * Fax: +44 (0)20 7434 1550 * Web: 
The Foundry Visionmongers Ltd * Registered in England and Wales No: 4642027

More information about the cairo mailing list