libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiText.h
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2009-2026
4 * GuiText.h
5 ***************************************************************************/
6#pragma once
7
9class GuiText : public GuiElement
10{
11 public:
16 GuiText(const char * t, int s, PixelColor c);
20 GuiText(const char * t);
22 ~GuiText();
25 void setText(const char * t);
28 void setWText(wchar_t * t);
30 int getLength();
39 static void setPresets(int sz, PixelColor c, int w, uint16_t s, ALIGN_H h, ALIGN_V v);
42 void setFontSize(int s);
45 void setMaxWidth(int w);
47 int getTextWidth();
51 void getNaturalSize(int& w, int& h) override;
54 void setScroll(SCROLL s);
58 void setWrap(bool w, int width = 0);
61 void setColor(PixelColor c);
64 void setStyle(uint16_t s);
68 void setAlignment(ALIGN_H hor, ALIGN_V vert);
70 void resetText();
72 void draw() override;
73 private:
74 PixelColor color;
75 wchar_t* text;
76 wchar_t *textDyn[20];
77 int textDynNum;
78 char * origText;
79 int size;
80 int maxWidth;
81 SCROLL textScroll;
82 int textScrollPos;
83 int textScrollInitialDelay;
84 int textScrollDelay;
85 uint32_t textScrollLastTick = 0;
86 uint16_t style;
87 bool wrap;
88
89 wchar_t* getText(const char *text) const;
90 bool scrollStepDue();
91};
92
93extern GuiTextTranslator* textTranslator;
int width
Element width.
Definition GuiElement.h:268
GuiElement()
Constructor.
Definition GuiElement.cpp:9
Hashed msgid -> UTF-8 string table loaded from a single binary .lang blob (see loadLanguage()).
void setWrap(bool w, int width=0)
Enables/disables text wrapping.
Definition GuiText.cpp:206
void setColor(PixelColor c)
Sets the font color.
Definition GuiText.cpp:245
void resetText()
Updates the text to the selected language.
Definition GuiText.cpp:289
GuiText(const char *t, int s, PixelColor c)
Constructor.
Definition GuiText.cpp:24
~GuiText()
Destructor.
Definition GuiText.cpp:88
void setScroll(SCROLL s)
Enables/disables text scrolling.
Definition GuiText.cpp:223
static void setPresets(int sz, PixelColor c, int w, uint16_t s, ALIGN_H h, ALIGN_V v)
Sets up preset values to be used by GuiText(t) Useful when printing multiple text elements,...
Definition GuiText.cpp:166
void getNaturalSize(int &w, int &h) override
Gets the text's size for layout: its rendered width and height on one line (at most the maximum width...
Definition GuiText.cpp:484
void setFontSize(int s)
Sets the font size.
Definition GuiText.cpp:176
void setText(const char *t)
Sets the text of the GuiText element.
Definition GuiText.cpp:107
int getTextWidth()
Gets the width of the text when rendered.
Definition GuiText.cpp:197
void draw() override
Constantly called to draw the text.
Definition GuiText.cpp:332
void setWText(wchar_t *t)
Sets the text of the GuiText element.
Definition GuiText.cpp:134
void setMaxWidth(int w)
Sets the maximum width of the drawn texture image.
Definition GuiText.cpp:181
int getLength()
Gets the translated text length of the GuiText element.
Definition GuiText.cpp:158
void setStyle(uint16_t s)
Sets the GuiTextRenderer style attributes.
Definition GuiText.cpp:251
void setAlignment(ALIGN_H hor, ALIGN_V vert)
Sets the text alignment.
Definition GuiText.cpp:256
SCROLL
Scrolling mode of a GuiText (none or horizontal).
Definition Gui.h:41
ALIGN_V
Vertical alignment of a GuiElement relative to its parent.
Definition GuiElement.h:20
ALIGN_H
Horizontal alignment of a GuiElement relative to its parent.
Definition GuiElement.h:28
8-bit-per-channel RGBA color used by the video interfaces.
Definition Mesh.h:16