Although this procedure can be used within any container, it was designed for use within a
TextFlowBox, and the descriptions of its use are given with that in mind.
If
g is sufficiently stretchy (has a stretch order equal to or greater than proportional-stretch-order), it will be stretched to the width used for laying out text.
If
g is not sufficiently stretchy, it can be made more stretchy by setting the object's
Graphic.width option to a
{add-stretch}; see
add-stretch for more information.
This procedure can be used to align contents to the left or right text's layout width through the appropriate use of
HBox and
Fill.
To create a colored stripe across a page:
| Example |
 |
{text-width-display {Fill height=10pt, background="yellow"}}
| |
To align some text to the right side of a page:
| Example |
 |
{text-width-display {HBox {Fill}, {paragraph April 19, 1775}}}
| |
To align text to both right and left sides of a page:
| Example |
 |
{text-width-display
{HBox
{paragraph Lexington},
{Fill},
{paragraph April 19, 1775}
}
}
| |
To convince a rigid object to stretch across a page:
| Example |
 |
{text-width-display
{CommandButton width={add-stretch}, label="Push me!"}
}
| |