[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide

Sharing Text Sources

Each Text widget has a data structure of type XmTextSource that functions as the source and sink of text for the widget. The source is the value of the XmNsource resource.

Two or more Text widgets can share the same source. In this case, editing of Text in one widget changes the text of the source and therefore the text of all widgets that share that source. For example, an application might use a PanedWindow with multiple text widgets, each functioning as a "window" onto a single text source. Editing changes in one pane are reflected in all Text panes that share the same source.

An application creates a Text source by creating a Text widget. The program uses XmTextGetSource for Text or XtGetValues for the XmNsource resource to obtain that widget's source. The application then creates another Text widget, supplying the source obtained from the first widget by using XmTextSetSource, the initialization argument list, or XtSetValues of the XmNsource resource.

Setting a Text source destroys the existing source of the widget if no other widgets are sharing that source. To replace a Text source but keep it for later use, the application can create an unmanaged Text widget and set its source to the Text source the program wants to keep.

If the application does not supply a source, Text creates a default string source.

[ Previous | Next | Contents | Glossary | Home | Search ]