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:
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.
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.