View | Details | Raw Unified | Return to bug 279884 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT/common/org/eclipse/swt/SWT.java (+100 lines)
Lines 715-720 Link Here
715
	 */
715
	 */
716
	public static final int OpenDocument = 46;
716
	public static final int OpenDocument = 46;
717
	
717
	
718
	/**
719
	 * The touch event type (value is 46).
720
	 * 
721
	 * <p>
722
	 * This event is sent when SWT receives notification that a document 
723
	 * should be opened.
724
	 * </p>
725
	 *  
726
     * @see org.eclipse.swt.widgets.Display#addListener
727
     * @see org.eclipse.swt.widgets.Event
728
     * 
729
     * @since 3.7
730
	 */
731
	public static final int Touch = 47;
732
733
	/**
734
	 * The gesture event type (value is 48).
735
	 * 
736
	 * <p>
737
	 * This event is sent when a gesture has been performed.
738
	 * </p>
739
	 *  
740
     * @see org.eclipse.swt.widgets.Display#addListener
741
     * @see org.eclipse.swt.widgets.Event
742
     * @see org.eclipse.swt.widgets.SWT#GESTURE_MAGNIFY
743
     * @see org.eclipse.swt.widgets.SWT#GESTURE_PAN
744
     * @see org.eclipse.swt.widgets.SWT#GESTURE_ROTATE
745
     * @see org.eclipse.swt.widgets.SWT#GESTURE_SWIPE
746
     * 
747
     * @since 3.7
748
	 */
749
	public static final int Gesture = 48;
750
751
	/**
752
	 * The end gesture event type (value is 49).
753
	 * 
754
	 * <p>
755
	 * This event is sent when SWT receives notification that a document 
756
	 * should be opened.
757
	 * </p>
758
	 *  
759
	 * @see org.eclipse.swt.widgets.Display#addListener
760
	 * @see org.eclipse.swt.widgets.Event
761
	 * 
762
	 * @since 3.7
763
	 */
764
	public static final int EndGesture = 49;
765
718
	/* Event Details */
766
	/* Event Details */
719
	
767
	
720
	/**
768
	/**
Lines 897-902 Link Here
897
	 * (value is 1&lt;&lt;9).
945
	 * (value is 1&lt;&lt;9).
898
	 */
946
	 */
899
	public static final int TRAVERSE_PAGE_NEXT = 1 << 9;
947
	public static final int TRAVERSE_PAGE_NEXT = 1 << 9;
948
949
	/**
950
	 * Gesture event detail field value indicating that a continuous
951
	 * gesture is about to begin.
952
	 * 
953
	 * @since 3.7
954
	 */
955
	public static final int GESTURE_BEGIN = 1 << 1;
956
957
	/**
958
	 * Gesture event detail field value indicating that a continuous 
959
	 * gesture has ended.
960
	 * 
961
	 * @since 3.7
962
	 */
963
	public static final int GESTURE_END = 1 << 2;
964
965
	/**
966
	 * Gesture event detail field value indicating that a 
967
	 * rotation gesture has happened. Only the rotation field
968
	 * of the event is valid.
969
	 * 
970
	 * @since 3.7
971
	 */
972
	public static final int GESTURE_ROTATE = 1 << 3;
973
	
974
	/**
975
	 * Gesture event detail field value indicating that a 
976
	 * swipe gesture has happened. Only the xDirection
977
	 * and yDirection fields of the event are valid.
978
	 * 
979
	 * @since 3.7
980
	 */
981
	public static final int GESTURE_SWIPE = 1 << 4;
982
	
983
	/**
984
	 * Gesture event detail field value indicating that a 
985
	 * magnification gesture has happened. Only the magnification
986
	 * field of the event is valid.
987
	 * 
988
	 * @since 3.7
989
	 */
990
	public static final int GESTURE_MAGNIFY = 1 << 5;
991
	
992
	/**
993
	 * Gesture event detail field value indicating that a 
994
	 * panning (two-finger scroll) gesture has happened. Only the
995
	 * xDirection and yDirection fields of the event are valid.
996
	 * 
997
	 * @since 3.7
998
	 */
999
	public static final int GESTURE_PAN = 1 << 6;
900
	
1000
	
901
	/**
1001
	/**
902
	 * A constant indicating that widgets have changed.
1002
	 * A constant indicating that widgets have changed.
(-)Eclipse (+37 lines)
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
 * This adapter class provides default implementations for the
15
 * methods described by the <code>GestureListener</code> interface.
16
 * <p>
17
 * Classes that wish to deal with <code>GestureEvent</code>s can
18
 * extend this class and override only the methods which they are
19
 * interested in.
20
 * </p>
21
 *
22
 * @see GestureListener
23
 * @see GestureEvent
24
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
25
 * @since 3.7
26
 */
