### Eclipse Workspace Patch 1.0
#P org.eclipse.swt_wpf
Index: Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolItem.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolItem.java,v
retrieving revision 1.5
diff -u -r1.5 CoolItem.java
--- Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolItem.java 31 May 2007 22:04:29 -0000 1.5
+++ Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolItem.java 5 Mar 2008 07:06:35 -0000
@@ -34,6 +34,7 @@
public class CoolItem extends Item {
CoolBar parent;
Control control;
+ Menu menu;
/**
* Constructs a new instance of this class given its parent
@@ -110,6 +111,34 @@
}
/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the platform-specific chevron 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
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @see MenuDetectListener
+ * @see #removeMenuDetectListener
+ *
+ * @since 3.4
+ */
+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 that will
* be notified when the control is selected by the user, by sending it one
* of the messages defined in the SelectionListener
@@ -285,6 +314,23 @@
}
/**
+ * Returns the receiver's chevron menu if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's drop-down menu
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @since 3.4
+ */
+public Menu getMenu () {
+ checkWidget();
+ return menu;
+}
+
+/**
* Returns the receiver's parent, which must be a CoolBar
.
*
* @return the receiver's parent
@@ -300,6 +346,35 @@
}
/**
+ * Sets the receiver's chevron menu to the argument, which may be
+ * null indicating that no drop-down menu should be displayed.
+ *
+ * If this property is null a drop-down menu can still be displayed manually by adding a
+ * {@link SelectionListener} to the receiver and handling{@link SWT#ARROW} events.
+ *
+ * @param menu the drop-down menu to be displayed when the receiver's arrow is pressed
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @since 3.4
+ */
+public void setMenu (Menu menu) {
+ checkWidget();
+ if (menu != null) {
+ if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((menu.style & SWT.POP_UP) == 0) {
+ error (SWT.ERROR_MENU_NOT_POP_UP);
+ }
+ if (menu.parent != parent.menuShell ()) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ }
+ this.menu = menu;
+}
+
+/**
* Returns a point describing the receiver's ideal size.
* The x coordinate of the result is the ideal width of the receiver.
* The y coordinate of the result is the ideal height of the receiver.
@@ -373,6 +448,14 @@
return result;
}
+void releaseWidget () {
+ super.releaseWidget ();
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+}
+
void releaseHandle () {
super.releaseHandle ();
if (handle != 0) OS.GCHandle_Free (handle);
@@ -381,6 +464,33 @@
}
/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the platform-specific chevron menu trigger has
+ * occurred.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @see MenuDetectListener
+ * @see #addMenuDetectListener
+ *
+ * @since 3.4
+ */
+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 that
* will be notified when the control is selected by the user.
*
Index: Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java,v
retrieving revision 1.38
diff -u -r1.38 Control.java
--- Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java 4 Mar 2008 17:32:39 -0000 1.38
+++ Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java 5 Mar 2008 07:06:35 -0000
@@ -17,7 +17,7 @@
import org.eclipse.swt.accessibility.*;
//TEMPORARY CODE
-import org.eclipse.swt.effects.*;
+//import org.eclipse.swt.effects.*;
/**
* Control is the abstract superclass of all windowed user interface classes.
@@ -2634,18 +2634,18 @@
/**
* WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED
*/
-public void setEffect(Effect effect){
- checkWidget ();
- if (effect != null && effect.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (effect != null) {
- OS.UIElement_BitmapEffect (handle, effect.handle);
- OS.UIElement_ClipToBounds (topHandle (), false);
- } else {
- OS.UIElement_BitmapEffect (handle, 0);
- setClipping();
- }
-// updateLayout(handle);
-}
+//public void setEffect(Effect effect){
+// checkWidget ();
+// if (effect != null && effect.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+// if (effect != null) {
+// OS.UIElement_BitmapEffect (handle, effect.handle);
+// OS.UIElement_ClipToBounds (topHandle (), false);
+// } else {
+// OS.UIElement_BitmapEffect (handle, 0);
+// setClipping();
+// }
+//// updateLayout(handle);
+//}
/**
* Enables the receiver if the argument is true
,
Index: Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolItem.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolItem.java,v
retrieving revision 1.10
diff -u -r1.10 ToolItem.java
--- Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolItem.java 5 Nov 2007 17:23:40 -0000 1.10
+++ Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolItem.java 5 Mar 2008 07:06:35 -0000
@@ -36,6 +36,7 @@
int imageHandle, textHandle, arrowHandle;
ToolBar parent;
Control control;
+ Menu menu;
String toolTipText;
Image disabledImage, hotImage;
boolean ignoreSelection;
@@ -124,6 +125,34 @@
/**
* Adds the listener to the collection of listeners who will
+ * be notified when the platform-specific drop-down 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
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @see MenuDetectListener
+ * @see #removeMenuDetectListener
+ *
+ * @since 3.4
+ */
+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 the control is selected by the user, by sending
* it one of the messages defined in the SelectionListener
* interface.
@@ -315,6 +344,26 @@
}
/**
+ * Returns the receiver's drop-down menu if it has one, or null
+ * if it does not.
+ *
+ * The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled receiver is pressed.
+ *
+ *
+ * @return the receiver's drop-down menu
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @since 3.4
+ */
+public Menu getMenu () {
+ checkWidget();
+ return menu;
+}
+
+/**
* Returns the receiver's disabled image if it has one, or null
* if it does not.
*
@@ -454,6 +503,7 @@
if (!checkEvent (e)) return;
if (ignoreSelection) return;
Event event = new Event ();
+ Point showTheMenuPos = null;
if ((style & SWT.DROP_DOWN) != 0) {
int mousePos = OS.Mouse_GetPosition (handle);
int zero = OS.gcnew_Point (0, OS.FrameworkElement_ActualHeight (topHandle ()));
@@ -463,11 +513,29 @@
int location = OS.UIElement_TranslatePoint (handle, zero, parent.handle);
event.x = (int) OS.Point_X (location);
event.y = (int) OS.Point_Y (location);
+ if (sendMenuDetectEvent (event.x, event.y, SWT.ARROW)) {
+ showTheMenuPos = parent.toDisplay(event.x, event.y);
+ }
OS.GCHandle_Free (location);
}
OS.GCHandle_Free (arrowPos);
OS.GCHandle_Free (zero);
OS.GCHandle_Free (mousePos);
+ } else {
+ int zero = OS.gcnew_Point (0, OS.FrameworkElement_ActualHeight (topHandle ()));
+ int location = OS.UIElement_TranslatePoint (handle, zero, parent.handle);
+ int x = (int) OS.Point_X (location);
+ int y = (int) OS.Point_Y (location);
+ if (sendMenuDetectEvent (x, y, 0)) {
+ showTheMenuPos = parent.toDisplay(x, y);
+ }
+ OS.GCHandle_Free(zero);
+ OS.GCHandle_Free(location);
+ }
+ if (showTheMenuPos != null) {
+ menu.setLocation (showTheMenuPos.x, showTheMenuPos.y);
+ menu.setVisible (true);
+ return;
}
postEvent (SWT.Selection, event);
}
@@ -542,6 +610,10 @@
void releaseWidget () {
super.releaseWidget ();
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
control = null;
toolTipText = null;
image = disabledImage = hotImage = null;
@@ -568,6 +640,33 @@
/**
* Removes the listener from the collection of listeners who will
+ * be notified when the platform-specific drop-down menu trigger has
+ * occurred.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @see MenuDetectListener
+ * @see #addMenuDetectListener
+ *
+ * @since 3.4
+ */
+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 control is selected by the user.
*
* @param listener the listener which should no longer be notified
@@ -636,6 +735,39 @@
}
/**
+ * Sets the receiver's drop-down menu to the argument, which may be
+ * null indicating that no drop-down menu should be displayed.
+ *
+ * If this property is null a drop-down menu can still be displayed manually by adding a
+ * {@link SelectionListener} to the receiver and handling{@link SWT#ARROW} events.
+ *
+ * The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled
+ * receiver or any portion of an {@link SWT#PUSH}-styled receiver is pressed.
+ *
+ *
+ * @param menu the drop-down menu to be displayed when the receiver's arrow is pressed
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ *
+ * @since 3.4
+ */
+public void setMenu (Menu menu) {
+ checkWidget();
+ if (menu != null) {
+ if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((menu.style & SWT.POP_UP) == 0) {
+ error (SWT.ERROR_MENU_NOT_POP_UP);
+ }
+ if (menu.parent != parent.menuShell ()) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ }
+ this.menu = menu;
+}
+
+/**
* Enables the receiver if the argument is true
,
* and disables it otherwise.
*
@@ -833,4 +965,14 @@
OS.FrameworkElement_Margin (imageHandle, margin);
OS.GCHandle_Free (margin);
}
+
+private boolean sendMenuDetectEvent (int x, int y, int detail) {
+ Event event = new Event ();
+ event.detail = detail;
+ event.x = x;
+ event.y = y;
+ this.sendEvent (SWT.MenuDetect, event);
+ return event.doit && menu != null && !menu.isDisposed ();
+}
+
}