Mercurial > projects > doodle
annotate tk/events.d @ 16:9e63308b749c
* Fix up public/private includes
* Make Mask a struct
author | David Bryant <daveb@acres.com.au> |
---|---|
date | Mon, 13 Jul 2009 16:16:17 +0930 |
parents | f0ade1b49fe7 |
children | c643c04e3f5e |
rev | line source |
---|---|
0 | 1 module tk.events; |
2 | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
3 public { |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
4 import tk.types; |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
5 import tk.geometry; |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
6 } |
0 | 7 |
8 abstract class Event { | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
9 this(in Mask mask) { |
6 | 10 mMask = mask; |
0 | 11 } |
12 | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
13 Mask mask() const { return mMask; } |
0 | 14 |
15 private { | |
16 Mask mMask; | |
17 } | |
18 } | |
19 | |
13 | 20 final class CrossingEvent : Event { |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
21 this(in Mask mask) { |
0 | 22 super(mask); |
23 } | |
24 | |
25 private { | |
26 } | |
27 } | |
28 | |
13 | 29 final class KeyEvent : Event { |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
30 this(in string str, in uint value, in Mask mask) { |
0 | 31 super(mask); |
32 mStr = str; | |
33 mValue = value; | |
34 } | |
35 | |
5 | 36 string str() const { return mStr; } |
0 | 37 |
5 | 38 override string toString() const { |
8 | 39 return std.string.format("Key event: %s, %d, %s", mStr, mValue, mMask); |
0 | 40 } |
41 | |
42 private { | |
43 string mStr; | |
44 uint mValue; | |
45 } | |
46 } | |
47 | |
13 | 48 abstract class PointerEvent : Event { |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
49 this(in Point screen_point, in Point model_point, in Mask mask) { |
0 | 50 super(mask); |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
51 mScreenPoint = screen_point; |
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
52 mModelPoint = model_point; |
0 | 53 } |
54 | |
5 | 55 Point screen_point() const { return mScreenPoint; } |
56 Point model_point() const { return mModelPoint; } | |
0 | 57 |
58 private { | |
3
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
59 Point mScreenPoint; |
7d57cae10805
Renamed geometry2 to geometry
David Bryant <daveb@acres.com.au>
parents:
2
diff
changeset
|
60 Point mModelPoint; |
0 | 61 } |
62 } | |
63 | |
64 final class ButtonEvent : PointerEvent { | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
65 this(in ButtonAction button_action, |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
66 in ButtonName button_name, |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
67 in Point screen_point, |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
68 in Point model_point, |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
69 in Mask mask) { |
0 | 70 super(screen_point, model_point, mask); |
7 | 71 mButtonAction = button_action; |
72 mButtonName = button_name; | |
0 | 73 } |
74 | |
5 | 75 override string toString() const { |
8 | 76 return std.string.format("Button event: %s, %s, %s, %s, %s", |
77 enumToString(mButtonAction), enumToString(mButtonName), | |
78 mScreenPoint, mModelPoint, mMask); | |
0 | 79 } |
80 | |
7 | 81 ButtonAction button_action() const { return mButtonAction; } |
82 ButtonName button_name() const { return mButtonName; } | |
0 | 83 |
84 private { | |
7 | 85 ButtonAction mButtonAction; |
86 ButtonName mButtonName; | |
0 | 87 } |
88 } | |
89 | |
90 final class MotionEvent : PointerEvent { | |
5 | 91 this(in Point screen_point, |
92 in Point model_point, | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
93 in Mask mask) { |
0 | 94 super(screen_point, model_point, mask); |
95 } | |
96 | |
5 | 97 override string toString() const { |
8 | 98 return std.string.format("Motion event: %s, %s, %s", |
99 mScreenPoint, mModelPoint, mMask); | |
0 | 100 } |
101 } | |
102 | |
103 final class ScrollEvent : PointerEvent { | |
5 | 104 this(in ScrollDirection scroll_direction, |
105 in Point screen_point, | |
106 in Point model_point, | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
107 in Mask mask) { |
0 | 108 super(screen_point, model_point, mask); |
109 mScrollDirection = scroll_direction; | |
110 } | |
111 | |
5 | 112 override string toString() const { |
8 | 113 return std.string.format("Scroll event: %s, %s, %s, %s", |
114 enumToString(mScrollDirection), mScreenPoint, mModelPoint, mMask); | |
0 | 115 } |
116 | |
5 | 117 ScrollDirection scroll_direction() const { return mScrollDirection; } |
0 | 118 |
119 private { | |
120 ScrollDirection mScrollDirection; | |
121 } | |
122 } |