next up previous contents index
Next: 10. Hash & Cache Up: 9. Inside XmStrings Previous: 4. Structures   Contents   Index

5. The Other Side of XmStrings

As you can easily imagine, the ASN.1 representation of a XmString isn't very suitable for fast handling, yet saves memory. Another advantage of a XmString is that it is independent of a XmFontList. Only when you need to know the height and/or width of a XmString or want to render it into a drawable a XmFontList must be specified so that the individual string components can be ``connected'' to the fonts from the font list.

_XmStringCreate()_XmStringUpdate()If you need to work many times with a particular XmString (like the list widget) it is more convenient to ``compile'' the ASN.1 representation of a XmString into an internal form - a _XmString. The individual TLV's from the ASN.1 XmString are thereby transformed into string components accessible through pointers. The compilation is carried out with _XmStringCreate() which takes a XmString and returns a _XmString. Next after the transformation the references to the fonts should be resolved - use _XmStringUpdate() for this task. Lateron, you can update the fonts the (internal) _XmString will use whenever you want by calling _XmStringUpdate().

A _XmString is merely a pointer to a __XmStringRec. This structure points to a table of pointers to the string's components. In addition the __XmStringRec also accounts for the size of that table of pointers (see figure [*]). As the table of pointers can grow and shrink whenever the string gets manipulated, it may also move in memory. Thus the the _XmString pointer can't point directly to the components table but must point to a data structure instead which stays at the same memory location all the time (well - at the same logical or linear memory location as modern virtual memory management may move memory blocks at any time around the physical memory).

In turn the string components are described by __XmStringComponentRecs, which contain the type of a component (see table [*] on page [*]), the component's data, its length, and finally the font to be used. Every __XmStringComponentRec can thus be regarded as a TLV converted to a more suitable form to the CPU. The font member of the component record is just an index into a XmFontList. So be sure to update these indices with _XmStringUpdate() whenever the font list changes which is used for rendering the _XmString.

Figure: Internal representation of a ``compiled'' _XmString.
\begin{figure}
\hskip\leftmargin\epsfig{file=XmStringInt_Repr.eps,scale=1.09}\end{figure}


next up previous contents index
Next: 10. Hash & Cache Up: 9. Inside XmStrings Previous: 4. Structures   Contents   Index
Danny Backx
2000-12-13