summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-04 03:28:21 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-04 03:28:21 +0300
commitd18b9616bbe54db5d33363a197c8b9efa6161fa8 (patch)
tree56b1bca0f9ca60699810e2bf31625365c0affd42 /src/gui
parent07e988baf55b0e0f4b736e9305604536dbc872ff (diff)
downloadplus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.tar.gz
plus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.tar.bz2
plus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.tar.xz
plus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.zip
Rename TrueTypeFont to SDLFont.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp16
-rw-r--r--src/gui/sdlfont.cpp (renamed from src/gui/truetypefont.cpp)44
-rw-r--r--src/gui/sdlfont.h (renamed from src/gui/truetypefont.h)18
-rw-r--r--src/gui/widgets/textpreview.cpp6
4 files changed, 42 insertions, 42 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index baccb7796..aecb6a6f8 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -26,7 +26,7 @@
#include "gui/palette.h"
#include "gui/sdlinput.h"
#include "gui/theme.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "gui/widgets/mouseevent.h"
#include "gui/widgets/window.h"
@@ -113,7 +113,7 @@ Gui::Gui(Graphics *graphics):
try
{
- mGuiFont = new TrueTypeFont(fontFile, fontSize);
+ mGuiFont = new SDLFont(fontFile, fontSize);
}
catch (const gcn::Exception &e)
{
@@ -128,7 +128,7 @@ Gui::Gui(Graphics *graphics):
try
{
- mInfoParticleFont = new TrueTypeFont(
+ mInfoParticleFont = new SDLFont(
fontFile, fontSize, TTF_STYLE_BOLD);
}
catch (const gcn::Exception &e)
@@ -144,7 +144,7 @@ Gui::Gui(Graphics *graphics):
try
{
- boldFont = new TrueTypeFont(fontFile, fontSize);
+ boldFont = new SDLFont(fontFile, fontSize);
}
catch (const gcn::Exception &e)
{
@@ -159,7 +159,7 @@ Gui::Gui(Graphics *graphics):
try
{
- mHelpFont = new TrueTypeFont(fontFile, fontSize);
+ mHelpFont = new SDLFont(fontFile, fontSize);
}
catch (const gcn::Exception &e)
{
@@ -295,20 +295,20 @@ void Gui::updateFonts()
if (fontFile.empty())
fontFile = branding.getStringValue("font");
- static_cast<TrueTypeFont*>(mGuiFont)->loadFont(fontFile, fontSize);
+ static_cast<SDLFont*>(mGuiFont)->loadFont(fontFile, fontSize);
fontFile = config.getValue("particleFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("particleFont");
- static_cast<TrueTypeFont*>(mInfoParticleFont)->loadFont(
+ static_cast<SDLFont*>(mInfoParticleFont)->loadFont(
fontFile, fontSize, TTF_STYLE_BOLD);
fontFile = config.getValue("boldFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("boldFont");
- static_cast<TrueTypeFont*>(boldFont)->loadFont(fontFile, fontSize);
+ static_cast<SDLFont*>(boldFont)->loadFont(fontFile, fontSize);
}
void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
diff --git a/src/gui/truetypefont.cpp b/src/gui/sdlfont.cpp
index 62003d94c..ab20eee97 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -2,8 +2,8 @@
* The ManaPlus Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011 The ManaPlus Developers
* Copyright (C) 2009 Aethyra Development Team
+ * Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "client.h"
#include "graphics.h"
@@ -41,21 +41,21 @@ const unsigned int CACHE_SIZE_SMALL2 = 150;
char *strBuf;
-class TextChunk
+class SDLTextChunk
{
public:
- TextChunk(const std::string &text, const gcn::Color &color) :
+ SDLTextChunk(const std::string &text, const gcn::Color &color) :
img(0), text(text), color(color)
{
}
- ~TextChunk()
+ ~SDLTextChunk()
{
delete img;
img = 0;
}
- bool operator==(const TextChunk &chunk) const
+ bool operator==(const SDLTextChunk &chunk) const
{
return (chunk.text == text && chunk.color == color);
}
@@ -89,11 +89,11 @@ class TextChunk
gcn::Color color;
};
-typedef std::list<TextChunk>::iterator CacheIterator;
+typedef std::list<SDLTextChunk>::iterator CacheIterator;
static int fontCounter;
-TrueTypeFont::TrueTypeFont(const std::string &filename, int size, int style) :
+SDLFont::SDLFont(const std::string &filename, int size, int style) :
mCreateCounter(0),
mDeleteCounter(0)
{
@@ -121,7 +121,7 @@ TrueTypeFont::TrueTypeFont(const std::string &filename, int size, int style) :
"fonts/dejavusans.ttf").c_str(), size);
if (!mFont)
{
- throw GCN_EXCEPTION("SDLTrueTypeFont::SDLTrueTypeFont: " +
+ throw GCN_EXCEPTION("SDLSDLFont::SDLSDLFont: " +
std::string(TTF_GetError()));
}
}
@@ -130,7 +130,7 @@ TrueTypeFont::TrueTypeFont(const std::string &filename, int size, int style) :
mCleanTime = cur_time + 120;
}
-TrueTypeFont::~TrueTypeFont()
+SDLFont::~SDLFont()
{
TTF_CloseFont(mFont);
mFont = 0;
@@ -143,7 +143,7 @@ TrueTypeFont::~TrueTypeFont()
}
}
-void TrueTypeFont::loadFont(const std::string &filename, int size, int style)
+void SDLFont::loadFont(const std::string &filename, int size, int style)
{
ResourceManager *resman = ResourceManager::getInstance();
@@ -158,7 +158,7 @@ void TrueTypeFont::loadFont(const std::string &filename, int size, int style)
if (!font)
{
- logger->log("SDLTrueTypeFont::SDLTrueTypeFont: " +
+ logger->log("SDLSDLFont::SDLSDLFont: " +
std::string(TTF_GetError()));
return;
}
@@ -171,7 +171,7 @@ void TrueTypeFont::loadFont(const std::string &filename, int size, int style)
clear();
}
-void TrueTypeFont::clear()
+void SDLFont::clear()
{
for (unsigned short f = 0; f < static_cast<unsigned short>(
CACHES_NUMBER); f ++)
@@ -180,7 +180,7 @@ void TrueTypeFont::clear()
}
}
-void TrueTypeFont::drawString(gcn::Graphics *graphics,
+void SDLFont::drawString(gcn::Graphics *graphics,
const std::string &text,
int x, int y)
{
@@ -197,10 +197,10 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics,
*/
col.a = 255;
- TextChunk chunk(text, col);
+ SDLTextChunk chunk(text, col);
unsigned char chr = text[0];
- std::list<TextChunk> *cache = &mCache[chr];
+ std::list<SDLTextChunk> *cache = &mCache[chr];
bool found = false;
@@ -260,7 +260,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics,
}
-void TrueTypeFont::createTextChunk(TextChunk *chunk)
+void SDLFont::createSDLTextChunk(SDLTextChunk *chunk)
{
if (!chunk || chunk->text.empty())
return;
@@ -272,13 +272,13 @@ void TrueTypeFont::createTextChunk(TextChunk *chunk)
chunk->img->setAlpha(alpha);
}
-int TrueTypeFont::getWidth(const std::string &text) const
+int SDLFont::getWidth(const std::string &text) const
{
if (text.empty())
return 0;
unsigned char chr = text[0];
- std::list<TextChunk> *cache = &mCache[chr];
+ std::list<SDLTextChunk> *cache = &mCache[chr];
#ifdef DEBUG_FONT
int cnt = 0;
@@ -311,16 +311,16 @@ int TrueTypeFont::getWidth(const std::string &text) const
return w;
}
-int TrueTypeFont::getHeight() const
+int SDLFont::getHeight() const
{
return TTF_FontHeight(mFont);
}
-void TrueTypeFont::doClean()
+void SDLFont::doClean()
{
for (int f = 0; f < CACHES_NUMBER; f ++)
{
- std::list<TextChunk> *cache = &mCache[f];
+ std::list<SDLTextChunk> *cache = &mCache[f];
if (cache->size() > CACHE_SIZE_SMALL2)
{
#ifdef DEBUG_FONT_COUNTERS
diff --git a/src/gui/truetypefont.h b/src/gui/sdlfont.h
index 9279cee63..86ef2f1e9 100644
--- a/src/gui/truetypefont.h
+++ b/src/gui/sdlfont.h
@@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef TRUETYPEFONT_H
-#define TRUETYPEFONT_H
+#ifndef SDLFONT_H
+#define SDLFONT_H
#include <guichan/font.hpp>
@@ -41,14 +41,14 @@
#define CACHES_NUMBER 256
-class TextChunk;
+class SDLTextChunk;
/**
* A wrapper around SDL_ttf for allowing the use of TrueType fonts.
*
* <b>NOTE:</b> This class initializes SDL_ttf as necessary.
*/
-class TrueTypeFont : public gcn::Font
+class SDLFont : public gcn::Font
{
public:
/**
@@ -57,22 +57,22 @@ class TrueTypeFont : public gcn::Font
* @param filename Font filename.
* @param size Font size.
*/
- TrueTypeFont(const std::string &filename, int size, int style = 0);
+ SDLFont(const std::string &filename, int size, int style = 0);
/**
* Destructor.
*/
- ~TrueTypeFont();
+ ~SDLFont();
void loadFont(const std::string &filename, int size, int style = 0);
- void createTextChunk(TextChunk *chunk);
+ void createSDLTextChunk(SDLTextChunk *chunk);
virtual int getWidth(const std::string &text) const;
virtual int getHeight() const;
- std::list<TextChunk> *getCache()
+ std::list<SDLTextChunk> *getCache()
{ return mCache; }
/**
@@ -98,7 +98,7 @@ class TrueTypeFont : public gcn::Font
unsigned mDeleteCounter;
// Word surfaces cache
- mutable std::list<TextChunk> mCache[CACHES_NUMBER];
+ mutable std::list<SDLTextChunk> mCache[CACHES_NUMBER];
int mCleanTime;
};
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 6171a072f..6d41bef06 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -28,7 +28,7 @@
#include "gui/gui.h"
#include "gui/palette.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include <typeinfo>
@@ -66,9 +66,9 @@ void TextPreview::draw(gcn::Graphics* graphics)
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
- if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont))
+ if (mTextBGColor && typeid(*mFont) == typeid(SDLFont))
{
- TrueTypeFont *font = static_cast<TrueTypeFont*>(mFont);
+ SDLFont *font = static_cast<SDLFont*>(mFont);
int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0);
int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0);
graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r),