# WoopsiUI::Label Class Reference

`#include <label.h>`

Inheritance diagram for WoopsiUI::Label:

List of all members.

## Public Types
enum | TextAlignmentHoriz { TEXT_ALIGNMENT_HORIZ_CENTRE = 0, TEXT_ALIGNMENT_HORIZ_LEFT = 1, TEXT_ALIGNMENT_HORIZ_RIGHT = 2 }
enum | TextAlignmentVert { TEXT_ALIGNMENT_VERT_CENTRE = 0, TEXT_ALIGNMENT_VERT_TOP = 1, TEXT_ALIGNMENT_VERT_BOTTOM = 2 }
## Public Member Functions
| Label (s16 x, s16 y, u16 width, u16 height, const WoopsiString &text, GadgetStyle *style=NULL)
virtual void | setTextAlignmentHoriz (TextAlignmentHoriz alignment)
virtual void | setTextAlignmentVert (TextAlignmentVert alignment)
virtual const WoopsiString & | getText () const
virtual void | setText (const WoopsiString &text)
virtual void | appendText (const WoopsiString &text)
virtual void | insertText (const WoopsiString &text, const u32 index)
virtual void | getPreferredDimensions (Rect &rect) const
virtual void | setFont (FontBase *font)
## Protected Member Functions
virtual void | drawContents (GraphicsPort *port)
virtual void | drawBorder (GraphicsPort *port)
virtual void | onResize (u16 width, u16 height)
virtual void | calculateTextPositionVertical ()
virtual void | calculateTextPositionHorizontal ()
virtual void | onTextChange ()
virtual | ~Label ()
| Label (const Label &label)
## Protected Attributes
WoopsiString | _text
s32 | _textX
s32 | _textY
TextAlignmentHoriz | _hAlignment
TextAlignmentVert | _vAlignment

## Detailed Description

Single-line label gadget. Can align text both vertically and horizontally in different ways.

## Member Enumeration Documentation

enum WoopsiUI::Label::TextAlignmentHoriz

Enum of horizontal alignment options.

Enumerator:

  TEXT_ALIGNMENT_HORIZ_CENTRE | Centre the text
  TEXT_ALIGNMENT_HORIZ_LEFT | Align left
  TEXT_ALIGNMENT_HORIZ_RIGHT | Align right

enum WoopsiUI::Label::TextAlignmentVert

Enum of vertical alignment options.

Enumerator:

  TEXT_ALIGNMENT_VERT_CENTRE | Align to centre of textbox
  TEXT_ALIGNMENT_VERT_TOP | Align to top of textbox
  TEXT_ALIGNMENT_VERT_BOTTOM | Align to bottom of textbox

## Constructor & Destructor Documentation

WoopsiUI::Label::Label | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | const WoopsiString & | text,
|  | GadgetStyle * | style = `NULL` |
| ) |  |  |

Constructor for a label containing a string.

Parameters:

  | x | The x co-ordinate of the text box, relative to its parent.
  | y | The y co-ordinate of the text box, relative to its parent.
  | width | The width of the textbox.
  | height | The height of the textbox.
  | text | Pointer to a string to display in the textbox.
  | style | The style that the gadget should use. If this is not specified, the gadget will use the values stored in the global defaultGadgetStyle object. The gadget will copy the properties of the style into its own internal style object.

virtual WoopsiUI::Label::~Label | ( |  | ) | `[inline, protected, virtual]`

Destructor.

WoopsiUI::Label::Label | ( | const Label & | label | ) | `[inline, protected]`

Copy constructor is protected to prevent usage.

## Member Function Documentation

virtual void WoopsiUI::Label::appendText | ( | const WoopsiString & | text | ) | `[virtual]`

Append new text to the end of the current text displayed in the label.

Parameters:

  | text | String to append.

Reimplemented in WoopsiUI::TextBox.

virtual void WoopsiUI::Label::calculateTextPositionHorizontal | ( |  | ) | `[protected, virtual]`

Calculate the position of the string based on its length and the alignment options.

Reimplemented in WoopsiUI::TextBox.

