summaryrefslogtreecommitdiff
path: root/src/gui/widgets/browserbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-17 16:34:36 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-17 16:34:36 +0300
commitc6c4eef4e49bb4de90845408af9f642a1a4e224b (patch)
tree81d192e85b3c075cb2e52671bea4c3c0499dc3f2 /src/gui/widgets/browserbox.cpp
parent093e392dd84c920d26bca17d48ac6611393d087c (diff)
downloadmanaverse-c6c4eef4e49bb4de90845408af9f642a1a4e224b.tar.gz
manaverse-c6c4eef4e49bb4de90845408af9f642a1a4e224b.tar.bz2
manaverse-c6c4eef4e49bb4de90845408af9f642a1a4e224b.tar.xz
manaverse-c6c4eef4e49bb4de90845408af9f642a1a4e224b.zip
Improve size calculations.
Diffstat (limited to 'src/gui/widgets/browserbox.cpp')
-rw-r--r--src/gui/widgets/browserbox.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 534bd1d19..cf2a9ea88 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -120,6 +120,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
// Check for links in format "@@link|Caption@@"
idx1 = tmp.find("@@");
+ const int sz = static_cast<int>(mTextRows.size());
while (idx1 != std::string::npos)
{
size_t idx2 = tmp.find("|", idx1);
@@ -129,7 +130,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
break;
bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
- bLink.y1 = static_cast<int>(mTextRows.size()) * font->getHeight();
+ bLink.y1 = sz * font->getHeight();
bLink.y2 = bLink.y1 + font->getHeight();
newRow += tmp.substr(0, idx1);
@@ -224,19 +225,19 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
i != i_end; ++ i)
{
std::string tempRow = *i;
- for (unsigned int j = 0; j < tempRow.size(); j++)
+ for (unsigned int j = 0, sz = tempRow.size(); j < sz; j++)
{
std::string character = tempRow.substr(j, 1);
x += font->getWidth(character);
nextChar = j + 1;
// Wraping between words (at blank spaces)
- if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ')
+ if (nextChar < sz && tempRow.at(nextChar) == ' ')
{
int nextSpacePos = static_cast<int>(
tempRow.find(" ", (nextChar + 1)));
if (nextSpacePos <= 0)
- nextSpacePos = static_cast<int>(tempRow.size()) - 1;
+ nextSpacePos = static_cast<int>(sz) - 1;
unsigned nextWordWidth = font->getWidth(
tempRow.substr(nextChar,