ScrollPane.java (setBlockIncrement): Throw error.
authorTom Tromey <tromey@redhat.com>
Wed, 3 Jan 2001 20:34:44 +0000 (20:34 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 3 Jan 2001 20:34:44 +0000 (20:34 +0000)
* 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
libjava/java/awt/ScrollPane.java
libjava/java/awt/peer/ScrollPanePeer.java

index e3247e38ed19b6bfa66bb704d0307b7ead44ebb9..10976fb28b82944570d837a90f6b6ed851ddf5bf 100644 (file)
@@ -1,3 +1,11 @@
+2001-01-03  Tom Tromey  <tromey@redhat.com>
+
+       * 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  <tromey@redhat.com>
 
        * java/awt/ScrollPane.java: Wrote.
index 69edf81101658eec064374b09c628df690731e6d..dd657ac19968ea1eb37cd17d0df158e497b5bf7e 100644 (file)
@@ -15,9 +15,6 @@ import java.awt.peer.ScrollPanePeer;
  * scrollbars as well as a single child which is scrolled by them.
  * @author Tom Tromey <tromey@redhat.com>
  * @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)
index 0fcf44da1654826af3227151c5131d5fd136e5fb..fe300e423c8b04b9949d4e08cd184a42113b99f2 100644 (file)
@@ -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);
 }