gcn::Label Class Reference

#include <label.hpp>

Inheritance diagram for gcn::Label:

gcn::Widget List of all members.

Detailed Description

A label for displaying text.

Definition at line 70 of file label.hpp.

Public Member Functions

 Label ()
 Constructor.
 Label (const std::string &caption)
 Constructor.
virtual const std::string & getCaption () const
 Gets the Label caption.
virtual void setCaption (const std::string &caption)
 Sets the Label caption.
virtual void setAlignment (unsigned int alignment)
 Sets the alignment for the caption.
virtual unsigned int getAlignment ()
 Gets the alignment for the caption.
virtual void adjustSize ()
 Adjusts the Label size to fit the font size.
virtual void draw (Graphics *graphics)
 Draws the Widget.
virtual void drawBorder (Graphics *graphics)
 Draws the Widget border.

Protected Attributes

std::string mCaption
unsigned int mAlignment


Constructor & Destructor Documentation

gcn::Label::Label ( const std::string &  caption  ) 

Constructor.

Parameters:
caption the Label caption.

Definition at line 74 of file label.cpp.

References gcn::Widget::getFont(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), mAlignment, mCaption, gcn::Widget::setHeight(), and gcn::Widget::setWidth().


Member Function Documentation

void gcn::Label::draw ( Graphics graphics  )  [virtual]

Draws the Widget.

It is called by the parent widget when it is time for the Widget to draw itself. The graphics object is set up so that all drawing is relative to the Widget, i.e coordinate (0,0) is the top-left corner of the Widget. It is not possible to draw outside of a Widgets dimension.

Parameters:
graphics a Graphics object to draw with.

Implements gcn::Widget.

Definition at line 103 of file label.cpp.

References gcn::Graphics::drawText(), getAlignment(), getCaption(), gcn::Widget::getFont(), gcn::Widget::getForegroundColor(), gcn::Font::getHeight(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), gcn::Graphics::setColor(), and gcn::Graphics::setFont().

void gcn::Label::drawBorder ( Graphics graphics  )  [virtual]

Draws the Widget border.

A border is drawn around a Widget. The width and height of the border is therefore the Widgets height+2*bordersize. Think of a painting that has a certain size, the border surrounds the painting.

Parameters:
graphics a Graphics object to draw with.

Reimplemented from gcn::Widget.

Definition at line 128 of file label.cpp.

References gcn::Color::a, gcn::Graphics::drawLine(), gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), and gcn::Graphics::setColor().

unsigned int gcn::Label::getAlignment (  )  [virtual]

Gets the alignment for the caption.

Returns:
alignment of caption.

Definition at line 98 of file label.cpp.

References mAlignment.

Referenced by draw().

const std::string & gcn::Label::getCaption (  )  const [virtual]

Gets the Label caption.

Returns:
the Label caption.

Definition at line 83 of file label.cpp.

References mCaption.

Referenced by adjustSize(), and draw().

void gcn::Label::setAlignment ( unsigned int  alignment  )  [virtual]

Sets the alignment for the caption.

Parameters:
alignemnt Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.
See also:
Graphics

Definition at line 93 of file label.cpp.

References mAlignment.

void gcn::Label::setCaption ( const std::string &  caption  )  [virtual]

Sets the Label caption.

Parameters:
caption the Label caption.

Definition at line 88 of file label.cpp.

References mCaption.


The documentation for this class was generated from the following files:
Generated on Sat Jul 29 19:38:49 2006 for Guichan by  doxygen 1.4.7