Article # 233, added by Geoworks, historical record
| first | previous | index | next | last |

How to make a "font" setting for the mail editor.



Here is how to make a "font" setting for the mail editor which would
work in a similar way to the one in the Notebook app - just a menu of
fonts whose selection will be stored in the init file.

This is very complicated. A font control is not intended to work
independently of a text object, so you have to use an invisible text
object and some UI tricks.

Here is how Notebook does this:
* Create a dummy text object, not connected to the gen tree (I don't
  know if all these settings are required, but the safest approach
  is to use them all).

(TextSetupVisTextClass is a subclass of VisTextClass)

/*
 * Text object only used to set and get the text attributes.
 */
@class TextSetupVisTextClass TextSetupTextObject = {
    VI_optFlags = (@default) & ~VOF_GEOMETRY_INVALID;
    VI_attrs = (@default) | VA_REALIZED;
    VTI_state = VTS_EDITABLE | VTS_TARGETABLE;
    VTI_storageFlags = (@default) | VTSF_MULTIPLE_CHAR_ATTRS;
    VTI_charAttrRuns = @NotesEditTextCharAttrRuns;
    ATTR_VIS_TEXT_NOTIFY_EVEN_IF_NOT_TARGETED;
}

* Set the output of the font control to this text.
* When you open the settings window, read the current font information
  from the init file and set the appropriate parameters on the text
  object: MSG_VIS_TEXT_SET_FONT_ID(id, TEXT_ADDRESS_PAST_END, 0).
* Subclass MSG_VIS_TEXT_SET_FONT_ID to call superclass (which will set
  the controller), and then write the value to the init file.