Woopsi 1.3
Nintendo DS Gui Framework
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
WoopsiUI::Label Class Reference

#include <libwoopsi/include/label.h>

Inheritance diagram for WoopsiUI::Label:
WoopsiUI::Gadget WoopsiUI::Button WoopsiUI::TextBox WoopsiUI::CheckBox WoopsiUI::CycleButton WoopsiUI::DecorationGlyphButton WoopsiUI::RadioButton WoopsiUI::StickyButton WoopsiUI::WindowBorderButton WoopsiUI::WoopsiKey

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 WoopsiStringgetText () 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)
void setBorderless (bool isBorderless)

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 void markTextRectDamaged ()
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 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 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:
xThe x co-ordinate of the text box, relative to its parent.
yThe y co-ordinate of the text box, relative to its parent.
widthThe width of the textbox.
heightThe height of the textbox.
textPointer to a string to display in the textbox.
styleThe 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:
textString 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:
portThe 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:
portThe 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:
rectReference to a rect to populate with data.

Reimplemented from WoopsiUI::Gadget.

Reimplemented in WoopsiUI::CycleButton, and WoopsiUI::TextBox.

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:
textThe text to insert.
indexIndex at which to insert the text.

Reimplemented in WoopsiUI::TextBox.

virtual void WoopsiUI::Label::markTextRectDamaged ( ) [protected, virtual]

Marks the horizontal band containing the text as damaged, ready for redrawing.

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

Resize the gadget to the new dimensions.

Parameters:
widthThe new width.
heightThe 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.

void WoopsiUI::Label::setBorderless ( bool  isBorderless) [virtual]

Sets this gadget's border state.

Parameters:
isBorderlessThe border state.

Reimplemented from WoopsiUI::Gadget.

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

Sets the font.

Parameters:
fontA 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:
textString to display.

Reimplemented in WoopsiUI::TextBox.

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

Set the horizontal alignment of text within the label.

Parameters:
alignmentThe horizontal position of the text.
virtual void WoopsiUI::Label::setTextAlignmentVert ( TextAlignmentVert  alignment) [virtual]

Set the vertical alignment of text within the label.

Parameters:
alignmentThe vertical position of the text.

Member Data Documentation

Horizontal alignment of the text.

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.

Vertical alignment of the text.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Enumerator