diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-26 21:29:49 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-26 21:29:49 +0100 |
commit | 3008805eea4b972265597ba196ab05ce64c69965 (patch) | |
tree | d3195600e956e496b6b21f200fc04e5b08cab368 /src/gui/textbox.cpp | |
parent | 3ad6ac47d4967870a54fddd66aa9996724115b94 (diff) | |
parent | 6b0cff837b7adae56dc90d12e9c0e256e6aab134 (diff) | |
download | mana-client-3008805eea4b972265597ba196ab05ce64c69965.tar.gz mana-client-3008805eea4b972265597ba196ab05ce64c69965.tar.bz2 mana-client-3008805eea4b972265597ba196ab05ce64c69965.tar.xz mana-client-3008805eea4b972265597ba196ab05ce64c69965.zip |
Merge branch 'aethyra/master'
Conflicts:
data/graphics/images/login_wallpaper.png
src/being.cpp
src/beingmanager.cpp
src/engine.cpp
src/game.cpp
src/gui/buysell.cpp
src/gui/buysell.h
src/gui/gui.h
src/gui/npc_text.cpp
src/gui/npc_text.h
src/gui/npcintegerdialog.cpp
src/gui/npclistdialog.cpp
src/gui/npclistdialog.h
src/gui/npcstringdialog.cpp
src/gui/sell.cpp
src/gui/shop.cpp
src/gui/table.cpp
src/net/beinghandler.cpp
src/net/npchandler.cpp
src/net/playerhandler.cpp
src/npc.cpp
src/npc.h
src/shopitem.cpp
src/shopitem.h
src/utils/stringutils.cpp
src/utils/stringutils.h
src/utils/trim.h
Diffstat (limited to 'src/gui/textbox.cpp')
-rw-r--r-- | src/gui/textbox.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 2a86d549..a4024de3 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -37,52 +37,46 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) { // Make sure parent scroll area sets width of this widget if (getParent()) - { getParent()->logic(); - } // Take the supplied minimum dimension as a starting point and try to beat it mMinWidth = minDimension; std::stringstream wrappedStream; - std::string::size_type newlinePos, lastNewlinePos = 0; + std::string::size_type spacePos, newlinePos, lastNewlinePos = 0; int minWidth = 0; int xpos; + spacePos = text.rfind(" ", text.size()); + + if (spacePos != std::string::npos) + { + const std::string word = text.substr(spacePos + 1); + const int length = getFont()->getWidth(word); + + if (length > mMinWidth) + mMinWidth = length; + } + do { // Determine next piece of string to wrap newlinePos = text.find("\n", lastNewlinePos); if (newlinePos == std::string::npos) - { newlinePos = text.size(); - } std::string line = text.substr(lastNewlinePos, newlinePos - lastNewlinePos); - std::string::size_type spacePos, lastSpacePos = 0; + std::string::size_type lastSpacePos = 0; xpos = 0; - spacePos = text.rfind(" ", text.size()); - - if (spacePos != std::string::npos) - { - const std::string word = text.substr(spacePos + 1); - const int length = getFont()->getWidth(word); - - if (length > mMinWidth) - mMinWidth = length; - } - do { spacePos = line.find(" ", lastSpacePos); if (spacePos == std::string::npos) - { spacePos = line.size(); - } std::string word = line.substr(lastSpacePos, spacePos - lastSpacePos); |