A figure defines -like a device- a collection of graphicals. In addition of class device, a figure offers:
figure ->clip_areaClip graphicals to this area graphical ->pen, graphical->textureDraw a box around the figure figure ->backgroundFill the background figure ->rotateTransform the image figure ->scaleTransform the image figure ->shearTransform the image
|{foreground,background}*->background:
background).<-status
of a figure is a name indicating which graphicals of the figure should
be visible: if figure<-status
equals all_active, all
device<-graphicals
are visible, otherwise only graphicals with the same name as figure<-status
are made visible.
This mechanism may be used to define graphical
objects that should be switched between different states. Consider the
example where we want to have a diagram which can be displayed opened
and as an icon. The code below outlines a possible
approach:
create_closable_diagram(F) :-
new(F, figure),
send(F, status, opened),
send(F, display, new(BM, bitmap('my_icon'))),
send(BM, name, closed),
send(BM, recogniser,
click_gesture(left, '', double,
message(F, status, opened),
send(F, display, new(F2, figure)),
send(F2, name, opened),
...
<create the real diagram on F2>
<-pen
to draw a visible frame at a distance from the contents.<-pen/figure<-elevation.
0 yields a square outline.elevation object describing a 3-D appearance (raised,
sunken, shadow, ...) of the figure's box. @nil
disables the effect. The legacy figure<->shadow
shortcut creates a shadow elevation.transform applied to the figure's
contents.
@nil means no
transform. The transform is applied to the children while drawing,
hit-testing and computing the bounding box, so a rotated/scaled figure
is still selectable by the mouse and reports a tight bounding box in its
parent's coordinates. The convenience methods figure->translate, figure->scale, figure->rotate
and figure->shear
compose operations into this transform without the caller having to
manage the transform
object explicitly.->compute.
Damage handling and child event dispatch use this to keep paint and hit
tests correct under rotation/scale.
->initialise,
it assigns figure<-background
to @nil, graphical<-pen
to 0 and figure<-status
to all_active.<-local_area,
update the bounding box and propagate figure<-transform
into the parent-coordinate area. Triggered automatically after slot
changes; rarely called directly.->display,
but if figure<-status
not is all_active and the graphical has not the same name, the graphical
is added to the figure with graphical<-displayed: @off.<-status
to the name of the next graphical in
device<-graphicals
(wrapping at the end). No-op when figure<-status
is
all_active. Convenient for cycling through alternative
representations.elevation(kind := shadow, height := N)
and assigning it via figure->elevation.translate(dx, dy) into figure<-transform.
Creates the transform on demand (starting from identity).scale(sx, sy) into figure<-transform.
When sy is omitted the same factor is applied to both axes.rotate(degrees) into figure<-transform.
Composition follows cairo's convention: the operation is applied to the
input first, then the existing transform on top.shear(kx, ky) into figure<-transform.shadow slot into an
elevation.
->clip_area,
or @nil if no
clipping is active.<-elevation
when the elevation kind is shadow, 0 otherwise.