Tutorial Six: Compound Strings and Font Lists

 

Tutorial Six: Compound Strings and Font Lists

In this tutorial, you will experiment briefly with Builder Xcessory's major tools for implementing internationalization, the Compound String Editor and the Font List Editor. Review the discussion of these editors in the Builder Xcessory Reference Manual before proceeding with the tutorial.

Clearing the BX display

Clear the Builder Xcessory display by selecting New from the Browser File menu.

Compound Strings

Builder Xcessory supports compound strings and font lists to assist you in the development of internationalized applications. Specifically, it allows you to build compound strings that combine the characters of multiple character sets.

Creating and applying a font list

In this example you will create and apply members of a font list to the labelString resource of a Label widget.

If you have questions about this procedure, review Creating and Resizing a Widget Instance .
If you have questions about this procedure, review Updating the Resource Editor .
  1. Create a Label widget.
  2. Update the Resource Editor.
  3. Confirm that the Resource Editor is displaying all of the resources of the currently selected widget by selecting All Resources from the Resource Editor Resources menu.

Using Compound Strings

Bring up the Compound String Editor for the Label widget's labelString resource.

If you have questions about this procedure, review Using an Extended Editor .

Compound String Editor

The Compound String Editor contains the following components:

· A CombinationBox widget, displaying a Font Tag text field.

· A large arrow button pointing to the right. This indicates the direction in which entered text is read.

· The text field (currently containing the string "label"). In this field you can edit the string and apply different font tags to different parts of the string.

· A Show Output toggle. When the toggle is set, the compound string is previewed in the lower window. Any changes made in the editor are reflected in this window before the contents are applied to the currently selected widget resource using the OK button.

Experiment for a moment to demonstrate how these components work.

Show Output example

As an example of how Show Output works:

When it is set, the button appears pushed in.
Notice that the altered string is displayed in the Show Output window ( Show Output Window ), but not in the widget itself:
  1. Make sure the Show Output toggle is set.
  2. Put an insertion point at the end of the string "label", press return, and enter the string "wysiwyg".

Show Output Window

The widget label now reflects the full contents of the editor.
  1. Click the Apply button at the bottom of the Compound String Editor.
  2. As an example of how the direction indicator works, click the arrow to point right to left. On a line under the string "wysiwyg", type the string "backward" and click the Apply button.
  3. Note: This part of the string reads right to left (see Right to Left Reading String ).

Right to Left Reading String

  1. Click the direction button back to left-to-right before proceeding.

Font Tags

Any segment of the compound string that is not explicitly tagged takes the default font tag at run-time. The default font tag is assigned according to the following order of precedence:

  1. The first (top-most) untagged font in the Font List associated with the widget.
  2. The first tagged font in the Font List (if all fonts are tagged).

The first unnamed tag in the Font List is FONTLIST_DEFAULT_TAG_STRING.

  1. Click the arrow button to the right of the Font Tag label on the Compound String Editor.
  2. Note: There are currently no other font tags in the font list.
To create a new font tag, use the Font List Editor:

Font List Editor

The font definition of the currently selected member of the list (the default, untagged font) is copied to the new, unnamed, tag.
The tag is applied to the new member of the list.
This text is all tagged as new_tag. You can also tag text by highlighting it and then selecting a tag from the pop-down menu.
  1. Click New to create a new tag.
  2. Enter the name new_tag in the Font Tag text field and press return (or click the OK button to the right of the text field).
  3. Enter new_tag in the Font Tag text field and press return.
  4. On a new line below "backward", enter the string "And now for something completely different..." and click Apply.
  5. Select the three characters "abe" in the string "label", pop down the menu and select new_tag, and click Apply.

Editing font tags

You will now change the characteristics of new_tag by editing the tag using the Font List Editor.

Note that there is one entry in the list, with no associated tag.
Don't worry about aesthetic value here; use your imagination and create something completely different from the rather staid default font definition. For example, make the Size very large or very small.
This applies the full font list, including the newly created font, new_tag, as the resource value for the Label widget's fontList resource.
Note that the list appears in the text field to the right of the fontList resource on the Resource Editor, in the form:
<lots of font info>,<lots of font info>=new_tag.
  1. Display the Font List Editor for the fontList resource of the Label object (see Font List Editor ).
  2. On the Font List Editor, change the definition of new_tag by picking new settings on the Family and Size pop-up menus, and the Bold and Italic toggles.
  3. Click the Apply button on the bottom of the Font List Editor.
  4. Click the Dismiss button to remove the Font List Editor.

Applying font tags

Returning to the Compound String Editor, you'll notice that the font has not changed either in Show Output.

Click Apply on the Compound String Editor.

The new font is applied correctly in both the preview and the widget. A sample font change is shown in Compound String with Multiple Character Sets :

Compound String with Multiple Character Sets

That's all there is to creating compound strings that combine the characters of multiple character sets.

You have now completed Tutorial Six.

 

Documentation: