diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-26 21:55:52 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-26 21:55:52 (GMT) |
| commit | 5a71068ba07f42cffbd50324176510d992ebbc5e (patch) | |
| tree | 10fbbf3e466d10175faaacced7cafba449edbb69 /src/interface/Textbox.h | |
| parent | 7c259c01238d91d41a778003e2529f5c06e09139 (diff) | |
| download | powder-5a71068ba07f42cffbd50324176510d992ebbc5e.zip powder-5a71068ba07f42cffbd50324176510d992ebbc5e.tar.gz | |
Textbox now inherits from Label - gets all the fancy text selection features
Diffstat (limited to 'src/interface/Textbox.h')
| -rw-r--r-- | src/interface/Textbox.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h index 551ff54..120194e 100644 --- a/src/interface/Textbox.h +++ b/src/interface/Textbox.h @@ -3,7 +3,7 @@ #include <string> -#include "Component.h" +#include "Label.h" #include "Misc.h" namespace ui @@ -15,7 +15,37 @@ public: virtual void TextChangedCallback(ui::Textbox * sender) {} virtual ~TextboxAction() {} }; -class Textbox : public Component + +class Textbox : public Label +{ + friend class TextboxAction; +protected: + bool mouseDown; + bool masked, border; + int cursor, cursorPosition; + TextboxAction *actionCallback; + std::string backingText; +public: + Textbox(Point position, Point size, std::string textboxText); + virtual ~Textbox(); + + virtual void SetDisplayText(std::string text); + virtual void SetText(std::string text); + virtual std::string GetText(); + + void SetBorder(bool border) { this->border = border; }; + void SetHidden(bool hidden) { masked = hidden; } + bool GetHidden() { return masked; } + void SetActionCallback(TextboxAction * action) { actionCallback = action; } + + virtual void OnMouseClick(int x, int y, unsigned button); + virtual void OnMouseUp(int x, int y, unsigned button); + virtual void OnMouseMoved(int localx, int localy, int dx, int dy); + virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt); + virtual void Draw(const Point& screenPos); +}; + +/*class Textbox : public Component { friend class TextboxAction; protected: @@ -44,6 +74,8 @@ public: virtual void Draw(const Point& screenPos); }; +}*/ } + #endif // TEXTBOX_H |
