GEOS SDK TechDocs
|
|
2.3 Justifying and Centering Children
|
2.5 Outlining the Composite
Sizing can occur in essentially one of two ways: First, the composite can size itself based on its children. Second, the children can size themselves based on their parent. You can specify additional sizing restrictions in the form of minimum, maximum, and fixed sizes.
HINT_NO_TALLER_THAN_CHILDREN_REQUIRE, HINT_NO_WIDER_THAN_CHILDREN_REQUIRE
A composite can size itself to be only as large as its children require. This may be applied to your primary window or to other organizational composites to keep them from growing into any extra space in their parents. You can set the width and height restrictions independently; to set them both, use both hints in the composite.
HINT_EXPAND_HEIGHT_TO_FIT_PARENT, HINT_EXPAND_WIDTH_TO_FIT_PARENT, HINT_DIVIDE_WIDTH_EQUALLY, HINT_DIVIDE_HEIGHT_EQUALLY
Often a composite will have a set size and its children will want to expand themselves to take up all the available space. For example, the interaction with the Apply, Reset, and Cancel triggers in the dialog box (shown in the figure below) must have
HINT_EXPAND_WIDTH_TO_FIT_PARENT
set for it to expand itself to the far right edge of the dialog box. Another potential situation is a GenView within a GenPrimary; when the user resizes the primary, the view should probably expand itself to take up any extra space in the window.
A third example would be a series of triggers that want to be the same width in a vertical composite. This appears in many menus; each of the triggers expands itself to the width of the parent; the parent composite sizes its width to the largest of the triggers. An example taken from the complex dialog box is shown in the figure above. Code for this example is shown in Using Full Justification of Children .
Some more complex examples of expanding a group and justifying the elements are shown in the figure below. All of the examples use a justification hint combined with an expand-to-fit hint.
Code Display 12-3 Using Full Justification of Children
/* This code display shows the basic Goc code that will get the configuration * shown in the figure above. Other attributes are left out of the * definitions of the objects. This code display is supplemental to * A Complex Dialog Box; most comments have been removed. */
@object GenInteractionClass TopInteraction = {
GI_comp = @ParaInteraction, @ReplyInteraction;
HINT_ORIENT_CHILDREN_VERTICALLY;
}
@object GenInteractionClass ParaInteraction = {
GI_comp = @FontInteraction, @JustInteraction, @StyleInteraction;
HINT_ORIENT_CHILDREN_HORIZONTALLY;
}
@object GenInteractionClass ReplyInteraction = {
GI_comp = @ApplyTrigger, @ResetTrigger, @CancelTrigger;
HINT_ORIENT_CHILDREN_HORIZONTALLY;
HINT_EXPAND_WIDTH_TO_FIT_PARENT;
HINT_FULL_JUSTIFY_CHILDREN_HORIZONTALLY;
HINT_INCLUDE_ENDS_IN_CHILD_SPACING;
}
@object GenInteractionClass FontInteraction = {
GI_comp = @RomanTrigger, @SansTrigger, @MonoTrigger;
HINT_ORIENT_CHILDREN_VERTICALLY;
}
@object GenInteractionClass JustInteraction = {
GI_comp = @LeftTrigger, @RightTrigger, @CenterTrigger, @FullTrigger;
HINT_ORIENT_CHILDREN_VERTICALLY;
}
@object GenInteractionClass StyleInteraction = {
GI_comp = @PlainTrigger, @BoldTrigger, @SuperTrigger, @SubTrigger;
HINT_ORIENT_CHILDREN_VERTICALLY;
}
/* Triggers. All the upper triggers are essentially the same. Each is named as it * appears in the GI_comp fields above, and each has the corresponding * GI_visMoniker field. The RomanTrigger object is shown as an example. */
@object GenTriggerClass RomanTrigger = {
GI_visMoniker = "Roman";
HINT_EXPAND_WIDTH_TO_FIT_PARENT;
}
/* The Apply, Reset, and Cancel triggers do not have the hint shown above. */
@object GenTriggerClass ApplyTrigger = {
GI_visMoniker = "Apply";
}
HINT_DIVIDE_WIDTH_EQUALLY and HINT_DIVIDE_HEIGHT_EQUALLY instruct a composite object to divide up its space along the affected dimension among the usable children. This hint can only suggest sizes for the children. The children themselves will decide if they can expand or contract to fit the requested space. (In general, children will not contract to fit a requested size, but they may expand.) Note: these hints will not work within GenValue objects; if you wish to use them on such an object, place them within a dummy GenInteraction object and use these hints on that object.
Typically, these hints work well in conjunction with HINT_EXPAND_WIDTH_TO_FIT_PARENT and HINT_EXPAND_HEIGHT_TO_FIT_PARENT. If these hints are not also in place (on a GenInteraction, for example) the division of width and/or height may be based on the children's default size; i.e., the parent will size itself based on total size of the children and then attempt to divide up its children's space, rather than the maximum allotted size for the parent, which is probably not desired.
HINT_INITIAL_SIZE, HINT_MAXIMINUM_SIZE, HINT_MINIMUM_SIZE, HINT_FIXED_SIZE
If you know certain sizing restrictions for window or interaction objects, you can set them with the following four hints. Each takes a parameter that details the appropriate height and width in points. The parameters are described for the hints.
HINT_INITIAL_SIZE
CompSizeHintArgs
, a structure that defines a suggested width, height, and the number of children the object has.
HINT_FIXED_SIZE
HINT_INITIAL_SIZE
, of type
CompSizeHintArgs
.
HINT_MAXIMUM_SIZE
HINT_INITIAL_SIZE
, of type
CompSizeHintArgs
.
HINT_MINIMUM_SIZE
HINT_INITIAL_SIZE
, of type
CompSizeHintArgs
.The following examples show different ways to set the initial size of an object. The third argument of the hint is the number of children in a particular line of a composite, when the composite is set up to wrap its children.
This example sets the initial size of the composite (probably a GenPrimary) to be half the screen's height and half the screen's width.
HINT_INITIAL_SIZE = {
SST_PCT_OF_FIELD_WIDTH | PCT_50,
SST_PCT_OF_FIELD_HEIGHT | PCT_50,
0 };
This example sets the size of the composite to be 100 pixels high and 200 pixels wide.
HINT_FIXED_SIZE = {
SST_PIXELS | 200,
SST_PIXELS | 100,
0 };
This example sets the composite's minimum size to be 10 average characters wide and 20 percent of the screen height tall.
HINT_MINIMUM_SIZE = {
SST_AVG_CHAR_WIDTHS | 10,
SST_PCT_OF_FIELD_HEIGHT | PCT_20,
0 };
GEOS SDK TechDocs
|
|
2.3 Justifying and Centering Children
|
2.5 Outlining the Composite