virtual void WoopsiUI::Label::calculateTextPositionVertical | ( |  | ) | `[protected, virtual]`

Calculate the vertical position of the string based on the font height and the alignment options.

virtual void WoopsiUI::Label::drawBorder | ( | GraphicsPort * | port | ) | `[protected, virtual]`

Draw the area of this gadget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters:

  | port | The GraphicsPort to draw to.

See also:
  redraw()

Reimplemented from WoopsiUI::Gadget.

Reimplemented in WoopsiUI::Button, WoopsiUI::CheckBox, WoopsiUI::CycleButton, WoopsiUI::DecorationGlyphButton, WoopsiUI::TextBox, and WoopsiUI::WindowBorderButton.

virtual void WoopsiUI::Label::drawContents | ( | GraphicsPort * | port | ) | `[protected, virtual]`

Draw the area of this gadget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters:

  | port | The GraphicsPort to draw to.

See also:
  redraw()

Reimplemented from WoopsiUI::Gadget.

Reimplemented in WoopsiUI::Button, WoopsiUI::CheckBox, WoopsiUI::CycleButton, WoopsiUI::DecorationGlyphButton, WoopsiUI::RadioButton, WoopsiUI::TextBox, and WoopsiUI::WindowBorderButton.

virtual void WoopsiUI::Label::getPreferredDimensions | ( | Rect & | rect | ) | const`[virtual]`

Insert the dimensions that this gadget wants to have into the rect passed in as a parameter. All co-ordinates are relative to the gadget's parent.

Parameters:

  | rect | Reference to a rect to populate with data.

Reimplemented from WoopsiUI::Gadget.

Reimplemented in WoopsiUI::CycleButton.

virtual const WoopsiString& WoopsiUI::Label::getText | ( |  | ) | const`[inline, virtual]`

Returns the string shown in the label.

Returns:
  The label's text.

virtual void WoopsiUI::Label::insertText | ( | const WoopsiString & | text,
|  | const u32 | index |
| ) |  |  | `[virtual]`

Insert text at the specified index.

Parameters:

  | text | The text to insert.
  | index | Index at which to insert the text.

Reimplemented in WoopsiUI::TextBox.

virtual void WoopsiUI::Label::onResize | ( | u16 | width,
|  | u16 | height |
| ) |  |  | `[protected, virtual]`

Resize the gadget to the new dimensions.

Parameters:

  | width | The new width.
  | height | The new height.

Reimplemented from WoopsiUI::Gadget.

Reimplemented in WoopsiUI::CycleButton.

virtual void WoopsiUI::Label::onTextChange | ( |  | ) | `[protected, virtual]`

Updates the GUI after the text has changed.

virtual void WoopsiUI::Label::setFont | ( | FontBase * | font | ) | `[virtual]`

Sets the font.

Parameters:

  | font | A pointer to the font to use.

Reimplemented from WoopsiUI::Gadget.

virtual void WoopsiUI::Label::setText | ( | const WoopsiString & | text | ) | `[virtual]`

Set the text displayed in the label.

Parameters:

  | text | String to display.

Reimplemented in WoopsiUI::TextBox.

virtual void WoopsiUI::Label::setTextAlignmentHoriz | ( | TextAlignmentHoriz | alignment | ) | `[virtual]`

Set the horizontal alignment of text within the label.

Parameters:

  | alignment | The horizontal position of the text.

virtual void WoopsiUI::Label::setTextAlignmentVert | ( | TextAlignmentVert | alignment | ) | `[virtual]`

Set the vertical alignment of text within the label.

Parameters:

  | alignment | The vertical position of the text.

## Member Data Documentation

TextAlignmentHoriz WoopsiUI::Label::_hAlignment`[protected]`

Horizontal alignment of the text

WoopsiString WoopsiUI::Label::_text`[protected]`

Text that the textbox will display

s32 WoopsiUI::Label::_textX`[protected]`

X co-ordinate of the text relative to the gadget

s32 WoopsiUI::Label::_textY`[protected]`

Y co-ordinate of the text relative to the gadget

TextAlignmentVert WoopsiUI::Label::_vAlignment`[protected]`

Vertical alignment of the text

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

- label.h