diff options
Diffstat (limited to 'src/gui/passwordfield.cpp')
-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; } |