Name
query_geometry — Core method called when a widget is destroyed.
Synopsis
typedef XtGeometryResult (∗XtGeometryHandler)(Widget, XtWidgetGeometry ∗);
Widget w;
XtWidgetGeometry ∗request;
XtWidgetGeometry ∗geometry_return;
Arguments
wSpecifies the widget.
requestSpecifies the proposed geometry.
geometry_return
Specifies the reply geometry.
Description
The query_geometry method is expected to examine the bits set in request->request_mode, evaluate the proposed geometry for the widget, and store the result in geometry_return (setting the bits in geometry_return->request_mode corresponding to those geometry fields that it cares about). If the proposed geometry change is acceptable without modification, the query_geometry method should return XtGeometryYes. If at least one field in geometry_return is different from the corresponding field in request or if a bit was set in geometry_return that was not set in request, the query_geometry method should return XtGeometryAlmost. If the preferred geometry is identical to the current geometry, the query_geometry method should return XtGeometryNo.
After calling the query_geometry method or if the query_geometry field is NULL, XtQueryGeometry examines all the unset bits in eometry_return->request_mode and sets the corresponding fields in eometry_return to the current values from the widget instance. If CWStackMode is not set, the stack_mode field is set to XtSMDontChange. XtQueryGeometry returns either the value returned by the query_geometry method or XtGeometryYes if the query_geometry field is NULL.
Therefore, the caller can interpret a return of XtGeometryYes as not needing to evaluate the contents of the reply and, more importantly, not needing to modify its layout plans. A return of XtGeometryAlmost means either that both the parent and the child expressed interest in at least one common field and the child’s preference does not match the parent’s intentions or that the child expressed interest in a field that the parent might need to consider. A return value of XtGeometryNo means that both the parent and the child expressed interest in a field and that the child suggests that the field’s current value is its preferred value. In addition, whether or not the caller ignores the return value or the reply mask, it is guaranteed that the geometry_return structure contains complete geometry information for the child.
Parents are expected to call XtQueryGeometry in their layout routine and wherever other information is significant after change_managed has been called. The change_managed method may assume that the child’s current geometry is its preferred geometry. Thus, the child is still responsible for storing values into its own geometry during its initialize method.
Structures
The XtWidgetGeometry structure is similar, but not identical, to the corresponding Xlib structure:
typedef unsigned long XtGeometryMask;
typedef struct {
XtGeometryMask request_mode;
Position x, y;
Dimension width, height;
Dimension border_width;
Widget sibling;
int stack_mode;
} XtWidgetGeometry;
The request_mode definitions are from <X11/X.h>:
#defineCWX(1<<0)
#defineCWY(1<<1)
#defineCWWidth(1<<2)
#defineCWHeight(1<<3)
#defineCWBorderWidth(1<<4)
#defineCWSibling(1<<5)
#defineCWStackMode(1<<6)
The Xt Intrinsics also support the following value:
#defineXtCWQueryOnly(1<<7)
XtCWQueryOnly indicates that the corresponding geometry request is only a query as to what would happen if this geometry request were made and that no widgets should actually be changed.
XtMakeGeometryRequest, like the Xlib XConfigureWindow function, uses request_mode to determine which fields in the XtWidgetGeometry structure you want to specify.
The stack_mode definitions are from <X11/X.h>:
#defineAbove0
#defineBelow1
#defineTopIf2
#defineBottomIf3
#defineOpposite4
The Intrinsics also support the following value:
#defineXtSMDontChange5
For precise definitions of Above, Below, TopIf, BottomIf, and Opposite, see the reference page for ConfigureWindow in Volume Two, Xlib Reference Manual. XtSMDontChange indicates that the widget wants its current stacking order preserved.
Examples
The following is the query_geometry method of the BitmapEdit widget class:
static XtGeometryResult QueryGeometry(w, proposed, answer)
Widget w;
XtWidgetGeometry ∗proposed, ∗answer;
{
BitmapEditWidget cw = (BitmapEditWidget) w;
answer->request_mode = CWWidth | CWHeight;
/∗ initial width and height ∗/
if (cw->bitmapEdit.showAll == True)
answer->width = cw->bitmapEdit.pixmap_width_in_pixels;
else
answer->width = (cw->bitmapEdit.pixmap_width_in_pixels >
DEFAULTWIDTH) ? DEFAULTWIDTH :
static XtGeometryResult QueryGeometry(w, proposed, answer)
Widget w;
XtWidgetGeometry ∗proposed, ∗answer;
{
BitmapEditWidget cw = (BitmapEditWidget) w;
answer->request_mode = CWWidth | CWHeight;
/∗ initial width and height ∗/
if (cw->bitmapEdit.showAll == True)
answer->width = cw->bitmapEdit.pixmap_width_in_pixels;
else
answer->width = (cw->bitmapEdit.pixmap_width_in_pixels >
DEFAULTWIDTH) ? DEFAULTWIDTH :
cw->bitmapEdit.pixmap_width_in_pixels;
if (cw->bitmapEdit.showAll == True)
answer->height = cw->bitmapEdit.pixmap_height_in_pixels;
else
answer->height = (cw->bitmapEdit.pixmap_height_in_pixels >
DEFAULTWIDTH) ? DEFAULTWIDTH :
cw->bitmapEdit.pixmap_height_in_pixels;
if ( ((proposed->request_mode & (CWWidth | CWHeight))
== (CWWidth | CWHeight)) &&
proposed->width == answer->width &&
proposed->height == answer->height)
return XtGeometryYes;
else if (answer->width == cw->core.width &&
answer->height == cw->core.height)
return XtGeometryNo;
else
return XtGeometryAlmost;
}