commit-classpath
[Top][All Lists]
Advanced

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

[commit-cp] classpath ChangeLog javax/swing/plaf/basic/Basi...


From: Robert Schuster
Subject: [commit-cp] classpath ChangeLog javax/swing/plaf/basic/Basi...
Date: Fri, 16 Jun 2006 12:36:22 +0000

CVSROOT:        /cvsroot/classpath
Module name:    classpath
Changes by:     Robert Schuster <rschuster>     06/06/16 12:36:22

Modified files:
        .              : ChangeLog 
        javax/swing/plaf/basic: BasicRadioButtonUI.java 

Log message:
        2006-06-16  Robert Schuster  <address@hidden>
        
                * javax/swing/plaf/basic/BasicRadioButtonUI.java:
                (installDefaults): Removed unneccessary code.
                (paint): Removed complex if-cascade, revert to default icon if
                icon property is not set.
                (getPreferredSize): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7838&r2=1.7839
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java?cvsroot=classpath&r1=1.18&r2=1.19

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7838
retrieving revision 1.7839
diff -u -b -r1.7838 -r1.7839
--- ChangeLog   16 Jun 2006 10:27:30 -0000      1.7838
+++ ChangeLog   16 Jun 2006 12:36:19 -0000      1.7839
@@ -1,3 +1,11 @@
+2006-06-16  Robert Schuster  <address@hidden>
+
+       * javax/swing/plaf/basic/BasicRadioButtonUI.java:
+       (installDefaults): Removed unneccessary code.
+       (paint): Removed complex if-cascade, revert to default icon if
+       icon property is not set.
+       (getPreferredSize): New method.
+
 2006-06-16  Roman Kennke  <address@hidden>
 
        PR 28027
@@ -333,6 +341,7 @@
        compatibility with filters.
        (getParameter): Modified to allow access to above. 
 
+>>>>>>> 1.7824
 2006-06-13  Sven de Marothy  <address@hidden>
 
        * gnu/java/awt/peer/gtk/CairoSurface.java
@@ -354,6 +363,7 @@
        or not the labels are visible,
        (paintTrack): Shift track down one pixel.
 
+>>>>>>> 1.7799
 2006-06-13  Lillian Angel  <address@hidden>
 
        * java/awt/image/PixelGrabber.java
@@ -1124,6 +1134,7 @@
        (TreeIncrementAction.actionPerformed): Use action name as command.
        (TreeIncrementAction.isEnabled): Implemented.
 
+>>>>>>> 1.7796
 2006-06-08  Mark Wielaard  <address@hidden>
 
        PR 27917

Index: javax/swing/plaf/basic/BasicRadioButtonUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- javax/swing/plaf/basic/BasicRadioButtonUI.java      13 Jun 2006 09:28:57 
-0000      1.18
+++ javax/swing/plaf/basic/BasicRadioButtonUI.java      16 Jun 2006 12:36:21 
-0000      1.19
@@ -42,6 +42,7 @@
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics;
+import java.awt.Insets;
 import java.awt.Rectangle;
 
 import javax.swing.AbstractButton;
@@ -92,14 +93,6 @@
   protected void installDefaults(AbstractButton b)
   {
     super.installDefaults(b);
-    if (b.getIcon() == null)
-      b.setIcon(icon);
-    if (b.getSelectedIcon() == null)
-      b.setSelectedIcon(icon);
-    if (b.getDisabledIcon() == null)
-      b.setDisabledIcon(icon);
-    if (b.getDisabledSelectedIcon() == null)
-      b.setDisabledSelectedIcon(icon);
   }
 
   /**
@@ -145,15 +138,16 @@
     g.setFont(f);
 
     ButtonModel m = b.getModel();
-    Icon currentIcon = null;
-    if (m.isSelected() && m.isEnabled())
-      currentIcon = b.getSelectedIcon();
-    else if (! m.isSelected() && m.isEnabled())
-      currentIcon = b.getIcon();
-    else if (m.isSelected() && ! m.isEnabled())
-      currentIcon = b.getDisabledSelectedIcon();
-    else // (!m.isSelected() && ! m.isEnabled())
-      currentIcon = b.getDisabledIcon();
+    // FIXME: Do a filtering on any customized icon if the following property
+    // is set.
+    boolean enabled = b.isEnabled();
+    
+    Icon currentIcon = b.getIcon();
+
+    if (currentIcon == null)
+      {
+        currentIcon = getDefaultIcon();
+      }
 
     SwingUtilities.calculateInnerArea(b, vr);
     String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), 
@@ -162,16 +156,58 @@
        b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
        vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
     
-    if (currentIcon != null)
-      {
         currentIcon.paintIcon(c, g, ir.x, ir.y);
-      }
+    
     if (text != null)
       paintText(g, b, tr, text);
     if (b.hasFocus() && b.isFocusPainted() && m.isEnabled())
       paintFocus(g, tr, c.getSize());
   }
 
+  public Dimension getPreferredSize(JComponent c)
+  {
+    // This is basically the same code as in
+    // BasicGraphicsUtils.getPreferredButtonSize() but takes the default icon
+    // property into account. JRadioButton and subclasses always have an icon:
+    // the check box. If the user explicitly changes it with setIcon() that
+    // one will be used for layout calculations and painting instead.
+    // The other icon properties are ignored.
+    AbstractButton b = (AbstractButton) c;
+    
+    Rectangle contentRect;
+    Rectangle viewRect;
+    Rectangle iconRect = new Rectangle();
+    Rectangle textRect = new Rectangle();
+    Insets insets = b.getInsets();
+    
+    Icon i = b.getIcon();
+    if (i == null)
+      i = getDefaultIcon(); 
+    
+    viewRect = new Rectangle();
+
+    SwingUtilities.layoutCompoundLabel(
+      b, // for the component orientation
+      b.getFontMetrics(b.getFont()),
+      b.getText(),
+      i,
+      b.getVerticalAlignment(), 
+      b.getHorizontalAlignment(),
+      b.getVerticalTextPosition(),
+      b.getHorizontalTextPosition(),
+      viewRect, iconRect, textRect,
+      defaultTextIconGap + defaultTextShiftOffset);
+
+    contentRect = textRect.union(iconRect);
+    
+    return new Dimension(insets.left
+                         + contentRect.width 
+                         + insets.right + b.getHorizontalAlignment(),
+                         insets.top
+                         + contentRect.height 
+                         + insets.bottom);
+  }
+
   /**
    * Paints the focus indicator for JRadioButtons.
    *




reply via email to

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