diff options
Diffstat (limited to 'plugingui/checkbox.h')
-rw-r--r-- | plugingui/checkbox.h | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/plugingui/checkbox.h b/plugingui/checkbox.h index 1d6f9d6..927bf6d 100644 --- a/plugingui/checkbox.h +++ b/plugingui/checkbox.h @@ -24,48 +24,50 @@ * 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 { class CheckBox : public Widget { public: - CheckBox(Widget *parent); + CheckBox(Widget *parent); - void setText(std::string text); + void setText(std::string text); - bool isFocusable() { return true; } + // From Widget: + bool isFocusable() override { return true; } + bool catchMouse() override { return true; } - bool checked(); - void setChecked(bool checked); + bool checked(); + void setChecked(bool checked); - void registerClickHandler(void (*handler)(void *), void *ptr); + Notifier<bool> stateChangedNotifier; - //protected: - virtual void clicked() {} - - virtual void repaintEvent(RepaintEvent *e); - virtual void buttonEvent(ButtonEvent *e); - virtual void keyEvent(KeyEvent *e); +protected: + // From Widget: + virtual void repaintEvent(RepaintEvent* repaintEvent) override; + virtual void buttonEvent(ButtonEvent* buttonEvent) override; + virtual void keyEvent(KeyEvent* keyEvent) override; + virtual void mouseLeaveEvent() override; + virtual void mouseEnterEvent() override; private: - Image bg_on; - Image bg_off; - Image knob; - - bool state; - bool middle; + void internalSetChecked(bool checked); - void (*handler)(void *); - void *ptr; + Image bg_on; + Image bg_off; + Image knob; - std::string _text; -}; + bool state; + bool middle; + bool buttonDown = false; + bool inCheckbox = false; + std::string _text; }; -#endif/*__DRUMGIZMO_CHECKBOX_H__*/ +} // GUI:: |