From 915c9b4e7daf2f49c25e254b66ef6e53a9207b29 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 12 Feb 2008 10:59:11 +0000 Subject: Merged revisions 3687-3688,3690 via svnmerge from https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0 ........ r3687 | crush_tmw | 2007-10-26 02:22:12 +0200 (Fri, 26 Oct 2007) | 1 line Added possibility of length limitation to browserbox and used it for the chatlog (length set by the config option "ChatLogLength"). ........ r3688 | crush_tmw | 2007-10-26 02:38:00 +0200 (Fri, 26 Oct 2007) | 1 line Removed some completely useless code from the chat class. ........ r3690 | crush_tmw | 2007-10-26 14:50:49 +0200 (Fri, 26 Oct 2007) | 1 line Implemented monster hurt sounds and added new sound effects by Cosmostrator. ........ --- src/gui/browserbox.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/gui/browserbox.cpp') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 584f2911..61bc571b 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -32,7 +32,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); @@ -119,6 +121,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) { @@ -134,15 +142,16 @@ void BrowserBox::addRow(const std::string &row) if (mMode == AUTO_WRAP) { - unsigned int i, j, y = 0; + unsigned int y = 0; unsigned int nextChar; char const *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]; - for (j = 0; j < row.size(); j++) + std::string row = *i; + for (unsigned int j = 0; j < row.size(); j++) { std::string character = row.substr(j, 1); x += font->getWidth(character); @@ -256,17 +265,16 @@ BrowserBox::draw(gcn::Graphics *graphics) } } - unsigned int i; int x = 0, y = 0; int wrappedLines = 0; TrueTypeFont *font = static_cast(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); bool wrapped = false; x = 0; -- cgit v1.2.3-70-g09d2