From b6e20e04b519e50909331f537df2ea6114a137ee Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 23 Jul 2016 19:16:28 +0200 Subject: General ui code improvements, moved layout related variables to ui::UI, added ColorPicker widget. --- src/ui/inputbox.h | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'src/ui/inputbox.h') 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; }; } -- cgit v1.2.3