By far the most important aspect
of defining attachments for a FRAME entry is to carefully think about
how you want various components and contained components to react
to the appropriate resize event.
Carefully examine the
components and determine which components should absorb the gain or
loss of space. Examine the horizontal and vertical dimensions separately;
it is fairly common for each dimension to handle resizing differently.
-
Use only the attachments.
When a component is
resized, all attachments are checked; therefore, unnecessary attachments
may affect performance. Also, attachment information is stored with
the FRAME entry, so unnecessary attachments increase the size of the
stored entry.
The same is not true
for component size restrictions. Virtually no overhead is paid for
these settings. Sometimes, you may want to turn on a fixed size restriction,
even if only for documentation purposes; that is, if the attachments
are viewed by another person at a later date, they will be more understandable.
-
Remember that the master component
always resizes from the lower right.
This is true even if
the master component is grown from the upper left of the window. Therefore,
absolute attachments to the top or the left of the master component
are unnecessary. Note that this is not true of components in general,
only of the master component.
-
Take advantage of Move Only situations.
If you know that a
container or group component will only be moved and not resized due
to attachments to its siblings and parent, then you do not need to
define any attachments to the child components of the container or
group.
-
Keep the attachment logic simple.
If the attachments
are getting too complicated, consider creating a container box just
to hold a set of related components. Attach the container to its parent
and siblings and set up attachments (if necessary) to the container's
children.
-
Avoid mixing absolute and relative
attachments in the same direction.
It is easy to create
a situation that cannot be satisfied when mixing absolute and relative
attachments in the same direction. Sometimes such situations are appropriate,
but you should take a second look to make sure this is really what
you need.
-
Avoid relative attachments with
text-based objects that must be aligned on a row/column boundary.
Usually the desired
placement of a component after honoring a relative attachment does
not exactly align on a row/column boundary, which necessitates a shift
of the component to attain the required alignment. This situation
can create odd visual effects, and it significantly increases the
chance that textual objects will overlap. If you feel you must use
relative attachments with text-based objects, be sure to leave space
around each component to allow for shifting without creating an overlap
situation.
A related problem occurs
when a container contains character-aligned objects (widgets) and
the container is relatively attached. The container is not character-cell
aligned, and when the master component is resized, the widgets often
shift within the container.
You can avoid this
shifting by creating a dummy character-cell-aligned component (for
example, a one-character text field that is protected and nondisplayable).
Attach this dummy component to the master component relatively, and
then attach the container to the dummy component absolutely. Make
sure the absolute attachment is short so that the resulting location
of the container is as close to relatively correct as possible.
When the master component
is resized, the dummy component will be positioned relatively, and
then it will align to a character-cell boundary. Then, the absolute
attachment between it and the container will be honored. No shifting
will occur within the container either since the net movement of the
container is guaranteed to be an integral number of character cells.
This guarantee is possible because the master component is always
an integral number of character cells in size and the dummy component
is always character-cell aligned.
-
Remember that you can resize in
define attachment mode.
Remember that you can
still resize any component without attachments being honored by entering
define attachment mode and performing the desired move or resize.
This action causes any associated attachments to be redefined instead
of honored.
-
Create small and allow for growth.
In general, results
are usually better when honoring the growth rather than the shrinkage
of the master component.
You are better off defining
your window to be as close to the smallest allowable size and ensuring
that you handle size increases gracefully through attachment. The primary reason for this is that if you create a window too
large and then try to shrink it, the master component may become too
small, and the containing component may also become too small to hold
other components.
-
Be careful when using very short
attachments.
Avoid very short attachments
to a component that contains a component that must be character-cell
aligned. These attachments are most likely to be ignored because of
the one-half character rule mentioned earlier. Short attachments are
acceptable if placement or size variations within ½ character
are insignificant and if propagation is not an issue. Such attachments
are a concern only when you are attaching to a component that contains
an object that must be character-cell aligned.
-
You can test all attachments
while in build mode. Position the components, create the attachments,
and save the entry so that the desired placement is not lost (in case
the attachments do not work as you expect them). If the attachments
do not work, then cancel them, re-edit the frame, and change the attachments
appropriately.
-
Use single-directional attachments
in most cases.
Single-directional
attachments are usually most appropriate, especially for attachments
from parent to child. Sibling attachments can also be made single
directional, but be sure to analyze how resizing the master component
will affect subcomponents so that you define sibling attachments in
the correct direction.
-
Use relative component size restrictions
to reduce the number of attachments required.
If you want a component
to maintain a relative size, attach one side to the parent relatively
and set the component-size restriction to fixed relative, instead
of attaching both sides relatively. This technique results in significantly
fewer attachments if you have many components that are being sized
relatively in this manner.
-
Check the kind of attachment for
a component if you are not sure what kind is defined.
To determine the kind
of attachment that is defined for a section, click in the section
while you are in define attachment mode. A message will be displayed
indicating what kind of attachment is defined there and what it is
attached to.