Mercurial > projects > dwt-mac
comparison dwt/widgets/Event.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 2952d5604c0a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 *******************************************************************************/ | |
11 module dwt.widgets.Event; | |
12 | |
13 import dwt.dwthelper.utils; | |
14 | |
15 | |
16 import dwt.graphics.GC; | |
17 import dwt.graphics.Rectangle; | |
18 | |
19 /** | |
20 * Instances of this class provide a description of a particular | |
21 * event which occurred within DWT. The DWT <em>untyped listener</em> | |
22 * API uses these instances for all event dispatching. | |
23 * <p> | |
24 * Note: For a given event, only the fields which are appropriate | |
25 * will be filled in. The contents of the fields which are not used | |
26 * by the event are unspecified. | |
27 * </p> | |
28 * | |
29 * @see Listener | |
30 * @see dwt.events.TypedEvent | |
31 */ | |
32 | |
33 public class Event { | |
34 | |
35 /** | |
36 * the display where the event occurred | |
37 * | |
38 * @since 2.0 | |
39 */ | |
40 public Display display; | |
41 | |
42 /** | |
43 * the widget that issued the event | |
44 */ | |
45 public Widget widget; | |
46 | |
47 /** | |
48 * the type of event, as defined by the event type constants | |
49 * in class <code>DWT</code> | |
50 * | |
51 * @see dwt.DWT | |
52 */ | |
53 public int type; | |
54 | |
55 /** | |
56 * the event specific detail field, as defined by the detail constants | |
57 * in class <code>DWT</code> | |
58 * | |
59 * @see dwt.DWT | |
60 */ | |
61 public int detail; | |
62 | |
63 /** | |
64 * the item that the event occurred in (can be null) | |
65 */ | |
66 public Widget item; | |
67 | |
68 /** | |
69 * the index of the item where the event occurred | |
70 * | |
71 * @since 3.2 | |
72 */ | |
73 public int index; | |
74 | |
75 /** | |
76 * the graphics context to use when painting | |
77 * that is configured to use the colors, font and | |
78 * damaged region of the control. It is valid | |
79 * only during the paint and must not be disposed | |
80 */ | |
81 public GC gc; | |
82 | |
83 /** | |
84 * depending on the event type, the x offset of the bounding | |
85 * rectangle of the region that requires painting or the | |
86 * widget-relative, x coordinate of the pointer at the | |
87 * time the mouse button was pressed or released | |
88 */ | |
89 public int x; | |
90 | |
91 /** | |
92 * depending on the event type, the y offset of the bounding | |
93 * rectangle of the region that requires painting or the | |
94 * widget-relative, y coordinate of the pointer at the | |
95 * time the mouse button was pressed or released | |
96 */ | |
97 public int y; | |
98 | |
99 /** | |
100 * the width of the bounding rectangle of the | |
101 * region that requires painting | |
102 */ | |
103 public int width; | |
104 | |
105 /** | |
106 * the height of the bounding rectangle of the | |
107 * region that requires painting | |
108 */ | |
109 public int height; | |
110 | |
111 /** | |
112 * depending on the event type, the number of following | |
113 * paint events which are pending which may always be zero | |
114 * on some platforms or the number of lines or pages to | |
115 * scroll using the mouse wheel | |
116 */ | |
117 public int count; | |
118 | |
119 /** | |
120 * the time that the event occurred. | |
121 * | |
122 * NOTE: This field is an unsigned integer and should | |
123 * be AND'ed with 0xFFFFFFFFL so that it can be treated | |
124 * as a signed long. | |
125 */ | |
126 public int time; | |
127 | |
128 /** | |
129 * the button that was pressed or released; 1 for the | |
130 * first button, 2 for the second button, and 3 for the | |
131 * third button, etc. | |
132 */ | |
133 public int button; | |
134 | |
135 /** | |
136 * depending on the event, the character represented by the key | |
137 * that was typed. This is the final character that results | |
138 * after all modifiers have been applied. For example, when the | |
139 * user types Ctrl+A, the character value is 0x01 (ASCII SOH). | |
140 * It is important that applications do not attempt to modify the | |
141 * character value based on a stateMask (such as DWT.CTRL) or the | |
142 * resulting character will not be correct. | |
143 */ | |
144 public char character; | |
145 | |
146 /** | |
147 * depending on the event, the key code of the key that was typed, | |
148 * as defined by the key code constants in class <code>DWT</code>. | |
149 * When the character field of the event is ambiguous, this field | |
150 * contains the unaffected value of the original character. For | |
151 * example, typing Ctrl+M or Enter both result in the character '\r' | |
152 * but the keyCode field will also contain '\r' when Enter was typed | |
153 * and 'm' when Ctrl+M was typed. | |
154 * | |
155 * @see dwt.DWT | |
156 */ | |
157 public int keyCode; | |
158 | |
159 /** | |
160 * depending on the event, the state of the keyboard modifier | |
161 * keys and mouse masks at the time the event was generated. | |
162 * | |
163 * @see dwt.DWT | |
164 */ | |
165 public int stateMask; | |
166 | |
167 /** | |
168 * depending on the event, the range of text being modified. | |
169 * Setting these fields has no effect. | |
170 */ | |
171 public int start, end; | |
172 | |
173 /** | |
174 * depending on the event, the new text that will be inserted. | |
175 * Setting this field will change the text that is about to | |
176 * be inserted or deleted. | |
177 */ | |
178 public String text; | |
179 | |
180 /** | |
181 * depending on the event, a flag indicating whether the operation | |
182 * should be allowed. Setting this field to false will cancel the | |
183 * operation. | |
184 */ | |
185 public bool doit = true; | |
186 | |
187 /** | |
188 * a field for application use | |
189 */ | |
190 public Object data; | |
191 | |
192 /** | |
193 * Gets the bounds. | |
194 * | |
195 * @return a rectangle that is the bounds. | |
196 */ | |
197 public Rectangle getBounds () { | |
198 return new Rectangle (x, y, width, height); | |
199 } | |
200 | |
201 /** | |
202 * Sets the bounds. | |
203 * | |
204 * @param rect the new rectangle | |
205 */ | |
206 public void setBounds (Rectangle rect) { | |
207 this.x = rect.x; | |
208 this.y = rect.y; | |
209 this.width = rect.width; | |
210 this.height = rect.height; | |
211 } | |
212 | |
213 /** | |
214 * Returns a string containing a concise, human-readable | |
215 * description of the receiver. | |
216 * | |
217 * @return a string representation of the event | |
218 */ | |
219 public String toString () { | |
220 return "Event {type=" + type + " " + widget + " time=" + time + " data=" + data + " x=" + x + " y=" + y + " width=" + width + " height=" + height + " detail=" + detail + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ | |
221 } | |
222 } |