"Fossies" - the Fresh Open Source Software archive

Member "Tix8.4.3/docs/html/TixBook/subsubsection3_5_2_2.html" of archive Tix8.4.3-src.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. Alternatively you can here view or download the uninterpreted source code. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.



Next: Creating Display Items Up: Display Items Previous: Advantages of Display

 

Display Items and Display Styles 

The appearance of a display item is controlled by a set of attributes. For example, the text attribute controls the text string displayed on the item and the font attribute specifies what font should be used.

Usually, each of the attributes falls into one of two categroies: ``individual'' or ``collective''. For example, each of the items inside a TixTList widget may display a different text string; therefore we call the text string an individual attribute. However, in most cases, the items share the same color, font and spacing and we call these collective attributes.

One question concerns where we keep the collective attribute for the display items. Certainly, we can keep a font attribute for each item, but this is not really an efficient solution. In fact, if all the items have the same font, we would be keeping a duplicated copy of the same font for each of the items we create. Since a host widget may have many thousands of items, keeping thousands of dupilcated copys of the same font, or any other collective attributes, would be very wasteful.

To avoid the unnecessary duplication of resources, Tix stores the collective attributes in special objects called display styles. The relationship between display items and their styles is depicted in figure 3-4. Each item holds its own copy of the individual attributes, such as text. However, the collective attributes are stored in the style objects. Each item has a special style attribute that tells it which style it should use. In figure 3-4 , since items a and b are assigned the same style, therefore, they share the same font and color. Item c is assigned a different style, thus, it uses a different font than a and b.