|
Next: Resource Precedence Rules Up: Widget Resource Management Previous: Setting Resources
Resource MatchingWhen an application starts up, a merged resource database is created, from resource settings in the X resource manager and various text files, in the manner described in the preceeding sections. When a widget is created, its hierarchy using both instance names and class names, plus its resource instance names and class names, are compared against each resource setting in the application's merged resource database. In order to begin to understand the resource matching mechanism, consider setting the background colour of the quit button widget in the Athena version of the xbutton application. It is a Command class widget and, like all widget classes, inherits the resource background from the Core widget class. Suppose the merged resource database was: 1 xbutton.background: red What will be the background colour of the quit button? Looking at the entries in the merged resource database, only those that have background as the last element of the specification part are relevant. Thus, the third entry can be eleminated. Next, the widget's hierarchy, using both instance names and class names, is compared against the remaining entries. To be a contender, the first element of each entry's specification part must match the first element of the widget's hierarchy, either by instance name or class name, remembering that an asterisk will match anything. The widget hierarchy for the Athena version is: xbutton.quit (instance names) So, the fifth entry can be eliminated from the proceedings. The process continues by stripping off the first element (unless it is an asterisk) of the specification part of the remaining entries and also the first element of the widget's hierarchy. The entries from the merged resource database now appear as: 1 background: red The widget's hierarchy becomes: quit (instance names) The comparison continues as before. Thus, the first entry can now be eliminated. The matching process is now complete with the second, fourth and sixth entries all viable resource settings for the widget's background colour. There are precendence rules to determine which entry is ultimately chosen.
Next: Resource Precedence Rules Up: Widget Resource Management Previous: Setting Resources
JR Pitchers Wed May 3 16:45:04 BST 1995 |
|||||||||||||||||
With any suggestions or questions please feel free to contact us |