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

       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::DefaultFont Class Reference

#include <defaultfont.h>

Inheritance diagram for gcn::DefaultFont:

gcn::Font

List of all members.

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)
virtual int getWidth (const std::string &text) const
virtual int getHeight () const
virtual int getStringIndexAt (const std::string &text, int x)


Detailed Description

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

Definition at line 67 of file defaultfont.h.


Constructor & Destructor Documentation

virtual gcn::DefaultFont::~DefaultFont (  )  [inline, virtual]

Destructor.

Definition at line 74 of file defaultfont.h.


Member Function Documentation

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:
graphics a Graphics object to be used for drawing.
glyph a glyph to draw.
x the x coordinate where to draw the glyph.
y the y coordinate where to draw the glyph.
Returns:
the width of the glyph in pixels.

Definition at line 74 of file defaultfont.cpp.

References gcn::Graphics::drawRectangle().

Referenced by drawString().

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

Draws a string.

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

Parameters:
graphics a Graphics object to use for drawing.
text the string to draw.
x the x coordinate where to draw the string.
y the y coordinate where to draw the string.

Implements gcn::Font.

Definition at line 81 of file defaultfont.cpp.

References drawGlyph(), and 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:
text the string to return the width of.
Returns:
the width of a string.

Implements gcn::Font.

Definition at line 69 of file defaultfont.cpp.

Referenced by drawString().

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.

Definition at line 64 of file defaultfont.cpp.

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.

Definition at line 92 of file defaultfont.cpp.


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

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