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 (+43 lines)
Lines 981-986 Link Here
981
	public static final int GESTURE_PAN = 1 << 6;
981
	public static final int GESTURE_PAN = 1 << 6;
982
	
982
	
983
	/**
983
	/**
984
	 * A constant indicating that a finger is still touching the device,
985
	 * but has not moved since the previous event.
986
	 * 
987
	 * @see org.eclipse.swt.widgets.Touch.state
988
	 * @since 3.7
989
	 */
990
	public static final int TOUCHSTATE_STATIONARY = 0;
991
992
	/**
993
	 * A constant indicating that a finger touched the device.  
994
	 * 
995
	 * @see org.eclipse.swt.widgets.Touch.state
996
	 * @since 3.7
997
	 */
998
	public static final int TOUCHSTATE_DOWN = 1 << 0;
999
1000
	/**
1001
	 * A constant indicating that a finger moved on the device.
1002
	 * 
1003
	 * @see org.eclipse.swt.widgets.Touch.state
1004
	 * @since 3.7
1005
	 */
1006
	public static final int TOUCHSTATE_MOVE = 1 << 1;
1007
1008
	/**
1009
	 * A constant indicating that a finger was lifted from the device. 
1010
	 * 
1011
	 * @see org.eclipse.swt.widgets.Touch.state
1012
	 * @since 3.7
1013
	 */
1014
	public static final int TOUCHSTATE_UP = 1 << 2;
1015
	
1016
	/**
1017
	 * A constant indicating that the touch is the first touch from a previous state
1018
	 * of no touch points. Once designated as such, the touch remains the
1019
	 * primary touch until all fingers are removed from the device. 
1020
	 * 
1021
	 * @see org.eclipse.swt.widgets.Touch.state
1022
	 * @since 3.7
1023
	 */
1024
	public static final int TOUCHSTATE_PRIMARY = 1 << 3;
1025
	
1026
	/**
984
	 * A constant indicating that widgets have changed.
1027
	 * A constant indicating that widgets have changed.
985
	 * (value is 1&lt;&lt;1).
1028
	 * (value is 1&lt;&lt;1).
986
	 * 
1029
	 * 
(-)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.widgets.*;
14
15
/**
16
 * Instances of this class are sent as a result of
17
 * a touch-based input source being touched.
18
 * <p>
19
 * </p>
20
 *
21
 * @see TouchListener
22
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
23
 * @since 3.7
24
 */
