
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
NULL);
two = XtVaCreateManagedWidget ("Two",
xmPushButtonWidgetClass, parent,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, one,
/* attach top of widget to same y coordinate as top of "one" */
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, one,
NULL);
three = XtVaCreateManagedWidget ("Three",
xmPushButtonWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, one,
/* attach left of widget to same x coordinate as left side of "one" */
XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNleftWidget, one,
NULL);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
The example uses three PushButton gadgets inside of a Form widget. The output of the program is shown in the
figure.
Output of attach.c
You should notice that the widgets are packed together quite tightly, which might not be how you expected them to
appear. In order to space the widgets more reasonably, we need to specify some distance between them using
attachment offsets.
9.4.2 Attachment Offsets
Attachment offsets control the spacing between widgets and the objects to which they are attached. The following
resources represent the attachment offsets for the four sides of a widget:
XmNleftOffset
XmNrightOffset
XmNtopOffset
XmNbottomOffset
9 Manager Widgets 9.4.2 Attachment Offsets
213