Mercurial > projects > dynamin
annotate dynamin/gui/events.d @ 30:545af935f201
Remove delta from MouseTurnedEventArgs (Windows-centric).
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 25 Jul 2009 15:27:35 -0500 |
parents | dfaa3da21b27 |
children | 2a194d52fdb5 |
rev | line source |
---|---|
0 | 1 // Written in the D programming language |
2 // www.digitalmars.com/d/ | |
3 | |
4 /* | |
5 * The contents of this file are subject to the Mozilla Public License Version | |
6 * 1.1 (the "License"); you may not use this file except in compliance with | |
7 * the License. You may obtain a copy of the License at | |
8 * http://www.mozilla.org/MPL/ | |
9 * | |
10 * Software distributed under the License is distributed on an "AS IS" basis, | |
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 * for the specific language governing rights and limitations under the | |
13 * License. | |
14 * | |
15 * The Original Code is the Dynamin library. | |
16 * | |
17 * The Initial Developer of the Original Code is Jordan Miner. | |
18 * Portions created by the Initial Developer are Copyright (C) 2006-2009 | |
19 * the Initial Developer. All Rights Reserved. | |
20 * | |
21 * Contributor(s): | |
22 * Jordan Miner <jminer7@gmail.com> | |
23 * | |
24 */ | |
25 | |
26 module dynamin.gui.events; | |
27 | |
28 import dynamin.all_core; | |
29 import dynamin.all_painting; | |
30 import dynamin.all_gui; | |
31 | |
32 /// | |
33 enum MouseButton { | |
34 None, /// | |
35 Left, /// | |
36 Right, /// | |
37 Middle, /// | |
38 XButton1, /// | |
39 XButton2 /// | |
40 } | |
41 | |
42 /// | |
43 class PaintingEventArgs : EventArgs { | |
44 Graphics g; | |
45 //NativeGraphics ng; | |
46 public: | |
47 /// | |
48 this(Graphics g) { | |
49 this.g = g; | |
50 } | |
51 /// | |
52 Graphics graphics() { return g; } | |
53 } | |
54 | |
55 /// | |
56 class MouseEventArgs : StopEventArgs { | |
57 Point _location; | |
58 MouseButton _button; | |
59 public: | |
60 /// | |
61 this(real x, real y, MouseButton b) { | |
62 _location = Point(x, y); | |
63 _button = b; | |
64 } | |
65 /// | |
66 Point location() { return _location; } | |
67 /// | |
68 void location(Point pt) { _location = pt; } | |
69 /// | |
70 real x() { return _location.x; } | |
71 /// | |
72 real y() { return _location.y; } | |
73 /// | |
74 MouseButton button() { return _button; } | |
26
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
75 string toString() { |
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
76 return format("MouseEventArgs [x={}, y={}, button={}]", |
27
dfaa3da21b27
Fix stupid mistake with last commit.
Jordan Miner <jminer7@gmail.com>
parents:
26
diff
changeset
|
77 x, y, _button); |
26
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
78 } |
0 | 79 } |
80 /// | |
81 class MouseTurnedEventArgs : StopEventArgs { | |
82 double _scrollAmount; | |
83 public: | |
30
545af935f201
Remove delta from MouseTurnedEventArgs (Windows-centric).
Jordan Miner <jminer7@gmail.com>
parents:
27
diff
changeset
|
84 this(double scrollAmount) { |
0 | 85 _scrollAmount = scrollAmount; |
86 } | |
87 /** | |
88 * The amount that a control should scroll in response to this event. | |
89 * In a text control, this is the number of lines to scroll. | |
90 * This will be negative if the control should scroll upward and positive | |
91 * if the control should scroll downward. If the amount to be scrolled | |
92 * is more than what is visible on screen, only what is on screen | |
93 * should be scrolled. | |
94 * | |
95 * All users of this class should check scrollScreen to see whether to | |
96 * scroll one screen or to scroll the amount by this. | |
97 */ | |
98 double scrollAmount() { return _scrollAmount; } | |
99 /** | |
100 * On some systems, such as Windows, there is the option of setting | |
101 * the mouse wheel to scroll a screen at a time, the same as the page up | |
102 * and page down keys do. If this option is turned on, scrollScreen will | |
103 * return true and scrollAmount will return ±3. If the option is turned off, | |
104 * scrollScreen will return false. | |
105 */ | |
106 bool scrollScreen() { | |
107 return false; | |
108 } | |
26
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
109 string toString() { |
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
110 return format("MouseTurnedEventArgs [scrollAmount={}, scrollScreen={}]", |
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
111 _scrollAmount, scrollScreen); |
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
112 } |
0 | 113 } |
114 /// | |
115 class KeyEventArgs : StopEventArgs { | |
116 Key _key; | |
117 bool _repeat; | |
118 public: | |
119 this(Key key, bool repeat) { | |
120 _key = key; | |
121 _repeat = repeat; | |
122 } | |
123 /** | |
124 * Returns: the key that was typed. | |
125 */ | |
126 Key key() { return _key; } | |
127 /** | |
128 * Gets whether this key event was generated by the user holding | |
129 * down the key. | |
130 * Returns: true if the key was already down before this event, false | |
131 * if the key was just pressed | |
132 */ | |
133 bool repeat() { return _repeat; } | |
26
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
134 string toString() { |
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
135 return format("KeyEventArgs [key={}, repeat={}]", _key, _repeat); |
87265a206638
Add toString() on some events.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
136 } |
0 | 137 } |
138 /// | |
139 class KeyTypedEventArgs : StopEventArgs { | |
140 dchar _ch; | |
141 bool _repeat; | |
142 public: | |
143 this(dchar c, bool repeat) { | |
144 _ch = c; | |
145 _repeat = repeat; | |
146 } | |
147 /** | |
148 * Gets whether this key event was generated from the user holding | |
149 * down the key. | |
150 * Returns: true if the key was already down before this event, false | |
151 * if the key was just pressed | |
152 */ | |
153 bool repeat() { return _repeat; } | |
154 /** | |
155 * Gets the character that was typed by the user. Many keys on the | |
156 * keyboard will not generate a KeyTyped event, as they do not represent | |
157 * characters. Shift, Insert, Home, F7, and Caps Lock are just some of | |
158 * the keys that do not represent characters. | |
159 */ | |
160 dchar character() { return _ch; } | |
161 } | |
162 |