WidgetSet(widget, varargs)
Widget *widget;
WidgetGet(widget, varargs)
Widget *widget;
char *
GenericWidgetName(buf)
char *buf;
Widget foo; foo = WidgetCreate("foo", labelWidgetClass, toplevel, XtNlabel, "Widget", XtNforeground, WhitePixelOfScreen(XtScreen(toplevel)), XtNbackground, BlackPixelOfScreen(XtScreen(toplevel)), XtNborderWidth, 1, NULL);As you can see, the list must be NULL terminated. You may pass up to to MAXARGS argument pairs (which is defined in WidgetWrap.h). There are special args available to the Create/Get/Set functions that are available:
XtNmanaged pass "False" to create a non-managed widget. XtNargList takes two parameters.
The XtNargList makes it possible to pass attributes to the Create/Get/Set calls that are probably common to many widgets to be created or reset.
static Arg args[] = { XtNforeground, black, XtNbackground, white, XtNwidth, 20, XtNheight, 10,
};
foo = WidgetCreate(NULL, widgetClass, toplevel, XtNargList, args, XtNumber(args), NULL);
There are two other XtN's that the widgetwrap code provides. You can create toplevel application shell widgets and popup shells as well as other widget types by passing these parameters:
XtNpopupShell pass "True" to create a PopupShellWidget.
XtNapplicShell pass "True" to create an applicationShellWidget
These obsolete the need for XtCreatePopupShell() and XtCreateApplicationShell() Note that for both of these, the "parent" parameter is ignored for the WidgetCreate() call (you may pass anything, but the parent parameter remains there for consistency).
Most large applications will create huge numbers of widgets which the programmer has to think up unique names for all of them. What's more, typically, as noted by the examples above, the names are constant strings which takes up memory, disk spaces, etc... So, if WidgetCreate() gets NULL as the name of the widget, then a widget name will be created automatically by calling GenericWidgetName() since most of the time, user's don't care what the name of a widget is, this capability is available.