summaryrefslogtreecommitdiff
path: root/plugingui/button.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-09-28 19:32:26 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-09-28 19:32:26 +0200
commitbf72f82495542f7e052978b7135fc312ede8eec4 (patch)
tree7108deec160a858dffd51ab89a2e36fabdce8ad4 /plugingui/button.h
parentf7bdf8448c3ea0fcb07a1dffb14c5811d4e91079 (diff)
Refactored Button.
Diffstat (limited to 'plugingui/button.h')
-rw-r--r--plugingui/button.h55
1 files changed, 25 insertions, 30 deletions
diff --git a/plugingui/button.h b/plugingui/button.h
index 682dfa2..7302b87 100644
--- a/plugingui/button.h
+++ b/plugingui/button.h
@@ -24,57 +24,52 @@
* 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"
namespace GUI {
class Button : public Widget {
public:
- Button(Widget *parent);
+ Button(Widget *parent);
+ ~Button();
- bool isFocusable() { return true; }
- bool catchMouse() { return true; }
+ bool isFocusable() { return true; }
+ bool catchMouse() { return true; }
- void setText(std::string text);
+ void setText(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 repaintEvent(RepaintEvent *e);
+ virtual void buttonEvent(ButtonEvent *e);
- virtual void mouseLeaveEvent();
- virtual void mouseEnterEvent();
- virtual void mouseMoveEvent(MouseMoveEvent *e);
+ virtual void mouseLeaveEvent();
+ virtual void mouseEnterEvent();
private:
- bool in_button;
+ bool in_button;
- Painter::Box box_up;
- Painter::Box box_down;
+ Painter::Box box_up;
+ Painter::Box box_down;
- typedef enum {
- up,
- down
- } state_t;
+ typedef enum {
+ up,
+ down
+ } state_t;
- std::string text;
-
- state_t draw_state;
- state_t button_state;
-
- void (*handler)(void *);
- void *ptr;
-};
+ std::string text;
+ state_t draw_state;
+ state_t button_state;
};
-#endif/*__DRUMGIZMO_BUTTON_H__*/
+} // GUI::