classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: BasicIconFactory, BasicMenuItemUI


From: David Gilbert
Subject: [cp-patches] FYI: BasicIconFactory, BasicMenuItemUI
Date: Thu, 29 Sep 2005 10:03:42 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

I committed this patch to improve the appearance of the arrow icon in the menus:

2005-09-29  David Gilbert  <address@hidden>

        * javax/swing/plaf/basic/BasicIconFactory.java
        (getMenuArrowIcon): adjusted the size and painting of the returned
        icon,
        * javax/swing/plaf/basic/BasicMenuItemUI.java
        (paintMenuItem): adjusted arrow icon position.

I think the menu item layout may be relying on the white space in the old icon, so the new positioning may not be entirely correct yet, but (for me at least) the menus look better now. Maybe someone (Roman/Lillian?) who knows the menu UI code better than I do could check that...

Regards,

Dave
Index: javax/swing/plaf/basic/BasicIconFactory.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicIconFactory.java,v
retrieving revision 1.12
diff -u -r1.12 BasicIconFactory.java
--- javax/swing/plaf/basic/BasicIconFactory.java        26 Aug 2005 18:17:57 
-0000      1.12
+++ javax/swing/plaf/basic/BasicIconFactory.java        29 Sep 2005 08:35:48 
-0000
@@ -41,7 +41,6 @@
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics;
-import java.awt.Polygon;
 import java.io.Serializable;
 
 import javax.swing.Icon;
@@ -241,34 +240,33 @@
   {
     return new DummyIcon();
   }
+  
+  /**
+   * Returns a new instance of a 4 x 8 icon showing a small black triangle that
+   * points to the right.  This is displayed in menu items that have a 
+   * sub menu.
+   * 
+   * @return The icon.
+   */
   public static Icon getMenuArrowIcon()
   {
     return new Icon()
       {
        public int getIconHeight()
        {
-         return 12;
+         return 8;
        }
-
        public int getIconWidth()
        {
-         return 12;
+         return 4;
        }
-
        public void paintIcon(Component c, Graphics g, int x, int y)
        {
-         g.translate(x, y);
-
          Color saved = g.getColor();
-
          g.setColor(Color.BLACK);
-
-         g.fillPolygon(new Polygon(new int[] { 3, 9, 3 },
-                                  new int[] { 2, 6, 10 },
-                                  3));
-
+          for (int i = 0; i < 4; i++)
+            g.drawLine(x + i, y + i, x + i, y + 7 - i);
          g.setColor(saved);
-         g.translate(-x, -y);
        }
       };
   }
Index: javax/swing/plaf/basic/BasicMenuItemUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java,v
retrieving revision 1.25
diff -u -r1.25 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java 22 Sep 2005 19:06:14 -0000      
1.25
+++ javax/swing/plaf/basic/BasicMenuItemUI.java 29 Sep 2005 08:35:50 -0000
@@ -572,9 +572,8 @@
           {
             int width = arrowIcon.getIconWidth();
             int height = arrowIcon.getIconHeight();
-
-            arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,
-                                vr.y + 2);
+            int offset = (vr.height - height) / 2;
+            arrowIcon.paintIcon(m, g, vr.width - width, vr.y + offset);
           }
       }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]