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



The Child's set_values and set_values_almost Method

When a user or application invokes XtSetValues on a geometry resource, XtSetValues makes a geometry request. (The five geometry resources are shown in Table 12-1.) After invoking all the widget's set_values methods, XtSetValues checks for changes to any geometry resources. If any of those resources have changed, it sets their values to those in effect before XtSetValues was called and then makes a geometry request with the new values as the requested geometry parameters. If the geometry request returns XtGeometryYes, XtSetValues calls the widget's resize method. If the parent's geometry_manager method returns XtGeometryDone, XtSetValues does not call the widget's resize method.

If the geometry request returns XtGeometryNo or XtGeometryAlmost, XtSetValues calls the widget's set_values_almost method. The child's set_values_almost method determines whether to accept the compromise, reject the compromise, or request an alternate geometry change.

XtSetValues passes set_values_almost the request and reply XtWidgetGeometry structures. If the request returns XtGeometryNo, the bitmask in the reply structure is 0. The set_values_almost method can accept a compromise geometry by copying the reply parameters into the request structure. It can also construct another request by altering the request structure, or it can end the negotiation by setting the request bitmask to 0. If the request bitmask is nonzero when the set_values_almost method returns, XtSetValues makes another geometry request and treats the result in the same way as for the original request.

A widget's set_values method can initiate a geometry request by changing any of the geometry resources. For example, if XtSetValues is invoked on a Label's text, the set_values method can calculate how large the widget should be to contain the new text and then set the relevant geometry fields accordingly. The set_values method should not do any resizing itself; in particular, it should not resize any child widgets because the geometry request might be denied. Resizing is usually done in the widget's resize method. The widget's set_values_almost method may need to restore some widget state in the event the geometry request is denied.


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