Understanding resources

Using classes and instances in resource specifications

When specifying the client, restrictions, and resource_name components of a resource specification, you need to decide if you want to use the component's class name or instance name. The ``class'' is the general category to which the component belongs, whereas the ``instance'' is the actual client, widget, or resource variable.

A class can consist of several different versions of an application, or several different widgets or resources. For example, in the case of the scoterm client, the background color resource (background), the active background color resource (activeBackground), and the top shadow color resource (topShadowColor) are all instances of the same class, Background.

You might choose to specify a class name instead of an instance name, if you wanted to set values for several resources that fell within the same class. This way, you could create the following resource specification:

   ScoTerm*Background:    blue
This specification is much quicker to define and achieves the same result as:
   ScoTerm*background:        blue
   ScoTerm*activeBackground:  blue
   ScoTerm*topShadowColor:    blue
In the case of clients, you might want to specify an application's class name instead of the binary name if, for example, there are different versions of the same program (perhaps to accommodate different machine architecture) on your network. By using the class name to set a resource, you could ensure that the resource specification would be used by all versions of the same client.

You can combine the use of class names and instance names in a resource specification so that you define a default for a wide range of cases and then define a particular case that varies from the default without overriding it. For example, you could specify that the buttons in all of the dialog boxes for a particular client be displayed in blue, with the exception of a particular button, which you want displayed in red. You might create resource specifications that read:

   xclient*buttonbox*XmPushButton*foreground:  blue
   xclient*buttonbox*delete*foreground:        red
The XmPushButton class configures all buttons in the dialog boxes, but the delete instance overrides the default for the Delete button only. This type of specification works because an instance name always overrides the corresponding class name.

By convention, class names begin with an uppercase letter, while instance names begin with a lowercase letter. However, if an instance name is a compound word, such as activeBackground, the second word is usually capitalized.

To identify the class and instance names for the resource variables that you can set for a client, refer to the client's manual pages.

Next topic: Using delimiters in resource specifications
Previous topic: Syntax for resource specifications

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003