54 void draw()
const override;
106 DERIVE_EVENT_HANDLERS(
Text)
Display text to the screen.
Definition text.hpp:18
void setWrap(bool wrap)
Set whether text wraps.
uisize_t getWidthAtChar(unsigned int index) const
Get the width (in pixels) of a substring of the total text.
String text
The text to display.
Definition text.hpp:23
bool wrap
If true, wrap the text when reaching the right side of the parent widget. If false,...
Definition text.hpp:29
Text(const String &text, const GFXfont &font, color_t color=COLOR_WHITE, const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP}, bool wrap=true)
Construct text with a given font.
color_t textColor
The text color.
Definition text.hpp:27
Text(const String &text, fontsize_t scale=1, color_t color=COLOR_WHITE, const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP}, bool wrap=true)
Construct text with the built-in font.
void setText(const String &text)
Set the text to display.
const GFXfont * font
The font to render the text in. If null, defaults to the built-in font.
Definition text.hpp:21
color_t getColor() const
Get the current widget color.
void setColor(color_t new_color)
Set the text color.
const String & getText() const
Get the currently displayed text.
fontsize_t scale
A scaling factor for the text, e.g. 2x, 3x, etc.
Definition text.hpp:25
Size size() const override
Get the size of the widget.
void setFont(const GFXfont &font)
Set the font to render text in.
void draw() const override
Render the widget to the screen.
void setScale(fontsize_t scale)
Set the scaling factor for the text.
uint16_t color_t
An RGB565 color value. 5 bits red, 6 bits green, 5 bits blue.
Definition color.hpp:13
uint16_t fontsize_t
A non-negative integer for font sizes.
Definition fontsize.hpp:12
uint16_t uisize_t
A non-negative size for UI widgets.
Definition size.hpp:12
A struct that holds a widget's vertical and horizontal alignment.
Definition alignment.hpp:22
A struct that holds the normalized position of a widget.
Definition position.hpp:15
A struct that holds the number of pixels that a widget would take up on the screen.
Definition size.hpp:17