[kaffe] CVS kaffe (riccardo): implemented dtubs by adapting classpath code

Kaffe CVS cvs-commits at kaffe.org
Wed Feb 8 04:09:27 PST 2006


PatchSet 7121 
Date: 2006/02/08 11:58:01
Author: riccardo
Branch: HEAD
Tag: (none) 
Log:
implemented dtubs by adapting classpath code

Members: 
	ChangeLog:1.4639->1.4640 
	libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.6->1.7 
	libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4639 kaffe/ChangeLog:1.4640
--- kaffe/ChangeLog:1.4639	Wed Feb  8 02:05:52 2006
+++ kaffe/ChangeLog	Wed Feb  8 11:58:01 2006
@@ -1,3 +1,8 @@
+2006-02-08  Riccardo Mottola <riccardo at kaffe.org>
+
+	libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:
+	Implemented stubs by adapting classpath methods.
+	
 2006-02-08  Dalibor Topic  <robilad at kaffe.org>
 
 	* THIRPARTY: Removed jzlib and jessie. No longer needed since 
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.6 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.7
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.6	Tue Feb  7 00:18:36 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java	Wed Feb  8 11:58:04 2006
@@ -1,3 +1,19 @@
+/**
+ * Component - abstract root of all widgets
+ *
+ * Copyright (c) 1998
+ *      Transvirtual Technologies, Inc.  All rights reserved.
+ * Copyright (c) 2006
+ *      Kaffe.org developers. See ChangeLog for details.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ *
+ * original code P.C.Mehlitz
+ * some code taken or adapted from Classpath
+ */
+ 
+ 
 package java.awt;
 
 import gnu.classpath.Pointer;
@@ -30,17 +46,9 @@
 
 import org.kaffe.awt.DoNothingPeer;
 
-/**
- * Component - abstract root of all widgets
- *
- * Copyright (c) 1998
- *    Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution 
- * of this file. 
- *
- * @author P.C.Mehlitz
- */
+
+ 
+ 
 abstract public class Component
   extends Object
   implements ImageObserver, MenuContainer, Serializable
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.2 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.3
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.2	Tue Feb  7 00:18:37 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java	Wed Feb  8 11:58:04 2006
@@ -1,22 +1,27 @@
-package java.awt;
-
-import java.awt.event.ContainerEvent;
-import java.awt.event.ContainerListener;
-import java.awt.event.PaintEvent;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
 /**
  * Container - abstract base for all Components capable of having children
  *
  * Copyright (c) 1998
  *      Transvirtual Technologies, Inc.  All rights reserved.
+ * Copyright (c) 2006
+ *      Kaffe.org developers. See ChangeLog for details.
  *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  *
- * @author P.C.Mehlitz
+ * original code P.C.Mehlitz
+ * some code taken or adapted from Classpath
  */
+
+package java.awt;
+
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.PaintEvent;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+
 abstract public class Container
   extends Component
 {
@@ -761,12 +766,92 @@
 		children[i].validate();
 }
 
-/* TODO this is only a stub */
-public final void setComponentZOrder(Component comp, int index) {
-}
 
-/* TODO this is only a stub */
-public final int getComponentZOrder(Component comp) {
-	return 0;
-}
+
+  /**
+   * Sets the Z ordering for the component <code>comp</code> to
+   * <code>index</code>. Components with lower Z order paint above components
+   * with higher Z order.
+   *
+   * @param comp the component for which to change the Z ordering
+   * @param index the index to set
+   *
+   * @throws NullPointerException if <code>comp == null</code>
+   * @throws IllegalArgumentException if comp is an ancestor of this container
+   * @throws IllegalArgumentException if <code>index</code> is not in
+   *         <code>[0, getComponentCount()]</code> for moving between
+   *         containers or <code>[0, getComponentCount() - 1]</code> for moving
+   *         inside this container
+   * @throws IllegalArgumentException if <code>comp == this</code>
+   * @throws IllegalArgumentException if <code>comp</code> is a
+   *         <code>Window</code>
+   *
+   * @see #getComponentZOrder(Component)
+   *
+   * @since 1.5
+   */
+  public final void setComponentZOrder(Component comp, int index)
+  {
+    if (comp == null)
+      throw new NullPointerException("comp must not be null");
+    if (comp instanceof Container && ((Container) comp).isAncestorOf(this))
+      throw new IllegalArgumentException("comp must not be an ancestor of "
+                                         + "this");
+    if (comp instanceof Window)
+      throw new IllegalArgumentException("comp must not be a Window");
+
+    if (comp == this)
+      throw new IllegalArgumentException("cannot add component to itself");
+
+    // FIXME: Implement reparenting.
+    if ( comp.getParent() != this)
+      throw new AssertionError("Reparenting is not implemented yet");
+    else
+      {
+        // Find current component index.
+        int currentIndex = getComponentZOrder(comp);
+        if (currentIndex < index)
+          {
+            System.arraycopy(children, currentIndex + 1, children,
+                             currentIndex, index - currentIndex);
+          }
+        else
+          {
+            System.arraycopy(children, index, children, index + 1,
+                             currentIndex - index);
+          }
+        children[index] = comp;
+      }
+  }
+
+  /**
+   * Returns the Z ordering index of <code>comp</code>. If <code>comp</code>
+   * is not a child component of this Container, this returns <code>-1</code>.
+   *
+   * @param comp the component for which to query the Z ordering
+   *
+   * @return the Z ordering index of <code>comp</code> or <code>-1</code> if
+   *         <code>comp</code> is not a child of this Container
+   *
+   * @see #setComponentZOrder(Component, int)
+   *
+   * @since 1.5
+   */
+  public final int getComponentZOrder(Component comp)
+  {
+    int index = -1;
+    if (children != null)
+      {
+        for (int i = 0; i < children.length; i++)
+          {
+            if (children[i] == comp)
+              {
+                index = i;
+                break;
+              }
+          }
+      }
+    return index;
+  }
+
 }




More information about the kaffe mailing list