|
When you specify the size of a graphical object using height= or
width=, you are merely stating a preference. The Curl layout
system will attempt to give every object its preferred size, but
if that is not possible it will make adjustments accordingly.
The simplest way to get the actual size of a Graphic object g is
to use get-bounds:
{let b:GRect = {g.layout.get-bounds}
This causes a layout negotiation to occur (if needed) and returns
the bounding rectangle for g. You can use operations like b.width
and b.height to get the actual height and width of g.
Note that the graphic hierarchy is automatically laid out and
then painted on the screen when your applet is first loaded. If
you resize the window, both layout and repaint will be repeated. If
you cover and uncover the window, only the repaint process will be
repeated.
If you're writing a subclass of Graphic and you want to do
something each time the size of a graphic is updated, you can
override the set-size method. The Layout process ends with a
bottom-up treewalk where each Graphic is assigned its actual size
by calling the set-size method on the object. The set-size method
is passed a rectangle (GRect) that represents the bounding box of
your object. You can do any processing that requires the exact
size at that time.
|