gcn::Label Class Reference

#include <label.hpp>

Inheritance diagram for gcn::Label:

gcn::Widget List of all members.

Detailed Description

Implementation of a label capable of displaying a caption.

Definition at line 71 of file label.hpp.

Public Member Functions

void adjustSize ()
 Adjusts the label's size to fit the caption.
virtual void draw (Graphics *graphics)
 Draws the widget.
Graphics::Alignment getAlignment () const
 Gets the alignment of the caption.
const std::string & getCaption () const
 Gets the caption of the label.
 Label (const std::string &caption)
 Constructor.
 Label ()
 Constructor.
void setAlignment (Graphics::Alignment alignment)
 Sets the alignment of the caption.
void setCaption (const std::string &caption)
 Sets the caption of the label.

Protected Attributes

Graphics::Alignment mAlignment
 Holds the alignment of the caption.
std::string mCaption
 Holds the caption of the label.


Constructor & Destructor Documentation

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

Constructor.

The label will be automatically resized to fit the caption.

Parameters:
caption The caption of the label.

Definition at line 74 of file label.cpp.

References gcn::Widget::getFont(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), gcn::Graphics::LEFT, 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 widget's dimension.

Parameters:
graphics aA graphics object to draw with.
Since:
0.1.0

Implements gcn::Widget.

Definition at line 103 of file label.cpp.

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

Graphics::Alignment gcn::Label::getAlignment (  )  const

Gets the alignment of the caption.

The alignment is relative to the center of the label.

Returns:
The alignment of caption of the label.
See also:
setAlignmentm Graphics

Definition at line 98 of file label.cpp.

References mAlignment.

Referenced by draw().

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

Gets the caption of the label.

Returns:
The caption of the label.
See also:
setCaption

Definition at line 83 of file label.cpp.

References mCaption.

Referenced by adjustSize(), and draw().

void gcn::Label::setAlignment ( Graphics::Alignment  alignment  ) 

Sets the alignment of the caption.

The alignment is relative to the center of the label.

Parameters:
alignemnt The alignment of the caption of the label.
See also:
getAlignment, Graphics

Definition at line 93 of file label.cpp.

References mAlignment.

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

Sets the caption of the label.

It's advisable to call adjustSize after setting of the caption to adjust the label's size to fit the caption.

Parameters:
caption The caption of the label.
See also:
getCaption, adjustSize

Definition at line 88 of file label.cpp.

References mCaption.

Referenced by gcn::Tab::setCaption().


The documentation for this class was generated from the following files:
Generated on Sun Jan 20 21:48:15 2008 for Guichan by  doxygen 1.5.2