From 234fb86caebe5e54a9bc0dc9d39ffe54d83892b0 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 3 Jan 2001 20:34:44 +0000 Subject: [PATCH] ScrollPane.java (setBlockIncrement): Throw error. * java/awt/ScrollPane.java (setBlockIncrement): Throw error. (getViewportSize): Insets include scrollbar size. (doLayout): Finished. (getScrollPosition): Wrote. * java/awt/peer/ScrollPanePeer.java (setBlockIncrement): Removed. From-SVN: r38670 --- libjava/ChangeLog | 8 ++++++ libjava/java/awt/ScrollPane.java | 33 +++++++++-------------- libjava/java/awt/peer/ScrollPanePeer.java | 1 - 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index e3247e38ed19..10976fb28b82 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2001-01-03 Tom Tromey + + * java/awt/ScrollPane.java (setBlockIncrement): Throw error. + (getViewportSize): Insets include scrollbar size. + (doLayout): Finished. + (getScrollPosition): Wrote. + * java/awt/peer/ScrollPanePeer.java (setBlockIncrement): Removed. + 2001-01-02 Tom Tromey * java/awt/ScrollPane.java: Wrote. diff --git a/libjava/java/awt/ScrollPane.java b/libjava/java/awt/ScrollPane.java index 69edf8110165..dd657ac19968 100644 --- a/libjava/java/awt/ScrollPane.java +++ b/libjava/java/awt/ScrollPane.java @@ -15,9 +15,6 @@ import java.awt.peer.ScrollPanePeer; * scrollbars as well as a single child which is scrolled by them. * @author Tom Tromey * @date December 31, 2000 - * Status: Unfinished. The Adjustables are probably wrong (there - * isn't a mechanism for scrollbar events to affect them), and also - * doLayout() is not finished. */ public class ScrollPane extends Container { @@ -90,7 +87,8 @@ public class ScrollPane extends Container Dimension c = component[0].getPreferredSize (); component[0].setSize (c.width, c.height); spp.childResized (c.width, c.height); - // FIXME + // Update the scrollbar position to the closest valid value. + setScrollPosition (hscroll.getValue (), vscroll.getValue ()); } /** Returns an Adjustable representing the horizontal scrollbar. @@ -121,8 +119,7 @@ public class ScrollPane extends Container /** Returns the viewport's scroll position. */ public Point getScrollPosition () { - // FIXME - return null; + return new Point (hscroll.getValue (), vscroll.getValue ()); } /** Returns an Adjustable representing the vertical scrollbar. @@ -138,6 +135,9 @@ public class ScrollPane extends Container /** Returns the size of the viewport. */ public Dimension getViewportSize () { + // Note: according to the online docs, the Insets are + // automatically updated by the peer to include the scrollbar + // sizes. Insets ins = getInsets (); int myw = width - ins.left - ins.right; int myh = height - ins.top - ins.bottom; @@ -148,14 +148,6 @@ public class ScrollPane extends Container else cs = new Dimension (myw, myh); - if (policy == SCROLLBARS_ALWAYS - || (policy == SCROLLBARS_AS_NEEDED && myw < cs.width)) - myw -= getVScrollbarWidth (); - - if (policy == SCROLLBARS_ALWAYS - || (policy == SCROLLBARS_AS_NEEDED && myh < cs.height)) - myh -= getHScrollbarHeight (); - // A little optimization -- reuse the Dimension. cs.setSize (myw, myh); return cs; @@ -228,6 +220,12 @@ public class ScrollPane extends Container setScrollPosition (p.x, p.y); } + // This implements the Adjustable for each scrollbar. The + // expectation is that the peer will look at these objects directly + // and modify the values in them when the user manipulates the + // scrollbars. This has to be done from CNI to bypass Java + // protection rules. The peer should also take care of calling the + // adjustment listeners. class ScrollPaneAdjustable implements Adjustable { AdjustmentListener listeners; @@ -295,12 +293,7 @@ public class ScrollPane extends Container public void setBlockIncrement (int b) { - block = b; - if (peer != null) - { - ScrollPanePeer spp = (ScrollPanePeer) peer; - spp.setBlockIncrement (this, b); - } + throw new AWTError ("can't use setBlockIncrement on this Adjustable"); } public void setMaximum (int max) diff --git a/libjava/java/awt/peer/ScrollPanePeer.java b/libjava/java/awt/peer/ScrollPanePeer.java index 0fcf44da1654..fe300e423c8b 100644 --- a/libjava/java/awt/peer/ScrollPanePeer.java +++ b/libjava/java/awt/peer/ScrollPanePeer.java @@ -17,6 +17,5 @@ public interface ScrollPanePeer extends ContainerPeer int getVScrollbarWidth(); void setScrollPosition(int x, int y); void setUnitIncrement(Adjustable adj, int increment); - void setBlockIncrement(Adjustable adj, int increment); void setValue(Adjustable adj, int value); } -- 2.43.5