]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/widgets/Event.java
Remove invalid SHA-256-Digests
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / widgets / Event.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.widgets;
15
16
17 import org.eclipse.swt.graphics.*;
18 import org.eclipse.swt.internal.*;
19
20 /**
21  * Instances of this class provide a description of a particular
22  * event which occurred within SWT. The SWT <em>untyped listener</em>
23  * API uses these instances for all event dispatching.
24  * <p>
25  * Note: For a given event, only the fields which are appropriate
26  * will be filled in. The contents of the fields which are not used
27  * by the event are unspecified.
28  * </p>
29  *
30  * @see Listener
31  * @see org.eclipse.swt.events.TypedEvent
32  * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Listeners</a>
33  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
34  */
35
36 public class Event {
37
38         /**
39          * the display where the event occurred
40          *
41          * @since 2.0
42          */
43         public Display display;
44
45         /**
46          * the widget that issued the event
47          */
48         public Widget widget;
49
50         /**
51          * the type of event, as defined by the event type constants
52          * in class <code>SWT</code>
53          *
54          * @see org.eclipse.swt.SWT
55          */
56         public int type;
57
58         /**
59          * the event specific detail field, as defined by the detail constants
60          * in class <code>SWT</code>
61          *
62          * @see org.eclipse.swt.SWT
63          */
64         public int detail;
65
66         /**
67          * the item that the event occurred in (can be null)
68          */
69         public Widget item;
70
71         /**
72          * the index of the item where the event occurred
73          *
74          * @since 3.2
75          */
76         public int index;
77
78         /**
79          * the graphics context to use when painting
80          * that is configured to use the colors, font and
81          * damaged region of the control.  It is valid
82          * only during the paint and must not be disposed
83          */
84         public GC gc;
85
86         /**
87          * depending on the event type, the x offset of the bounding
88          * rectangle of the region that requires painting or the
89          * widget-relative, x coordinate of the pointer at the
90          * time the mouse button was pressed or released
91          */
92         public int x;
93
94         /**
95          * depending on the event type, the y offset of the bounding
96          * rectangle of the  region that requires painting or the
97          * widget-relative, y coordinate of the pointer at the
98          * time the mouse button was pressed or released
99          */
100         public int y;
101
102         /**
103          * the width of the bounding rectangle of the
104          * region that requires painting
105          */
106         public int width;
107
108         /**
109          * the height of the bounding rectangle of the
110          * region that requires painting
111          */
112         public int height;
113
114         /**
115          * depending on the event type, the number of following
116          * paint events that are pending which may always be zero
117          * on some platforms, or the number of lines or pages to
118          * scroll using the mouse wheel, or the number of times the
119          * mouse has been clicked
120          */
121         public int count;
122
123         /**
124          * the time that the event occurred.
125          *
126          * NOTE: This field is an unsigned integer and should
127          * be AND'ed with 0xFFFFFFFFL so that it can be treated
128          * as a signed long.
129          */
130         public int time;
131
132         /**
133          * the button that was pressed or released; 1 for the
134          * first button, 2 for the second button, and 3 for the
135          * third button, etc.
136          */
137         public int button;
138
139         /**
140          * depending on the event, the character represented by the key
141          * that was typed.  This is the final character that results
142          * after all modifiers have been applied.  For example, when the
143          * user types Ctrl+A, the character value is 0x01 (ASCII SOH).
144          * It is important that applications do not attempt to modify the
145          * character value based on a stateMask (such as SWT.CTRL) or the
146          * resulting character will not be correct.
147          */
148         public char character;
149
150         /**
151          * depending on the event, the key code of the key that was typed,
152          * as defined by the key code constants in class <code>SWT</code>.
153          * When the character field of the event is ambiguous, this field
154          * contains the unaffected value of the original character.  For
155          * example, typing Ctrl+M or Enter both result in the character '\r'
156          * but the keyCode field will also contain '\r' when Enter was typed
157          * and 'm' when Ctrl+M was typed.
158          *
159          * @see org.eclipse.swt.SWT
160          */
161         public int keyCode;
162
163         /**
164          * depending on the event, the location of key specified by the
165          * keyCode or character. The possible values for this field are
166          * <code>SWT.LEFT</code>, <code>SWT.RIGHT</code>, <code>SWT.KEYPAD</code>,
167          * or <code>SWT.NONE</code> representing the main keyboard area.
168          * <p>
169          * The location field can be used to differentiate key events that have
170          * the same key code and character but are generated by different keys
171          * in the keyboard. For example, a key down event with the key code equals
172          * to SWT.SHIFT can be generated by the left and the right shift keys in the
173          * keyboard. The location field can only be used to determine the location
174          * of the key code or character in the current event. It does not
175          * include information about the location of modifiers in state
176          * mask.
177          * </p>
178          *
179          * @see org.eclipse.swt.SWT#LEFT
180          * @see org.eclipse.swt.SWT#RIGHT
181          * @see org.eclipse.swt.SWT#KEYPAD
182          *
183          * @since 3.6
184          */
185         public int keyLocation;
186
187         /**
188          * depending on the event, the state of the keyboard modifier
189          * keys and mouse masks at the time the event was generated.
190          *
191          * @see org.eclipse.swt.SWT#MODIFIER_MASK
192          * @see org.eclipse.swt.SWT#BUTTON_MASK
193          */
194         public int stateMask;
195
196         /**
197          * depending on the event, the range of text being modified.
198          * Setting these fields only has effect during ImeComposition
199          * events.
200          */
201         public int start, end;
202
203         /**
204          * depending on the event, the new text that will be inserted.
205          * Setting this field will change the text that is about to
206          * be inserted or deleted.
207          */
208         public String text;
209
210         /**
211          * Bidi segment offsets
212          * @since 3.8
213          */
214         public int[] segments;
215
216         /**
217          * Characters to be applied on the segment boundaries
218          * @since 3.8
219          */
220         public char[] segmentsChars;
221
222         /**
223          * depending on the event, a flag indicating whether the operation
224          * should be allowed.  Setting this field to false will cancel the
225          * operation.
226          */
227         public boolean doit = true;
228
229         /**
230          * a field for application use
231          */
232         public Object data;
233
234         /**
235          * An array of the touch states for the current touch event.
236          *
237          * @since 3.7
238          */
239         public Touch[] touches;
240
241         /**
242          * If nonzero, a positive value indicates a swipe to the right,
243          * and a negative value indicates a swipe to the left.
244          *
245          * @since 3.7
246          */
247         public int xDirection;
248
249         /**
250          * If nonzero, a positive value indicates a swipe in the up direction,
251          * and a negative value indicates a swipe in the down direction.
252          *
253          * @since 3.7
254          */
255         public int yDirection;
256
257         /**
258          * The change in magnification. This value should be added to the current
259          * scaling of an item to get the new scale factor.
260          *
261          * @since 3.7
262          */
263         public double magnification;
264
265         /**
266          * The number of degrees rotated on the track pad.
267          *
268          * @since 3.7
269          */
270         public double rotation;
271
272 /**
273  * Gets the bounds.
274  *
275  * @return a rectangle that is the bounds.
276  */
277 public Rectangle getBounds () {
278         return new Rectangle (x, y, width, height);
279 }
280 Rectangle getBoundsInPixels () {
281         return DPIUtil.autoScaleUp(getBounds());
282 }
283
284 Point getLocation () {
285         return new Point (x, y);
286 }
287
288 Point getLocationInPixels () {
289         return DPIUtil.autoScaleUp(new Point(x, y));
290 }
291
292 /**
293  * Sets the bounds.
294  *
295  * @param rect the new rectangle
296  */
297 public void setBounds (Rectangle rect) {
298         this.x = rect.x;
299         this.y = rect.y;
300         this.width = rect.width;
301         this.height = rect.height;
302 }
303
304 void setBoundsInPixels (Rectangle rect) {
305         setBounds(DPIUtil.autoScaleDown(rect));
306 }
307
308 void setLocationInPixels (int x, int y) {
309         this.x = DPIUtil.autoScaleDown(x);
310         this.y = DPIUtil.autoScaleDown(y);
311 }
312
313 /**
314  * Returns a string containing a concise, human-readable
315  * description of the receiver.
316  *
317  * @return a string representation of the event
318  */
319 @Override
320 public String toString () {
321         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$
322 }
323 }