| 1 | /*! | 
|---|
| 2 | * @file glgui_inputline.h | 
|---|
| 3 | * The gl_INPUTLINE widget of th openglGUI | 
|---|
| 4 | * | 
|---|
| 5 | */ | 
|---|
| 6 |  | 
|---|
| 7 | #ifndef _GLGUI_INPUTLINE_H | 
|---|
| 8 | #define _GLGUI_INPUTLINE_H | 
|---|
| 9 |  | 
|---|
| 10 | #include "glgui_widget.h" | 
|---|
| 11 | #include "limited_width_text.h" | 
|---|
| 12 | #include "event.h" | 
|---|
| 13 |  | 
|---|
| 14 | // FORWARD DECLARATION | 
|---|
| 15 | namespace OrxGui | 
|---|
| 16 | { | 
|---|
| 17 |  | 
|---|
| 18 | //! This is InputLine part of the openglGUI class | 
|---|
| 19 | /** | 
|---|
| 20 | * The InputLine is a Widget, that displays a Line, that can be manipulated through | 
|---|
| 21 | * Writing Text on it. | 
|---|
| 22 | * | 
|---|
| 23 | * Whenever the Text is changed the textChanged signal is emitted. | 
|---|
| 24 | */ | 
|---|
| 25 | class GLGuiInputLine : public OrxGui::GLGuiWidget | 
|---|
| 26 | { | 
|---|
| 27 | ObjectListDeclaration(GLGuiInputLine); | 
|---|
| 28 | public: | 
|---|
| 29 | GLGuiInputLine(); | 
|---|
| 30 | virtual ~GLGuiInputLine(); | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | /** @returns the text of the inputLine */ | 
|---|
| 34 | const std::string& _getText() const { return this->_text.text(); }; | 
|---|
| 35 |  | 
|---|
| 36 | void setText(const std::string& text); | 
|---|
| 37 | void append(const std::string& appendText); | 
|---|
| 38 | void appendCharacter(char character); | 
|---|
| 39 | void removeCharacters(unsigned int chars); | 
|---|
| 40 | void clear(); | 
|---|
| 41 |  | 
|---|
| 42 | void clearOnEnter(bool clear = true) { this->_clearOnEnter = clear; }; | 
|---|
| 43 |  | 
|---|
| 44 | virtual void removedFocus(); | 
|---|
| 45 |  | 
|---|
| 46 | virtual void tick(float dt); | 
|---|
| 47 | virtual void draw() const; | 
|---|
| 48 |  | 
|---|
| 49 | virtual bool processEvent(const Event& event); | 
|---|
| 50 |  | 
|---|
| 51 | sigslot::signal1<const std::string&> textChanged; | 
|---|
| 52 | sigslot::signal1<const std::string&> enterPushed; | 
|---|
| 53 |  | 
|---|
| 54 | protected: | 
|---|
| 55 | virtual void updateFrontColor(); | 
|---|
| 56 | virtual void hiding(); | 
|---|
| 57 | virtual void showing(); | 
|---|
| 58 | virtual void resize(); | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | private: | 
|---|
| 62 | void init(); | 
|---|
| 63 | void pushEnter(); | 
|---|
| 64 | void changedText(); | 
|---|
| 65 |  | 
|---|
| 66 |  | 
|---|
| 67 | private: | 
|---|
| 68 | LimitedWidthText        _text;            //!< The Text to display inside of the InputLine. | 
|---|
| 69 | bool                    _clearOnEnter;    //!< Clear on Enter | 
|---|
| 70 |  | 
|---|
| 71 | Uint16                  pressedKey;       //!< the pressed key that will be repeated. | 
|---|
| 72 | Uint16                  pressedKeyName;   //!< The Name of the Key, that was pressed. | 
|---|
| 73 |  | 
|---|
| 74 | float                   delayNext;        //!< How much time must pass before next output. | 
|---|
| 75 |  | 
|---|
| 76 | static float            repeatDelay;      //!< Repead Delay. | 
|---|
| 77 | static float            repeatRate;       //!< Repeat Rate. | 
|---|
| 78 | }; | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | #endif /* _GLGUI_INPUTLINE_H */ | 
|---|