Mercurial > projects > doodle
annotate doodle/tk/events.d @ 48:1b4c9ba58673
Stylistic overhaul.
author | daveb |
---|---|
date | Tue, 03 Aug 2010 17:37:21 +0930 |
parents | 157b4ad5615d |
children | c63719604adb |
rev | line source |
---|---|
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
17
diff
changeset
|
1 module doodle.tk.events; |
0 | 2 |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
3 public { |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
17
diff
changeset
|
4 import doodle.tk.types; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
17
diff
changeset
|
5 import doodle.tk.geometry; |
16
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) { |
48 | 10 _mask = mask; |
0 | 11 } |
12 | |
48 | 13 Mask mask() const { return _mask; } |
0 | 14 |
15 private { | |
48 | 16 Mask _mask; |
0 | 17 } |
18 } | |
19 | |
33
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
20 /+ |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
21 final class FocusEvent : Event { |
0 | 22 } |
33
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
23 +/ |
0 | 24 |
13 | 25 final class KeyEvent : Event { |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
26 this(in string str, in uint value, in Mask mask) { |
0 | 27 super(mask); |
48 | 28 _str = str; |
29 _value = value; | |
0 | 30 } |
31 | |
48 | 32 string str() const { return _str; } |
0 | 33 |
5 | 34 override string toString() const { |
48 | 35 return std.string.format("Key event: %s, %d, %s", _str, _value, _mask); |
0 | 36 } |
37 | |
38 private { | |
48 | 39 string _str; |
40 uint _value; | |
0 | 41 } |
42 } | |
43 | |
13 | 44 abstract class PointerEvent : Event { |
48 | 45 this(in Point pixelPoint, in Point modelPoint, in Mask mask) { |
0 | 46 super(mask); |
48 | 47 _pixelPoint = pixelPoint; |
48 _modelPoint = modelPoint; | |
0 | 49 } |
50 | |
48 | 51 Point pixelPoint() const { return _pixelPoint; } |
52 Point modelPoint() const { return _modelPoint; } | |
0 | 53 |
54 private { | |
48 | 55 Point _pixelPoint; |
56 Point _modelPoint; | |
0 | 57 } |
58 } | |
59 | |
33
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
60 /* |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
61 final class CrossingEvent : PointerEvent { |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
62 this(in Mask mask) { |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
63 super(mask); |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
64 } |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
65 |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
66 private { |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
67 } |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
68 } |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
69 */ |
157b4ad5615d
Added intersection code for lines and segments.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
70 |
0 | 71 final class ButtonEvent : PointerEvent { |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
72 this(in ButtonAction button_action, |
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
73 in ButtonName button_name, |
48 | 74 in Point pixelPoint, |
75 in Point modelPoint, | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
76 in Mask mask) { |
48 | 77 super(pixelPoint, modelPoint, mask); |
78 _buttonAction = button_action; | |
79 _buttonName = button_name; | |
0 | 80 } |
81 | |
5 | 82 override string toString() const { |
8 | 83 return std.string.format("Button event: %s, %s, %s, %s, %s", |
48 | 84 enumToString(_buttonAction), enumToString(_buttonName), |
85 _pixelPoint, _modelPoint, _mask); | |
0 | 86 } |
87 | |
48 | 88 ButtonAction button_action() const { return _buttonAction; } |
89 ButtonName button_name() const { return _buttonName; } | |
0 | 90 |
91 private { | |
48 | 92 ButtonAction _buttonAction; |
93 ButtonName _buttonName; | |
0 | 94 } |
95 } | |
96 | |
97 final class MotionEvent : PointerEvent { | |
48 | 98 this(in Point pixelPoint, |
99 in Point modelPoint, | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
100 in Mask mask) { |
48 | 101 super(pixelPoint, modelPoint, mask); |
0 | 102 } |
103 | |
5 | 104 override string toString() const { |
8 | 105 return std.string.format("Motion event: %s, %s, %s", |
48 | 106 _pixelPoint, _modelPoint, _mask); |
0 | 107 } |
108 } | |
109 | |
110 final class ScrollEvent : PointerEvent { | |
48 | 111 this(in ScrollDirection scrollDirection, |
112 in Point pixelPoint, | |
113 in Point modelPoint, | |
16
9e63308b749c
* Fix up public/private includes
David Bryant <daveb@acres.com.au>
parents:
13
diff
changeset
|
114 in Mask mask) { |
48 | 115 super(pixelPoint, modelPoint, mask); |
116 _scrollDirection = scrollDirection; | |
0 | 117 } |
118 | |
5 | 119 override string toString() const { |
8 | 120 return std.string.format("Scroll event: %s, %s, %s, %s", |
48 | 121 enumToString(_scrollDirection), _pixelPoint, _modelPoint, _mask); |
0 | 122 } |
123 | |
48 | 124 ScrollDirection scrollDirection() const { return _scrollDirection; } |
0 | 125 |
126 private { | |
48 | 127 ScrollDirection _scrollDirection; |
0 | 128 } |
129 } |