diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 14:53:10 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 14:53:10 +0000 |
commit | 75feac69e27648fb50142756651270891c492537 (patch) | |
tree | 3c5d6eb28674c3664df48c1261f2eca9eb138d13 /src/gui | |
parent | 30a90b9ad7859fa56184cf6a775e7fd99a6c1647 (diff) | |
download | mana-client-75feac69e27648fb50142756651270891c492537.tar.gz mana-client-75feac69e27648fb50142756651270891c492537.tar.bz2 mana-client-75feac69e27648fb50142756651270891c492537.tar.xz mana-client-75feac69e27648fb50142756651270891c492537.zip |
Removed duplicated code.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/passwordfield.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp index 7f27607b..533f54fb 100644 --- a/src/gui/passwordfield.cpp +++ b/src/gui/passwordfield.cpp @@ -23,9 +23,7 @@ #include "passwordfield.h" -#include <guichan/font.hpp> -#include <guichan/graphics.hpp> - +#include <string> PasswordField::PasswordField(const std::string& text): TextField(text) @@ -34,16 +32,9 @@ PasswordField::PasswordField(const std::string& text): void PasswordField::draw(gcn::Graphics *graphics) { - std::string stars; - stars.assign(mText.length(), '*'); - - if (hasFocus()) { - drawCaret(graphics, - getFont()->getWidth(stars.substr(0, mCaretPosition)) - - mXScroll); - } - - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - graphics->drawText(stars, 1 - mXScroll, 1); + // std::string uses cow, thus cheap copy + const std::string original = mText; + mText.assign(mText.length(), '*'); + TextField::draw(graphics); + mText = original; } |