Next | Prev | Up | Top | Contents | Index

Resource Inheritance

Each widget belongs to a class, whose name is the widget creation command name. Each widget inherits resources from its superclass. For example, xmLabel is a subclass of Primitive, which in turn is a subclass of superclass Core. From Core, xmLabel inherits resources such as -background, -height, and -width. From Primitive, it inherits resources such as -foreground. It is necessary to consult superclasses to get a full resource list for a particular xmLabel. Furthermore, each class adds resources. For example, xmLabel has the additional resources -labelType, -labelPixmap, and -labelString, among others.

Some special resource values are inherited through multiple levels of the widget hierarchy at creation time. For instance, the -buttonFontList of a bulletin board might be inherited from the -defaultFontList of an ancestor subclassing the abstract classes vendorShell or menuShell. In this case, the resource value is copied and is not modified if the original resource is modified.

For instance, in the following example, the button inherits its -fontList default value from bulletin board -buttonFontList. On the other hand, the button's background color is taken from the class defaults, not from the BulletinBoard. Pushing the button will change the BulletinBoard's -buttonFontList resource, which does not update the button's font list.

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmBulletinBoard .top managed \
   -background #A22 -buttonFontList "-*-courier-*-o-*--20-*"
xmPushButton .top.bold managed \
   -y 10 -labelString Bold
xmPushButton .top.quit managed \
   -y 40 -labelString Quit
.top.bold activateCallback {
   .top setValues -buttonFontList "-*-courier-bold-o-*--20-*"
}
.top.quit activateCallback {exit 0}
. realizeWidget
. mainLoop

Next | Prev | Up | Top | Contents | Index