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