
CHAPTER 3 Layout
As an example, lets wrap the vbox of figure 3-3 inside a monoglyph that prints debug information to standard output.
GlyphVar debugged_vbox = new DebugGlyph( vbox, "vbox", DebugGlyph::trace_request );The wrapped vbox can still be placed into the hbox:
hbox->append(debugged_vbox);because the drawing and other behavior is delegated to the body vbox. The constant DebugGlyph::trace_request tells the DebugGlyph how much of its body's behavior to redefine. "Trace_request" means just print the debug information when the Glyph::Request() operation is called.
When the program is run, the component displays and interacts exactly as before, except now a message is print to standard output each time the hbox calls request on its child vbox:
vbox(0x3abb8) request 225.00, 170.00 @ 1.0, undefThis shows that the vbox requests a "natural size" of 225.00 in the X dimension (with alignment = 0.0) and a natural size of 170.00 in the Y dimension with an alignment of 1.0. The Z dimension is undefined. Note that this verifies our hypothesis that vboxes request vertical alignments of 1.0.
As a second example of dynamically modifying behavior, let's wrap the buttons of figure 3-1 with monoglyphs that change their horizontal alignment so that we get a "stairstep" effect. As shown in the following code, we get these monoglyphs from the layout kit. This code results in the layout shown in figure 3-8.
Glyph_var vbox = layouts->vbox(); vbox->append(Glyph_var(layouts->halign(button1, 1.0))); vbox->append(Glyph_var(layouts->halign(button2, 0.5))); vbox->append(button3); Glyph_var margin = layouts->margin(vbox, 15.0); FrescoLib::run(nil, margin);Fresco's layout kit provides various type of monoglyphs which override their bodys as follows:

We'll explore natural size, stretchability, and shrinkability in the next section.
Generated with CERN WebMaker