diff options
author | Roman Kennke <roman@kennke.org> | 2006-01-21 22:49:47 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-01-21 22:49:47 +0000 |
commit | 89d3400188d98621b3a4cfd27132ee94f0f304ff (patch) | |
tree | 94104b993fe4fdebdd71170cc434c4bffed64b15 | |
parent | 389128ad9e78d61b272a1c47d1fd48846aabe7ef (diff) | |
download | classpath-89d3400188d98621b3a4cfd27132ee94f0f304ff.tar.gz |
2006-01-21 Roman Kennke <kennke@aicas.com>
PR classpath/25843:
* javax/swing/plaf/basic/BasicBorders.java
(getSplitPaneDividerBorder): Use new border constructor
without arguments.
(SplitPaneDividerBorder.highlight): Removed unneeded field.
(SplitPaneDividerBorder.shadow): Removed unneeded field.
(SplitPaneDividerBorder()): Changed constructor to do nothing. The
colors are fetched dynamically in the paintBorder method.
(SplitPaneDividerBorder.paintBorder): Fetch colors dynamically from
the look and feel.
(SplitPaneDividerBorder.isBorderOpaque): Returns true
unconditionally.
* javax/swing/plaf/basic/BasicLookAndFeel.java
(initComponentDefaults): Added default for SplitPaneDivider.border.
* javax/swing/plaf/basic/BasicSplitPaneDivider.java
(tmpBorder): Removed unneeded inner class.
(BasicSplitPaneDivider): Removed setting of border.
(setSplitPaneUI): Don't add the mouse handler to the splitpane
itself.
* javax/swing/plaf/basic/BasicSplitPaneUI.java
(BasicHorizontalLayoutManager.layoutContainer): Mostly rewritten
to get behaviour right.
(BasicHorizontalLayoutManager.distributeExtraSpace): Removed
implementation. This must be rewritten since the layout now works
slightly different (basically, it shouldn't modify the sizes[]
here but instead the dividerLocation.
(dividerLocation): New field.
(installDefaults): Initialize border on divider.
(uninstallDefaults): Only remove background color and border from
splitPane if they are instances of UIDefaults (== not set by
application).
(setDividerLocation): Set the dividerLocation field instead of
doing stunt acts here.
(getDividerLocation): Return dividerLocation field.
(getMinimumDividerLocation): Fixed calculation of minimum location.
-rw-r--r-- | ChangeLog | 38 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicBorders.java | 36 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicLookAndFeel.java | 1 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicSplitPaneDivider.java | 30 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicSplitPaneUI.java | 97 |
5 files changed, 73 insertions, 129 deletions
@@ -1,3 +1,41 @@ +2006-01-21 Roman Kennke <kennke@aicas.com> + + PR classpath/25843: + * javax/swing/plaf/basic/BasicBorders.java + (getSplitPaneDividerBorder): Use new border constructor + without arguments. + (SplitPaneDividerBorder.highlight): Removed unneeded field. + (SplitPaneDividerBorder.shadow): Removed unneeded field. + (SplitPaneDividerBorder()): Changed constructor to do nothing. The + colors are fetched dynamically in the paintBorder method. + (SplitPaneDividerBorder.paintBorder): Fetch colors dynamically from + the look and feel. + (SplitPaneDividerBorder.isBorderOpaque): Returns true + unconditionally. + * javax/swing/plaf/basic/BasicLookAndFeel.java + (initComponentDefaults): Added default for SplitPaneDivider.border. + * javax/swing/plaf/basic/BasicSplitPaneDivider.java + (tmpBorder): Removed unneeded inner class. + (BasicSplitPaneDivider): Removed setting of border. + (setSplitPaneUI): Don't add the mouse handler to the splitpane + itself. + * javax/swing/plaf/basic/BasicSplitPaneUI.java + (BasicHorizontalLayoutManager.layoutContainer): Mostly rewritten + to get behaviour right. + (BasicHorizontalLayoutManager.distributeExtraSpace): Removed + implementation. This must be rewritten since the layout now works + slightly different (basically, it shouldn't modify the sizes[] + here but instead the dividerLocation. + (dividerLocation): New field. + (installDefaults): Initialize border on divider. + (uninstallDefaults): Only remove background color and border from + splitPane if they are instances of UIDefaults (== not set by + application). + (setDividerLocation): Set the dividerLocation field instead of + doing stunt acts here. + (getDividerLocation): Return dividerLocation field. + (getMinimumDividerLocation): Fixed calculation of minimum location. + 2006-01-21 Guilhem Lavaux <guilhem@kaffe.org> * m4/acinclude.m4 diff --git a/javax/swing/plaf/basic/BasicBorders.java b/javax/swing/plaf/basic/BasicBorders.java index 5d4ce1893..5e2cf2e48 100644 --- a/javax/swing/plaf/basic/BasicBorders.java +++ b/javax/swing/plaf/basic/BasicBorders.java @@ -299,9 +299,7 @@ public class BasicBorders public static Border getSplitPaneDividerBorder() { /* See comment in methods above for why this border is not shared. */ - return new SplitPaneDividerBorder( - UIManager.getColor("SplitPane.highlight"), - UIManager.getColor("SplitPane.darkShadow")); + return new SplitPaneDividerBorder(); } @@ -1518,34 +1516,15 @@ public class BasicBorders implements Border, UIResource, Serializable { /** - * The highlight color, which is drawn on the left or top edge - * depending on the orientation of the JSplitPanel. - */ - protected Color highlight; - - - /** - * The highlight color, which is drawn on the right or bottom edge - * depending on the orientation of the JSplitPanel. - */ - protected Color shadow; - - - /** * Constructs a new border for drawing the divider of a JSplitPane * in the Basic look and feel. The outer parts of the JSplitPane have * their own border class, <code>SplitPaneBorder</code>. - * - * @param shadow the shadow color. - * @param highlight the highlight color. */ - public SplitPaneDividerBorder(Color highlight, Color shadow) + public SplitPaneDividerBorder() { - this.highlight = (highlight != null) ? highlight : Color.white; - this.shadow = (shadow != null) ? shadow : Color.black; + // Nothing to do here. } - /** * Paints the border around the divider of a <code>JSplitPane</code>. * @@ -1564,6 +1543,8 @@ public class BasicBorders public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Color highlight = UIManager.getColor("SplitPane.highlight"); + Color shadow = UIManager.getColor("SplitPane.shadow"); Color oldColor, dcol; int x2, y2; JSplitPane sp; @@ -1624,17 +1605,15 @@ public class BasicBorders return new Insets(1, 1, 1, 1); } - /** * Determines whether this border fills every pixel in its area * when painting. * - * @return <code>true</code> if both highlight and shadow - * color are fully opaque. + * @return <code>true</code> */ public boolean isBorderOpaque() { - return (highlight.getAlpha() == 255) && (shadow.getAlpha() == 255); + return true; } @@ -1785,4 +1764,5 @@ public class BasicBorders return insets; } } + } diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java index f5217be1f..0e41ed0ca 100644 --- a/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -1023,6 +1023,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "SplitPane.dividerSize", new Integer(7), "SplitPane.highlight", new ColorUIResource(highLight), "SplitPane.shadow", new ColorUIResource(shadow), + "SplitPaneDivider.border", BasicBorders.getSplitPaneDividerBorder(), "TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "ctrl PAGE_DOWN","navigatePageDown", "ctrl PAGE_UP", "navigatePageUp", diff --git a/javax/swing/plaf/basic/BasicSplitPaneDivider.java b/javax/swing/plaf/basic/BasicSplitPaneDivider.java index ff17ff084..c4db75540 100644 --- a/javax/swing/plaf/basic/BasicSplitPaneDivider.java +++ b/javax/swing/plaf/basic/BasicSplitPaneDivider.java @@ -161,31 +161,6 @@ public class BasicSplitPaneDivider extends Container */ transient int currentDividerLocation = 1; - /** DOCUMENT ME! */ - private transient Border tmpBorder = new Border() - { - public Insets getBorderInsets(Component c) - { - return new Insets(2, 2, 2, 2); - } - - public boolean isBorderOpaque() - { - return false; - } - - public void paintBorder(Component c, Graphics g, int x, int y, - int width, int height) - { - Color saved = g.getColor(); - g.setColor(Color.BLACK); - - g.drawRect(x + 2, y + 2, width - 4, height - 4); - - g.setColor(saved); - } - }; - /** * Constructs a new divider. * @@ -196,7 +171,6 @@ public class BasicSplitPaneDivider extends Container setLayout(new DividerLayout()); setBasicSplitPaneUI(ui); setDividerSize(splitPane.getDividerSize()); - setBorder(tmpBorder); } /** @@ -212,8 +186,6 @@ public class BasicSplitPaneDivider extends Container if (splitPane != null) { splitPane.removePropertyChangeListener(this); - splitPane.removeMouseListener(mouseHandler); - splitPane.removeMouseMotionListener(mouseHandler); removeMouseListener(mouseHandler); removeMouseMotionListener(mouseHandler); splitPane = null; @@ -227,8 +199,6 @@ public class BasicSplitPaneDivider extends Container if (splitPane != null) { splitPane.addPropertyChangeListener(this); - splitPane.addMouseListener(mouseHandler); - splitPane.addMouseMotionListener(mouseHandler); addMouseListener(mouseHandler); addMouseMotionListener(mouseHandler); hiddenDivider = splitPaneUI.getNonContinuousLayoutDivider(); diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java index cf31e8b5d..bd0993818 100644 --- a/javax/swing/plaf/basic/BasicSplitPaneUI.java +++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java @@ -62,6 +62,7 @@ import javax.swing.LookAndFeel; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.SplitPaneUI; +import javax.swing.plaf.UIResource; /** * This is the Basic Look and Feel implementation of the SplitPaneUI class. @@ -253,20 +254,21 @@ public class BasicSplitPaneUI extends SplitPaneUI JSplitPane split = (JSplitPane) container; distributeExtraSpace(); Insets insets = split.getInsets(); - int width = getInitialLocation(insets); Dimension dims = split.getSize(); - for (int i = 0; i < components.length; i += 2) - { - if (components[i] == null) - continue; - setComponentToSize(components[i], sizes[i], width, insets, dims); - width += sizes[i]; - } - if (components[1] != null) - { - setComponentToSize(components[1], sizes[1], width, insets, dims); - width += sizes[1]; - } + int loc = getInitialLocation(insets); + int available = getAvailableSize(dims, insets); + sizes[0] = getDividerLocation(split) - loc; + sizes[1] = available - sizes[0] - sizes[1]; + // The size of the divider won't change. + + // Layout component#1. + setComponentToSize(components[0], sizes[0], loc, insets, dims); + // Layout divider. + loc += sizes[0]; + setComponentToSize(components[2], sizes[2], loc, insets, dims); + // Layout component#2. + loc += sizes[2]; + setComponentToSize(components[1], sizes[1], loc, insets, dims); } } @@ -451,21 +453,7 @@ public class BasicSplitPaneUI extends SplitPaneUI */ void distributeExtraSpace() { - int availSize = getAvailableSize(splitPane.getSize(), - splitPane.getInsets()); - int[] newSizes = new int[3]; - double weight = splitPane.getResizeWeight(); - - int oldLen = sizes[0] + sizes[1]; - - // dividers don't change size. - availSize -= sizes[2] + oldLen; - - int rightAlloc = (int) (availSize * (1 - weight)); - int leftAlloc = availSize - rightAlloc; - - sizes[0] += leftAlloc; - sizes[1] += rightAlloc; + // FIXME: This needs to be reimplemented correctly. } /** @@ -933,6 +921,8 @@ public class BasicSplitPaneUI extends SplitPaneUI /** The JSplitPane that this UI draws. */ protected JSplitPane splitPane; + private int dividerLocation; + /** * Creates a new BasicSplitPaneUI object. */ @@ -992,6 +982,7 @@ public class BasicSplitPaneUI extends SplitPaneUI "SplitPane.foreground"); LookAndFeel.installBorder(splitPane, "SplitPane.border"); divider = createDefaultDivider(); + divider.setBorder(UIManager.getBorder("SplitPaneDivider.border")); resetLayoutManager(); nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider(); splitPane.add(divider, JSplitPane.DIVIDER); @@ -1012,8 +1003,10 @@ public class BasicSplitPaneUI extends SplitPaneUI divider = null; nonContinuousLayoutDivider = null; - splitPane.setBackground(null); - splitPane.setBorder(null); + if (splitPane.getBackground() instanceof UIResource) + splitPane.setBackground(null); + if (splitPane.getBorder() instanceof UIResource) + splitPane.setBorder(null); } /** @@ -1298,44 +1291,7 @@ public class BasicSplitPaneUI extends SplitPaneUI */ public void setDividerLocation(JSplitPane jc, int location) { - location = validLocation(location); - Container p = jc.getParent(); - Component right = jc.getRightComponent(); - Dimension rightPrefSize = right == null ? new Dimension(0, 0) - : right.getPreferredSize(); - Dimension size = jc.getSize(); - // check if the size has been set for the splitpane - if (size.width == 0 && size.height == 0) - size = jc.getPreferredSize(); - - if (getOrientation() == 0 && location > size.height) - { - location = size.height; - while (p != null) - { - p.setSize(p.getWidth(), p.getHeight() + rightPrefSize.height); - p = p.getParent(); - } - } - else if (location > size.width) - { - location = size.width; - while (p != null) - { - p.setSize(p.getWidth() + rightPrefSize.width, p.getHeight()); - p = p.getParent(); - } - } - - setLastDragLocation(getDividerLocation(splitPane)); - splitPane.setLastDividerLocation(getDividerLocation(splitPane)); - int[] tmpSizes = layoutManager.getSizes(); - tmpSizes[0] = location - - layoutManager.getInitialLocation(splitPane.getInsets()); - tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(), - splitPane.getInsets()) - - tmpSizes[0]; - layoutManager.setSizes(tmpSizes); + dividerLocation = validLocation(location); splitPane.revalidate(); splitPane.repaint(); } @@ -1349,8 +1305,7 @@ public class BasicSplitPaneUI extends SplitPaneUI */ public int getDividerLocation(JSplitPane jc) { - return layoutManager.sizes[0] - + layoutManager.getInitialLocation(splitPane.getInsets()); + return dividerLocation; } /** @@ -1365,7 +1320,7 @@ public class BasicSplitPaneUI extends SplitPaneUI { int value = layoutManager.getInitialLocation(jc.getInsets()); if (layoutManager.components[0] != null) - value -= layoutManager.minimumSizeOfComponent(0); + value += layoutManager.minimumSizeOfComponent(0); return value; } |