Chapter 3. Text labels

#include <x/w/label.H>

x::w::label s=factory->create_label("Hello world");
      

create_label() creates a simple display element, a x::w::label, that displays text. The first parameter to create_label() is actually a x::w::text_param object. An explicitly-constructed x::w::text_param gives the ability of using custom fonts and colors for the new label. Labels use a default font and color, if not specified in the x::w::text_param.

\n characters in the text string create labels with multiple lines. An optional second parameter controls the alignment of multiple lines of text:

x::w::halign::left (default)

Display the lines normally, left-aligned.

x::w::halign::center

Center all the lines.

x::w::halign::right

Align all lines against their right margin.

Sometimes it's desirable to explicitly set the alignment even for labels with just a single line of text. Normally display elements get automatically sized for their content. It's possible that a container adjusts the label to a wider size that it needs, due to other elements in the container, and the alignment setting will then govern how the text gets padded.