
These two use the same edge for the constrained window and the
constraining window; that is, if you specify lmLeft for edge, the left edge of
your child window is constrained to the left edge of otherWin.
A single layout constraint is not enough to lay out a window. For example,
Defining
specifying that one window must be 10 pixels below another window
constraining
doesn’t tell you anything about the width or height of the window the,
relationships
location of the left or right borders, or the location of the bottom border It.
only tells you that one edge is located 10 pixels below another window.
A combination of layout constraints can define fully a window’ locations
(there are some exceptions, as discussed on page 160). The class
TLayoutMetrics uses four layout constraint structures—two TEdgeConstraint
objects named X and Y, a TEdgeOrWidthConstraint named Width, and a
TEdgeOrHeightConstraint named Height.
TLayoutMetrics is a fairly simple class. The constructor takes no parameters.
The only thing it does is to set up each layout constraint member For each.
layout constraint,
■ The constraining window is zeroed out.
■ The relationship is set to lmAsIs.
■ Units are set to lmLayoutUnits.
■ The value is set to 0.
The only difference is to MyEdge, which indicates to which edge of the
window this constraint applies. X is set to lmLeft, Y is set to lmT p, Width iso
set to lmWidth, and Height is set to lmHeight.
Once you have constructed a TLayoutMetrics object, you need to set the
layout constraints for the window you want to lay out. Y u can use theo
functions described in the preceding section for setting each layout
constraint.
It is important to realize that the labels X, Y, Width, and Height are more
labels of convenience than strict rules on how the constraints should be
used. X can represent the X coordinate of the left edge, the right edge, or
the center Y u can combine this with the Width constraint—which can be. o
one of lmCenter, lmRight, or lmWidth—to completely define the window’s
X-axis location and width. Using all of the edge constraints is easy and is,
useful in situations where tiling is performed.
The simplest way is to assign an X coordinate to X and a width to width.
But you could also set the edge for X to lmCenter and the edge for Width to
lmRight. So Width doesn’t really represent a width, but the X-coordinate of
Chapter 6, Window objects
159