Mercurial > projects > doodle
annotate tk/events.d @ 8:bf7903435f58
Checkpoint
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sat, 11 Jul 2009 21:49:04 +0930 |
parents | 936feb16eed4 |
children | f0ade1b49fe7 |
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 { |
8 | 59 return std.string.format("Key event: %s, %d, %s", mStr, mValue, mMask); |
0 | 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 { |
8 | 96 return std.string.format("Button event: %s, %s, %s, %s, %s", |
97 enumToString(mButtonAction), enumToString(mButtonName), | |
98 mScreenPoint, mModelPoint, mMask); | |
0 | 99 } |
100 | |
7 | 101 ButtonAction button_action() const { return mButtonAction; } |
102 ButtonName button_name() const { return mButtonName; } | |
0 | 103 |
104 private { | |
7 | 105 ButtonAction mButtonAction; |
106 ButtonName mButtonName; | |
0 | 107 } |
108 } | |
109 | |
110 final class MotionEvent : PointerEvent { | |
5 | 111 this(in Point screen_point, |
112 in Point model_point, | |
6 | 113 Mask mask) { |
0 | 114 super(screen_point, model_point, mask); |
115 } | |
116 | |
5 | 117 override string toString() const { |
8 | 118 return std.string.format("Motion event: %s, %s, %s", |
119 mScreenPoint, mModelPoint, mMask); | |
0 | 120 } |
121 } | |
122 | |
123 final class ScrollEvent : PointerEvent { | |
5 | 124 this(in ScrollDirection scroll_direction, |
125 in Point screen_point, | |
126 in Point model_point, | |
6 | 127 Mask mask) { |
0 | 128 super(screen_point, model_point, mask); |
129 mScrollDirection = scroll_direction; | |
130 } | |
131 | |
5 | 132 override string toString() const { |
8 | 133 return std.string.format("Scroll event: %s, %s, %s, %s", |
134 enumToString(mScrollDirection), mScreenPoint, mModelPoint, mMask); | |
0 | 135 } |
136 | |
5 | 137 ScrollDirection scroll_direction() const { return mScrollDirection; } |
0 | 138 |
139 private { | |
140 ScrollDirection mScrollDirection; | |
141 } | |
142 } |