Mercurial > projects > doodle
annotate tk/events.d @ 7:936feb16eed4
Checkpoint
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sat, 11 Jul 2009 21:29:03 +0930 |
parents | a27d2093991c |
children | bf7903435f58 |
rev | line source |
---|---|
0 | 1 module tk.events; |
2 | |
3 import tk.types; | |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
4 import tk.geometry; |
0 | 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 { | |
6 | 29 this(Mask mask) { |
30 mMask = mask; | |
0 | 31 } |
32 | |
5 | 33 const(Mask) mask() const { return mMask; } |
0 | 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 | |
5 | 56 string str() const { return mStr; } |
0 | 57 |
5 | 58 override string toString() const { |
0 | 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 { | |
6 | 69 this(in Point screen_point, in Point model_point, Mask mask) { |
0 | 70 super(mask); |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
71 mScreenPoint = screen_point; |
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
72 mModelPoint = model_point; |
0 | 73 } |
74 | |
5 | 75 Point screen_point() const { return mScreenPoint; } |
76 Point model_point() const { return mModelPoint; } | |
0 | 77 |
78 private { | |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
79 Point mScreenPoint; |
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
80 Point mModelPoint; |
0 | 81 } |
82 } | |
83 | |
84 final class ButtonEvent : PointerEvent { | |
7 | 85 this(ButtonAction button_action, |
86 ButtonName button_name, | |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
87 Point screen_point, |
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
88 Point model_point, |
0 | 89 Mask mask) { |
90 super(screen_point, model_point, mask); | |
7 | 91 mButtonAction = button_action; |
92 mButtonName = button_name; | |
0 | 93 } |
94 | |
5 | 95 override string toString() const { |
7 | 96 return std.string.format("Button event: %s, %s, %s, %s, %s", mButtonAction, mButtonName, mScreenPoint, mModelPoint, mMask); |
0 | 97 } |
98 | |
7 | 99 ButtonAction button_action() const { return mButtonAction; } |
100 ButtonName button_name() const { return mButtonName; } | |
0 | 101 |
102 private { | |
7 | 103 ButtonAction mButtonAction; |
104 ButtonName mButtonName; | |
0 | 105 } |
106 } | |
107 | |
108 final class MotionEvent : PointerEvent { | |
5 | 109 this(in Point screen_point, |
110 in Point model_point, | |
6 | 111 Mask mask) { |
0 | 112 super(screen_point, model_point, mask); |
113 } | |
114 | |
5 | 115 override string toString() const { |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
116 return std.string.format("Motion event: %s, %s, %s", mScreenPoint, mModelPoint, mMask); |
0 | 117 } |
118 } | |
119 | |
120 final class ScrollEvent : PointerEvent { | |
5 | 121 this(in ScrollDirection scroll_direction, |
122 in Point screen_point, | |
123 in Point model_point, | |
6 | 124 Mask mask) { |
0 | 125 super(screen_point, model_point, mask); |
126 mScrollDirection = scroll_direction; | |
127 } | |
128 | |
5 | 129 override string toString() const { |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
130 return std.string.format("Scroll event: %s, %s, %s, %s", mScrollDirection, mScreenPoint, mModelPoint, mMask); |
0 | 131 } |
132 | |
5 | 133 ScrollDirection scroll_direction() const { return mScrollDirection; } |
0 | 134 |
135 private { | |
136 ScrollDirection mScrollDirection; | |
137 } | |
138 } |