summaryrefslogtreecommitdiff
path: root/src/interface/Textbox.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-20 22:07:49 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-20 22:07:49 (GMT)
commitc8073657fcbfd1bfa72538d7babe4964857e7101 (patch)
treef3488e993c9828121b2f89ed2f639d2ebbe54dc9 /src/interface/Textbox.h
parentc5e8b345219cd7d8ca4b0aa638f59a1fed2cd83b (diff)
downloadpowder-c8073657fcbfd1bfa72538d7babe4964857e7101.zip
powder-c8073657fcbfd1bfa72538d7babe4964857e7101.tar.gz
More stuff, need to fix memory leak
Diffstat (limited to 'src/interface/Textbox.h')
-rw-r--r--src/interface/Textbox.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h
new file mode 100644
index 0000000..5cd14f4
--- /dev/null
+++ b/src/interface/Textbox.h
@@ -0,0 +1,44 @@
+#ifndef TEXTBOX_H
+#define TEXTBOX_H
+
+#include <string>
+
+#include "Component.h"
+#include "Misc.h"
+
+namespace ui
+{
+class Textbox;
+class TextboxAction
+{
+public:
+ virtual void TextChangedCallback(ui::Textbox * sender) {}
+};
+class Textbox : public Component
+{
+ std::string text;
+ ui::Point textPosition;
+ HorizontalAlignment textHAlign;
+ VerticalAlignment textVAlign;
+ int cursor, cursorPosition;
+ TextboxAction *actionCallback;
+public:
+ Textbox(Window* parent_state, std::string textboxText);
+ Textbox(Point position, Point size, std::string textboxText);
+ Textbox(std::string textboxText);
+ virtual ~Textbox();
+
+ void TextPosition();
+ void SetText(std::string text);
+ std::string GetText();
+ HorizontalAlignment GetHAlignment() { return textHAlign; }
+ VerticalAlignment GetVAlignment() { return textVAlign; }
+ void SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign) { textHAlign = hAlign; textVAlign = vAlign; TextPosition(); }
+ void SetActionCallback(TextboxAction * action) { actionCallback = action; }
+ virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt);
+
+ virtual void Draw(const Point& screenPos);
+};
+}
+
+#endif // TEXTBOX_H