Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2016-07-23 19:16:28 +0200
committerStijn Buys <ingar@osirion.org>2016-07-23 19:16:28 +0200
commitb6e20e04b519e50909331f537df2ea6114a137ee (patch)
treeaf49c890160dd5b96b992ff9e95bc44830955c3a /src/ui/inputbox.h
parent0d3a65aad03d9ac726238b21ba8224e9558a8a08 (diff)
General ui code improvements, moved layout related variables to ui::UI,
added ColorPicker widget.
Diffstat (limited to 'src/ui/inputbox.h')
-rw-r--r--src/ui/inputbox.h47
1 files changed, 34 insertions, 13 deletions
diff --git a/src/ui/inputbox.h b/src/ui/inputbox.h
index 5da9bc5..20dd9b5 100644
--- a/src/ui/inputbox.h
+++ b/src/ui/inputbox.h
@@ -18,6 +18,16 @@ class InputBox : public Widget
public:
InputBox(Widget *parent);
~InputBox();
+
+ /// text alignment
+ inline unsigned int alignment() const {
+ return _alignment;
+ }
+
+ /// return the text displayed by the label
+ inline const std::string &text() const {
+ return _text;
+ }
/// set the text displayed by the label
void set_text(const std::string &text);
@@ -31,14 +41,12 @@ public:
/// set the prompt
void set_prompt(const char *prompt);
- /// set the maximal input width
+ /// set the maximal input length
void set_max(const size_t max);
-
- /// return the text displayed by the label
- inline const std::string &text() const {
- return input_text;
- }
+ /// set the text alignment
+ void set_alignment(const unsigned int alignment);
+
/// clear the text
void clear();
@@ -46,21 +54,34 @@ public:
void complete();
protected:
- /// draw the widget
+ /**
+ * @brief draw the windget
+ * */
virtual void draw();
- /// called when the widget receives a key press
+ /**
+ * @brief key press event handler
+ * */
virtual bool on_keypress(const int key, const unsigned int modifier);
- /// called when the widget receives a key release
+ /**
+ * @brief key release event handler
+ * */
virtual bool on_keyrelease(const int key, const unsigned int modifier);
+
+ /**
+ * @brief mouse button press event handler
+ * */
+ virtual bool on_mousepress(const unsigned int button);
private:
- std::string input_text;
- std::string input_prompt;
- size_t input_pos;
- size_t input_max;
+ std::string _text;
+ std::string _prompt;
+ size_t _pos;
+ size_t _max;
+
+ unsigned int _alignment;
};
}