summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/browserbox.cpp51
-rw-r--r--src/gui/widgets/browserbox.h9
2 files changed, 47 insertions, 13 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 1419e213c..5b862d16c 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -29,6 +29,7 @@
#include "utils/stringutils.h"
+#include "gui/gui.h"
#include "gui/palette.h"
#include "gui/theme.h"
@@ -371,7 +372,10 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (!part.mType)
{
graphics->setColor(part.mColor);
- font->drawString(graphics, part.mText, part.mX, part.mY);
+ if (part.mBold)
+ boldFont->drawString(graphics, part.mText, part.mX, part.mY);
+ else
+ font->drawString(graphics, part.mText, part.mX, part.mY);
}
else if (part.mImage)
{
@@ -389,6 +393,8 @@ int BrowserBox::calcHeight()
int moreHeight = 0;
int maxWidth = getWidth();
int link = 0;
+ bool bold = false;
+
if (getWidth() < 0)
return 1;
@@ -417,7 +423,7 @@ int BrowserBox::calcHeight()
const int dashWidth = fontWidthMinus;
for (x = 0; x < (unsigned)getWidth(); x++)
{
- mLineParts.push_back(LinePart(x, y, selColor, "-"));
+ mLineParts.push_back(LinePart(x, y, selColor, "-", false));
x += dashWidth - 2;
}
@@ -458,6 +464,8 @@ int BrowserBox::calcHeight()
wrapped = false;
}
+ bold = false;
+
// "Tokenize" the string at control sequences
if (mUseLinksAndUserColors)
end = row.find("##", start + 1);
@@ -483,6 +491,14 @@ int BrowserBox::calcHeight()
prevColor = selColor;
selColor = col;
}
+ else if (c == 'B')
+ {
+ bold = true;
+ }
+ else if (c == 'b')
+ {
+ bold = false;
+ }
else if (valid)
{
selColor = col;
@@ -533,10 +549,16 @@ int BrowserBox::calcHeight()
std::string part = row.substr(start, len);
+ int width = 0;
+ if (bold)
+ width = boldFont->getWidth(part);
+ else
+ width = font->getWidth(part);
+
// Auto wrap mode
if (mMode == AUTO_WRAP && getWidth() > 0
- && font->getWidth(part) > 0
- && (x + font->getWidth(part) + 10) > (unsigned)getWidth())
+ && width > 0
+ && (x + width + 10) > (unsigned)getWidth())
{
bool forced = false;
@@ -564,16 +586,20 @@ int BrowserBox::calcHeight()
end--; // And then to the last byte of the previous one
part = row.substr(start, end - start + 1);
+ if (bold)
+ width = boldFont->getWidth(part);
+ else
+ width = font->getWidth(part);
}
- while (end > start && font->getWidth(part) > 0
- && (x + font->getWidth(part) + 10)
+ while (end > start && width > 0
+ && (x + width + 10)
> (unsigned)getWidth());
if (forced)
{
x -= hyphenWidth; // Remove the wrap-notifier accounting
mLineParts.push_back(LinePart(getWidth() - hyphenWidth,
- y, selColor, hyphen));
+ y, selColor, hyphen, bold));
end++; // Skip to the next character
}
else
@@ -585,12 +611,17 @@ int BrowserBox::calcHeight()
wrappedLines++;
}
- mLineParts.push_back(LinePart(x, y, selColor, part.c_str()));
+ mLineParts.push_back(LinePart(x, y, selColor, part.c_str(), bold));
+
+ if (bold)
+ width = boldFont->getWidth(part);
+ else
+ width = font->getWidth(part);
- if (mMode == AUTO_WRAP && font->getWidth(part) == 0)
+ if (mMode == AUTO_WRAP && width == 0)
break;
- x += font->getWidth(part);
+ x += width;
}
y += fontHeight;
}
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index e86f0288e..cf2f9c1f1 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -44,13 +44,15 @@ struct BROWSER_LINK
class LinePart
{
public:
- LinePart(int x, int y, gcn::Color color, std::string text) :
- mX(x), mY(y), mColor(color), mText(text), mType(0), mImage(0)
+ LinePart(int x, int y, gcn::Color color, std::string text, bool bold) :
+ mX(x), mY(y), mColor(color), mText(text), mType(0),
+ mImage(0), mBold(bold)
{
}
LinePart(int x, int y, gcn::Color color, Image *image) :
- mX(x), mY(y), mColor(color), mText(""), mType(1), mImage(image)
+ mX(x), mY(y), mColor(color), mText(""), mType(1),
+ mImage(image), mBold(false)
{
}
@@ -61,6 +63,7 @@ class LinePart
std::string mText;
unsigned char mType;
Image *mImage;
+ bool mBold;
};
/**