From 88ad7366a3eb6bc73bc99078ae13302099b76f09 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 26 Oct 2015 19:48:30 +0100 Subject: Refactored LineEdit and FileBrowser. Renamed all KEY_XYZ event types to KeyXyz. --- plugingui/lineedit.h | 62 ++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) (limited to 'plugingui/lineedit.h') diff --git a/plugingui/lineedit.h b/plugingui/lineedit.h index f85e9bd..21e448b 100644 --- a/plugingui/lineedit.h +++ b/plugingui/lineedit.h @@ -24,9 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_LINEEDIT_H__ -#define __DRUMGIZMO_LINEEDIT_H__ - +#pragma once #include @@ -38,49 +36,45 @@ namespace GUI { class LineEdit : public Widget { public: - LineEdit(Widget *parent); + LineEdit(Widget *parent); + ~LineEdit(); - bool isFocusable() { return true; } + bool isFocusable() override { return true; } - std::string text(); - void setText(std::string text); + std::string text(); + void setText(const std::string& text); - void setReadOnly(bool readonly); - bool readOnly(); + void setReadOnly(bool readonly); + bool readOnly(); - void registerEnterPressedHandler(void (*handler)(void *), void *ptr); + Notifier<> enterPressedNotifier; - //protected: - virtual void keyEvent(KeyEvent *e); - virtual void repaintEvent(RepaintEvent *e); - virtual void buttonEvent(ButtonEvent *e); + //protected: + virtual void keyEvent(KeyEvent *keyEvent); + virtual void repaintEvent(RepaintEvent *repaintEvent); + virtual void buttonEvent(ButtonEvent *buttonEvent); protected: - virtual void textChanged() {} + virtual void textChanged() {} private: - Painter::Box box; - - Font font; + Painter::Box box; - std::string _text; - size_t pos; - std::string _visibletext; - size_t offsetpos; + Font font; - enum state_t { - NOOP = 0, - WALK_LEFT = 1, - WALK_RIGHT = 2 - }; - state_t walkstate; + std::string _text; + size_t pos = 0; + std::string visibleText; + size_t offsetPos = 0; - bool readonly; - - void (*handler)(void *); - void *ptr; -}; + enum state_t { + Noop, + WalkLeft, + WalkRight, + }; + state_t walkstate; + bool readonly; }; -#endif/*__DRUMGIZMO_LINEEDIT_H__*/ +} // GUI:: -- cgit v1.2.3