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



DrawingArea and Advanced Text Editing

Some applications may need text-editing capabilities beyond those provided by the Motif Text widget. For example, the application may want to display text using different fonts or colors within the same editor. Such an application might use a DrawingArea to implement a text editor based on compound strings.

Text Output

An application that uses compound strings can use XmStringDraw or XmStringDrawImage to display the compound string text in a DrawingArea. These functions use different Xlib routines to display compound string segments, depending on whether the segments are associated with font sets or font structs in the font list. XmStringDraw uses XmbDrawString to display segments associated with font sets. It uses XDrawString or XDrawString16 to display segments associated with font structs. XmStringDrawImage uses XmbDrawImageString to display segments associated with font sets. It uses XDrawImageString or XDrawImageString16 to display segments associated with font structs.

An application that does not use compound strings may call the Xlib text-drawing routines directly. In addition to those mentioned previously, these include XDrawText for text associated with a font and XmbDrawText for text associated with a font set. Wide-character versions exist for all the Xmb routines.

An application that draws text must determine where to place the text, what the width and height of the text will be, and how to move to the origin of the next text it will draw. For compound strings, an application can use XmStringExtent, XmStringHeight, XmStringWidth, and XmStringBaseline to determine the extents of the text.

An application that does not use compound strings may call Xlib routines. To determine the extents of a font struct, the application can examine the ascent, descent, max_bounds, and min_bounds members of the XFontStruct. To determine the width and extents of text, the application can call XStringWidth, XTextExtents, and XTextExtents16.

To determine the extents of a font set, the application can call XExtentsOfFontSet. To determine the width and extents of text, the application can call XmbTextEscapement, XmbTextExtents, and XmbTextPerCharExtents. Wide-character versions exist for all the Xmb routines.

For more information about the Xlib text facilities, see Xlib--C Language X Interface.

Text Input

To obtain text input in a DrawingArea, an application should use the Xlib input method facilities. These facilities allow the application to open an input method and an input context and to obtain input from the input method. For more information, see Chapter 11 and Xlib--C Language X Interface.


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