Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2010 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 |
package org.eclipse.swt.events; |
12 |
|
13 |
|
14 |
import org.eclipse.swt.widgets.*; |
15 |
|
16 |
/** |
17 |
* Instances of this class are sent as a result of |
18 |
* a touch-based gesture being generated by the user. |
19 |
* <p> |
20 |
* </p> |
21 |
* |
22 |
* @see GestureListener |
23 |
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
24 |
* @since 3.7 |
25 |
*/ |
26 |
|
27 |
public class GestureEvent extends TypedEvent { |
28 |
|
29 |
/** |
30 |
* the state of the keyboard modifier keys and mouse masks |
31 |
* at the time the event was generated. |
32 |
* |
33 |
* @see org.eclipse.swt.SWT#MODIFIER_MASK |
34 |
* @see org.eclipse.swt.SWT#BUTTON_MASK |
35 |
*/ |
36 |
public int stateMask; |
37 |
|
38 |
/** |
39 |
* The gesture type. |
40 |
* <p><ul> |
41 |
* <li>{@link org.eclipse.swt.SWT#GESTURE_NONE}</li> |
42 |
* <li>{@link org.eclipse.swt.SWT#GESTURE_MAGNIFY}</li> |
43 |
* <li>{@link org.eclipse.swt.SWT#GESTURE_PAN}</li> |
44 |
* <li>{@link org.eclipse.swt.SWT#GESTURE_ROTATE}</li> |
45 |
* <li>{@link org.eclipse.swt.SWT#GESTURE_SWIPE}</li> |
46 |
* </ul></p> |
47 |
* |
48 |
* The value of the <code>detail</code> field determines which fields of the |
49 |
* <code>GestureEvent</code> contain valid data. |
50 |
*/ |
51 |
public int detail; |
52 |
|
53 |
/** |
54 |
* Depending on the value of the <code>detail</code> field and the current platform, this field |
55 |
* can mean the x coordinate of the centroid of the touches that make up the gesture (Windows), or the x coordinate of |
56 |
* the screen location of the cursor at the time the gesture was performed (Mac OS X). |
57 |
* |
58 |
* NOTE: The definition of this field is subject to change before the API freeze for 3.7. |
59 |
*/ |
60 |
public int x; |
61 |
|
62 |
/** |
63 |
* Depending on the value of the <code>detail</code> field and the current platform, this field |
64 |
* can mean the y coordinate of the centroid of the touches that make up the gesture (Windows), or the y component of |
65 |
* the screen location of the cursor at the time the gesture was performed (Mac OS X). |
66 |
* |
67 |
* NOTE: The definition of this field is subject to change before the API freeze for 3.7. |
68 |
*/ |
69 |
public int y; |
70 |
|
71 |
/** |
72 |
* Number of degrees rotated on the device since the gesture started. Positive values indicated counter-clockwise |
73 |
* rotation; negative values indicate clockwise rotation. |
74 |
* |
75 |
* This field is valid when the <code>detail</code> field is set to <code>GESTURE_ROTATE</code>. |
76 |
*/ |
77 |
public double rotation; |
78 |
|
79 |
/** |
80 |
* The meaning of this field depends on the value of the <code>detail</code> field. |
81 |
* |
82 |
* If <code>detail</code> is <code>GESTURE_SWIPE</code> |
83 |
* and non-zero, a positive value indicates a swipe to the right, and a negative value indicates a swipe to the left. |
84 |
* |
85 |
* If <code>detail</code> is <code>GESTURE_PAN</code> a positive value indicates a pan to the right of that many pixels, |
86 |
* and a negative value indicates a pan to the left of that many pixels. |
87 |
* |
88 |
* This field is valid when the <code>detail</code> field is set to <code>GESTURE_SWIPE</code> or <code>GESTURE_PAN</code>. |
89 |
* Both the <code>xDirection</code> and <code>yDirection</code> can be valid for an individual gesture. |
90 |
*/ |
91 |
public int xDirection; |
92 |
|
93 |
/** |
94 |
* The meaning of this field depends on the value of the <code>detail</code> field. |
95 |
* |
96 |
* If <code>detail</code> is <code>GESTURE_SWIPE</code> |
97 |
* and non-zero, a positive value indicates a swipe down, and a negative value indicates a swipe up. |
98 |
* |
99 |
* If <code>detail</code> is <code>GESTURE_PAN</code> a positive value indicates a pan downwards of that many pixels, |
100 |
* and a negative value indicates a pan upwards of that many pixels. |
101 |
* |
102 |
* This field is valid when the <code>detail</code> field is set to <code>GESTURE_SWIPE</code> or <code>GESTURE_PAN</code>. |
103 |
* Both the <code>xDirection</code> and <code>yDirection</code> can be valid for an individual gesture. |
104 |
*/ |
105 |
public int yDirection; |
106 |
|
107 |
/** |
108 |
* Scale factor to be applied. In the first <code>GESTURE_MAGNIFY</code> received for a magnification this value will be 1.0 |
109 |
* and will then fluctuate as the user moves their fingers. |
110 |
* |
111 |
* This field is valid when the <code>detail</code> field is set to <code>GESTURE_MAGNIFY</code>. |
112 |
*/ |
113 |
public double magnification; |
114 |
|
115 |
/** |
116 |
* A flag indicating whether the operation should be allowed. |
117 |
* Setting this field to <code>false</code> will cancel the operation. |
118 |
*/ |
119 |
public boolean doit; |
120 |
|
121 |
static final long serialVersionUID = -8348741538373572182L; |
122 |
|
123 |
/** |
124 |
* Constructs a new instance of this class based on the |
125 |
* information in the given untyped event. |
126 |
* |
127 |
* @param e the untyped event containing the information |
128 |
*/ |
129 |
public GestureEvent(Event e) { |
130 |
super(e); |
131 |
this.stateMask = e.stateMask; |
132 |
this.x = e.x; |
133 |
this.y = e.y; |
134 |
this.detail = e.detail; |
135 |
this.rotation = e.rotation; |
136 |
this.xDirection = e.xDirection; |
137 |
this.yDirection = e.yDirection; |
138 |
this.magnification = e.magnification; |
139 |
this.doit = e.doit; |
140 |
} |
141 |
|
142 |
/** |
143 |
* Returns a string containing a concise, human-readable |
144 |
* description of the receiver. |
145 |
* |
146 |
* @return a string representation of the event |
147 |
*/ |
148 |
public String toString() { |
149 |
String string = super.toString (); |
150 |
return string.substring (0, string.length() - 1) // remove trailing '}' |
151 |
+ " stateMask=" + stateMask |
152 |
+ " detail=" + detail |
153 |
+ " x=" + x |
154 |
+ " y=" + y |
155 |
+ " rotation=" + rotation |
156 |
+ " xDirection=" + xDirection |
157 |
+ " yDirection=" + yDirection |
158 |
+ " magnification=" + magnification |
159 |
+ "}"; |
160 |
} |
161 |
} |