diff options
Diffstat (limited to 'plugingui/button.h')
-rw-r--r-- | plugingui/button.h | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/plugingui/button.h b/plugingui/button.h index 682dfa2..f42dc99 100644 --- a/plugingui/button.h +++ b/plugingui/button.h @@ -24,57 +24,56 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_BUTTON_H__ -#define __DRUMGIZMO_BUTTON_H__ +#pragma once #include <string> #include "widget.h" #include "painter.h" +#include "notifier.h" +#include "font.h" namespace GUI { class Button : public Widget { public: - Button(Widget *parent); + Button(Widget *parent); + ~Button(); - bool isFocusable() { return true; } - bool catchMouse() { return true; } + // From Widget: + bool isFocusable() override { return true; } + bool catchMouse() override { return true; } - void setText(std::string text); + void setText(const std::string& text); - void registerClickHandler(void (*handler)(void *), void *ptr); + Notifier<> clickNotifier; - //protected: - virtual void clicked() {} +protected: + virtual void clicked() {} - virtual void repaintEvent(RepaintEvent *e); - virtual void buttonEvent(ButtonEvent *e); - - virtual void mouseLeaveEvent(); - virtual void mouseEnterEvent(); - virtual void mouseMoveEvent(MouseMoveEvent *e); + // From Widget: + virtual void repaintEvent(RepaintEvent* e) override; + virtual void buttonEvent(ButtonEvent* e) override; + virtual void mouseLeaveEvent() override; + virtual void mouseEnterEvent() override; private: - bool in_button; - - Painter::Box box_up; - Painter::Box box_down; + bool in_button{false}; - typedef enum { - up, - down - } state_t; + Painter::Box box_up; + Painter::Box box_down; - std::string text; + typedef enum { + up, + down + } state_t; - state_t draw_state; - state_t button_state; + std::string text; - void (*handler)(void *); - void *ptr; -}; + Font font{":fontemboss.png"}; + state_t draw_state{up}; + state_t button_state{up}; }; -#endif/*__DRUMGIZMO_BUTTON_H__*/ +} // GUI:: |