[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Widget Writer's Guide



The Child's resize Method

When a child's size changes, the Intrinsics automatically call the child's resize method. This call informs the child that its size has been changed. The child's resize method must make any internal changes necessary to conform to the new dimensions. If the child is itself a composite widget, its resize method can move or resize its own children.

A widget's resize method is invoked in the following circumstances:

  1. Whenever a parent calls XtConfigureWidget, XtResizeWidget, or XmeConfigureObject to resize the child

  2. By XtSetValues when the widget's geometry resources are changed and the resulting geometry request returns XtGeometryYes

    In addition, a shell's resize method is invoked when the size of the shell is changed, often by a user through the window manager.

    When the Intrinsics call the resize method, the widget's Core geometry resources contain the new position and dimensions. The resize method must take these resource values as given; the resize method cannot issue a geometry request. The resize method uses these resource values to recalculate the widget's layout.

    The resize method of a manager widget should not do layout itself. Rather, a manager widget should provide a separate layout routine. This layout routine should take as an argument the child that is making the request (if any) so that the layout routine can avoid resizing that child.

  3. What to Cut When Space is Limited

    One of the responsibilities of a resize method is to determine what should be displayed when there is not enough space to display everything. Motif provides the following precedence recommendations for handling this situation:

    1. Try to reduce or eliminate any unused space (white space) inside the widget. In many widgets, this unused space is caused by the widget margins. The purpose of the margins is to provide a break between the widget's visual and the widget's border decorations. When there is plenty of space inside the widget, the margins are helpful. However, when space becomes tight, the margins must be reduced or eliminated.

    2. Try to reduce the size of the widget's visual. For example, if the widget's visual is some sort of geometric shape, your widget should maintain the shape but scale down its size. If the widget's visual is text, then portions of the text will have to be clipped.

    3. Try to reduce the size of the widget's shadows.

    4. Try to reduce the size of the border highlight. (This is a last resort; always try to maintain at least the border highlight.)

    5. [ Previous | Next | Contents | Glossary | Home | Search ]