UpPreviousNext

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.

  1. Create a Label widget.
  2. If you have questions about this procedure, review Creating and Resizing a Widget Instance .
  3. Update the Resource Editor.
  4. If you have questions about this procedure, review Updating the Resource Editor .
  5. 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:

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

Show Output Window

  1. Click the Apply button at the bottom of the Compound String Editor.
  2. The widget label now reflects the full contents of the editor.
  3. 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.

  4. 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

  1. Click New to create a new tag.
  2. The font definition of the currently selected member of the list (the default, untagged font) is copied to the new, unnamed, tag.
  3. 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).
  4. The tag is applied to the new member of the list.
  5. Enter new_tag in the Font Tag text field and press return.
  6. On a new line below "backward", enter the string "And now for something completely different..." and click Apply.
  7. 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.
  8. 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.

  1. Display the Font List Editor for the fontList resource of the Label object (see Font List Editor ).
  2. Note that there is one entry in the list, with no associated tag.
  3. 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.
  4. 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.
  5. Click the Apply button on the bottom of the Font List Editor.
  6. This applies the full font list, including the newly created font, new_tag, as the resource value for the Label widget's fontList resource.
  7. Click the Dismiss button to remove the Font List Editor.
  8. 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.

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.

UpPreviousNext