libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiText Class Reference

Display, manage, and manipulate text in the GUI. More...

#include <GuiText.h>

Inheritance diagram for GuiText:
[legend]

Public Member Functions

 GuiText (const char *t, int s, PixelColor c)
 Constructor.
 
 GuiText (const char *t)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Assumes SetPresets() has been called to setup preferred text attributes.
 
 ~GuiText ()
 Destructor.
 
void setText (const char *t)
 Sets the text of the GuiText element.
 
void setWText (wchar_t *t)
 Sets the text of the GuiText element.
 
int getLength ()
 Gets the translated text length of the GuiText element.
 
void setFontSize (int s)
 Sets the font size.
 
void setMaxWidth (int w)
 Sets the maximum width of the drawn texture image.
 
int getTextWidth ()
 Gets the width of the text when rendered.
 
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, if one is set).
 
void setScroll (SCROLL s)
 Enables/disables text scrolling.
 
void setWrap (bool w, int width=0)
 Enables/disables text wrapping.
 
void setColor (PixelColor c)
 Sets the font color.
 
void setStyle (uint16_t s)
 Sets the GuiTextRenderer style attributes.
 
void setAlignment (ALIGN_H hor, ALIGN_V vert)
 Sets the text alignment.
 
void resetText ()
 Updates the text to the selected language.
 
void draw () override
 Constantly called to draw the text.
 
- Public Member Functions inherited from GuiElement
 GuiElement ()
 Constructor.
 
virtual ~GuiElement ()
 Destructor.
 
void setParent (GuiElement *e)
 Set the element's parent.
 
GuiElement * getParent ()
 Gets the element's parent.
 
virtual void remove (GuiElement *)
 Removes the specified child.
 
void setRemoveOnDestroy (bool autoRemove)
 Whether to notify parent on destruction to allow removal.
 
int getLeft ()
 Gets the current leftmost coordinate of the element Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values.
 
int getTop ()
 Gets the current topmost coordinate of the element Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values.
 
void setMinY (int y)
 Sets the minimum y offset of the element.
 
int getMinY ()
 Gets the minimum y offset of the element.
 
void setMaxY (int y)
 Sets the maximum y offset of the element.
 
int getMaxY ()
 Gets the maximum y offset of the element.
 
void setMinX (int x)
 Sets the minimum x offset of the element.
 
int getMinX ()
 Gets the minimum x offset of the element.
 
void setMaxX (int x)
 Sets the maximum x offset of the element.
 
int getMaxX ()
 Gets the maximum x offset of the element.
 
int getWidth ()
 Gets the current width of the element.
 
int getHeight ()
 Gets the height of the element.
 
void setSize (int w, int h)
 Sets the size (width/height) of the element.
 
bool isVisible ()
 Checks whether or not the element is visible.
 
bool isSelectable ()
 Checks whether or not the element is selectable.
 
bool isClickable ()
 Checks whether or not the element is clickable.
 
bool isHoldable ()
 Checks whether or not the element is holdable.
 
void setSelectable (bool s)
 Sets whether or not the element is selectable.
 
void setClickable (bool c)
 Sets whether or not the element is clickable.
 
void setHoldable (bool h)
 Sets whether or not the element is holdable.
 
STATE getState ()
 Gets the element's current state.
 
int getStateChan ()
 Gets the controller channel that last changed the element's state.
 
void setAlpha (int a)
 Sets the element's alpha value.
 
int getAlpha ()
 Gets the element's alpha value Considers alpha, alphaDyn, and the parent element's GetAlpha() value.
 
void setScale (float s)
 Sets the element's x and y scale.
 
void setScaleX (float s)
 Sets the element's x scale.
 
void setScaleY (float s)
 Sets the element's y scale.
 
void setScale (int w, int h)
 Sets the element's x and y scale, using the provided max width/height.
 
float getScale ()
 Gets the element's current scale Considers scale, scaleDyn, and the parent element's GetScale() value.
 
float getScaleX ()
 Gets the element's current x scale Considers scale, scaleDyn, and the parent element's GetScale() value.
 
float getScaleY ()
 Gets the element's current y scale Considers scale, scaleDyn, and the parent element's GetScale() value.
 
void setTrigger (GuiTrigger *t)
 Set a new GuiTrigger for the element.
 
void setTrigger (uint8_t i, GuiTrigger *t)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool isRumble ()
 Checks whether rumble was requested by the element.
 
