/[classpath]/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3.2.7 by gnu_andrew, Sat Sep 10 15:31:52 2005 UTC revision 1.3.2.8 by gnu_andrew, Wed Nov 2 00:43:59 2005 UTC
# Line 58  import java.beans.PropertyChangeListener Line 58  import java.beans.PropertyChangeListener
58  import javax.swing.JComponent;  import javax.swing.JComponent;
59  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
60  import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
61  import javax.swing.UIDefaults;  import javax.swing.LookAndFeel;
62  import javax.swing.UIManager;  import javax.swing.UIManager;
63  import javax.swing.plaf.ComponentUI;  import javax.swing.plaf.ComponentUI;
64  import javax.swing.plaf.SplitPaneUI;  import javax.swing.plaf.SplitPaneUI;
# Line 404  public class BasicSplitPaneUI extends Sp Line 404  public class BasicSplitPaneUI extends Sp
404       */       */
405      protected void setComponentToSize(Component c, int size, int location,      protected void setComponentToSize(Component c, int size, int location,
406                                        Insets insets, Dimension containerSize)                                        Insets insets, Dimension containerSize)
407      {      {
408        int w = size;        int w = size;
409        int h = containerSize.height - insets.top - insets.bottom;        int h = containerSize.height - insets.top - insets.bottom;
410        int x = location;        int x = location;
# Line 637  public class BasicSplitPaneUI extends Sp Line 637  public class BasicSplitPaneUI extends Sp
637        int x = insets.left;        int x = insets.left;
638        int h = size;        int h = size;
639        int w = containerSize.width - insets.left - insets.right;        int w = containerSize.width - insets.left - insets.right;
   
640        c.setBounds(x, y, w, h);        c.setBounds(x, y, w, h);
641      }      }
642    
# Line 817  public class BasicSplitPaneUI extends Sp Line 816  public class BasicSplitPaneUI extends Sp
816            int newSize = splitPane.getDividerSize();            int newSize = splitPane.getDividerSize();
817            int[] tmpSizes = layoutManager.getSizes();            int[] tmpSizes = layoutManager.getSizes();
818            dividerSize = tmpSizes[2];            dividerSize = tmpSizes[2];
819            Component left = splitPane.getLeftComponent();        int newSpace = newSize - tmpSizes[2];
           Component right = splitPane.getRightComponent();  
           int newSpace = newSize - tmpSizes[2];  
   
