![]() |
• Interface Manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
API Links
Developer Links
|
class TextWidgetDefined in:
The C4Widgets.hTextWidget class represents an interface widget that displays a text string.
Definition
Member Functions
Constructor
Parameters
Description
The TextWidget class handles all text rendering in the C4 Engine. A text widget displays a text string of arbitrary length using a single font. Text can be rendered on a single line, or it can be rendered on multiple lines in a text box. There are also several formatting tags that can be embedded in the text to control color, underlining, and alignment.If the text parameter is not nullptr, then the string that it points to is copied into the text widget. If the font parameter is not nullptr, then the font resource corresponding to the specified path is loaded and used for the text widget.The size parameter specifies the size of a text widget's render box. The text box is used in different ways depending on the value of the text flags (see TextWidget::SetTextFlags). By default, only the kTextClipped flag is set, and the text widget renders text on a single line that is clipped on the left and right sides of the widget's bounds. A text widget can be changed to a multi-line text box configuration by calling the TextWidget::SetTextFlags function to set the kTextWrapped flag.If the kTextWrapped flag is set, then the width of the text box determines the maximum width of each rendered line. The width also determines how right- and center-aligned text is positioned. The height of the text box is not used for anything other than the background size for an editable text widget. Multi-line text widgets are bottomless unless the rendered line count is set using the TextWidget::SetRenderLineCount function.If the kTextWrapped flag is not set, then text is always rendered on a single line. If the kTextClipped flag is set, then the text is clipped against the left and right edges of the text box. Otherwise, the width of the text box only affects alignment positioning. If the text box has a width of 0.0, then the left end, right end, or center of the text will coincide with the text widget's local origin. (If the kTextClipped flag remains set in this case, however, no text is rendered because it is completely clipped away.)The text stored in a text widget may contain embedded formatting tags. A formatting tag is composed of four characters enclosed in square brackets. Formatting can be disabled altogether by setting the kTextUnformatted flag with the TextWidget::SetTextFlags function, and specific types of formatting can be masked off using the TextWidget::SetTextFormatExclusionMask function. (By default, alignment formatting is masked.) The following table lists the formatting tags recognized by the text widget.
The default widget color corresponds to the kWidgetColorText color type and determines the initial color of the text. The kWidgetColorLine color type is also supported by the text widget, and it controls the color of any underlining.
Base Classes
See Also
|