summaryrefslogtreecommitdiff
path: root/plugingui/guievent.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui/guievent.h')
-rw-r--r--plugingui/guievent.h134
1 files changed, 73 insertions, 61 deletions
diff --git a/plugingui/guievent.h b/plugingui/guievent.h
index 4732101..6e2ded9 100644
--- a/plugingui/guievent.h
+++ b/plugingui/guievent.h
@@ -24,8 +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_GUI_EVENT_H__
-#define __DRUMGIZMO_GUI_EVENT_H__
+#pragma once
#include <unistd.h>
@@ -38,104 +37,117 @@
namespace GUI {
+enum class EventType {
+ mouseMove,
+ repaint,
+ button,
+ scroll,
+ key,
+ close,
+ resize
+};
+
class Event {
public:
- typedef enum {
- MouseMove,
- Repaint,
- Button,
- Scroll,
- Key,
- Close,
- Resize
- } Type;
- virtual ~Event() {}
-
- virtual Type type() = 0;
+ virtual ~Event() {}
+
+ virtual EventType type() = 0;
#ifdef X11
- ::Window window_id;
+ ::Window window_id;
#endif/*X11*/
};
class MouseMoveEvent : public Event {
public:
- Type type() { return MouseMove; }
+ EventType type() { return EventType::mouseMove; }
+
+ int x;
+ int y;
+};
+
+
+enum class Direction {
+ up,
+ down,
+};
- int x;
- int y;
+enum class MouseButton {
+ right,
+ middle,
+ left,
};
class ButtonEvent : public Event {
public:
- Type type() { return Button; }
+ EventType type() { return EventType::button; }
- int x;
- int y;
+ int x;
+ int y;
- int direction;
- int button;
- int doubleclick;
+ Direction direction;
+ MouseButton button;
+
+ bool doubleClick;
};
class ScrollEvent : public Event {
public:
- Type type() { return Scroll; }
+ EventType type() { return EventType::scroll; }
- int x;
- int y;
+ int x;
+ int y;
- int delta;
+ int delta;
};
class RepaintEvent : public Event {
public:
- Type type() { return Repaint; }
+ EventType type() { return EventType::repaint; }
+
+ int x;
+ int y;
+ size_t width;
+ size_t height;
+};
- int x;
- int y;
- size_t width;
- size_t height;
+enum class Key {
+ unknown,
+ left,
+ right,
+ up,
+ down,
+ deleteKey,
+ backspace,
+ home,
+ end,
+ pageDown,
+ pageUp,
+ enter,
+ character, //!< The actual character is stored in KeyEvent::text
};
class KeyEvent : public Event {
public:
- Type type() { return Key; }
-
- int direction;
- int keycode;
- std::string text;
-
- enum {
- KEY_UNKNOWN =-1,
- KEY_LEFT = 1,
- KEY_RIGHT = 2,
- KEY_UP = 3,
- KEY_DOWN = 4,
- KEY_DELETE = 5,
- KEY_BACKSPACE = 6,
- KEY_HOME = 7,
- KEY_END = 8,
- KEY_PGDOWN = 9,
- KEY_PGUP = 10,
- KEY_ENTER = 11,
- KEY_CHARACTER = 0xffff // character data is stored in 'text'
- };
+ EventType type() { return EventType::key; }
+
+ Direction direction;
+
+ Key keycode;
+ std::string text;
};
class CloseEvent : public Event {
public:
- Type type() { return Close; }
+ EventType type() { return EventType::close; }
};
class ResizeEvent : public Event {
public:
- Type type() { return Resize; }
-
- size_t width;
- size_t height;
-};
+ EventType type() { return EventType::resize; }
+ size_t width;
+ size_t height;
};
-#endif/*__DRUMGIZMO_GUI_EVENT_H__*/
+} // GUI::