classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: MetalBorders


From: David Gilbert
Subject: [cp-patches] FYI: MetalBorders
Date: Mon, 12 Sep 2005 14:34:59 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

I committed this patch to implement the getDesktopIconBorder() method and tweak the colors for the line highlights for the InternalFrameBorder:

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

        * javax/swing/plaf/metal/MetalBorders.java
        (desktopIconBorder): new private field,
        (DesktopIconBorder): new support class,
        (getDesktopIconBorder): implemented,
        (InternalFrameBorder.paintBorder): change color of line highlights if
        the internal frame is selected.

Regards,

Dave Gilbert
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.12
diff -u -r1.12 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java    10 Sep 2005 21:52:24 -0000      
1.12
+++ javax/swing/plaf/metal/MetalBorders.java    12 Sep 2005 13:28:18 -0000
@@ -69,6 +69,9 @@
   /** The shared instance for getButtonBorder(). */
   private static Border buttonBorder;
 
+  /** The shared instance for getDesktopIconBorder(). */
+  private static Border desktopIconBorder;
+
   /** The shared instance for getRolloverButtonBorder(). */
   private static Border toolbarButtonBorder;
 
@@ -191,6 +194,70 @@
   }
 
   /**
+   * A border used when painting address@hidden JInternalFrame} instances.
+   */
+  static class DesktopIconBorder extends AbstractBorder
+    implements UIResource
+  {
+    /**
+     * Creates a new border instance.
+     */
+    public DesktopIconBorder()
+    {
+    }
+    
+    /**
+     * Returns the border insets.
+     * 
+     * @param c  the component (ignored).
+     * 
+     * @return The border insets.
+     */
+    public Insets getBorderInsets(Component c)
+    {
+      return getBorderInsets(c, null);
+    }
+    
+    /**
+     * Returns the border insets.
+     * 
+     * @param c  the component (ignored).
+     * @return The border insets.
+     */
+    public Insets getBorderInsets(Component c, Insets newInsets)
+    {
+      if (newInsets == null)
+        newInsets = new Insets(3, 3, 2, 3);
+      else
+        {
+          newInsets.top = 3;
+          newInsets.left = 3;
+          newInsets.bottom = 2;
+          newInsets.right = 3;
+        }
+      return newInsets;  
+    }
+    
+    /**
+     * Paints the border for the specified component.
+     * 
+     * @param c  the component.
+     * @param g  the graphics device.
+     * @param x  the x-coordinate.
+     * @param y  the y-coordinate.
+     * @param w  the width.
+     * @param h  the height.
+     */
+    public void paintBorder(Component c, Graphics g, int x, int y, int w, 
+        int h)
+    {
+      g.setColor(MetalLookAndFeel.getControlDarkShadow());      
+      g.drawRect(x, y, w - 1, h - 1); 
+    }
+    
+  }
+
+  /**
    * A simple 3D border.
    */
   public static class Flush3DBorder extends AbstractBorder
@@ -468,7 +535,10 @@
       g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
       
       // draw the line highlights
-      g.setColor(MetalLookAndFeel.getControl());
+      if (f.isSelected())
+        g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+      else 
+        g.setColor(MetalLookAndFeel.getControlShadow());
       g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
       g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
       g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
@@ -866,6 +936,21 @@
             (outer, inner);
       }
     return buttonBorder;
+  }
+  
+  /**
+   * Returns a border instance that is used with a address@hidden 
JInternalFrame} when
+   * it is in the iconified state.
+   * 
+   * @return A border.
+   * 
+   * @since 1.3
+   */
+  public static Border getDesktopIconBorder()
+  {
+    if (desktopIconBorder == null)
+      desktopIconBorder = new DesktopIconBorder();
+    return desktopIconBorder;      
   }
 
   /**

reply via email to

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