diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-15 17:55:36 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-15 17:55:36 (GMT) |
| commit | ba5efb101e30c75e9d1a639a717f48767785982d (patch) | |
| tree | b56885c79618054b5de1a2d52449d28638b3f03c /src/interface | |
| parent | 136675b56a8a1862afb41ccee5c14e93e483b964 (diff) | |
| download | powder-ba5efb101e30c75e9d1a639a717f48767785982d.zip powder-ba5efb101e30c75e9d1a639a717f48767785982d.tar.gz | |
Username, password icons for Login window
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Textbox.cpp | 24 | ||||
| -rw-r--r-- | src/interface/Textbox.h | 3 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp index 8657e8e..9db4dc6 100644 --- a/src/interface/Textbox.cpp +++ b/src/interface/Textbox.cpp @@ -11,7 +11,6 @@ using namespace ui; Textbox::Textbox(Point position, Point size, std::string textboxText): Component(position, size), text(textboxText), - textPosition(ui::Point(0, 0)), actionCallback(NULL), masked(false), border(true) @@ -26,19 +25,32 @@ Textbox::~Textbox() delete actionCallback; } +void Textbox::TextPosition() +{ + if(cursor) + { + cursorPosition = Graphics::textnwidth((char *)displayText.c_str(), cursor); + } + else + { + cursorPosition = 0; + } + Component::TextPosition(displayText); +} + void Textbox::SetText(std::string text) { cursor = text.length(); this->text = text; this->displayText = text; - TextPosition(displayText); + TextPosition(); } void Textbox::SetDisplayText(std::string text) { displayText = text; - TextPosition(displayText); + TextPosition(); } std::string Textbox::GetText() @@ -129,14 +141,14 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool if(actionCallback) actionCallback->TextChangedCallback(this); } - TextPosition(displayText); + TextPosition(); } void Textbox::Draw(const Point& screenPos) { if(!drawn) { - TextPosition(displayText); + TextPosition(); drawn = true; } Graphics * g = Engine::Ref().g; @@ -150,4 +162,6 @@ void Textbox::Draw(const Point& screenPos) if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255); } g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, displayText, 255, 255, 255, 255); + if(Appearance.icon) + g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon); } diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h index e502768..551ff54 100644 --- a/src/interface/Textbox.h +++ b/src/interface/Textbox.h @@ -21,7 +21,6 @@ class Textbox : public Component protected: std::string text; std::string displayText; - ui::Point textPosition; int cursor, cursorPosition; TextboxAction *actionCallback; bool masked; @@ -40,6 +39,8 @@ public: bool GetHidden() { return masked; } void SetBorder(bool border) {this->border = border;} + + void TextPosition(); virtual void Draw(const Point& screenPos); }; |
