Next: Chapter 6  Index, Glossary and Bibliography Up: Part I  User's Guide Previous: Chapter 4  Drawings


Chapter 5
Managing Visual Styles

As we already mentioned, the key difference between the RichDoc framework and classical strictly WYSIWYG word processors is sharp separation of document structure from its visual representation. To get some specific visual representation of a document, we must apply some visual formatting rules to the document. These rules are defined in a structure called style sheet. Since the style sheet does not depend on the document, we may use different style sheets for the same document to get alternative visual representations of the document, see Figure 5.1. It is, of course, also possible to apply the same style sheet to a group of documents to provide uniform look and feel for such group.

[picture]
Document
Style
Sheet A
Visual
Representation A
Style
Sheet B
Visual
Representation B
[end of picture]

Figure 5.1 Applying Visual Rules to a Document

The style sheet structure may be split into several cascades, to provide rules of different levels of generality, see Figure 5.2. There may be general style files providing rules applicable for wide variety of situations, which may be refined with more specific style files providing exceptions from general cases. When the visual presentation module needs to find a specific visual formatting rule, it first checks the more specific style files, and continues up the cascade until an appropriate rule is found. The style language used to define style files is described in detail in Chapter 19.

[picture]
Style
File 
Style
File 
general rules
specific rules
rule lookup
[end of picture]

Figure 5.2 Cascading Style Sheets

As described in Section 2.5, it is possible to assign each document element some visual attributes such as font and color, in an ad-hoc manner. This is convenient for handling special cases, but for regularly occurring patterns, it is recommended to treat visual attributes more systematically.

For each document element type, such as paragraph, paragraph fragment, table or section, has some standard set of visual properties that is acquired from the style sheet currently in use. We may, however, declare special named variants, called classes for any element type, and override the visual properties for these. For some elements, there are already some predefined classes, such as class border for tables, but you can create your own classes. For each class, you may define a set of attributes in the same way as you define attributes for a concrete document elements. You can then associate instances of document elements with an appropriate class, which causes the element to inherit all visual attributes from its class. You can later change the attributes of the class, and all elements associated with that class immediately reset their appearance to reflect the changes. It is of course possible to override the inherited values with ad-hoc settings for each individual element.

[picture]
class drop-down lists
[end of picture]

Figure 5.3 Specifying Class from the Toolbar

We can specify the name of element class using the toolbar, see Figure 5.3. Select the element for which you want to set the class, and access the drop-down list on its toolbar. Here either type the class name, or select it from the list. When the class is specified, the element view immediately acquires visual attributes from the class and resets its appearance accordingly.


Next: Chapter 6  Index, Glossary and Bibliography Up: Part I  User's Guide Previous: Chapter 4  Drawings