void setRumble (bool r)
 Sets whether or not the element is requesting a rumble event.
 
void setEffect (int e, int a, int t=0)
 Set an effect for the element.
 
void setEffectOnOver (int e, int a, int t=0)
 Sets an effect to be enabled on wiimote cursor over.
 
void setEffectGrow ()
 Shortcut to SetEffectOnOver(EFFECT::SCALE, 4, 110)
 
int getEffect ()
 Gets the current element effects.
 
bool isInside (int x, int y)
 Checks whether the specified coordinates are within the element's boundaries.
 
void setPosition (int x, int y)
 Sets the element's position.
 
void updateEffects ()
 Updates the element's effects (dynamic values) Called by Draw(), used for animation purposes.
 
void setUpdateCallback (UpdateCallback u)
 Sets a function to called after after Update() Callback function can be used to response to changes in the state of the element, and/or update the element's attributes.
 
int isFocused ()
 Checks whether the element is in focus.
 
virtual void setVisible (bool v)
 Sets the element's visibility.
 
virtual void setFocus (int f)
 Sets the element's focus.
 
virtual void setState (STATE s, int c=-1)
 Sets the element's state.
 
virtual void resetState ()
 Resets the element's state to STATE::DEFAULT.
 
virtual int getSelected ()
 Gets whether or not the element is in STATE::SELECTED.
 
virtual void setLayoutPosition (int x, int y)
 Places the element so its top-left corner is at (x, y) relative to its parent's top-left (default: LEFT/TOP alignment plus an offset)
 
virtual void setLayoutSize (int w, int h)
 Gives the element a size chosen by a container (default: sets width and height)
 
virtual void layout ()
 Brings the element's own layout up to date.
 
virtual void collectNavigable (std::vector< GuiElement * > &out)
 Appends the elements that selection can move between (default: this element; layout containers add their children instead, so the D-pad moves through them)
 
virtual void update (InputController *c)
 Called constantly to allow the element to respond to the current input data.
 

Static Public Member Functions

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, all with the same attributes set.
 

Additional Inherited Members

- Protected Attributes inherited from GuiElement
GuiTrigger * trigger [MAX_TRIGGERS]
 GuiTriggers (input actions) that this element responds to.
 
UpdateCallback updateCB
 Callback function to call when this element is updated.
 
GuiElement * parentElement
 Parent element.
 
bool removeOnDestroy
 Whether to instruct parent to remove this element when it is destroyed.
 
int focus
 Element focus (-1 = focus disabled, 0 = not focused, 1 = focused)
 
int width
 Element width.
 
int height
 Element height.
 
int xoffset
 Element X offset.
 
int yoffset
 Element Y offset.
 
int ymin
 Element's min Y offset allowed.
 
int ymax
 Element's max Y offset allowed.
 
int xmin
 Element's min X offset allowed.
 
int xmax
 Element's max X offset allowed.
 
int xoffsetDyn
 Element X offset, dynamic (added to xoffset value for animation effects)
 
int yoffsetDyn
 Element Y offset, dynamic (added to yoffset value for animation effects)
 
int alpha
 Element alpha value (0-255)
 
int alphaDyn
 Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
 
float xscale
 Element X scale (1 = 100%)
 
float yscale
 Element Y scale (1 = 100%)
 
float scaleDyn
 Element scale, dynamic (multiplied by alpha value for blending/fading effects)
 
int effects
 Currently enabled effect(s).
 
int effectAmount
 Effect amount.
 
int effectTarget
 Effect target amount.
 
int effectsOver
 Effects to enable when wiimote cursor is over this element.
 
int effectAmountOver
 EffectAmount to set when wiimote cursor is over this element.
 
int effectTargetOver
 EffectTarget to set when wiimote cursor is over this element.
 
ALIGN_H alignmentHor
 Horizontal element alignment, respective to parent element (LEFT, RIGHT, CENTRE)
 
ALIGN_V alignmentVert
 Horizontal element alignment, respective to parent element (TOP, BOTTOM, MIDDLE)
 
STATE state
 Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
 
int stateChan
 Which controller channel is responsible for the last change in state.
 
bool selectable
 Whether or not this element selectable (can change to SELECTED state)
 
bool clickable
 Whether or not this element is clickable (can change to CLICKED state)
 
bool holdable
 Whether or not this element is holdable (can change to HELD state)
 
bool visible
 Visibility of the element.
 
