summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
diff options
context:
space:
mode:
authorScott Kovatch <skovatch>2010-12-20 23:31:25 +0000
committerScott Kovatch <skovatch>2010-12-20 23:31:25 +0000
commit46958a15f43936733bc819b97c827c339d68bc9e (patch)
treee15ce7830e7f4b5adbd8d6fb2d957a12dd5d8767 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
parent47ba9e76486cd9d9cdae92690c6b15ee0252a7d8 (diff)
downloadeclipse.platform.swt-46958a15f43936733bc819b97c827c339d68bc9e.tar.gz
eclipse.platform.swt-46958a15f43936733bc819b97c827c339d68bc9e.tar.xz
eclipse.platform.swt-46958a15f43936733bc819b97c827c339d68bc9e.zip
279884 - Implement gestures on Win32
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 580e7f22ad..8b57f49fc6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -44,6 +44,8 @@ import org.eclipse.swt.accessibility.*;
*/
public abstract class Control extends Widget implements Drawable {
+ static final int GESTURE_COUNT = 5;
+
/**
* the handle to the OS resource
* (Warning: This field is platform dependent)
@@ -194,6 +196,32 @@ public void addFocusListener (FocusListener listener) {
/**
* Adds the listener to the collection of listeners who will
+ * be notified when gesture events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>GestureListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see GestureListener
+ * @see #removeGestureListener
+ */
+public void addGestureListener (GestureListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Gesture, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
* by sending it one of the messages defined in the
* <code>HelpListener</code> interface.
@@ -640,6 +668,31 @@ void createHandle () {
OS.ImmAssociateContext (handle, hIMC);
OS.ImmReleaseContext (hwndParent, hIMC);
}
+
+}
+
+void checkGesture() {
+ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 1)) {
+ int value = OS.GetSystemMetrics(OS.SM_DIGITIZER);
+
+ if ((value & (OS.NID_READY | OS.NID_MULTI_INPUT)) != 0) {
+ int /*long*/ hHeap = OS.GetProcessHeap();
+ int /*long*/ pConfigs = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, GESTURE_COUNT * GESTURECONFIG.sizeof);
+
+ if (pConfigs != 0) {
+ GESTURECONFIG config = new GESTURECONFIG();
+ for (int i = 0; i < GESTURE_COUNT; i++) {
+ config.dwID = i + OS.GID_ZOOM;
+ config.dwWant = 1;
+ config.dwBlock = 0;
+ OS.MoveMemory(pConfigs + i * GESTURECONFIG.sizeof, config, GESTURECONFIG.sizeof);
+ }
+
+ OS.SetGestureConfig(handle, 0, GESTURE_COUNT, pConfigs, GESTURECONFIG.sizeof);
+ OS.HeapFree(hHeap, 0, pConfigs);
+ }
+ }
+ }
}
void createWidget () {
@@ -655,6 +708,7 @@ void createWidget () {
setDefaultFont ();
checkMirrored ();
checkBorder ();
+ checkGesture();
if ((state & PARENT_BACKGROUND) != 0) {
setBackground ();
}
@@ -2379,6 +2433,30 @@ public void removeFocusListener(FocusListener listener) {
/**
* Removes the listener from the collection of listeners who will
+ * be notified when gesture events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see GestureListener
+ * @see #addGestureListener
+ */
+public void removeGestureListener (GestureListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Gesture, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
*
* @param listener the listener which should no longer be notified
@@ -4180,6 +4258,7 @@ int /*long*/ windowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*
case OS.WM_ENDSESSION: result = WM_ENDSESSION (wParam, lParam); break;
case OS.WM_ENTERIDLE: result = WM_ENTERIDLE (wParam, lParam); break;
case OS.WM_ERASEBKGND: result = WM_ERASEBKGND (wParam, lParam); break;
+ case OS.WM_GESTURE: result = WM_GESTURE (wParam, lParam); break;
case OS.WM_GETDLGCODE: result = WM_GETDLGCODE (wParam, lParam); break;
case OS.WM_GETFONT: result = WM_GETFONT (wParam, lParam); break;
case OS.WM_GETOBJECT: result = WM_GETOBJECT (wParam, lParam); break;
@@ -4242,6 +4321,7 @@ int /*long*/ windowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*
case OS.WM_SYSCOMMAND: result = WM_SYSCOMMAND (wParam, lParam); break;
case OS.WM_SYSKEYDOWN: result = WM_SYSKEYDOWN (wParam, lParam); break;
case OS.WM_SYSKEYUP: result = WM_SYSKEYUP (wParam, lParam); break;
+ case OS.WM_TABLET_FLICK: result = WM_TABLET_FLICK (wParam, lParam); break;
case OS.WM_TIMER: result = WM_TIMER (wParam, lParam); break;
case OS.WM_UNDO: result = WM_UNDO (wParam, lParam); break;
case OS.WM_UPDATEUISTATE: result = WM_UPDATEUISTATE (wParam, lParam); break;
@@ -4358,6 +4438,10 @@ LRESULT WM_ERASEBKGND (int /*long*/ wParam, int /*long*/ lParam) {
return null;
}
+LRESULT WM_GESTURE (int /*long*/ wParam, int /*long*/ lParam) {
+ return wmGesture(handle, wParam, lParam);
+}
+
LRESULT WM_GETDLGCODE (int /*long*/ wParam, int /*long*/ lParam) {
return null;
}
@@ -4951,6 +5035,10 @@ LRESULT WM_SYSKEYUP (int /*long*/ wParam, int /*long*/ lParam) {
return wmSysKeyUp (handle, wParam, lParam);
}
+LRESULT WM_TABLET_FLICK (int /*long*/ wParam, int /*long*/ lParam) {
+ return wmTabletFlick (handle, wParam, lParam);
+}
+
LRESULT WM_TIMER (int /*long*/ wParam, int /*long*/ lParam) {
return null;
}