HPlogo Using the X Window System > Chapter 5 Application Resources

Scope of Resource

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

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:

  • Using names or classes of clients.

  • Using names or classes of resources.

  • Specifying particular areas of clients (for example, softkeys and scrollbars).

  • Using wildcards in the resource string.

Names and Classes of Clients

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.

Naming a Client

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.

   hpterm -name localTerminal

If the following resource exists in the resource database:

   HPterm.name:              localTerminal

   localTerminal*background  white

then the localTerminal window will be white, overriding the colors used by the current palette.

Names and Classes of Resources

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.

Name/Class Precedence

Specific resource specifications always have precedence over general specifications. For example, suppose a resource file contains:

   *Foreground:           red

   HPterm*Foreground:     DarkSlateGray

   HPterm*foreground:     coral

   HPterm*cursorColor:    green

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:

   hpterm.name:                 local

   HPterm*softkey*background:   wheat

   HPterm*background:           pink

   local*background:            white

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.

Wildcards and Exact Paths

The * character in a resource string is a wildcard that provides resource generality. For example, the following list of resources shows increasing specificity.

   *foreground:                 white

   hpterm*foreground:           yellow

   hpterm*softkey*foreground:   red

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.

© 1995 Hewlett-Packard Development Company, L.P.