summaryrefslogtreecommitdiff
path: root/src/gui/browserbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/browserbox.cpp')
-rw-r--r--src/gui/browserbox.cpp56
1 files changed, 14 insertions, 42 deletions
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index 430a2aa2..18acfa6a 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -29,13 +29,7 @@
#include "colour.h"
#include "linkhandler.h"
-#ifdef USE_OPENGL
-#include "../configuration.h"
-#include "../resources/resourcemanager.h"
-
-int BrowserBox::instances = 0;
-gcn::ImageFont* BrowserBox::browserFont = NULL;
-#endif
+#include "../sdltruetypefont.hpp"
BrowserBox::BrowserBox(unsigned int mode):
gcn::Widget(),
@@ -47,35 +41,10 @@ BrowserBox::BrowserBox(unsigned int mode):
{
setFocusable(true);
addMouseListener(this);
-
-#ifdef USE_OPENGL
- if (config.getValue("opengl", 0.0f)) {
- if (instances == 0) {
- browserFont = new gcn::ImageFont(
- "graphics/gui/browserfont.png",
- " abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567"
- "89:@!\"$%&/=?^+*#[]{}()<>_;'.,\\|-~`"
- "øåáÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßèÈÅ");
- }
- setFont(browserFont);
- instances++;
- }
-#endif
}
BrowserBox::~BrowserBox()
{
-#ifdef USE_OPENGL
- instances--;
-
- if (instances == 0)
- {
- // Clean up static resource font
- delete browserFont;
- browserFont = NULL;
- }
-#endif
}
void BrowserBox::setLinkHandler(LinkHandler* linkHandler)
@@ -104,7 +73,7 @@ void BrowserBox::addRow(const std::string &row)
std::string newRow;
BROWSER_LINK bLink;
int idx1, idx2, idx3;
- gcn::ImageFont *font = dynamic_cast<gcn::ImageFont*>(getFont());
+ gcn::Font *font = getFont();
// Use links and user defined colors
if (mUseLinksAndUserColors)
@@ -178,7 +147,7 @@ void BrowserBox::addRow(const std::string &row)
{
unsigned int j, y = 0;
unsigned int nextChar;
- char hyphen = '~';
+ const char *hyphen = "~";
int hyphenWidth = font->getWidth(hyphen);
int x = 0;
@@ -187,7 +156,8 @@ void BrowserBox::addRow(const std::string &row)
std::string row = *i;
for (j = 0; j < row.size(); j++)
{
- x += font->getWidth(row.at(j));
+ std::string character = row.substr(j, 1);
+ x += font->getWidth(character);
nextChar = j + 1;
// Wraping between words (at blank spaces)
@@ -302,7 +272,7 @@ BrowserBox::draw(gcn::Graphics *graphics)
unsigned int j;
int x = 0, y = 0;
int wrappedLines = 0;
- gcn::ImageFont *font = dynamic_cast<gcn::ImageFont*>(getFont());
+ gcn::Font *font = getFont();
graphics->setColor(BLACK);
for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++)
@@ -353,22 +323,24 @@ BrowserBox::draw(gcn::Graphics *graphics)
{
for (x = 0; x < getWidth(); x++)
{
- font->drawGlyph(graphics, '-', x, y);
- x += font->getWidth('-') - 2;
+ const std::string dash = "-";
+ font->drawString(graphics, dash, x, y);
+ x += font->getWidth("-") - 2;
}
break;
}
// Draw each char
else
{
- font->drawGlyph(graphics, row.at(j), x, y);
- x += font->getWidth(row.at(j));
+ std::string character = row.substr(j, 1);
+ font->drawString(graphics, character, x, y);
+ x += font->getWidth(character.c_str());
// Auto wrap mode
if (mMode == AUTO_WRAP)
{
unsigned int nextChar = j + 1;
- char hyphen = '~';
+ const std::string hyphen = "~";
int hyphenWidth = font->getWidth(hyphen);
// Wraping between words (at blank spaces)
@@ -395,7 +367,7 @@ BrowserBox::draw(gcn::Graphics *graphics)
// Wrapping looong lines (brutal force)
else if ((x + 2 * hyphenWidth) > getWidth())
{
- font->drawGlyph(graphics, hyphen,
+ font->drawString(graphics, hyphen,
getWidth() - hyphenWidth, y);
x = 15; // Ident in new line
y += font->getHeight();