[AdgDress] First implementation
This class improves the styling behavior previously done by AdgContext.
The rendering customization is provided throught the interaction of the
following ADG components:
- AdgStyle and children
The styles, in their basic form, implement the apply() method that
should be called by the entities whenever needed to change the
behavior of the current cairo context.
- AdgDress
This is an abstraction layer to virtualize the styles. The entities
will always refer to dress instead of style, allowing to do some quite
complex operation such as overriding a specific style for a given
branch in the entity hierarchy or implementing different defaults
for the same style (such as providing diffent font for quote values
and tolerances). The latter would be possible also without AdgDress by
instantiating style singletons when required but AdgDress provides a
central point where all this defaults are grouped, leaving the door
opened to future improvements.
- AdgEntity
The entities are the natural consumers of styles. They provide APIs to
access styles directly, although internally they always use AdgDress
values. Furthermore, adg_entity_set_style() provides a way to override
the style of a specific dress for the subject entity and its children.
The main getter function is adg_entity_style(), which requires an
AdgDress value. The following operation are executed up to when a
defined style is found:
1. adg_entity_get_style(entity, dress);
check if the style is defined directly by this entity type, that
is if it was explicitely set with adg_entity_set_style();
2. adg_entity_style(parent, dress);
if the subject entity has a parent returns its style by recursively
call adg_entity_style() on the parent entity;
3. adg_dress_get_style(dress);
return the default style for the given AdgDress value.
Without any customization all the styles will be resolved by
adg_dress_get_style(), but this implementation gives a good level of
freedom, allowing the cascade overriding of a dress style with a
single adg_entity_set_style() call. When required, new AdgDress
values can be easily added with adg_dress_new(). Every dress always
requires a default style, just to be sure to resolve any request as
stated above.