[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: swing fixes

Kaffe CVS cvs-commits at kaffe.org
Mon Jul 25 06:48:12 PDT 2005


PatchSet 6764 
Date: 2005/07/25 13:43:26
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: swing fixes

Members: 
	ChangeLog:1.4289->1.4290 
	libraries/javalib/javax/swing/JMenu.java:1.13->1.14 
	libraries/javalib/javax/swing/plaf/basic/BasicMenuUI.java:1.8->1.9 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4289 kaffe/ChangeLog:1.4290
--- kaffe/ChangeLog:1.4289	Sun Jul 24 17:17:28 2005
+++ kaffe/ChangeLog	Mon Jul 25 13:43:26 2005
@@ -1,3 +1,26 @@
+2005-07-25  Dalibor Topic  <robilad at kaffe.org>
+
+	Resynced with GNU Classpath.
+
+	2005-07-11  Anthony Balkissoon  <abalkiss at redhat.com>
+
+        * javax/swing/plaf/basic/BasicMenuUI.java:
+        (MouseInputHandler.mouseEntered): Added check: if a different menu in
+        the menubar was selected, we don't select this one unless the old one
+        had its popup menu showing.  This complies with the reference
+        implementation.
+
+	2005-07-11  Anthony Balkissoon  <abalkiss at redhat.com>
+
+        * javax/swing/JMenu.java:
+        (setSelectedHelper): new method.
+        (setSelected): Code moved to setSelectedHelper. Calls
+        setSelectedHelper(selected,true,false) which doesn't expand the popup
+        menu and works whether the menu is enabled or not.
+        (menuSelectionChanged): Changed call to setSelected(changed) to 
+        setSelectedHelper(changed,isEnabled(),true) which does expand the
+        popup menu, but only if the menu is enabled.
+
 2005-07-24  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* libraries/clib/awt/X/fnt.c
Index: kaffe/libraries/javalib/javax/swing/JMenu.java
diff -u kaffe/libraries/javalib/javax/swing/JMenu.java:1.13 kaffe/libraries/javalib/javax/swing/JMenu.java:1.14
--- kaffe/libraries/javalib/javax/swing/JMenu.java:1.13	Sun Jul 10 02:11:41 2005
+++ kaffe/libraries/javalib/javax/swing/JMenu.java	Mon Jul 25 13:43:28 2005
@@ -332,52 +332,53 @@
   }
 
   /**
-   * Changes this menu selected state if selected is true and false otherwise
-   * This method fires menuEvents to menu's registered listeners.
-   *
-   * @param selected true if the menu should be selected and false otherwise
+   * A helper method to handle setSelected calls from both mouse events and 
+   * direct calls to setSelected.  Direct calls shouldn't expand the popup
+   * menu and should select the JMenu even if it is disabled.  Mouse events
+   * only select the JMenu if it is enabled and should expand the popup menu
+   * associated with this JMenu.
+   * @param selected whether or not the JMenu was selected
+   * @param menuEnabled whether or not selecting the menu is "enabled".  This
+   * is always true for direct calls, and is set to isEnabled() for mouse 
+   * based calls.
+   * @param showMenu whether or not to show the popup menu
    */
-  public void setSelected(boolean selected)
+  private void setSelectedHelper(boolean selected, boolean menuEnabled, boolean showMenu)
   {
     // If menu is selected and enabled, activates the menu and 
     // displays associated popup.	
-    if (selected && isEnabled())
+    if (selected && menuEnabled)
       {
 	super.setArmed(true);
 	super.setSelected(true);
-
-	// FIXME: The reference implementation behaves different here. When
-	// calling setSelected(true) it will *not* open the popup but appear
-	// selected. This is even true when the menu is disabled. Our
-	// implementation will always open the popup (when enabled) and 
-	// will not appear selected when disabled.
-
-	// FIXME: The popup menu should be shown on the screen after certain
-	// number of seconds pass. The 'delay' property of this menu indicates
-	// this amount of seconds. 'delay' property is 0 by default.
+        
+        // FIXME: The popup menu should be shown on the screen after certain
+        // number of seconds pass. The 'delay' property of this menu indicates
+        // this amount of seconds. 'delay' property is 0 by default.
 	if (isShowing())
 	  {
 	    fireMenuSelected();
-
+            
 	    int x = 0;
 	    int y = 0;
-
-	    if (menuLocation == null)
-	      {
-		// Calculate correct position of the popup. Note that location of the popup 
-		// passed to show() should be relative to the popup's invoker
-		if (isTopLevelMenu())
-		  y = this.getHeight();
-		else
-		  x = this.getWidth();
-
-		getPopupMenu().show(this, x, y);
-	      }
-	    else
-	      getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+            if (showMenu)
+              if (menuLocation == null)
+                {
+                  // Calculate correct position of the popup. Note that location of the popup 
+                  // passed to show() should be relative to the popup's invoker
+                  if (isTopLevelMenu())
+                    y = this.getHeight();
+                  else
+                    x = this.getWidth();
+                  getPopupMenu().show(this, x, y);
+                }
+              else
+                {
+                  getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+                }
 	  }
       }
-
+    
     else
       {
 	super.setSelected(false);
@@ -388,6 +389,17 @@
   }
 
   /**
+   * Changes this menu selected state if selected is true and false otherwise
+   * This method fires menuEvents to menu's registered listeners.
+   *
+   * @param selected true if the menu should be selected and false otherwise
+   */
+  public void setSelected(boolean selected)
+  {
+    setSelectedHelper(selected, true, false); 
+  }
+
+  /**
    * Checks if PopupMenu associated with this menu is visible
    *
    * @return true if the popup associated with this menu is currently visible
@@ -715,7 +727,7 @@
   {
     // if this menu selection is true, then activate this menu and 
     // display popup associated with this menu
-    setSelected(changed);
+    setSelectedHelper(changed, isEnabled(), true);
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuUI.java:1.8 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuUI.java:1.9
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuUI.java:1.8	Sun Jul 10 02:11:42 2005
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuUI.java	Mon Jul 25 13:43:29 2005
@@ -297,14 +297,18 @@
       /* When mouse enters menu item, it should be considered selected
 
        if (i) if this menu is a submenu in some other menu
-          (ii) or if this menu is in a menu bar and some other menu in a menu bar was just
-               selected. (If nothing was selected, menu should be pressed before
+          (ii) or if this menu is in a menu bar and some other menu in a 
+          menu bar was just selected and has its popup menu visible. 
+               (If nothing was selected, menu should be pressed before
                it will be selected)
       */
       JMenu menu = (JMenu) menuItem;
+      JMenuBar mb = (JMenuBar) menu.getParent();
       if (! menu.isTopLevelMenu()
-          || (menu.isTopLevelMenu()
-          && (((JMenuBar) menu.getParent()).isSelected() && ! menu.isArmed())))
+          || (mb.isSelected() && (((JMenu)(mb.getComponent             
+                                           (mb.getSelectionModel().
+                                            getSelectedIndex()))).
+                                  isPopupMenuVisible()) && ! menu.isArmed()))
         {
 	  // set new selection and forward this event to MenuSelectionManager
 	  MenuSelectionManager manager = MenuSelectionManager.defaultManager();




More information about the kaffe mailing list