libwiigui 1.07
libwiigui is a GUI library for the Wii
 
Loading...
Searching...
No Matches
GuiText Class Reference

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

#include <gui_text.h>

Inheritance diagram for GuiText:
GuiElement

Public Member Functions

 GuiText (const char *t, int s, GXColor c)
 
 GuiText (const char *t)
 
 ~GuiText ()
 Destructor. More...
 
void SetText (const char *t)
 
void SetWText (wchar_t *t)
 
int GetLength ()
 Gets the translated text length of the GuiText element.
 
void SetFontSize (int s)
 
void SetMaxWidth (int w)
 
int GetTextWidth ()
 Gets the width of the text when rendered.
 
void SetScroll (SCROLL s)
 
void SetWrap (bool w, int width=0)
 
void SetColor (GXColor c)
 
void SetStyle (u16 s)
 
void SetAlignment (ALIGN_H hor, ALIGN_V vert)
 
void ResetText ()
 Updates the text to the selected language. More...
 
void Draw () override
 Constantly called to draw the text. More...
 
- Public Member Functions inherited from GuiElement
 GuiElement ()
 Constructor. More...
 
virtual ~GuiElement ()
 Destructor. More...
 
void SetParent (GuiElement *e)
 
GuiElementGetParent ()
 
int GetLeft ()
 
int GetTop ()
 
void SetMinY (int y)
 
int GetMinY ()
 
void SetMaxY (int y)
 
int GetMaxY ()
 
void SetMinX (int x)
 
int GetMinX ()
 
void SetMaxX (int x)
 
int GetMaxX ()
 
int GetWidth ()
 
int GetHeight ()
 
void SetSize (int w, int h)
 
bool IsVisible ()
 
bool IsSelectable ()
 
bool IsClickable ()
 
bool IsHoldable ()
 
void SetSelectable (bool s)
 
void SetClickable (bool c)
 
void SetHoldable (bool h)
 
STATE GetState ()
 
int GetStateChan ()
 
void SetAlpha (int a)
 
int GetAlpha ()
 
void SetScale (float s)
 
void SetScaleX (float s)
 
void SetScaleY (float s)
 
void SetScale (int w, int h)
 
float GetScale ()
 
float GetScaleX ()
 
float GetScaleY ()
 
void SetTrigger (GuiTrigger *t)
 
void SetTrigger (u8 i, GuiTrigger *t)
 
bool Rumble ()
 
void SetRumble (bool r)
 
void SetEffect (int e, int a, int t=0)
 
void SetEffectOnOver (int e, int a, int t=0)
 
void SetEffectGrow ()
 Shortcut to SetEffectOnOver(EFFECT_SCALE, 4, 110)
 
int GetEffect ()
 
bool IsInside (int x, int y)
 
void SetPosition (int x, int y)
 
void UpdateEffects ()
 
void SetUpdateCallback (UpdateCallback u)
 
int IsFocused ()
 
virtual void SetVisible (bool v)
 
virtual void SetFocus (int f)
 
virtual void SetState (STATE s, int c=-1)
 
virtual void ResetState ()
 Resets the element's state to STATE::DEFAULT. More...
 
virtual int GetSelected ()
 
virtual void SetAlignment (ALIGN_H hor, ALIGN_V vert)
 
virtual void ResetText ()
 Called when the language has changed, to obtain new text values for all text elements. More...
 
virtual void Update (GuiTrigger *t)
 
virtual void Draw ()=0
 Called constantly to redraw the element. More...
 
virtual void DrawTooltip ()
 Called constantly to redraw the element's tooltip. More...
 

Static Public Member Functions

static void SetPresets (int sz, GXColor c, int w, u16 s, ALIGN_H h, ALIGN_V v)
 

Protected Attributes

GXColor color
 Font color.
 
wchar_t * text
 Translated Unicode text value.
 
wchar_t * textDyn [20]
 Text value, if max width, scrolling, or wrapping enabled.
 
int textDynNum
 Number of text lines.
 
char * origText
 Original text data (English)
 
int size
 Font size.
 
int maxWidth
 Maximum width of the generated text object (for text wrapping)
 
SCROLL textScroll
 Scrolling toggle.
 
int textScrollPos
 Current starting index of text string for scrolling.
 
int textScrollInitialDelay
 Delay to wait before starting to scroll.
 
int textScrollDelay
 Scrolling speed.
 
u16 style
 FreeTypeGX style attributes.
 
bool wrap
 Wrapping toggle.
 
- Protected Attributes inherited from GuiElement
GuiTriggertrigger [MAX_TRIGGERS]
 GuiTriggers (input actions) that this element responds to.
 
UpdateCallback updateCB
 Callback function to call when this element is updated.
 
GuiElementparentElement
 Parent element.
 
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)
 
f32 xscale
 Element X scale (1 = 100%)
 
f32 yscale
 Element Y scale (1 = 100%)
 
f32 scaleDyn
 Element scale, dynamic (multiplied by alpha value for blending/fading effects)
 
int effects
 Currently enabled effect(s). 0 when no effects are enabled.
 
int effectAmount
 Effect amount. Used by different effects for different purposes.
 
int effectTarget
 Effect target amount. Used by different effects for different purposes.
 
int effectsOver
 Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event.
 
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. If false, Draw() is skipped.
 
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.

Constructor & Destructor Documentation

◆ GuiText() [1/2]

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

Constructor

Parameters
tText
sFont size
cFont color

Constructor for the GuiText class.

◆ 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

Parameters
tText

Constructor for the GuiText class, uses presets

◆ ~GuiText()

GuiText::~GuiText ( )

Destructor.

Destructor for the GuiText class.

Member Function Documentation

◆ Draw()

void GuiText::Draw ( )
overridevirtual

Constantly called to draw the text.

Draw the text on screen

Implements GuiElement.

◆ ResetText()

void GuiText::ResetText ( )
virtual

Updates the text to the selected language.

Reimplemented from GuiElement.

◆ 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.

◆ SetColor()

void GuiText::SetColor ( GXColor  c)

Sets the font color

Parameters
cFont color

◆ SetFontSize()

void GuiText::SetFontSize ( int  s)

Sets the font size

Parameters
sFont size

◆ SetMaxWidth()

void GuiText::SetMaxWidth ( int  w)

Sets the maximum width of the drawn texture image

Parameters
wMaximum width

◆ SetPresets()

void GuiText::SetPresets ( int  sz,
GXColor  c,
int  w,
u16  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)

◆ SetScroll()

void GuiText::SetScroll ( SCROLL  s)

Enables/disables text scrolling

Parameters
sScrolling on/off

◆ SetStyle()

void GuiText::SetStyle ( u16  s)

Sets the FreeTypeGX style attributes

Parameters
sStyle attributes

◆ SetText()

void GuiText::SetText ( const char *  t)

Sets the text of the GuiText element

Parameters
tText

◆ SetWrap()

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

Enables/disables text wrapping

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

◆ SetWText()

void GuiText::SetWText ( wchar_t *  t)

Sets the text of the GuiText element

Parameters
tUTF-8 Text

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