GEOS SDK TechDocs
|
|
2.2 Orienting Children
|
2.4 Sizing Objects
Although child justification defaults to whatever the specific UI normally uses, you can set the justification of a composite's children with several different hints.
Typically, horizontal composites will have their children top-justified and vertical composites will have left-justified children (as shown in the previous examples).
HINT_TOP_JUSTIFY_CHILDREN, HINT_BOTTOM_JUSTIFY_CHILDREN, HINT_LEFT_JUSTIFY_CHILDREN, HINT_RIGHT_JUSTIFY_CHILDREN
If you want to line all of a composite's children up on one of their edges, you should use one of these hints. They are self-explanatory; the edge specified in the name of the hint (top, left, etc.) is the edge of the composite along which all the children will appear.
Add the justification hints along with an orientation hint. Examples of justification are shown in the figure below.
HINT_ALIGN_LEFT_EDGE_WITH_OBJECT, HINT_ALIGN_TOP_EDGE_WITH_OBJECT, HINT_ALIGN_RIGHT_EDGE_WITH_OBJECT, HINT_ALIGN_BOTTOM_EDGE_WITH_OBJECT
These hints align an object's respective edge with the same edge of another object; the optr of the other object is the hint's argument. The other object does not necessarily have to be a direct sibling or parent, but the result must not cause the object to stray outside its parent's bounds.
HINT_CENTER_CHILDREN_VERTICALLY, HINT_CENTER_CHILDREN_HORIZONTALLY
Often, rather than justifying a composite's children, you will want to center them. These two hints allow you to center the children as shown in the figure below.
HINT_FULL_JUSTIFY_CHILDREN_HORIZONTALLY, HINT_FULL_JUSTIFY_CHILDREN_VERTICALLY, HINT_DONT_FULL_JUSTIFY_CHILDREN, HINT_INCLUDE_ENDS_IN_CHILD_SPACING, HINT_DONT_INCLUDE_ENDS_IN_CHILD_SPACING
Besides justifying the composite's children either on a single edge or on the center line of the composite, you might want to full-justify the children. To do this, you will want to give the composite an orientation first (either vertical or horizontal). The composite may also require a special sizing hint to expand its bounds--see
HINT_EXPAND_WIDTH_TO_FIT_PARENT
and the other sizing hints in Sizing Objects
.
If the full justification hint is in the same dimension as the orientation of the composite (e.g.,
HINT_FULL_JUSTIFY_CHILDREN_HORIZONTALLY
and
HINT_ORIENT_CHILDREN_HORIZONTALLY
), then the geometry manager will divide up the entire space of the composite and spread the children out equally along it. If you also specify
HINT_INCLUDE_ENDS_IN_CHILD_SPACING
, the geometry manager will calculate the spacing as if there were one more child than there actually is; it will then put half the extra space on either end of the children. HINT_DONT_INCLUDE_ENDS_IN_CHILD_SPACING performs the default calculations. Examples of various full justification are shown in the figure below. See Using Full Justification of Children
for the code required to implement this full justification behavior.
Typically, full justification is not implemented by default. Some specific UIs may try to full-justify children always; if you want the children non-justified (when possible), apply
HINT_DONT_FULL_JUSTIFY_CHILDREN
. Added spacing is also typically not turned on by default; you can ensure that added spacing will not be included (where possible) by applying the hint
HINT_DONT_INCLUDE_ENDS_IN_CHILD_SPACING
to your composite.
GEOS SDK TechDocs
|
|
2.2 Orienting Children
|
2.4 Sizing Objects