25
26
public class TouchEvent extends TypedEvent {
27
	
28
	public Touch[] touches;
29
30
	/**
31
	 * the state of the keyboard modifier keys and mouse masks
32
	 * at the time the event was generated.
33
	 * 
34
	 * @see org.eclipse.swt.SWT#MODIFIER_MASK
35
	 * @see org.eclipse.swt.SWT#BUTTON_MASK
36
	 */
37
	public int stateMask;
38
	
39
	/**
40
	 * the widget-relative, x coordinate of the pointer
41
	 * at the time the touch occurred
42
	 */
43
	public int x;
44
	
45
	/**
46
	 * the widget-relative, y coordinate of the pointer
47
	 * at the time the touch occurred
48
	 */	
49
	public int y;
50
		
51
	static final long serialVersionUID = -8348741538373572182L;
52
	
53
/**
54
 * Constructs a new instance of this class based on the
55
 * information in the given untyped event.
56
 *
57
 * @param e the untyped event containing the information
58
 */
59
public TouchEvent(Event e) {
60
	super(e);
61
	this.touches = e.touches;
62
	this.stateMask = e.stateMask;
63
	this.x = e.x;
64
	this.y = e.y;
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
	String string = super.toString();
75
	string = string.substring (0, string.length() - 1); // remove trailing '}'
76
	if (touches != null) {
77
		for (int i = 0; i < touches.length; i++) {
78
			string += "\n     " + touches[i].toString();
79
		}
80
	}
81
	string += "}";
82
	return string;
83
}
84
}
(-)Eclipse (+41 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 touches
19
 * occur on a touch-aware input surface.
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>addTouchListener</code> method and removed using
24
 * the <code>removeTouchListener</code> method. When a
25
 * touch occurs or changes state, the <code>touch</code> method
26
 * will be invoked.
27
 * </p>
28
 *
29
 * @see TouchAdapter
30
 * @see TouchEvent
31
 * @since 3.7
32
 */
33
public interface TouchListener extends SWTEventListener {
34
35
/**
36
 * Sent when a touch sequence begins, changes state, or ends.
37
 *
38
 * @param e an event containing information about the touch
39
 */
40
public void touch(TouchEvent e);
41
}
(-)Eclipse SWT/common/org/eclipse/swt/widgets/Event.java (-1 / +1 lines)
Lines 219-225 Link Here
219
	 * An array of the touch states for the current touch event.
219
	 * An array of the touch states for the current touch event.
220
	 * @since 3.7
220
	 * @since 3.7
221
	 */
221
	 */
222
	//public Touch[] touches;
222
	public Touch[] touches;
223
	
223
	
224
	/**
224
	/**
225
	 * If nonzero, a positive value indicates a swipe to the right,
225
	 * If nonzero, a positive value indicates a swipe to the right,
(-)Eclipse (+97 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.widgets;
12
13
import org.eclipse.swt.events.*;
14
15
16
/**
17
 * Instances of this class are created as a result of
18
 * a touch-based input device being touched. They are found
19
 * in the <code>touches</code> field of an Event or TouchEvent.
20
 * <p>
21
 * </p>
22
 *
23
 * @see TouchEvent
24
 * @see Event
25
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
26
 * @since 3.7
27
 */
28
29
public final class Touch {
30
	
31
	/**
32
	 * unique identity of the touch. Use this value to track changes to a touch during
33
	 * the touch's life. Two touches may have the same identity even though they came
34
	 * from different sources.
35
	 */
36
	public long id;
37
	
38
	/**
39
	 * object representing the input source that generated the touch
40
	 */
41
	public TouchSource source;
42
	
43
	/**
44
	 * the state of this touch at the time it was generated
45
	 * 
46
	 * @see org.eclipse.swt.SWT#TOUCHSTATE_DOWN
47
	 * @see org.eclipse.swt.SWT#TOUCHSTATE_MOVED
48
	 * @see org.eclipse.swt.SWT#TOUCHSTATE_UP
49
	 * @see org.eclipse.swt.SWT#TOUCHSTATE_STATIONARY
50
	 * @see org.eclipse.swt.SWT#TOUCHSTATE_PRIMARY
51
	 */
52
	public int state;
53
	
54
	/** 
55
	 * the X location of the touch in screen coordinates
56
	 */
57
	public int x;
58
	
59
	/**
60
	 * the Y location of the touch in screen coordinates
61
	 */
62
	public int y;
63
	
64
	static final long serialVersionUID = 4739171633050362401L;
65
66
/**
67
 * Constructs a new touch state from the given inputs.
68
 * 
69
 * @param identity Identity of the touch. 
70
 * @param source Object representing the device that generated the touch. 
71
 * @param state One of the state constants representing the state of this touch.
72
 * @param x X location of the touch in screen coordinates
73
 * @param y Y location of the touch in screen coordinates
74
 */
75
public Touch(long identity, TouchSource source, int state, int x, int y) {
76
	this.id = identity;
77
	this.source = source;
78
	this.state = state;
79
	this.x = x;
80
	this.y = y;
81
}
82
83
/**
84
 * Returns a string containing a concise, human-readable
85
 * description of the receiver.
86
 *
87
 * @return a string representation of the event
88
 */
89
public String toString() {
90
	return "{id=" + id
91
	+ " source=" + source
92
	+ " state=" + state
93
	+ " x=" + x
94
	+ " y=" + y
95
	+ "}";
96
}
97
}
(-)Eclipse (+78 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.widgets;
12
13
import org.eclipse.swt.graphics.*;
14
15
16
/**
17
 * Instances of this class represent a source of touch input. It is used to identify which input source
18
 * generated a <code>Touch</code> object. It also provides information about the input source, which is important
19
 * when deciding how to interpret the information in the <code>Touch</code> object.
20
 * <p>
21
 * Instances of this class can be marked as direct or indirect:
22
 * <ul>
23
 * <li>When an instance is marked as <em>direct</em> the touch source is a touch-sensitive digitizer surface such
24
 * as a tablet or a touch screen. There is a one-to-one mapping between a touch point and a location in a window.
25
 * </li><li>
26
 * When an instance is marked as <em>indirect</em> (or, more precisely, not direct) the touch source is a track pad 
27
 * or other device that normally moves the cursor, but can also interpret multiple touches on its surface. In this 
28
 * case, there is not a one-to-one map between the location of the touch on the device and a location on the display
29
 * because the user can remove their finger or stylus and touch another part of the device and resume what they were
30
 * doing.
31
 * </li>
32
 * </ul>
33
 * <p> 
34
 * IMPORTANT: This class is not intended to be subclassed.
35
 * </p>
36
 *
37
 * @see Touch
38
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
39
 * 
40
 * @since 3.7
41
 */
42
43
public final class TouchSource {
44
45
	/**
46
	 * the type of touch input this source generates; true for direct, false for indirect.
47
	 */
48
	public boolean direct;
49
	
50
	/**
51
	 * Bounding rectangle of the device. For a direct source, corresponds to the bounds of the display
52
	 * device in pixels. For an indirect source, contains the size of the device in pixels.
53
	 */
54
	public Rectangle bounds;
55
56
/**
57
 * Constructs a new touch source from the given inputs.
58
 * 
59
 * @param direct Is the touch source direct or indirect? 
60
 * @param height height of the source in pixels.
61
 * @param width width of the source in pixels.
62
 */
63
public TouchSource(boolean direct, Rectangle bounds) {
64
	this.direct = direct;
65
	this.bounds = bounds;
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
	return "{direct=" + direct
76
	+ " bounds=" + bounds;
77
}
78
}
(-)Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java (-1 / +7 lines)
Lines 144-150 Link Here
144
			break;
144
			break;
145
		}
145
		}
146
		case SWT.Gesture: {
146
		case SWT.Gesture: {
147
			((GestureListener)eventListener).gesture(new GestureEvent(e));
147
			GestureEvent event = new GestureEvent(e);
148
			((GestureListener)eventListener).gesture(event);
149
			e.doit = event.doit;
148
			break;
150
			break;
149
		}
151
		}
150
		case SWT.Help: {
152
		case SWT.Help: {
Lines 245-250 Link Here
245
			((MenuListener) eventListener).menuShown(new MenuEvent(e));
247
			((MenuListener) eventListener).menuShown(new MenuEvent(e));
246
			break;
248
			break;
247
		}
249
		}
250
		case SWT.Touch: {
251
			((TouchListener)eventListener).touch(new TouchEvent(e));
252
			break;
253
		}
248
		case SWT.Traverse: {
254
		case SWT.Traverse: {
249
			/* Fields set by Control */
255
			/* Fields set by Control */
250
			TraverseEvent event = new TraverseEvent (e);
256
			TraverseEvent event = new TraverseEvent (e);

Return to bug 279884