____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

gcn::Label Class Reference

#include <label.h>

Inheritance diagram for gcn::Label:

gcn::Widget

List of all members.

Public Member Functions

 Label ()
 Label (const std::string &caption)
virtual const std::string & getCaption () const
virtual void setCaption (const std::string &caption)
virtual void setAlignment (unsigned int alignment)
virtual unsigned int getAlignment ()
virtual void adjustSize ()
virtual void draw (Graphics *graphics)
virtual void drawBorder (Graphics *graphics)


Detailed Description

A label for displaying text.

Definition at line 68 of file label.h.


Constructor & Destructor Documentation

gcn::Label::Label (  ) 

Constructor.

Definition at line 64 of file label.cpp.

References gcn::Graphics::LEFT.

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

Constructor.

Parameters:
caption the Label caption.

Definition at line 69 of file label.cpp.

References gcn::Widget::getFont(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), gcn::Graphics::LEFT, gcn::Widget::setHeight(), and gcn::Widget::setWidth().


Member Function Documentation

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

Gets the Label caption.

Returns:
the Label caption.

Definition at line 78 of file label.cpp.

Referenced by adjustSize(), and draw().

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

Sets the Label caption.

Parameters:
caption the Label caption.

Definition at line 83 of file label.cpp.

References gcn::Widget::setDirty().

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

Sets the alignment for the caption.

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

Definition at line 89 of file label.cpp.

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

Gets the alignment for the caption.

Returns:
alignment of caption.

Definition at line 94 of file label.cpp.

Referenced by draw().

void gcn::Label::adjustSize (  )  [virtual]

Adjusts the Label size to fit the font size.

Definition at line 148 of file label.cpp.

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

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 99 of file label.cpp.

References gcn::Graphics::CENTER, gcn::Graphics::drawText(), GCN_EXCEPTION, 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().

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

Draws a 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 124 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().


The documentation for this class was generated from the following files:

Generated on Sat Feb 21 00:28:27 2009 for Bos Wars by  doxygen 1.5.6