27
public abstract class GestureAdapter implements GestureListener {
28
29
/**
30
 * Sent when a recognized gesture has occurred.
31
 *
32
 * @param e an event containing information about the gesture.
33
 */
34
public void gesture(GestureEvent e) {
35
}
36
37
}
(-)Eclipse (+161 lines)
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
}
(-)Eclipse (+42 lines)
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.internal.*;
15
16
/**
17
 * Classes which implement this interface provide methods
18
 * that deal with the events that are generated as gestures
19
 * are triggered when the user interacts with a touch pad or
20
 * touch screen.
21
 * <p>
22
 * After creating an instance of a class that implements
23
 * this interface it can be added to a control using the
24
 * <code>addGestureListener</code> method and removed using
25
 * the <code>removeGestureListener</code> method. When a
26
 * gesture is invoked, the appropriate method will be invoked.
27
 * </p>
28
 *
29
 * @see GestureAdapter
30
 * @see GestureEvent
31
 * @since 3.7
32
 */
33
public interface GestureListener extends SWTEventListener {
34
35
/**
36
 * Sent when a recognized gesture has occurred.
37
 *
38
 * @param e an event containing information about the gesture.
39
 */
40
public void gesture(GestureEvent e);
41
42
}
(-)Eclipse (+39 lines)
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
/**
15
 * This adapter class provides default implementations for the
16
 * methods described by the <code>TouchListener</code> interface.
17
 * <p>
18
 * Classes that wish to deal with <code>TouchEvent</code>s can
19
 * extend this class and override only the methods which they are
20
 * interested in.
21
 * </p>
22
 *
23
 * @see TouchListener
24
 * @see TouchEvent
25
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
26
 * @since 3.7
27
 */
28
public class TouchAdapter implements TouchListener {
29
30
/**
31
 * Sent when a touch was canceled for some reason. The default behavior is
32
 * to do nothing.
33
 * 
34
 * @param e
35
 *            an event containing information about the touch
36
 */
37
public void touch(TouchEvent e) {
38
}
39
}
(-)Eclipse (+85 lines)
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 input source being touched.
19
 * <p>
20
 * </p>
21
 *
22
 * @see TouchListener
23
 * @see TraverseListener
24
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
25
 */
26
27
public class TouchEvent extends TypedEvent {
28
	
29
	public TouchState[] touches;
30
31
	/**
32
	 * the state of the keyboard modifier keys and mouse masks
33
	 * at the time the event was generated.
34
	 * 
35
	 * @see org.eclipse.swt.SWT#MODIFIER_MASK
36
	 * @see org.eclipse.swt.SWT#BUTTON_MASK
37
	 */
38
	public int stateMask;
39
	
40
	/**
41
	 * the widget-relative, x coordinate of the pointer
42
	 * at the time the touch occurred
43
	 */
44
	public int x;
45
	
46
	/**
47
	 * the widget-relative, y coordinate of the pointer
48
	 * at the time the touch occurred
49
	 */	
50
	public int y;
51
		
52
	static final long serialVersionUID = -8348741538373572182L;
53
	
54
/**
55
 * Constructs a new instance of this class based on the
56
 * information in the given untyped event.
57
 *
58
 * @param e the untyped event containing the information
59
 */
60
public TouchEvent(Event e) {
61
	super(e);
62
	//this.touches = e.touches;
63
	this.stateMask = e.stateMask;
64
	this.x = e.x;
65
	this.y = e.y;
66
}
67
68
/**
69
 * Returns a string containing a concise, human-readable
70
 * description of the receiver.
71
 *
72
 * @return a string representation of the event
73
 */
74
public String toString() {
75
	String string = super.toString();
76
	string = string.substring (0, string.length() - 1); // remove trailing '}'
77
	if (touches != null) {
78
		for (int i = 0; i < touches.length; i++) {
79
			string += "\n     " + touches[i].toString();
80
		}
81
	}
82
	string += "}";
83
	return string;
84
}
85
}
(-)Eclipse (+40 lines)
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.internal.*;
15
16
/**
17
 * Classes which implement this interface provide methods
18
 * that deal with the events that are generated as keys
19
 * are pressed on the system keyboard.
20
 * <p>
21
 * After creating an instance of a class that implements
22
 * this interface it can be added to a control using the
23
 * <code>addKeyListener</code> method and removed using
24
 * the <code>removeKeyListener</code> method. When a
25
 * key is pressed or released, the appropriate method will
26
 * be invoked.
27
 * </p>
28
 *
29
 * @see TouchAdapter
30
 * @see TouchEvent
31
 */
