Commit 48918616 by Roman Kennke Committed by Michael Koch

2005-04-19 Roman Kennke <roman@ontographics.com>

	* javax/swing/JList.java
	(getPreferredScrollableViewportSize):
	The previous implementation was merely guessing the size,
	now it respects layoutOrientation, visibleRowCount
	and preferredSize.
	(getScrollableTracksViewportHeight):
	Reimplemented so that layoutOrientation, visibleRowCount
	and preferred size are respected.
	(getScrollableTracksViewportWidth):
	Reimplemented so that layoutOrientation, visibleRowCount
	and preferred size are respected.
	* javax/swing/plaf/basic/BasicListUI.java
	(getPreferredSize):
	Improved calculation of preferredSize when JList is
	set to HORIZONTAL_WRAP or VERTICAL_WRAP.
	(getCellBounds):
	The previous implementation assumed a layoutOrientation of
	JList.VERTICAL, now also ok with JList.HORIZONTAL_WRAP and
	JList.VERTICAL_WRAP.

2005-04-19  Roman Kennke  <roman@ontographics.com>

	* javax/swing/plaf/basic/BasicListUI.java
	(paintCell): use CellRendererPane for painting the cells.

2005-04-19  Roman Kennke  <roman@ontographics.com>

	* javax/swing/plaf/basic/BasicListUI:
	fixed modifiers of several fields, methods and inner
	classes to match the 'spec'.
	(getMaximumSize): removed. It's not in the spec and the
	implementations was superfluous.

2005-04-19  Roman Kennke  <roman@ontographics.com>

	* javax/swing/plaf/basic/BasicListUI:
	make BasicListUI capable of wrapping lists
	(layoutOrientation property of javax.swing.JList)

2005-04-19  Roman Kennke  <roman@ontographics.com>

	* javax/swing/plaf/basic/BasicListUI
	(updateLayoutState,paint): make BasicListUI aware of the
	width of the rendered JList.

From-SVN: r98385
parent b9d896d6
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/JList.java
(getPreferredScrollableViewportSize):
The previous implementation was merely guessing the size,
now it respects layoutOrientation, visibleRowCount
and preferredSize.
(getScrollableTracksViewportHeight):
Reimplemented so that layoutOrientation, visibleRowCount
and preferred size are respected.
(getScrollableTracksViewportWidth):
Reimplemented so that layoutOrientation, visibleRowCount
and preferred size are respected.
* javax/swing/plaf/basic/BasicListUI.java
(getPreferredSize):
Improved calculation of preferredSize when JList is
set to HORIZONTAL_WRAP or VERTICAL_WRAP.
(getCellBounds):
The previous implementation assumed a layoutOrientation of
JList.VERTICAL, now also ok with JList.HORIZONTAL_WRAP and
JList.VERTICAL_WRAP.
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI.java
(paintCell): use CellRendererPane for painting the cells.
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI:
fixed modifiers of several fields, methods and inner
classes to match the 'spec'.
(getMaximumSize): removed. It's not in the spec and the
implementations was superfluous.
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI:
make BasicListUI capable of wrapping lists
(layoutOrientation property of javax.swing.JList)
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI
(updateLayoutState,paint): make BasicListUI aware of the
width of the rendered JList.
2005-04-19 Roman Kennke <roman@kennke.org> 2005-04-19 Roman Kennke <roman@kennke.org>
* javax/swing/ImageIcon.java * javax/swing/ImageIcon.java
......
...@@ -1029,32 +1029,20 @@ public class JList extends JComponent implements Accessible, Scrollable ...@@ -1029,32 +1029,20 @@ public class JList extends JComponent implements Accessible, Scrollable
*/ */
public Dimension getPreferredScrollableViewportSize() public Dimension getPreferredScrollableViewportSize()
{ {
int vis = getVisibleRowCount();
int nrows = getModel() == null ? 0 : getModel().getSize();
// FIXME: this is a somewhat arbitrary default, but.. ?
Dimension single = new Dimension(10, 10);;
Rectangle bounds = null;
if (vis > nrows) Dimension retVal = getPreferredSize();
if (getLayoutOrientation() == VERTICAL)
{ {
if (fixedCellWidth != -1 && if (fixedCellHeight != -1)
fixedCellHeight != -1)
{ {
single = new Dimension(fixedCellWidth, fixedCellHeight); if (fixedCellWidth != -1)
} {
else if (nrows != 0 && getUI() != null) int size = getModel().getSize();
{ retVal = new Dimension(fixedCellWidth, size * fixedCellHeight);
Rectangle tmp = getUI().getCellBounds(this, 0, 0); } // TODO: add else clause (preferredSize is ok for now)
if (tmp != null) } // TODO: add else clause (preferredSize is ok for now)
single = tmp.getSize();
}
}
else if (getUI() != null)
{
return getUI().getCellBounds(this, 0, vis - 1).getSize();
} }
return retVal;
return new Dimension(single.width, single.height * vis);
} }
/** /**
...@@ -1193,7 +1181,19 @@ public class JList extends JComponent implements Accessible, Scrollable ...@@ -1193,7 +1181,19 @@ public class JList extends JComponent implements Accessible, Scrollable
*/ */
public boolean getScrollableTracksViewportWidth() public boolean getScrollableTracksViewportWidth()
{ {
return false; Component parent = getParent();
boolean retVal = false;
if (parent instanceof JViewport)
{
JViewport viewport = (JViewport) parent;
Dimension pref = getPreferredSize();
if (viewport.getSize().width > pref.width)
retVal = true;
if ((getLayoutOrientation() == HORIZONTAL_WRAP)
&& (getVisibleRowCount() <= 0))
retVal = true;
}
return retVal;
} }
/** /**
...@@ -1206,7 +1206,19 @@ public class JList extends JComponent implements Accessible, Scrollable ...@@ -1206,7 +1206,19 @@ public class JList extends JComponent implements Accessible, Scrollable
*/ */
public boolean getScrollableTracksViewportHeight() public boolean getScrollableTracksViewportHeight()
{ {
return false; Component parent = getParent();
boolean retVal = false;
if (parent instanceof JViewport)
{
JViewport viewport = (JViewport) parent;
Dimension pref = getPreferredSize();
if (viewport.getSize().height > pref.height)
retVal = true;
if ((getLayoutOrientation() == VERTICAL_WRAP)
&& (getVisibleRowCount() <= 0))
retVal = true;
}
return retVal;
} }
public int getAnchorSelectionIndex() public int getAnchorSelectionIndex()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment