Next: , Previous: Object interface, Up: Interface reference



8.2.8 Painter interface

An interface for painters – VCL backends. It does not have any interesting public methods.

Every object implementing the painter interface must also implement the object interface.

A painter should walk through the VCL node tree and draw the appropriate nodes. Common walking logic can be handled (in implementation of the painter interface) by using struct context.

Painting methods

These painting methods share a common structure of arguments – node is the current drawing node, bbox is the bbox to be redrawn in pixel coordinates, bbox_local is the bbox to be redrawn in the node's coordinate system (in case of _draw_node or _draw_leaf), or the node's children coordinate system (in case of _draw_composite – to match the coordinate system of vcl_composite_get_children).

A painter is supposed to be used as a sequence of calls of _draw_begin, _draw_node on the root node and _draw_end. The _draw_node function is supposed to draw the node (and, in case of composite, all its descendants, too). The remaining two functions are used in a case of implementing _draw_node using struct context and its recursive decomposing. In that case, in _draw_node, a dispatch and enclosure handling are done, for leaf handling _draw_leaf is called and for composite handling _draw_composite. _draw_leaf really draws a leaf and _draw_composite calls _draw_node on its children.

     vcl_painter_draw_begin (void * obj, const struct vcl_rectangle *bbox)
     
     vcl_painter_draw_end (void * obj)
     
     vcl_painter_draw_node (void * obj, void * node,
                            const struct vcl_rectangle *bbox,
                            const struct geom_rectangle *bbox_local)
     
     vcl_painter_draw_leaf (void * obj, void * node, const struct vcl_rectangle *bbox,
                            const struct geom_rectangle *bbox_local)
     
     vcl_painter_draw_composite (void * obj, void * node,
                                 const struct vcl_rectangle *bbox,
                                 const struct geom_rectangle *bbox_local)