summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-01-21 20:16:40 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-01-21 20:16:40 +0000
commit14d43383605281885ed576664594343d167e57f1 (patch)
tree2bfff062cf78dcb64b9e140f078e791e3039dd7c
parent43ef3719e12fd01befbf8c7d7605b346f6d6a25e (diff)
downloadmana-client-14d43383605281885ed576664594343d167e57f1.tar.gz
mana-client-14d43383605281885ed576664594343d167e57f1.tar.bz2
mana-client-14d43383605281885ed576664594343d167e57f1.tar.xz
mana-client-14d43383605281885ed576664594343d167e57f1.zip
Applied patch by Ar2ro that worked around scrolldown bug in the chatbox.
-rw-r--r--ChangeLog6
-rw-r--r--src/gui/browserbox.cpp50
2 files changed, 55 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index eacdd77d..9fe3489d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-21 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/browserbox.cpp: Applied a patch by Ar2ro that works around
+ the problems with line wrapping in the chatbox. Note though that this
+ while code should be properly rewritten later.
+
2006-01-19 Eugenio Favalli <elvenprogrammer@gmail.com>
* INSTALL, README, The Mana World.dev, data/help/support.txt,
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index 94978200..9fab4f52 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -172,7 +172,55 @@ void BrowserBox::addRow(const std::string& row)
if (w > getWidth())
setWidth(w);
}
- setHeight(browserFont->getHeight() * mTextRows.size());
+
+ if (mMode == AUTO_WRAP)
+ {
+ unsigned int i, j, x = 0, y = 0;
+ unsigned int nextChar;
+ char hyphen = '~';
+ int hyphenWidth = browserFont->getWidth(hyphen);
+ for (i = 0; i < mTextRows.size(); i++)
+ {
+ std::string row = mTextRows[i];
+ for (j = 0; j < row.size(); j++)
+ {
+ x += browserFont->getWidth(row.at(j));
+ nextChar = j + 1;
+
+ // Wraping between words (at blank spaces)
+ if ((nextChar < row.size()) && (row.at(nextChar) == ' '))
+ {
+ int nextSpacePos = row.find(" ", (nextChar + 1));
+ if (nextSpacePos <= 0)
+ {
+ nextSpacePos = row.size() - 1;
+ }
+ int nextWordWidth = browserFont->getWidth(
+ row.substr(nextChar,
+ (nextSpacePos - nextChar)));
+
+ if ((int)(x + nextWordWidth + 10) > getWidth())
+ {
+ x = 15; // Ident in new line
+ y += 1;
+ j++;
+ }
+ }
+ // Wrapping looong lines (brutal force)
+ else if ((int)(x + 2 * hyphenWidth) > getWidth())
+ {
+ x = 15; // Ident in new line
+ y += 1;
+ }
+ }
+ }
+
+ setHeight(browserFont->getHeight() * (mTextRows.size() + y));
+ }
+ else
+ {
+ setHeight(browserFont->getHeight() * mTextRows.size());
+ }
}
void BrowserBox::clearRows()