summaryrefslogtreecommitdiff
path: root/src/guichan/widgets/textbox.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/guichan/widgets/textbox.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/guichan/widgets/textbox.cpp')
-rw-r--r--src/guichan/widgets/textbox.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index 6b03a1cb5..97256eb44 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -130,7 +130,7 @@ namespace gcn
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
- for (size_t i = 0; i < mTextRows.size(); i++)
+ for (size_t i = 0, sz = mTextRows.size(); i < sz; i++)
{
// Move the text one pixel so we can have a caret before a letter.
graphics->drawText(mTextRows[i], 1,
@@ -170,7 +170,7 @@ namespace gcn
void TextBox::adjustSize()
{
int width = 0;
- for (size_t i = 0; i < mTextRows.size(); ++i)
+ for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i)
{
int w = getFont()->getWidth(mTextRows[i]);
if (width < w)
@@ -183,7 +183,8 @@ namespace gcn
void TextBox::setCaretPosition(unsigned int position)
{
- for (int row = 0; row < static_cast<int>(mTextRows.size()); row ++)
+ for (int row = 0, sz = static_cast<int>(mTextRows.size());
+ row < sz; row ++)
{
if (position <= mTextRows[row].size())
{
@@ -280,7 +281,8 @@ namespace gcn
int i;
std::string text;
- for (i = 0; i < static_cast<int>(mTextRows.size()) - 1; ++ i)
+ const int sz = static_cast<int>(mTextRows.size());
+ for (i = 0; i < sz - 1; ++ i)
text = text + mTextRows[i] + "\n";
text = text + mTextRows[i];