MAUI::Label Class Reference

#include <MAUI/Label.h>

Inheritance diagram for MAUI::Label:

MAUI::Widget MAUI::EditBox List of all members.

Detailed Description

A label widget is a simple widget capable of displaying text. The text can be aligned left, right or centered both vertically and horizontally.


Public Types

enum  HorizontalAlignment { HA_LEFT, HA_CENTER, HA_RIGHT }
enum  VerticalAlignment { VA_TOP, VA_CENTER, VA_BOTTOM }

Public Member Functions

 Label (int x, int y, int width, int height, Widget *parent)
 Label (int x, int y, int width, int height, Widget *parent, const String &caption, int backColor, Font *font)
void setMultiLine (bool b=true)
bool isMultiLine ()
void setHorizontalAlignment (HorizontalAlignment alignment)
void setVerticalAlignment (VerticalAlignment alignment)
virtual void setCaption (const String &caption)
void setFont (Font *font)
void setAutoSizeX (bool f=true)
void setAutoSizeY (bool f=true)
const StringgetCaption () const
FontgetFont () const
HorizontalAlignment getHorizontalAlignment () const
VerticalAlignment getVerticalAlignment () const
bool getAutoSizeX () const
bool getAutoSizeY () const
void setPaddingLeft (int l)
void setPaddingTop (int t)
void setPaddingRight (int r)
void setPaddingBottom (int b)
virtual void setParameter (const String &name, const String &value)
void update ()
virtual void add (Widget *w)
void setParent (Widget *w)
WidgetgetParent ()
Vector< Widget * > & getChildren ()
const Vector< Widget * > & getChildren () const
virtual void draw (bool forceDraw=false)
void requestRepaint ()
virtual bool isTransparent () const
virtual void setSkin (WidgetSkin *widgetSkin)
void setDrawBackground (bool b=true)
void setBackgroundColor (int col)
WidgetwidgetAt (const Point &p)
WidgetwidgetAt (int x, int y)
virtual void setPosition (int x, int y)
const PointgetPosition () const
const PointgetPaddedPosition () const
virtual void setWidth (int width)
int getWidth () const
virtual void setHeight (int height)
int getHeight () const
virtual const RectgetBounds ()
virtual bool contains (const Point &p)
virtual bool contains (int x, int y)
virtual void setSelected (bool selected=true)
bool isSelected () const
virtual void setEnabled (bool enabled=true)
bool isEnabled () const
virtual void trigger ()
void addWidgetListener (WidgetListener *wl)
void removeWidgetListener (WidgetListener *wl)
Vector< WidgetListener * > & getWidgetListeners ()
void setInputManager (InputManager *inputManager)
int getPaddingLeft () const
int getPaddingTop () const
int getPaddingRight () const
int getPaddingBottom () const
const RectgetPaddedBounds () const

Protected Member Functions

void getTextStart (int *x, int *y)
void drawWidget ()
void resize (int width, int height)
void calcStrSize ()
void drawBackground ()
void updateAbsolutePosition ()
void updateAbsolutePositionChildren (int x, int y)
void updatePaddedBounds ()
bool isDirty () const
void setDirty (bool d=true)

Protected Attributes

bool mustCalcStrSize
String caption
String cuttedCaption
Fontfont
bool autoSizeX
bool autoSizeY
bool multiLine
HorizontalAlignment horizontalAlignment
VerticalAlignment verticalAlignment
MAExtent strSize
int strWidth
int strHeight
Vector< Widget * > children
Widgetparent
Rect bounds
int relX
int relY
bool dirty
WidgetSkinskin
int backColor
bool shouldDrawBackground
bool selected
bool enabled
Vector< WidgetListener * > widgetListeners
InputManagermInputManager
Rect paddedBounds
int paddingLeft
int paddingTop
int paddingBottom
int paddingRight


Member Enumeration Documentation

enum MAUI::Label::HorizontalAlignment
 

Enumerator:
HA_LEFT 
HA_CENTER 
HA_RIGHT 

enum MAUI::Label::VerticalAlignment
 

Enumerator:
VA_TOP 
VA_CENTER 
VA_BOTTOM 


Constructor & Destructor Documentation

