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



Text Resources and Geometry

In addition to the resources discussed in the previous section, Text has many others, including the following:

  1. The text itself, XmNvalue or XmNvalueWcs. For Text and TextField, the text is represented to the application as an array of either char elements (for XmNvalue) or wchar_t elements (for XmNvalueWcs). The application can set or get either resource.

  2. The render table (XmNrenderTable) that the widget uses to select a font or font set and other attributes to display the text. Text and TextField use only the font-related rendition resources of the render table.

  3. Resources representing the insertion cursor position and blink rate, the position of text at the top of the window, and whether the insertion cursor is always visible. A text position (of type XmTextPosition) is an integer representing the number of characters from the beginning of the buffer.

  4. A resource (XmNmaxLength) representing the maximum length of the text string that the user can enter.

  5. A resource (XmNwordWrap) that specifies whether lines are broken at word boundaries when the text would be wider than the widget. Breaking a line at a word boundary does not insert a newline into the text.

    In addition, Text and TextField have several resources that determine the geometry of the widget:

    1. Two resources, XmNmarginHeight and XmNmarginWidth, that determine the margins between the text and the shadow, if present. Text and TextField also use the Primitive resources that determine shadow and highlight appearance.

    2. Resources that specify the number of rows of text (XmNrows) and the number of horizontal character positions (XmNcolumns). Single-line Text and TextField always have one row.

    3. Resources that determine whether or not the widget grows vertically (XmNresizeHeight) or horizontally (XmNresizeWidth) to accommodate all its text. XmNresizeHeight does not apply to single-line Text or TextField.

    4. Resources that apply only when the widget is inside a ScrolledWindow whose XmNvisualPolicy is XmVARIABLE. XmNscrollHorizontal determines whether or not the widget should have a horizontal ScrollBar and should scroll horizontally instead of growing when the text expands beyond the width allocated for it. XmNscrollVertical determines whether or not the widget should have a vertical ScrollBar and should scroll vertically instead of growing when the text expands beyond the height allocated for it. XmNscrollLeftSide and XmNscrollTopSide determine which side of the widget receives the corresponding ScrollBar. These resources do not apply to TextField, and XmNscrollVertical and XmNscrollLeftSide do not apply to single-line Text.

      XmNresizeWidth is initialized to False when XmNscrollHorizontal is True or XmNwordWrap is True. XmNresizeHeight is initialized to False when XmNscrollVertical is True. Word wrap will not take effect if XmNscrollHorizontal is True.

      If the user or application initializes or sets a specific height (XmNheight) or width (XmNwidth), that value is used as the corresponding dimension of the widget. In addition, if a height is specified, XmNrows is recalculated based on that height and, if a width is specified, XmNcolumns is recalculated based on that width.

      If the user or application initializes or sets XmNrows but not XmNheight, the geometry calculation depends on the value of XmNresizeHeight. If XmNresizeHeight is False, as it is by default, the height of the widget is simply the height needed to display XmNrows of text. The same relations hold for XmNcolumns, XmNwidth, and XmNresizeWidth.

      If the user or application does not initialize either XmNrows or XmNheight, the geometry calculation depends on the value of XmNresizeHeight. If XmNresizeHeight is True, the height of the widget is the height needed to display all the text. If XmNresizeHeight is False, the height of the widget is the height needed to display the default for XmNrows, which is one row of text. The same relations hold for XmNcolumns, XmNwidth, and XmNresizeWidth, except that the default number of columns is 20.

      If the contents of the text (XmNvalue or XmNvalueWcs) change, as a result of user editing or an action by the application, the geometry calculation depends on the value of XmNresizeHeight. If XmNresizeHeight is True, the height of the widget is the height needed to display all the text. If XmNresizeHeight is False, the height of the widget does not change. The same relations hold for XmNvalue, XmNvalueWcs, XmNresizeWidth, and the width of the widget.

      If the application sets another resource that affects the height needed by the widget, such as XmNmarginHeight or XmNrenderTable, the geometry calculation depends on the value of XmNresizeHeight. If XmNresizeHeight is True, the height of the widget is the height needed to display all the text with the new resource values. If XmNresizeHeight is False, the height of the widget is the height needed to display XmNrows of text by using the new resources. The same relations hold for these resources, XmNresizeWidth, XmNcolumns, and the width of the widget.

      Note:

      Most of the resources described in this section have other meanings when XmNlayoutDirection is XmTOP_TO_BOTTOM (for vertical writing). For example, if word-wrapping is turned on, text is broken at the end of a column and is continued at the next column.


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