32
public interface TouchListener extends SWTEventListener {
33
34
/**
35
 * Sent when a touch sequence begins, changes state, or ends.
36
 *
37
 * @param e an event containing information about the touch
38
 */
39
public void touch(TouchEvent e);
40
}
(-)Eclipse (+84 lines)
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
import org.eclipse.swt.internal.*;
14
15
/**
16
 * Instances of this class are sent as a result of
17
 * a touch-based input device being touched. It represents the state of a single finger in a touch.
18
 * <p>
19
 * </p>
20
 *
21
 * @see TouchEvent
22
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
23
 * @since 3.7
24
 */
25
26
public final class TouchState implements SerializableCompatibility {
27
	
28
	public static final int TOUCHSTATE_DOWN = 1 << 0;
29
	public static final int TOUCHSTATE_MOVE = 1 << 1;
30
	public static final int TOUCHSTATE_STATIONARY = 1 << 2;
31
	public static final int TOUCHSTATE_UP = 1 << 3;
32
	
33
	public long identity;
34
	public long device;
35
	public int phase;
36
	public boolean primary;
37
	
38
	public double normalizedX, normalizedY;
39
	public long screenX, screenY;
40
	
41
	static final long serialVersionUID = 4739171633050362401L;
42
43
/**
44
 * Constructs a new touch state from the given inputs.
45
 * 
46
 * @param identity Identity of the touch. Use this value to track changes to a touch during the touch's life. 
47
 * @param device Identifier for the device that generated the touch. Two touches may have the same identifier
48
 * even though they came from different devices.
49
 * @param phase One of the state constants representing the state of this touch.
50
 * @param primary This touch represents the primary input of the current touch session.
51
 * @param screenX X location of the touch in screen coordinates
52
 * @param screenY  Y location of the touch in screen coordinates
53
 * @param normalizedX X location of the touch, normalized to a value 0.0 to 1.0 inclusive.
54
 * @param normalizedY Y location of the touch, normalized to a value 0.0 to 1.0 inclusive.
55
 */
56
public TouchState(long identity, long device, int phase, boolean primary, long screenX, long screenY, double normalizedX, double normalizedY) {
57
	this.identity = identity;
58
	this.device = device;
59
	this.phase = phase;
60
	this.primary = primary;
61
	this.screenX = screenX;
62
	this.screenY = screenY;
63
	this.normalizedX = normalizedX;
64
	this.normalizedY = normalizedY;
65
}
66
67
/**
68
 * Returns a string containing a concise, human-readable
69
 * description of the receiver.
70
 *
71
 * @return a string representation of the event
72
 */
73
public String toString() {
74
	return "{identity=" + identity
75
	+ " device=" + device
76
	+ " phase=" + phase
77
	+ " primary=" + primary
78
	+ " normalizedX=" + normalizedX
79
	+ " normalizedY=" + normalizedY
80
	+ " screenX=" + screenX
81
	+ " screenY=" + screenY
82
	+ "}";
83
}
84
}
(-)Eclipse SWT/common/org/eclipse/swt/widgets/Event.java (+34 lines)
Lines 215-220 Link Here
215
	 */
215
	 */
216
	public Object data;
216
	public Object data;
217
	
217
	
218
	/**
219
	 * An array of the touch states for the current touch event.
220
	 * @since 3.7
221
	 */
222
	//public Touch[] touches;
223
	
224
	/**
225
	 * If nonzero, a positive value indicates a swipe to the right,
226
	 * and a negative value indicates a swipe to the left.
227
	 * @since 3.7
228
	 */
229
	public int xDirection;
230
	
231
	/**
232
	 * If nonzero, a positive value indicates a swipe in the up direction,
233
	 * and a negative value indicates a swipe in the down direction.
234
	 * @since 3.7
235
	 */
236
	public int yDirection;
237
	
238
	/**
239
	 * Change in magnification. This value should be added to the current 
240
	 * scaling of an item to get the new scale factor.
241
	 * @since 3.7
242
	 */
243
	public double magnification;
244
	
245
	/**
246
	 * Number of degrees rotated on the track pad.
247
	 * @since 3.7
248
	 */
249
	public double rotation;
250
	
251
218
/**
252
/**
219
 * Gets the bounds.
253
 * Gets the bounds.
220
 * 
254
 * 
(-)Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java (+4 lines)
Lines 143-148 Link Here
143
			((FocusListener) eventListener).focusLost(new FocusEvent(e));
143
			((FocusListener) eventListener).focusLost(new FocusEvent(e));
144
			break;
144
			break;
145
		}
145
		}
146
		case SWT.Gesture: {
147
			((GestureListener)eventListener).gesture(new GestureEvent(e));
148
			break;
149
		}
146
		case SWT.Help: {
150
		case SWT.Help: {
147
			((HelpListener) eventListener).helpRequested (new HelpEvent (e));
151
			((HelpListener) eventListener).helpRequested (new HelpEvent (e));
148
			break;
152
			break;

Return to bug 279884