|
|
Using the X Window System > Chapter 5 Application ResourcesScope of Resource |
|
You can specify how generally or specifically a resource is applied. For example, you can specify that all clients have a background color of black (very general). At the other extreme, you can say that you want the softkeys of one particular hpterm window to be red. Scope of customization is determined by:
Every client has both a name and a class. The name defines the specific client, while the class categorizes the client. Thus, the class is more general than the name. Frequently, the two identifiers are very similar, and often differ only in capitalization. For example, the client named xclock belongs to class Xclock. Resources specified by client name take precedence over resources specified by client class. You can assign a name to a particular instance of a client. This allows you to allocate resources to that client by class, by client, and by name. For example, the following command line starts an instance of hpterm named localTerminal.
If the following resource exists in the resource database:
then the localTerminal window will be white, overriding the colors used by the current palette. Like clients, resources have both a name and a class. An individual resource begins with a lowercase letter. For example, foreground refers to the foreground resource. A class resource, however, begins with an upper-case letter. For example, Foreground refers to the entire class of foreground resources. Thus, if no other specifications overruled, the line *foreground: blue in your resource file would make all foregrounds blue. However, the line *Foreground: blue would make all resources that belonged to the Foreground class blue. This would include such resources as foreground, cursorColor, pointerColor, bottomShadowColor for softkeys, frames, icons, and mattes. Specific resource specifications always have precedence over general specifications. For example, suppose a resource file contains:
The first line makes all resources of the class Foreground red. The second line overrules the first line, but only in the case of clients of class HPterm (of which there is only one-the hpterm client itself). Line two makes the Foreground class resources of all hpterm clients DarkSlateGray. Lines three and four give hpterm clients coral foregrounds and green cursors, while the other resources of class Foreground (pointerColor, cursorColor, softkey foreground and bottomShadowColor, and scrollbar foreground and bottomShadowColor) remain DarkSlateGray for hpterm clients. Similarly, if a resource file contains:
then all softkey backgrounds will be wheat. For the rest of the hpterm window, the backgrounds will vary. Windows named local will be white, other windows will be pink. The * character in a resource string is a wildcard that provides resource generality. For example, the following list of resources shows increasing specificity.
The resource *foreground refers to all foregrounds. The more specific resources override it. All the hpterm foregrounds will be yellow except for the foreground of the softkeys. |
|