Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ XtGetAppliB(3) — OSF1 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtGetSubresources(1)

XtOffset(1)

XtOffsetOf(1)

 

Name

XtGetApplicationResources — set application variables from resource database. 

Synopsis

void XtGetApplicationResources(object, base, resources, num_resources, args, num_args)

    Widget object;
    XtPointer base;
    XtResourceList resources;
    Cardinal num_resources;
    ArgList args;
    Cardinal num_args;

Arguments

objectSpecifies the object that identifies the resource database to search (the database is that associated with the display for this object); may be of class Object or any subclass. 

baseSpecifies the base address of the subpart data structure into which the resources will be written. 

resourcesSpecifies the resource list for the subpart. 

num_resources
Specifies the number of resources in the resource list.

argsSpecifies the argument list to override any other resource specifications. 

num_argsSpecifies the number of arguments in the argument list. 

Description

XtGetApplicationResources can be used to retrieve resource settings that apply to an overall application, rather than to a particular widget. (Widget resources are automatically retrieved by XtCreateWidget.) 

First, XtGetApplicationResources uses the passed object, which is usually an application shell widget, to construct a resource name and class list.  The full name and class of the specified object (that is, including its ancestors, if any) is logically prepended to each resource name and class.  Then, it retrieves resources from the argument list, the resource database, or the resource list default values.  After adding base to each address, XtGetApplicationResources copies the resource values into the corresponding base-offset address.  If args is NULL, num_args must be zero.  However, if num_args is zero, the argument list is not referenced. 

The portable and recommended way to specify application resources is to declare them as structure members and pass a pointer to such a structure as base;  then XtOffset or XtOffsetOf can be used to specify resource_offset.  (XtOffset and XtOffsetOf determine the relative address of a field.)  This is how widget instance variables are accessed by the Resource Manager in widget instances. 

Here is a short program that sets up an application resource list and accesses it. 

XtGetApplicationResources may overwrite the specified resource list with an equivalent representation in an internal format that optimizes access time if the list is used repeatedly.  The resource list must be allocated in writable storage and the caller must not modify the list contents after the call if the same list is to be used again.  Any per-display resources fetched by XtGetApplicationResources will not be freed from the resource cache until the display is closed. 

/∗ res.c - access application resources ∗/
#include <stdio.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
/∗
 ∗ fields to be filled in from resources
 ∗/
typedef struct _instance_variables {
String label;
XFontStruct ∗font_struct;
long foreground;
} instance_variable_rec;
 static XtResource resources[] = {
{
XtNforeground,
XtCForeground,
XtRPixel, sizeof(Pixel),
XtOffsetOf(instance_variable_rec, foreground),
XtRString, "XtDefaultForeground"
},
{
XtNfont,
XtCFont,
XtRFontStruct, sizeof(XFontStruct ∗),
XtOffsetOf(instance_variable_rec, font_struct),
XtRString, "XtDefaultFont"
},
{
XtNlabel,
XtCLabel,
XtRString, sizeof(String),
XtOffsetOf(instance_variable_rec, label),
XtRString, "Default Label"
},
};
 main(argc, argv)
int argc;
char ∗∗argv;
{
XtAppContext app_context;
Widget toplevel;
instance_variable_rec iv;
 toplevel = XtAppInitialize(&app_context, argv[0],
            "my-widget", NULL, 0, &argc, argv);
XtGetApplicationResources(toplevel,       /∗ widget ∗/
                          &iv,            /∗ base address ∗/
                          resources,      /∗ resource ∗/
                          XtNumber(resources),/∗ how many ∗/
                          NULL, 0);       /∗ ArgList to merge ∗/
 printf("label=%s\n", iv.label);
}

All resource-fetching routines (for example, XtGetSubresources and XtGetApplicationResources) call resource converters if the user specifies a resource that is a different representation from the desired representation or if the widget’s default resource value representation is different from the desired representation. 

Structures

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

typedef struct _XtResource {
String    resource_name;/∗ Resource name ∗/
String    resource_class;/∗ Resource class ∗/
String    resource_type;/∗ Representation type desired ∗/
Cardinal  resource_size;/∗ Size in bytes of representation ∗/
Cardinal  resource_offset;/∗ Offset from base to put resource value ∗/
String    default_type;/∗ Representation type of specified default ∗/
XtPointer default_addr;/∗ Address of resource default value ∗/
} XtResource, ∗XtResourceList;

See Also

XtGetSubresources(1), XtOffset(1), XtOffsetOf(1). 

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