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

The child's query_geometry Method

When calculating its layout, a parent widget may take account of a child's preferred size and location. The parent uses XtQueryGeometry to inquire about a child's preferred geometry. The parent passes to XtQueryGeometry pointers to two XtWidgetGeometry structures, one containing the parameters that the parent intends to impose and the other containing the preferred parameters returned by the child.

When the parent calls XtQueryGeometry, the Intrinsics automatically call the geometry_manager method of the child. The child's query_geometry method is responsible for determining the widget's preferred geometry. The method stores the parameters into the return XtWidgetGeometry structure, setting corresponding bits in the bitmask for fields that it cares about. The query_geometry method must return one of the following values:

  1. If the parent's intended geometry is acceptable, the child's query_geometry method returns XtGeometryYes.

  2. If the parent's and child's parameters differ for some field that both widgets care about, or if the child has expressed interest in a field that the parent does not care about, it returns XtGeometryAlmost.

  3. If the child's preferred geometry is the same as its current geometry, it returns XtGeometryNo.

    After the query_geometry method returns, XtQueryGeometry fills in any fields in the return XtWidgetGeometry structure that the child does not care about with the current values of the resources in the child widget. XtQueryGeometry returns the value returned by the query_geometry method.

    Most composite widgets should call XtQueryGeometry whenever they intend to change the geometry of a child that is not in the process of making a geometry request. A geometry_manager method should not call XtQueryGeometry for the child making the request. For a widget making a geometry request, the requested geometry is the preferred geometry.

  4. Handling Easy Query Geometry Requests

    In many cases, the query_geometry method needs to consist of only two parts. The first part should calculate the widget's preferred width and height. The second part should pass the preferred dimensions to the XmeReplyToQueryGeometry convenience function.

    Later on in this chapter, we'll see a sample query_geometry method that calls XmeReplyToQueryGeometry.

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