Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ set_valuesB(3) — OSF1 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtCreateWidget(1)

XtSetSubvalues(1)

XtSetValues(1)

Core(3)

set_values(4)

 

Name

set_values_hook — Core method for processing subpart resources. 

Synopsis

typedef Boolean (∗XtArgsFunc)(Widget, ArgList, Cardinal ∗);

    Widget w;
    ArgList args;
    Cardinal ∗num_args;

Arguments

wSpecifies the widget whose nonwidget resource values are to be changed. 

argsSpecifies the argument list that was passed to XtSetValues. 

num_argsSpecifies the number of arguments in the argument list. 

Description

The set_values_hook method is obsolete, but still called (immediately after the Core set_values method) for backwards compatibility.  Its job was to set resources values of subparts by called XtSetSubresources, but this job can now be handled by the Core set_values method, since the argument list of set_values_hook has been added to Core set_values in R4. 

The set_values_hook method returns a Boolean indicating whether, based on the values passed in args, the widget needs to be redrawn.  To set the actual subvalues of the nonwidget data, the widget should call XtSetSubvalues and pass the appropriate resource list. 

The set_values_hook method is similar to the set_values method, except that it is passed only the current widget instance structure, instead of the old and new copies of the widget instance structure which are passed to set_values.  As a result, set_values_hook needs to use a different technique for comparing the current subresource values with the values set by XtSetValues. 

There are two ways to do this.  One is to loop through the widget’s resource list, using strcmp to compare each resource name in the argument list with the subresource names, and then comparing each argument value with the current value of the subresource. 

The other way is to copy the instance structure passed in using bcopy (after allocating memory for the new copy with XtNew, described in Chapter 13, Miscellaneous Toolkit Programming Techniques, in Volume Four, X Toolkit Intrinsics Programming Manual).  Then call XtSetSubvalues to set the actual values to those in the argument list.  After this process, you can compare the old and new values the same way this is done in the set_values method.  But since the Core set_values method is now called with the arglist, you can avoid having to do this bcopy by moving your code into Core set_values. 

Similarly, initialize_hook is also obsolete beginning in R4: use initialize instead. 

Structures

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

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

Examples

The following is the set_values_hook method of the Athena SimpleMenu widget class:

static Boolean
SetValuesHook(w, arglist, num_args)
Widget w;
ArgList arglist;
Cardinal ∗num_args;
{
    register Cardinal i;
    Dimension width, height;
     width = w->core.width;
    height = w->core.height;
     for ( i = 0 ; i < ∗num_args ; i++) {
    if ( streq(arglist[i].name, XtNwidth) )
        width = (Dimension) arglist[i].value;
    if ( streq(arglist[i].name, XtNheight) )
        height = (Dimension) arglist[i].value;
    }
     if ((width != w->core.width) || (height != w->core.height))
    MakeSetValuesRequest(w, width, height);
    return(FALSE);
}

See Also

XtCreateWidget(1), XtSetSubvalues(1), XtSetValues(1),
Core(3),
set_values(4). 

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