International Language Environments Guide

How to Develop CTL Applications

The following sections show how to develop CTL applications.

Layout Direction

The direction of a compound string is stored so that the data structure is equally useful for describing text in left-to-right languages such as English, Spanish, French, and German, or for text in right-to-left languages, such as Hebrew and Arabic. In Motif applications, you can set the layout direction using the XmNlayoutDirection resource from the VendorShell or MenuShell. Manager and Primitive widgets (as well as Gadgets) also have an XmNlayoutDirection resource. The default value is inherited from the closest ancestor with the same resource.

In the case of an XmText widget, you must specify the vertical direction as well. Setting the layoutDirection to XmRIGHT_TO_LEFT results in the string direction from right-to-left, but the cursor moves vertically down. If the vertical direction is important and you require top to bottom alignment, be sure to specify XmRIGHT_TO_LEFT_TOP_TO_BOTTOM, which specifies that the components are laid out from right-to-left first and then top-to-bottom, and results in the desired behavior.

Furthermore, the behavior of XmText and TextField widgets is influenced by the XmNalignment and XmNlayoutModifier resources of the XmRendition. These resources, in addition to XmNlayoutDirection, control the layout behavior of the Text widget. This behavior is illustrated in Figure 6–2.

The input string used in the figure is:

Graphic

The XmNlayoutModifier string @ls orientation= setting values for the following figure are shown in the left column.

Figure 6–2 Layout Direction

Graphic

As the illustration shows, XmNAlignment dictates whether the text is flush right or left in conjunction with the layout direction. XmNlayoutModifier breaks the text into segments and arranges them left-to-right or right-to-left, depending on the orientation value. In other words, if the XmNlayoutDirection is XmRIGHT_TO_LEFT, and the XmNAlignment value is XmALIGNMENT_BEGINNING, the string is flush right.