CAIRO Base Driver

This driver represents a basic driver for all system-dependent drivers implemented in the X-Windows and MS-Windows systems. The implementation uses the Cairo and Pango functions. This driver can be compiled and used in all systems Cairo is supported. But the pre-compiled libraries will include it only in Linux. The drivers Native Window, Image, EMF, Printer and Double Buffer were also implemented.

It can be used as the context plus driver of the GDI, GDK and X-Win based drivers. But its primary focus is the GDK base driver, so the pre-compiled libraries will be available only in Linux.

The main motivation for the use of Cairo was transparency for all the primitives. Beyond that we got other features like anti-aliasing, gradient filling, transformations and other back-ends (support to rendering: PDF, PS, SVG and IMAGERGB surfaces).

This driver still does not completely replace the X-Windows, GDK and GDI Windows base drivers, because Cairo does not have support for bitwise XOR operations and for complex clipping regions.

So we let the programmer to choose what to use. We created the function cdUseContextPlus that allows to activate or to deactivate the use of Cairo for the available GDK, Win32 or X-Win based drivers. This function affects only the cdCreateCanvas function call, once created the canvas will be always a Cairo canvas. In fact the function affects primary the definitions CD_NATIVEWINDOW, CD_IMAGE, CD_EMF, CD_PRINTER and CD_DBUFFER, because they are function calls and not static defines. CD_PRINTER can be used with the GDK base driver in UNIX, or with the Win32 base driver in Windows. CD_EMF can be used in Windows only, with GDK or Win32 base drivers.

Using Cairo it is allowed to create more that one canvas at the same time for the same Window. And they can co-exist with a standard GDK, Win32 or X-Windows canvas.

To enable the use of Cairo based drivers in Linux when using GTK2, you must call the initialization function cdInitContextPlus once, and link to the library "cdcontextplus". In GTK3 Cairo is already the main driver, but it is not a problem to call cdInitContextPlus. In Windows you must link with the cdcairo.lib library.

IMPORTANT: when using GTK 3.x the Cairo driver is the main driver, because there is no support for drawing primitives in GDK since GTK 3.0. The cdUseContextPlus function will do nothing internally.

Also the Cairo library must be installed in your system.

In CDLua it is not necessary any additional initialization, and require"cdluacontextplus" can be used when using dynamic libraries.

Extra Drivers (cdcairo.h)

These are not ContextPlus drivers.

CD_CAIRO_PS - PostScript Driver

Similar to CD_PS, uses the same creation parameters. But margins are not supported and Postscript level can be 2 (parameter -2) or 3 (parameter -3). The "CMD" attribute is not supported, and the new attribute "DSCCOMMENT" accepts a string that is saved as a DSC comment.

CD_CAIRO_PDF - PDF Driver

Similar to CD_PDF, uses the same creation parameters. The driver also does not depends on the PDFLib. The additional attributes "OPACITY", "PATTERN", "PDF", "PDFLIBVERSION" and the description strings, are not supported.

CD_CAIRO_SVG - Scalable Vector Graphics Driver

Similar to CD_SVG, uses the same creation parameters. The additional attributes "OPACITY" and "CMD" are not supported.

CD_CAIRO_IMAGERGB - RGB Client Image Driver

Similar to CD_IMAGERGB, uses almost the same creation parameters. The main difference is that the data pointers are packed in RGBARGBARGBA... format. So it is used only 1 pointer for data, instead of 3. Also the attributes "REDIMAGE", "GREENIMAGE", "BLUEIMAGE" and "ALPHAIMAGE are not supported and replaced by the "RGBDATA" attribute. There are also two new attributes, "STRIDE" that returns the line size in bytes, when data is specified during creation then stride is always width*32. Even when there is not alpha channel, data is stored in 32 bits per pixel. Image data is also organized in top-bottom orientation, it means the data pointer points to the top-left corner. And the "WRITE2PNG" attribute that accepts a filename to save the image as a PNG file (this does not depends of the IM library).

Behavior of Functions

Control 

Coordinate System and Clipping

Primitives

Attributes

Colors

Exclusive Attributes