From 3ec43973d1e269c5e6124e02276107c2c3020180 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 3 Sep 2015 18:20:34 +0200 Subject: Use Notifier in CheckBox class. --- plugingui/checkbox.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'plugingui/checkbox.h') diff --git a/plugingui/checkbox.h b/plugingui/checkbox.h index 1d6f9d6..8dd3821 100644 --- a/plugingui/checkbox.h +++ b/plugingui/checkbox.h @@ -24,11 +24,11 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_CHECKBOX_H__ -#define __DRUMGIZMO_CHECKBOX_H__ +#pragma once #include "widget.h" #include "image.h" +#include "notifier.h" namespace GUI { @@ -38,21 +38,24 @@ public: void setText(std::string text); - bool isFocusable() { return true; } + bool isFocusable() override { return true; } bool checked(); void setChecked(bool checked); - void registerClickHandler(void (*handler)(void *), void *ptr); + Notifier stateChangedNotifier; - //protected: +protected: virtual void clicked() {} - virtual void repaintEvent(RepaintEvent *e); - virtual void buttonEvent(ButtonEvent *e); - virtual void keyEvent(KeyEvent *e); + // From Widget: + virtual void repaintEvent(RepaintEvent *e) override; + virtual void buttonEvent(ButtonEvent *e) override; + virtual void keyEvent(KeyEvent *e) override; private: + void internalSetChecked(bool checked); + Image bg_on; Image bg_off; Image knob; @@ -60,12 +63,7 @@ private: bool state; bool middle; - void (*handler)(void *); - void *ptr; - std::string _text; }; -}; - -#endif/*__DRUMGIZMO_CHECKBOX_H__*/ +} // GUI:: -- cgit v1.2.3