Specifications
Athena Widget Set libXaw 1.0.7
2.10.2.2. Creating Argument Lists
To set up an argument list for the inline specification of widget attributes, you may use anyofthe
four approaches discussed in this section. Each resource name has a global symbol associated
with it. This global symbol has the form XtNresource name.For example, the symbol for ‘‘fore-
ground’’is XtNforeground.For further information, see the XToolkit Intrinsics — C Language
Interface.
Argument are specified by using the following structure:
typedef struct {
String name;
XtArgVal value;
}Arg,*ArgList;
The first approach is to statically initialize the argument list. Forexample:
static Argarglist[] = {
{XtNwidth, (XtArgVal) 400},
{XtNheight, (XtArgVal) 300},
};
This approach is convenient for lists that do not need to be computed at runtime and makes
adding or deleting newelements easy.The XtNumber macro is used to compute the number of
elements in the argument list, preventing simple programming errors:
XtCreateWidget(name, class, parent, arglist,XtNumber(arglist));
The second approach is to use the XtSetArg macro. For example:
Argarglist[10];
XtSetArg(arglist[1], XtNwidth, 400);
XtSetArg(arglist[2], XtNheight, 300);
To makeiteasier to insert and delete entries, you also can use a variable index:
Argarglist[10];
Cardinal i=0;
XtSetArg(arglist[i], XtNwidth, 400); i++;
XtSetArg(arglist[i], XtNheight, 300); i++;
The i variable can then be used as the argument list count in the widget create function. In this
example, XtNumber would return 10, not 2, and therefore is not useful.
Note
Youshould not use auto-increment or auto-decrement within the first argument to
XtSetArg.Asitiscurrently implemented, XtSetArg is a macro that dereferences
the first argument twice.
The third approach is to individually set the elements of the argument list array:
Argarglist[10];
arglist[0].name = XtNwidth;
arglist[0].value = (XtArgVal) 400;
arglist[1].name = XtNheight;
arglist[1].value = (XtArgVal) 300;
16