# 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 char *text, FontBase *font=NULL)
| Label (s16 x, s16 y, u16 width, u16 height, const char letter, FontBase *font=NULL)
virtual void | draw (Rect clipRect)
virtual void | setTextAlignmentHoriz (TextAlignmentHoriz alignment)
virtual void | setTextAlignmentVert (TextAlignmentVert alignment)
virtual const char * | getText () const
virtual void | setText (const char *text)
virtual void | setText (const char text)
virtual void | appendText (const char *text)
virtual void | appendText (const char text)
virtual void | insertText (const char *text, const u32 index)
virtual void | insertText (const char text, const u32 index)
virtual bool | resize (u16 width, u16 height)
virtual void | getPreferredDimensions (Rect &rect) const
## Protected Member Functions
virtual void | calculateTextPosition ()
virtual | ~Label ()
| Label (const Label &label)
## Protected Attributes
WoopsiString * | _text
u16 | _textX
u16 | _textY
u8 | _padding
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

Label::Label | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | const char * | text,
|  | FontBase * | font = `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.
  | font | The font to use in this text box.

Label::Label | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | const char | letter,
|  | FontBase * | font = `NULL` |
| ) |  |  |

Constructor for a label containing a single character.

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.
  | letter | Single character to display in the textbox.
  | font | The font to use in this text box.

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

void Label::appendText | ( | const char | text | ) | `[virtual]`

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

Parameters:

  | text | Char to append.

Reimplemented in WoopsiUI::TextBox.

void Label::appendText | ( | const char * | 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.

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

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

Reimplemented in WoopsiUI::CycleButton.

void Label::draw | ( | Rect | clipRect | ) | `[virtual]`

Draw the region of the label within the clipping rect. Should not be called directly.

Parameters:

  | clipRect | The clipping rect to limit drawing to.

Reimplemented from WoopsiUI::Gadget.

Reimplemented in WoopsiUI::Button, WoopsiUI::CheckBox, WoopsiUI::ContextMenuItem, WoopsiUI::CycleButton, WoopsiUI::DecorationGlyphButton, WoopsiUI::RadioButton, WoopsiUI::SkinnedScreenDepthButton, WoopsiUI::SkinnedScreenFlipButton, WoopsiUI::SkinnedWindowCloseButton, WoopsiUI::SkinnedWindowDepthButton, WoopsiUI::TextBox, and WoopsiUI::WindowBorderButton.

void 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 char* WoopsiUI::Label::getText | ( |  | ) | const`[inline, virtual]`

Returns a pointer to the string shown in the label.

Returns:
  Pointer to the string.

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

Insert text at the specified index.

Parameters:

  | text | Char to insert.
  | index | Index at which to insert the char.

Reimplemented in WoopsiUI::TextBox.

void Label::insertText | ( | const char * | 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.

bool Label::resize | ( | u16 | width,
|  | u16 | height |
| ) |  |  | `[virtual]`

Resize the gadget to the new dimensions.

Parameters:

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

Returns:
  True if the resize was successful.

Reimplemented from WoopsiUI::Gadget.

void Label::setText | ( | const char | text | ) | `[virtual]`

Set the text displayed in the label.

Parameters:

  | text | Character to display.

Reimplemented in WoopsiUI::TextBox.

void Label::setText | ( | const char * | text | ) | `[virtual]`

Set the text displayed in the label.

Parameters:

  | text | String to display.

Reimplemented in WoopsiUI::TextBox.

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

Set the horizontal alignment of text within the label.

Parameters:

  | alignment | The horizontal position of the text.

void 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

u8 WoopsiUI::Label::_padding`[protected]`

Padding around the text in pixels

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

Text that the textbox will display

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

X co-ordinate of the text relative to the gadget

u16 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 files:

- C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.39/Woopsi/woopsi/label.h
- C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.39/Woopsi/woopsi/label.cpp

All Classes Functions Variables Enumerations Enumerator