diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-10-26 00:22:12 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-10-26 00:22:12 +0000 |
commit | db8b740bfa402c929247efd954096fac7b72b2a3 (patch) | |
tree | 62164d11ad6ce852bb672298068b69f9b5b4de7e /src/gui/browserbox.cpp | |
parent | 4f49eb94ddf9d2f0f3c59560c761188d101bd5f8 (diff) | |
download | mana-db8b740bfa402c929247efd954096fac7b72b2a3.tar.gz mana-db8b740bfa402c929247efd954096fac7b72b2a3.tar.bz2 mana-db8b740bfa402c929247efd954096fac7b72b2a3.tar.xz mana-db8b740bfa402c929247efd954096fac7b72b2a3.zip |
Added possibility of length limitation to browserbox and used it for the chatlog (length set by the config option "ChatLogLength").
Diffstat (limited to 'src/gui/browserbox.cpp')
-rw-r--r-- | src/gui/browserbox.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 21609434..185777d0 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -42,7 +42,9 @@ BrowserBox::BrowserBox(unsigned int mode): gcn::Widget(), mMode(mode), mHighMode(UNDERLINE | BACKGROUND), mOpaque(true), - mUseLinksAndUserColors(true), mSelectedLink(-1) + mUseLinksAndUserColors(true), + mSelectedLink(-1), + mMaxRows(0) { setFocusable(true); addMouseListener(this); @@ -154,6 +156,12 @@ void BrowserBox::addRow(const std::string &row) mTextRows.push_back(newRow); + //discard older rows when a row limit has been set + if (mMaxRows > 0) + { + while (mTextRows.size() > mMaxRows) mTextRows.pop_front(); + } + // Auto size mode if (mMode == AUTO_SIZE) { @@ -169,14 +177,15 @@ void BrowserBox::addRow(const std::string &row) if (mMode == AUTO_WRAP) { - unsigned int i, j, y = 0; + unsigned int j, y = 0; unsigned int nextChar; char hyphen = '~'; int hyphenWidth = font->getWidth(hyphen); int x = 0; - for (i = 0; i < mTextRows.size(); i++) + + for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) { - std::string row = mTextRows[i]; + std::string row = *i; for (j = 0; j < row.size(); j++) { x += font->getWidth(row.at(j)); @@ -290,17 +299,17 @@ BrowserBox::draw(gcn::Graphics *graphics) } } - unsigned int i, j; + unsigned int j; int x = 0, y = 0; int wrappedLines = 0; gcn::ImageFont *font = dynamic_cast<gcn::ImageFont*>(getFont()); graphics->setColor(BLACK); - for (i = 0; i < mTextRows.size(); i++) + for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) { int selColor = BLACK; int prevColor = selColor; - std::string row = mTextRows[i]; + std::string row = *(i); x = 0; for (j = 0; j < row.size(); j++) |