MAUI::Label::Label int  x,
int  y,
int  width,
int  height,
Widget parent
 

Constructor.

Parameters:
x the horizontal position of the Label relative to its parent's top left padded corner.
y the vertical position of the Label relative to its parent's top left padded corner
width the width of the Label.
height the height of the Label.
parent pointer to the parent widget. Passing anything else than NULL causes the Label to be added to the parent's children.

MAUI::Label::Label int  x,
int  y,
int  width,
int  height,
Widget parent,
const String caption,
int  backColor,
Font font
 

Constructor

Parameters:
x the horizontal position of the Label relative to its parent's top left padded corner.
y the vertical position of the Label relative to its parent's top left padded corner
width the width of the Label.
height the height of the Label.
parent pointer to the parent widget. Passing anything else than NULL causes the widget to be added to the parent's children.
caption the text displayed by the Label.
backColor the background color of the widget.
font the font to be used by to render the caption.


Member Function Documentation

void MAUI::Label::setMultiLine bool  b = true  ) 
 

Turns multiline mode on or off

bool MAUI::Label::isMultiLine  ) 
 

Returns whether multiline is enabled or not

void MAUI::Label::setHorizontalAlignment HorizontalAlignment  alignment  ) 
 

Controls the horizontal alignment of the labels text.

void MAUI::Label::setVerticalAlignment VerticalAlignment  alignment  ) 
 

Controls the horizontal alignment of the labels text.

virtual void MAUI::Label::setCaption const String caption  )  [virtual]
 

Sets the text that appears on the label

Reimplemented in MAUI::EditBox.

void MAUI::Label::setFont Font font  ) 
 

Sets the font used to render text on the label

void MAUI::Label::setAutoSizeX bool  f = true  ) 
 

When this is set to true the label will automatically be resized in the horizontal axis to perfectly fit the text. Then only new line characters in the label string will line break the text.

void MAUI::Label::setAutoSizeY bool  f = true  ) 
 

When this is set to true the label will automatically be resized in the vertical axis to perfectly fit the text.

const String& MAUI::Label::getCaption  )  const
 

Returns the text displayed on the label

Font* MAUI::Label::getFont  )  const
 

Returns the font used by this label

HorizontalAlignment MAUI::Label::getHorizontalAlignment  )  const
 

Returns the horizontal alignment of the label

VerticalAlignment MAUI::Label::getVerticalAlignment  )  const
 

Returns the vertical alignment of the label

bool MAUI::Label::getAutoSizeX  )  const
 

Returns wether the label automatically adjusts its width to accomodate its caption

bool MAUI::Label::getAutoSizeY  )  const
 

Returns wether the label automatically adjusts its height to acommodate its caption

void MAUI::Label::setPaddingLeft int  l  )  [virtual]
 

Set left padding width.

Reimplemented from MAUI::Widget.

void MAUI::Label::setPaddingTop int  t  )  [virtual]
 

Set top padding height.

Reimplemented from MAUI::Widget.

void MAUI::Label::setPaddingRight int  r  )  [virtual]
 

Set right padding width.

Reimplemented from MAUI::Widget.

void MAUI::Label::setPaddingBottom int  b  )  [virtual]
 

Set bottom padding height.

Reimplemented from MAUI::Widget.

virtual void MAUI::Label::setParameter const String name,
const String value
[virtual]
 

Reimplemented from MAUI::Widget.

void MAUI::Label::update  )  [virtual]
 

Reimplemented from MAUI::Widget.

void MAUI::Label::getTextStart int *  x,
int *  y
[protected]
 

void MAUI::Label::drawWidget  )  [protected, virtual]
 

This is the only function that is absolutely neccesary to implement when inheriting Widget to create a custom widget. It is responsible for painting the widget. When it is called, the widget must respect its own padded bounds and not extend rendering beyond that area.

Implements MAUI::Widget.

void MAUI::Label::resize int  width,
int  height
[protected]
 

void MAUI::Label::calcStrSize  )  [protected]
 

virtual void MAUI::Widget::add Widget w  )  [virtual, inherited]
 

Function used to add childs to a widget. The parent of the children will automatically be set. The widget cannot have a parent already.

Reimplemented in MAUI::Layout, and MAUI::ListBox.

