diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/gui/passwordfield.cpp | 21 |
2 files changed, 7 insertions, 15 deletions
@@ -1,5 +1,6 @@ 2006-02-01 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/gui/passwordfield.cpp: Removed duplicated code. * src/Makefile.am, src/main.cpp, src/gui/error.cpp, src/gui/error.h: Replaced ErrorDialog by OkDialog + listener. * src/Makefile.am, src/game.cpp, src/gui/buysell.cpp, 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; } |