summaryrefslogtreecommitdiff
path: root/src/interface/Textbox.cpp
diff options
context:
space:
mode:
authorSimon 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)
commitba5efb101e30c75e9d1a639a717f48767785982d (patch)
treeb56885c79618054b5de1a2d52449d28638b3f03c /src/interface/Textbox.cpp
parent136675b56a8a1862afb41ccee5c14e93e483b964 (diff)
downloadpowder-ba5efb101e30c75e9d1a639a717f48767785982d.zip
powder-ba5efb101e30c75e9d1a639a717f48767785982d.tar.gz
Username, password icons for Login window
Diffstat (limited to 'src/interface/Textbox.cpp')
-rw-r--r--src/interface/Textbox.cpp24
1 files changed, 19 insertions, 5 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);
}