void MAUI::Widget::setParent Widget w  )  [inherited]
 

Function used to set the parent of a widget. The widget will not be added to the parent as a child. The widget cannot have a parent already.

Widget* MAUI::Widget::getParent  )  [inherited]
 

Function to retrieve the parent of a widget.

Vector<Widget*>& MAUI::Widget::getChildren  )  [inherited]
 

Function to retrieve a reference to the list of childrens for a widget.

const Vector<Widget*>& MAUI::Widget::getChildren  )  const [inherited]
 

const version of getChildren()

virtual void MAUI::Widget::draw bool  forceDraw = false  )  [virtual, inherited]
 

Renders the Widget and all its children recursively.

Reimplemented in MAUI::ListBox.

void MAUI::Widget::requestRepaint  )  [inherited]
 

Registers an idle listener with the current environment that will redraw the widget and anything else that may be made dirty by doing so. For instance, if the widget is transparent its parent also has to be repainted, and so on recursively.

virtual bool MAUI::Widget::isTransparent  )  const [virtual, inherited]
 

Returns whether or not the widget is transparent. A widget is transparent if it has a skin that is transparent in the current selection state (selected/unselected) or if it has no solid background color.

virtual void MAUI::Widget::setSkin WidgetSkin widgetSkin  )  [virtual, inherited]
 

Assigns a widget skin to be used during the rendering of the widget. What The skin applies to varies depending on the widget. Labels extend the skin over their entire area, while listboxes apply the skin to each individual item they contain.

void MAUI::Widget::setDrawBackground bool  b = true  )  [inherited]
 

Sets the background drawing state. If b is true, the Widget's background will be drawn - otherwise not. In most cases, the background is either a constant color or a skin.

void MAUI::Widget::setBackgroundColor int  col  )  [inherited]
 

Widget* MAUI::Widget::widgetAt const Point p  )  [inherited]
 

Returns a pointer to the first child widget or deeper descendant, surrounding the point. Returns NULL if no widget is found.

Widget* MAUI::Widget::widgetAt int  x,
int  y
[inherited]
 

virtual void MAUI::Widget::setPosition int  x,
int  y
[virtual, inherited]
 

Sets the widget's position relative to its parent.

Reimplemented in MAUI::Layout.

const Point& MAUI::Widget::getPosition  )  const [inherited]
 

Gets the widget's position relative to its parent.

const Point& MAUI::Widget::getPaddedPosition  )  const [inherited]
 

Gets the widget's padded position relative to its parent.

virtual void MAUI::Widget::setWidth int  width  )  [virtual, inherited]
 

Sets the width of the widget

Reimplemented in MAUI::Layout, MAUI::ListBox, and MAP::MapWidget.

int MAUI::Widget::getWidth  )  const [inherited]
 

Returns the width of the widget

virtual void MAUI::Widget::setHeight int  height  )  [virtual, inherited]
 

Sets the height of the widget

Reimplemented in MAUI::Layout, MAUI::ListBox, and MAP::MapWidget.

int MAUI::Widget::getHeight  )  const [inherited]
 

Returns the height of the widget

virtual const Rect& MAUI::Widget::getBounds  )  [virtual, inherited]
 

Returns a Rect containing the absolute screen position of the widget together with its dimensions.

virtual bool MAUI::Widget::contains const Point p  )  [virtual, inherited]
 

Check if widget surrounds position 'p'.

virtual bool MAUI::Widget::contains int  x,
int  y
[virtual, inherited]
 

Check if widget surrounds position 'x' and 'y'.

virtual void MAUI::Widget::setSelected bool  selected = true  )  [virtual, inherited]
 

Set widget selected state (default: true).

Reimplemented in MAUI::EditBox.

bool MAUI::Widget::isSelected  )  const [inherited]
 

Is widget selected?.

virtual void MAUI::Widget::setEnabled bool  enabled = true  )  [virtual, inherited]
 

Set Widget enabled state

Reimplemented in MAUI::EditBox.

bool MAUI::Widget::isEnabled  )  const [inherited]
 

Is Widget enabled ?

virtual void MAUI::Widget::trigger  )  [virtual, inherited]
 

