Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 91607 Details for
Bug 193318
Implement ToolItem.setMenu
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
swt setmenu wpf patch
swt setmenu wpf patch.txt (text/plain), 13.72 KB, created by
Nikolay Botev
on 2008-03-05 02:08:29 EST
(
hide
)
Description:
swt setmenu wpf patch
Filename:
MIME Type:
Creator:
Nikolay Botev
Created:
2008-03-05 02:08:29 EST
Size:
13.72 KB
patch
obsolete
>### 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 <code>MenuDetectListener</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 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 <code>SelectionListener</code> >@@ -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 <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> >+ * >+ * @since 3.4 >+ */ >+public Menu getMenu () { >+ checkWidget(); >+ return menu; >+} >+ >+/** > * Returns the receiver's parent, which must be a <code>CoolBar</code>. > * > * @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. >+ * <p> >+ * 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 <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> >+ * >+ * @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 <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 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 <code>true</code>, >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 <code>MenuDetectListener</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 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 <code>SelectionListener</code> > * interface. >@@ -315,6 +344,26 @@ > } > > /** >+ * Returns the receiver's drop-down menu if it has one, or null >+ * if it does not. >+ * <p> >+ * The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled receiver is pressed. >+ * </p> >+ * >+ * @return the receiver's drop-down menu >+ * @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> >+ * >+ * @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. > * <p> >@@ -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 <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 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. >+ * <p> >+ * 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. >+ * <p> >+ * 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. >+ * </p> >+ * >+ * @param menu the drop-down menu to be displayed when the receiver's arrow is pressed >+ * @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> >+ * >+ * @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 <code>true</code>, > * and disables it otherwise. > * <p> >@@ -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 (); >+} >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 193318
:
71745
|
71746
|
71747
|
71748
|
71749
|
72862
|
72863
|
72930
|
72931
|
90591
|
90592
|
91606
| 91607