### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java,v retrieving revision 1.26 diff -u -r1.26 TrayItem.java --- Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java 9 May 2006 19:46:56 -0000 1.26 +++ Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java 15 Mar 2007 19:02:23 -0000 @@ -109,6 +109,34 @@ addListener (SWT.DefaultSelection,typedListener); } +/** + * Adds the listener to the collection of listeners who will + * be notified when the platform-specific context menu trigger + * has occurred, by sending it one of the messages defined in + * the MenuDetectListener interface. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see MenuDetectListener + * @see #removeMenuDetectListener + * + * @since 3.3 + */ +public void addMenuDetectListener (MenuDetectListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.MenuDetect, typedListener); +} + protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } @@ -322,6 +350,33 @@ } /** + * Removes the listener from the collection of listeners who will + * be notified when the platform-secific context menu trigger has + * occurred. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see MenuDetectListener + * @see #addMenuDetectListener + * + * @since 3.3 + */ +public void removeMenuDetectListener (MenuDetectListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.MenuDetect, listener); +} + +/** * Sets the receiver's image. * * @param image the new image Index: Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java,v retrieving revision 1.308 diff -u -r1.308 Control.java --- Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java 22 Feb 2007 22:13:21 -0000 1.308 +++ Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java 15 Mar 2007 19:02:23 -0000 @@ -245,6 +245,34 @@ /** * Adds the listener to the collection of listeners who will + * be notified when the platform-specific context menu trigger + * has occurred, by sending it one of the messages defined in + * the MenuDetectListener interface. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see MenuDetectListener + * @see #removeMenuDetectListener + * + * @since 3.3 + */ +public void addMenuDetectListener (MenuDetectListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.MenuDetect, typedListener); +} + +/** + * Adds the listener to the collection of listeners who will * be notified when mouse buttons are pressed and released, by sending * it one of the messages defined in the MouseListener * interface. @@ -327,6 +355,34 @@ /** * Adds the listener to the collection of listeners who will + * be notified when the mouse wheel is scrolled, by sending + * it one of the messages defined in the + * MouseWheelListener interface. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see MouseWheelListener + * @see #removeMouseWheelListener + * + * @since 3.3 + */ +public void addMouseWheelListener (MouseWheelListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.MouseWheel, typedListener); +} + +/** + * Adds the listener to the collection of listeners who will * be notified when the receiver needs to be painted, by sending it * one of the messages defined in the PaintListener * interface. @@ -2047,6 +2103,33 @@ /** * Removes the listener from the collection of listeners who will + * be notified when the platform-secific context menu trigger has + * occurred. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see MenuDetectListener + * @see #addMenuDetectListener + * + * @since 3.3 + */ +public void removeMenuDetectListener (MenuDetectListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.MenuDetect, listener); +} + +/** + * Removes the listener from the collection of listeners who will * be notified when the mouse passes or hovers over controls. * * @param listener the listener which should no longer be notified @@ -2123,6 +2206,32 @@ /** * Removes the listener from the collection of listeners who will + * be notified when the mouse wheel is scrolled. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see MouseWheelListener + * @see #addMouseWheelListener + * + * @since 3.3 + */ +public void removeMouseWheelListener (MouseWheelListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.MouseWheel, listener); +} + +/** + * Removes the listener from the collection of listeners who will * be notified when the receiver needs to be painted. * * @param listener the listener which should no longer be notified Index: Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java,v retrieving revision 1.17 diff -u -r1.17 TypedListener.java --- Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java 18 Jan 2007 00:51:35 -0000 1.17 +++ Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java 15 Mar 2007 19:02:23 -0000 @@ -166,6 +166,14 @@ ((ModifyListener) eventListener).modifyText(new ModifyEvent(e)); break; } + case SWT.MenuDetect: { + MenuDetectEvent event = new MenuDetectEvent(e); + ((MenuDetectListener) eventListener).menuDetected(event); + e.x = event.x; + e.y = event.y; + e.doit = event.doit; + break; + } case SWT.MouseDown: { ((MouseListener) eventListener).mouseDown(new MouseEvent(e)); break; @@ -190,6 +198,10 @@ ((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e)); return; } + case SWT.MouseWheel: { + ((MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e)); + return; + } case SWT.MouseUp: { ((MouseListener) eventListener).mouseUp(new MouseEvent(e)); break; Index: Eclipse SWT/common/org/eclipse/swt/events/MouseWheelListener.java =================================================================== RCS file: Eclipse SWT/common/org/eclipse/swt/events/MouseWheelListener.java diff -N Eclipse SWT/common/org/eclipse/swt/events/MouseWheelListener.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Eclipse SWT/common/org/eclipse/swt/events/MouseWheelListener.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.events; + + +import org.eclipse.swt.internal.SWTEventListener; + +/** + * Classes which implement this interface provide a method + * that deals with the event that is generated as the mouse + * wheel is scrolled. + *

+ * After creating an instance of a class that implements + * this interface it can be added to a control using the + * addMouseWheelListener method and removed using + * the removeMouseWheelListener method. When the + * mouse wheel is scrolled the mouseScrolled method + * will be invoked. + *

+ * + * @see MouseEvent + * + * @since 3.3 + */ +public interface MouseWheelListener extends SWTEventListener { + +/** + * Sent when the mouse wheel is scrolled. + * + * @param e an event containing information about the mouse wheel action + */ +public void mouseScrolled (MouseEvent e); +} Index: Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java =================================================================== RCS file: Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java diff -N Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.events; + + +import org.eclipse.swt.widgets.Event; + +/** + * Instances of this class are sent whenever the platform- + * specific trigger for showing a context menu is detected. + * + * @see MenuDetectListener + * + * @since 3.3 + */ + +public final class MenuDetectEvent extends TypedEvent { + + /** + * the widget-relative, x coordinate of the pointer + * at the time the context menu trigger occurred + */ + public int x; + + /** + * the widget-relative, y coordinate of the pointer + * at the time the context menu trigger occurred + */ + public int y; + + /** + * A flag indicating whether the operation should be allowed. + * Setting this field to false will cancel the operation. + */ + public boolean doit; + + private static final long serialVersionUID = -3061660596590828941L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public MenuDetectEvent(Event e) { + super(e); + this.x = e.x; + this.y = e.y; + this.doit = e.doit; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public String toString() { + String string = super.toString (); + return string.substring (0, string.length() - 1) // remove trailing '}' + + " x=" + x + + " y=" + y + + " doit=" + doit + + "}"; +} +} Index: Eclipse SWT/common/org/eclipse/swt/events/MenuDetectListener.java =================================================================== RCS file: Eclipse SWT/common/org/eclipse/swt/events/MenuDetectListener.java diff -N Eclipse SWT/common/org/eclipse/swt/events/MenuDetectListener.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Eclipse SWT/common/org/eclipse/swt/events/MenuDetectListener.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.events; + + +import org.eclipse.swt.internal.SWTEventListener; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated when the + * platform-specific trigger for showing a context menu is + * detected. + *

+ * After creating an instance of a class that implements + * this interface it can be added to a control or TrayItem + * using the addMenuDetectListener method and + * removed using the removeMenuDetectListener method. + * When the context menu trigger occurs, the + * menuDetected method will be invoked. + *

+ * + * @see MenuDetectEvent + * + * @since 3.3 + */ +public interface MenuDetectListener extends SWTEventListener { + +/** + * Sent when the platform-dependent trigger for showing a menu item is detected. + * + * @param e an event containing information about the menu detect + */ +public void menuDetected (MenuDetectEvent e); +}