Next: , Previous: The purpose of VCL, Up: VCL Overview

8.1.2 VCL general usage

The library must be initialised by calling the vcl_init() function. After that, the programmer can create a new VCL canvas with the vcl_canvas_new() function, set its options with vcl_canvas_setup() and set the root VCL widget of that canvas with vcl_canvas_set_root(). After that, the programmer can take (from canvas -> gtk -> widget) a GTK DrawingArea widget containing VCL canvas and use it in a GTK application. Now you can insert, remove, or alter any children VCL widgets (in the root VCL widget) and everything is redrawn automatically. The library is not limited to one canvas, there may be several canvases at the same time.

The programmer should include exactly one of the vcl.h (for common usage) and vcl_internal.h (common usage and additional access to hidden internal function) headers.

VCL uses its own object system based on the interfaces and implementations paradigm. Interface oriented functions are dispatched in a way based on the first argument's class. Each class can implement many interfaces. The object system has some introspection abilities – an object can be asked whether it supports a specific interface, and so on. There is kind of interface hierarchy: if a class A implements interface B, then it has to implement an ancestor interface C as well.