Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ XtSetArg(3) — OSF1 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtMergeArgLists(1)

XtNumber(1)

 

Name

XtSetArg — modify an argument list dynamically. 

Synopsis

void XtSetArg(arg, resource_name, value)

    Arg arg;
    String resource_name;
    XtArgVal value;

Arguments

argSpecifies the Arg structure to set. 

resource_name
Specifies the name of the resource.

valueSpecifies the value of the resource, or its address.  (If the size of the resource is less than or equal to the size of an XtArgVal, the resource value is stored directly in value; otherwise, a pointer to it is stored in value.) 

Description

Many Intrinsics functions need to be passed pairs of resource names and values to set or override resource values.  One way to do this is to construct and pass an ArgList (see the Structures section below).  To dynamically change values in an existing Arg or ArgList, use XtSetArg. 

The (varargs interfaces) style of Intrinsics calls (those that start with XtVa) avoid the need to build an ArgList or call XtSetArg. 

Note that XtSetArg is implemented as a macro.  Expressions involving autoincrement and autodecrement operations are unsafe in its argument list, since XtSetArg evaluates its first argument twice. 

XtSetArg is usually used in a highly stylized manner to minimize the probability of making a mistake; for example:

Arg args[20];
int n;
n = 0;
XtSetArg(args[n], XtNheight, 100);      n++;
XtSetArg(args[n], XtNwidth, 200);       n++;
XtSetValues(widget, args, n);

Alternatively, an application can statically declare the argument list and use XtNumber:

static Args args[] = {
        {XtNheight, (XtArgVal) 100},
        {XtNwidth, (XtArgVal) 200},
};
XtSetValues(Widget, args, XtNumber(args));

Volume Four, X Toolkit Intrinsics Programming Manual, presents several examples that use Args, setting them in several ways: with values initialized at compile time; by using XtSetArg; and, by using the varargs interfaces. 

Structures

Arg are defined as follows in <X11/Intrinsic.h>:

typedef struct {
String name;
XtArgVal value;
} Arg, ∗ArgList;

If the size of the resource is less than or equal to the size of an XtArgVal, the resource value is stored directly in value; otherwise, a pointer to it is stored into value. 

The definition of XtArgVal differs depending on architecture--its purpose is precisely to make code portable between architectures with different byte sizes. 

The macro itself, from the same file, is listed below:

#define XtSetArg(arg,n,d) ((arg).name=(n),(arg).value=(XtArgVal)(d))

See Also

XtMergeArgLists(1), XtNumber(1). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026