0
|
1 module tk.events;
|
|
2
|
|
3 import tk.types;
|
|
4 import tk.geometry;
|
|
5
|
|
6 //
|
|
7 // Should we pass the screen and model points into
|
|
8 // the events or pass a transform in separately to the handler
|
|
9 //
|
|
10
|
|
11 abstract class Event {
|
|
12 this() {
|
|
13 }
|
|
14
|
|
15 private {
|
|
16 }
|
|
17 }
|
|
18
|
|
19 final class ExposeEvent : Event {
|
|
20 this() {
|
|
21 super();
|
|
22 }
|
|
23
|
|
24 private {
|
|
25 }
|
|
26 }
|
|
27
|
|
28 abstract class InputEvent : Event {
|
|
29 this(Mask mask) {
|
|
30 mMask = mask;
|
|
31 }
|
|
32
|
|
33 Mask mask() { return mMask; }
|
|
34
|
|
35 private {
|
|
36 Mask mMask;
|
|
37 }
|
|
38 }
|
|
39
|
|
40 final class CrossingEvent : InputEvent {
|
|
41 this(Mask mask) {
|
|
42 super(mask);
|
|
43 }
|
|
44
|
|
45 private {
|
|
46 }
|
|
47 }
|
|
48
|
|
49 final class KeyEvent : InputEvent {
|
|
50 this(string str, uint value, Mask mask) {
|
|
51 super(mask);
|
|
52 mStr = str;
|
|
53 mValue = value;
|
|
54 }
|
|
55
|
|
56 string str() { return mStr; }
|
|
57
|
|
58 override string toString() {
|
|
59 return std.string.format("Key event: %s, %d", mStr, mValue);
|
|
60 }
|
|
61
|
|
62 private {
|
|
63 string mStr;
|
|
64 uint mValue;
|
|
65 }
|
|
66 }
|
|
67
|
|
68 abstract class PointerEvent : InputEvent {
|
|
69 this(Point screen_point, Point model_point, Mask mask) {
|
|
70 super(mask);
|
|
71 mScreenPoint = screen_point;
|
|
72 mModelPoint = model_point;
|
|
73 }
|
|
74
|
|
75 Point screen_point() { return mScreenPoint; }
|
|
76 Point model_point() { return mModelPoint; }
|
|
77
|
|
78 private {
|
|
79 Point mScreenPoint;
|
|
80 Point mModelPoint;
|
|
81 }
|
|
82 }
|
|
83
|
|
84 final class ButtonEvent : PointerEvent {
|
|
85 this(ButtonPress button_press,
|
|
86 ButtonNumber button_number,
|
|
87 Point screen_point,
|
|
88 Point model_point,
|
|
89 Mask mask) {
|
|
90 super(screen_point, model_point, mask);
|
|
91 mButtonPress = button_press;
|
|
92 mButtonNumber = button_number;
|
|
93 }
|
|
94
|
|
95 override string toString() {
|
|
96 return std.string.format("Button event: %s, %s, %s, %s, %s", mButtonPress, mButtonNumber, mScreenPoint, mModelPoint, mMask);
|
|
97 }
|
|
98
|
|
99 ButtonPress button_press() { return mButtonPress; }
|
|
100 ButtonNumber button_number() { return mButtonNumber; }
|
|
101
|
|
102 private {
|
|
103 ButtonPress mButtonPress;
|
|
104 ButtonNumber mButtonNumber;
|
|
105 }
|
|
106 }
|
|
107
|
|
108 final class MotionEvent : PointerEvent {
|
|
109 this(Point screen_point,
|
|
110 Point model_point,
|
|
111 Mask mask) {
|
|
112 super(screen_point, model_point, mask);
|
|
113 }
|
|
114
|
|
115 override string toString() {
|
|
116 return std.string.format("Motion event: %s, %s, %s", mScreenPoint, mModelPoint, mMask);
|
|
117 }
|
|
118 }
|
|
119
|
|
120 final class ScrollEvent : PointerEvent {
|
|
121 this(ScrollDirection scroll_direction,
|
|
122 Point screen_point,
|
|
123 Point model_point,
|
|
124 Mask mask) {
|
|
125 super(screen_point, model_point, mask);
|
|
126 mScrollDirection = scroll_direction;
|
|
127 }
|
|
128
|
|
129 override string toString() {
|
|
130 return std.string.format("Scroll event: %s, %s, %s, %s", mScrollDirection, mScreenPoint, mModelPoint, mMask);
|
|
131 }
|
|
132
|
|
133 ScrollDirection scroll_direction() { return mScrollDirection; }
|
|
134
|
|
135 private {
|
|
136 ScrollDirection mScrollDirection;
|
|
137 }
|
|
138 }
|