_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Member Functions | List of all members
gcn::DefaultFont Class Reference

#include <defaultfont.h>

Inheritance diagram for gcn::DefaultFont:
gcn::Font

Public Member Functions

virtual ~DefaultFont ()
 
virtual int drawGlyph (Graphics *graphics, unsigned char glyph, int x, int y)
 
virtual void drawString (Graphics *graphics, const std::string &text, int x, int y, bool is_normal)
 
virtual int getWidth (const std::string &text) const
 
virtual int getHeight () const
 
virtual int getStringIndexAt (const std::string &text, int x)
 
- Public Member Functions inherited from gcn::Font
virtual ~Font ()
 

Detailed Description

A font only capable of drawing rectangles. It is used by default merely to show that no font have been set.

Constructor & Destructor Documentation

◆ ~DefaultFont()

virtual gcn::DefaultFont::~DefaultFont ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ drawGlyph()

int gcn::DefaultFont::drawGlyph ( Graphics graphics,
unsigned char  glyph,
int  x,
int  y 
)
virtual

Draws a glyph as a rectangle. The glyphs always be drawn as rectangles no matter the glyph.

NOTE: You normally won't use this function to draw text since the Graphics class contains better functions for drawing text.

Parameters
graphicsa Graphics object to be used for drawing.
glypha glyph to draw.
xthe x coordinate where to draw the glyph.
ythe y coordinate where to draw the glyph.
Returns
the width of the glyph in pixels.

◆ drawString()

void gcn::DefaultFont::drawString ( Graphics graphics,
const std::string &  text,
int  x,
int  y,
bool  is_normal 
)
virtual

Draws a string.

NOTE: You normally won't use this function to draw text since Graphics contains better functions for drawing text.

Parameters
graphicsa Graphics object to use for drawing.
textthe string to draw.
xthe x coordinate where to draw the string.
ythe y coordinate where to draw the string.

Implements gcn::Font.

◆ getHeight()

int gcn::DefaultFont::getHeight ( ) const
virtual

Gets the height of the glyphs in the font.

Returns
the height of the glyphs int the font.

Implements gcn::Font.

◆ getStringIndexAt()

int gcn::DefaultFont::getStringIndexAt ( const std::string &  text,
int  x 
)
virtual

Gets a string index in a string providing an x coordinate. Used to retrive a string index (for a character in a string) at a certain x position. It is especially useful when a mouse clicks in a TextField and you want to know which character was clicked.

Returns
a string index in a string providing an x coordinate.

Reimplemented from gcn::Font.

◆ getWidth()

int gcn::DefaultFont::getWidth ( const std::string &  text) const
virtual

Gets the width of a string. The width of a string is not necesserily the sum of all the widths of it's glyphs.

Parameters
textthe string to return the width of.
Returns
the width of a string.

Implements gcn::Font.


The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.