820            tmpSizes[2] = newSize;            tmpSizes[2] = newSize;
821    
822            tmpSizes[0] += newSpace / 2;            tmpSizes[0] += newSpace / 2;
823            tmpSizes[1] += newSpace / 2;            tmpSizes[1] += newSpace / 2;
824          
825            layoutManager.setSizes(tmpSizes);            layoutManager.setSizes(tmpSizes);
826          }          }
827        else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))        else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))
# Line 942  public class BasicSplitPaneUI extends Sp Line 938  public class BasicSplitPaneUI extends Sp
938     */     */
939    public BasicSplitPaneUI()    public BasicSplitPaneUI()
940    {    {
941        // Nothing to do here.
942    }    }
943    
944    /**    /**
# Line 991  public class BasicSplitPaneUI extends Sp Line 988  public class BasicSplitPaneUI extends Sp
988     */     */
989    protected void installDefaults()    protected void installDefaults()
990    {    {
991        LookAndFeel.installColors(splitPane, "SplitPane.background",
992                                  "SplitPane.foreground");
993        LookAndFeel.installBorder(splitPane, "SplitPane.border");
994      divider = createDefaultDivider();      divider = createDefaultDivider();
995      resetLayoutManager();      resetLayoutManager();
996      nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider();      nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider();
997      splitPane.add(divider, JSplitPane.DIVIDER);      splitPane.add(divider, JSplitPane.DIVIDER);
998    
999      // There is no need to add the nonContinuousLayoutDivider      // There is no need to add the nonContinuousLayoutDivider
1000      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      splitPane.setDividerSize(UIManager.getInt("SplitPane.dividerSize"));
     splitPane.setBackground(defaults.getColor("SplitPane.background"));  
     splitPane.setBorder(defaults.getBorder("SplitPane.border"));  
     splitPane.setDividerSize(defaults.getInt("SplitPane.dividerSize"));  
1001      splitPane.setOpaque(true);      splitPane.setOpaque(true);
1002    }    }
1003    
# Line 1301  public class BasicSplitPaneUI extends Sp Line 1298  public class BasicSplitPaneUI extends Sp
1298     */     */
1299    public void setDividerLocation(JSplitPane jc, int location)    public void setDividerLocation(JSplitPane jc, int location)
1300    {    {
1301        location = validLocation(location);
1302        Container p = jc.getParent();
1303        Dimension rightPrefSize = jc.getRightComponent().getPreferredSize();
1304        Dimension size = jc.getSize();
1305        // check if the size has been set for the splitpane
1306        if (size.width == 0 && size.height == 0)
1307          size = jc.getPreferredSize();
1308        
1309        if (getOrientation() == 0 && location > size.height)
1310          {
1311            location = size.height;
1312            while (p != null)
1313              {
1314                p.setSize(p.getWidth(), p.getHeight() + rightPrefSize.height);
1315                p = p.getParent();
1316              }
1317          }
1318        else if (location > size.width)
1319          {
1320            location = size.width;
1321            while (p != null)
1322              {
1323                p.setSize(p.getWidth() + rightPrefSize.width, p.getHeight());
1324                p = p.getParent();
1325              }
1326          }
1327        
1328      setLastDragLocation(getDividerLocation(splitPane));      setLastDragLocation(getDividerLocation(splitPane));
1329      splitPane.setLastDividerLocation(getDividerLocation(splitPane));      splitPane.setLastDividerLocation(getDividerLocation(splitPane));
1330      int[] tmpSizes = layoutManager.getSizes();      int[] tmpSizes = layoutManager.getSizes();
1331      tmpSizes[0] = location      tmpSizes[0] = location
1332                    - layoutManager.getInitialLocation(splitPane.getInsets());                    - layoutManager.getInitialLocation(splitPane.getInsets());
1333      tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),      tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),
1334                                                   splitPane.getInsets())                                                   splitPane.getInsets())
1335                    - tmpSizes[0] - tmpSizes[1];                    - tmpSizes[0];
   
1336      layoutManager.setSizes(tmpSizes);      layoutManager.setSizes(tmpSizes);
1337      splitPane.revalidate();      splitPane.revalidate();
1338      splitPane.repaint();      splitPane.repaint();
# Line 1388  public class BasicSplitPaneUI extends Sp Line 1411  public class BasicSplitPaneUI extends Sp
1411     */     */
1412    public void paint(Graphics g, JComponent jc)    public void paint(Graphics g, JComponent jc)
1413    {    {
1414        // TODO: What should be done here?
1415    }    }
1416    
1417    /**    /**
# Line 1550  public class BasicSplitPaneUI extends Sp Line 1574  public class BasicSplitPaneUI extends Sp
1574     */     */
1575    private int validLocation(int location)    private int validLocation(int location)
1576    {    {
1577      if (location < getMinimumDividerLocation(splitPane))      int min = getMinimumDividerLocation(splitPane);
1578        return getMinimumDividerLocation(splitPane);      int max = getMaximumDividerLocation(splitPane);
1579      if (location > getMaximumDividerLocation(splitPane))      if (min > 0 && location < min)
1580        return getMaximumDividerLocation(splitPane);        return min;
1581        if (max > 0 && location > max)
1582          return max;
1583      return location;      return location;
1584    }    }
1585  }  }

Legend:
Removed from v.1.3.2.7  
changed lines
  Added in v.1.3.2.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26