aboutsummaryrefslogtreecommitdiff
path: root/dw/events.hh
blob: 5309186eb0669d3d5e2f2778c294ff3108a553da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __DW_EVENTS_HH__
#define __DW_EVENTS_HH__

#ifndef __INCLUDED_FROM_DW_CORE_HH__
#   error Do not include this file directly, use "core.hh" instead.
#endif

namespace dw {
namespace core {

/**
 * \brief Platform independent representation.
 */
enum ButtonState
{
   /* We won't use more than these ones. */
   SHIFT_MASK    = 1 << 0,
   CONTROL_MASK  = 1 << 1,
   META_MASK     = 1 << 2,
   BUTTON1_MASK  = 1 << 3,
   BUTTON2_MASK  = 1 << 4,
   BUTTON3_MASK  = 1 << 5
};

/**
 * \brief Base class for all events.
 *
 * The dw::core::Event hierarchy describes events in a platform independent
 * way.
 */
class Event: public lout::object::Object
{
public:
};

/**
 * \brief Base class for all mouse events.
 */
class MouseEvent: public Event
{
public:
   ButtonState state;
};

/**
 * \brief Base class for all mouse events related to a specific position.
 */
class MousePositionEvent: public MouseEvent
{
public:
   int xCanvas, yCanvas, xWidget, yWidget;
};

/**
 * \brief Represents a button press or release event.
 */
class EventButton: public MousePositionEvent
{
public:
   int numPressed; /* 1 for simple click, 2 for double click, etc. */
   int button;
};

/**
 * \brief Represents a mouse motion event.
 */
class EventMotion: public MousePositionEvent
{
};

/**
 * \brief Represents a enter or leave notify event.
 */
class EventCrossing: public MouseEvent
{
public:
   Widget *lastWidget, *currentWidget;
};

} // namespace core
} // namespace dw

#endif // __DW_EVENTS_HH__