bool rumble
 Wiimote rumble (on/off) - set to on when this element requests a rumble event.
 

Detailed Description

Display, manage, and manipulate text in the GUI.

Definition at line 9 of file GuiText.h.

Constructor & Destructor Documentation

◆ GuiText() [1/2]

GuiText::GuiText ( const char * t,
int s,
PixelColor c )

Constructor.

Constructor for the GuiText class.

Parameters
tText
sFont size
cFont color

Definition at line 24 of file GuiText.cpp.

◆ GuiText() [2/2]

GuiText::GuiText ( const char * t)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Assumes SetPresets() has been called to setup preferred text attributes.

Constructor for the GuiText class, uses presets.

Parameters
tText

Definition at line 56 of file GuiText.cpp.

◆ ~GuiText()

GuiText::~GuiText ( )

Destructor.

Destructor for the GuiText class.

Definition at line 88 of file GuiText.cpp.

Member Function Documentation

◆ draw()

void GuiText::draw ( )
overridevirtual

Constantly called to draw the text.

Draw the text on screen.

Implements GuiElement.

Definition at line 332 of file GuiText.cpp.

◆ getLength()

int GuiText::getLength ( )

Gets the translated text length of the GuiText element.

Definition at line 158 of file GuiText.cpp.

◆ getNaturalSize()

void GuiText::getNaturalSize ( int & w,
int & h )
overridevirtual

Gets the text's size for layout: its rendered width and height on one line (at most the maximum width, if one is set).

A layout container places text by its top-left corner: it calls setAlignment(LEFT, TOP), which anchors the text there.

Reimplemented from GuiElement.

Definition at line 484 of file GuiText.cpp.

◆ getTextWidth()

int GuiText::getTextWidth ( )

Gets the width of the text when rendered.

Definition at line 197 of file GuiText.cpp.

◆ resetText()

void GuiText::resetText ( )
virtual

Updates the text to the selected language.

Reimplemented from GuiElement.

Definition at line 289 of file GuiText.cpp.

◆ setAlignment()

void GuiText::setAlignment ( ALIGN_H hor,
ALIGN_V vert )
virtual

Sets the text alignment.

Parameters
horHorizontal alignment (LEFT, RIGHT, CENTRE)
vertVertical alignment (TOP, BOTTOM, MIDDLE)

Reimplemented from GuiElement.

Definition at line 256 of file GuiText.cpp.

◆ setColor()

void GuiText::setColor ( PixelColor c)

Sets the font color.

Parameters
cFont color

Definition at line 245 of file GuiText.cpp.

◆ setFontSize()

void GuiText::setFontSize ( int s)

Sets the font size.

Parameters
sFont size

Definition at line 176 of file GuiText.cpp.

◆ setMaxWidth()

void GuiText::setMaxWidth ( int w)

Sets the maximum width of the drawn texture image.

Parameters
wMaximum width

Definition at line 181 of file GuiText.cpp.

◆ setPresets()

void GuiText::setPresets ( int sz,
PixelColor c,
int w,
uint16_t s,
ALIGN_H h,
ALIGN_V v )
static

Sets up preset values to be used by GuiText(t) Useful when printing multiple text elements, all with the same attributes set.

Parameters
szFont size
cFont color
wMaximum width of texture image (for text wrapping)
sFont size
hText alignment (horizontal)
vText alignment (vertical)

Definition at line 166 of file GuiText.cpp.

◆ setScroll()

void GuiText::setScroll ( SCROLL s)

Enables/disables text scrolling.

Parameters
sScrolling on/off

Definition at line 223 of file GuiText.cpp.

◆ setStyle()

void GuiText::setStyle ( uint16_t s)

Sets the GuiTextRenderer style attributes.

Parameters
sStyle attributes

Definition at line 251 of file GuiText.cpp.

◆ setText()

void GuiText::setText ( const char * t)

Sets the text of the GuiText element.

Parameters
tText

Definition at line 107 of file GuiText.cpp.

◆ setWrap()

void GuiText::setWrap ( bool w,
int width = 0 )

Enables/disables text wrapping.

Parameters
wWrapping on/off
widthMaximum width (0 to disable)

Definition at line 206 of file GuiText.cpp.

◆ setWText()

void GuiText::setWText ( wchar_t * t)

Sets the text of the GuiText element.

Parameters
tUTF-8 Text

Definition at line 134 of file GuiText.cpp.


The documentation for this class was generated from the following files: