Name
XtConvertArgProc — prototype procedure for argument conversion.
Synopsis
typedef void (∗XtConvertArgProc)(Widget, Cardinal ∗, XrmValue ∗)
Widget object;
Cardinal ∗size;
XrmValue ∗value;
Arguments
objectPasses the object for which the resource is being converted, or passes NULL if the converter was invoked by XtCallConverter or XtDirectConvert.
sizePasses a pointer to the size field from the XtConvertArgRec structure.
valuePasses a pointer to a descriptor into which the procedure must store the conversion argument.
Description
XtConvertArgProc gets an argument needed when calling a converter. It is registered in an XtConvertArgRec structure with the symbol XtProcedureArg. When invoked, the XtConvertArgProc procedure must derive a conversion argument and store the address and size of the argument in its value argument.
To permit re-entry, XtConvertArgProc should return the address of storage whose lifetime is no shorter than the lifetime of object. If object is NULL, the lifetime of the conversion argument must be no shorter than the lifetime of the resource with which the conversion argument is associated. The Intrinsics do not guarantee to copy this storage, but they do guarantee not to reference it if the resource is removed from the conversion cache.
Examples
Here is how the XtRString-to-XtRCursor converter would be registered if it were not already registered by Xt:
/∗ARGSUSED∗/
static void FetchDisplayArg(widget, size, value)
Widget widget;
Cardinal ∗size;
XrmValue∗ value;
{
if (widget == NULL) {
XtErrorMsg("missingWidget", "fetchDisplayArg", "XtToolkitError",
"FetchDisplayArg called without a widget to reference",
(String∗)NULL, (Cardinal∗)NULL);
}
value->size = sizeof(Display∗);
value->addr = (caddr_t)&DisplayOfScreen(XtScreenOfObject(widget));
}
static XtConvertArgRec displayConvertArg[] = {
{XtProcedureArg, (XtPointer)FetchDisplayArg, 0},
};
XtSetTypeConverter(XtQString, XtQCursor, CvtStringToCursor,
displayConvertArg, XtNumber(displayConvertArg),
XtCacheByDisplay, FreeCursor);
/∗ARGSUSED∗/
static Boolean CvtStringToCursor(dpy, args, num_args, fromVal, toVal,
closure_ret)
Display∗ dpy;
XrmValuePtr args;
Cardinal ∗num_args;
XrmValuePtr fromVal;
XrmValuePtr toVal;
XtPointer ∗closure_ret;
{
.
.
.
if (∗num_args != 1)
XtAppErrorMsg(....);
.
.
Display ∗display = ∗(Display∗∗)args[0].addr;
.
.
}
Structures
The enumerated type XtAddressMode and the structure XtConvertArgRec specify how each argument is derived. These are defined in <X11/Convert.h>, as follows:
typedef enum {
/∗ address mode parameter representation ∗/
XtAddress, /∗ address ∗/
XtBaseOffset, /∗ offset ∗/
XtImmediate /∗ constant ∗/
XtResourceString /∗ resource name string ∗/
XtResourceQuark /∗ resource name quark ∗/
} XtAddressMode;
typedef struct {
XtAddressMode address_mode;
caddr_t address_id;
Cardinal size;
} XtConvertArgRec, ∗XtConvertArgList;