This function is called whenever the widget is "triggered", which is roughly equivalent to having been "clicked" on. However, sice MAUI is independant of input facilities, the more input-neutral concept of triggering is used.

Reimplemented in MAUI::Layout.

void MAUI::Widget::addWidgetListener WidgetListener wl  )  [inherited]
 

Add WidgetListener.

void MAUI::Widget::removeWidgetListener WidgetListener wl  )  [inherited]
 

Remove WidgetListener.

Vector<WidgetListener*>& MAUI::Widget::getWidgetListeners  )  [inherited]
 

returns a reference the the vector of Widget listeners

void MAUI::Widget::setInputManager InputManager inputManager  )  [inherited]
 

Sets the input manager to use for this widget

int MAUI::Widget::getPaddingLeft  )  const [inherited]
 

Get left padding width.

int MAUI::Widget::getPaddingTop  )  const [inherited]
 

Get top padding height.

int MAUI::Widget::getPaddingRight  )  const [inherited]
 

Get right padding width.

int MAUI::Widget::getPaddingBottom  )  const [inherited]
 

Get bottom padding height.

const Rect& MAUI::Widget::getPaddedBounds  )  const [inherited]
 

void MAUI::Widget::drawBackground  )  [protected, inherited]
 

void MAUI::Widget::updateAbsolutePosition  )  [protected, inherited]
 

This function is used to regenerate the absolute positions of each widget in the tree. This is done in a depth first manner where each widget takes the parent absolute position and adds it to their own relative position to calculate their absolute position.

void MAUI::Widget::updateAbsolutePositionChildren int  x,
int  y
[protected, inherited]
 

the recursive function used by updateAbsolutePosition().

void MAUI::Widget::updatePaddedBounds  )  [protected, inherited]
 

Used to recalculate the padded bounds from the global bounds.

bool MAUI::Widget::isDirty  )  const [protected, inherited]
 

Returns the dirty state of the widget, indicating whether it requires to be redrawn or not. When a widget calls requestRepaint(), it's dirty state is set to true. Normally, you shouldn't have to use isDirty() or setDirty() unless possibly when implementing your own widgets.

void MAUI::Widget::setDirty bool  d = true  )  [protected, inherited]
 

Sets the dirty state of the widget.


Member Data Documentation

bool MAUI::Label::mustCalcStrSize [protected]
 

String MAUI::Label::caption [protected]
 

String MAUI::Label::cuttedCaption [protected]
 

Font* MAUI::Label::font [protected]
 

bool MAUI::Label::autoSizeX [protected]
 

bool MAUI::Label::autoSizeY [protected]
 

bool MAUI::Label::multiLine [protected]
 

HorizontalAlignment MAUI::Label::horizontalAlignment [protected]
 

VerticalAlignment MAUI::Label::verticalAlignment [protected]
 

MAExtent MAUI::Label::strSize [protected]
 

int MAUI::Label::strWidth [protected]
 

int MAUI::Label::strHeight [protected]
 

Vector<Widget*> MAUI::Widget::children [protected, inherited]
 

Widget* MAUI::Widget::parent [protected, inherited]
 

Rect MAUI::Widget::bounds [protected, inherited]
 

int MAUI::Widget::relX [protected, inherited]
 

int MAUI::Widget::relY [protected, inherited]
 

bool MAUI::Widget::dirty [protected, inherited]
 

WidgetSkin* MAUI::Widget::skin [protected, inherited]
 

int MAUI::Widget::backColor [protected, inherited]
 

bool MAUI::Widget::shouldDrawBackground [protected, inherited]
 

bool MAUI::Widget::selected [protected, inherited]
 

bool MAUI::Widget::enabled [protected, inherited]
 

Vector<WidgetListener*> MAUI::Widget::widgetListeners [protected, inherited]
 

InputManager* MAUI::Widget::mInputManager [protected, inherited]
 

Rect MAUI::Widget::paddedBounds [protected, inherited]
 

int MAUI::Widget::paddingLeft [protected, inherited]
 

int MAUI::Widget::paddingTop [protected, inherited]
 

int MAUI::Widget::paddingBottom [protected, inherited]
 

int MAUI::Widget::paddingRight [protected, inherited]
 


Generated on Sat Feb 13 00:15:39 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO