diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-29 19:17:51 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-29 19:17:51 (GMT) |
| commit | d138b2de544ab6ccdd7ec72bb5051e0bc437a1a9 (patch) | |
| tree | 05792ec51751bbe3ad62a124500738b0bb6381ea /src/interface/Textbox.h | |
| parent | 418373a3cd6cf93ee1e41ffa502b8f4754831349 (diff) | |
| download | powder-d138b2de544ab6ccdd7ec72bb5051e0bc437a1a9.zip powder-d138b2de544ab6ccdd7ec72bb5051e0bc437a1a9.tar.gz | |
Number type for text fields, addresses some of issue #39
Diffstat (limited to 'src/interface/Textbox.h')
| -rw-r--r-- | src/interface/Textbox.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h index f975bd7..9f00139 100644 --- a/src/interface/Textbox.h +++ b/src/interface/Textbox.h @@ -19,18 +19,8 @@ public: class Textbox : public Label { friend class TextboxAction; -protected: - size_t limit; - bool mouseDown; - bool masked, border; - int cursor, cursorPositionX, cursorPositionY; - TextboxAction *actionCallback; - std::string backingText; - std::string placeHolder; - - virtual void cutSelection(); - virtual void pasteIntoSelection(); public: + enum ValidInput { All, Numeric, Number }; Textbox(Point position, Point size, std::string textboxText = "", std::string textboxPlaceholder = ""); virtual ~Textbox(); @@ -45,12 +35,34 @@ public: bool GetHidden() { return masked; } void SetActionCallback(TextboxAction * action) { actionCallback = action; } + void SetLimit(size_t limit); + size_t GetLimit(); + + ValidInput GetInputType(); + void SetInputType(ValidInput input); + + //Determines if the given character is valid given the input type + bool CharacterValid(Uint16 character); + virtual void OnContextMenuAction(int item); 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); + +protected: + ValidInput inputType; + size_t limit; + bool mouseDown; + bool masked, border; + int cursor, cursorPositionX, cursorPositionY; + TextboxAction *actionCallback; + std::string backingText; + std::string placeHolder; + + virtual void cutSelection(); + virtual void pasteIntoSelection(); }; /*class Textbox : public Component |
