Using Styled Text element

The Styled Text element seems to be used very rare or not used at all. This may come from the fact that the users know so little about this element. In this regard, I intent to present some aspects related to this element.

The Styled Text element can present only static text. No data elements can be presented using it. The major feature of this Styled Text element is the fact that it can contain as content text having different formatting for different text segments. One word can be bold, another can be italic, and another can have a specific color as foreground. The text content can be spread through several lines.

A short example is presented in Figure 1 :

Styled Text Editor

Figure 1: Styled Text Editor

In Figure 2 we can see the Microsoft Word output produce from the Styled Text:

Microsoft Word Output

Figure 2: Microsoft Word Output

If we need more formatting options for the Styled Text element, like the Font Size property,or  maybe a Style to be applied to it, we have to insert this Style Text element into a Paragraph element. We will use formatting inheritance feature of Rational Publishing Engine.

 Adding Style on Paragraph

Figure 3: Adding Style on Paragraph

Setting the desired value for Font Size or a Style to be Paragraph will assure that the proper settings will be applied to the Styled Text content.

In the Figure 4 is presented the output when the RPE Style named Title is applied to the paragraph containing the Styled Text element.

RPE Generated Output

Figure 4: RPE Generated Output

The Styled Text element can be useful in some situations when a user need some fancy static text to be presented in output. Styled Text element offers a quick method to achieve that. There is an alternative, more expensive to implement, in which we have to use one or more paragraphs and Text element. For each block of text having different formatting properties, we will need another Text element.

One Comments to “Using Styled Text element”

  1. Yury Levin says:

    Thanks. But I’m looking for any code example, uses StyledText widget for XML-like text presentation. I could not adjust existing Eclipse’ StructuredTextEditor class…

Leave a Reply