[kaffe] CVS kaffe (riccardo): implemented a stuff with a classpath merge

Kaffe CVS cvs-commits at kaffe.org
Sun Feb 12 15:25:23 PST 2006


PatchSet 7131 
Date: 2006/02/12 22:58:02
Author: riccardo
Branch: HEAD
Tag: (none) 
Log:
implemented a stuff with a classpath merge

Members: 
	ChangeLog:1.4649->1.4650 
	libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.4->1.5 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4649 kaffe/ChangeLog:1.4650
--- kaffe/ChangeLog:1.4649	Sun Feb 12 21:34:21 2006
+++ kaffe/ChangeLog	Sun Feb 12 22:58:02 2006
@@ -1,3 +1,7 @@
+2006-02-12  Riccardo Mottola <riccardo at kaffe.org>
+	* libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:
+	implemented a stub with a Classpath merge
+	
 2006-02-12  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/vmspecific/gnu/classpath/VMSystemProperties.java:
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.4 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.5
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.4	Sun Jan 29 14:33:49 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java	Sun Feb 12 22:58:10 2006
@@ -1,3 +1,19 @@
+/**
+ * Window -
+ *
+ * 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 java.awt.event.FocusEvent;
@@ -7,17 +23,7 @@
 
 import gnu.classpath.Pointer;
 
-/**
- * Window -
- *
- * 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
- */
+
 public class Window
   extends Container
 {
@@ -398,6 +404,79 @@
 
 // TODO this is only a stub
 public void setLocationRelativeTo(Component c) {
+    int x = 0;
+    int y = 0;
+    
+    if (c == null || !c.isShowing())
+      {
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        Point center = ge.getCenterPoint();
+        x = center.x - (width / 2);
+        y = center.y - (height / 2);
+      }
+    else
+      {
+        int cWidth = c.getWidth();
+        int cHeight = c.getHeight();
+        Dimension screenSize = getToolkit().getScreenSize();
+
+        x = c.getLocationOnScreen().x;
+        y = c.getLocationOnScreen().y;
+        
+        // If bottom of component is cut off, window placed
+        // on the left or the right side of component
+        if ((y + cHeight) > screenSize.height)
+          {
+            // If the right side of the component is closer to the center
+            if ((screenSize.width / 2 - x) <= 0)
+              {
+                if ((x - width) >= 0)
+                  x -= width;
+                else
+                  x = 0;
+              }
+            else
+              {
+                if ((x + cWidth + width) <= screenSize.width)
+                  x += cWidth;
+                else
+                  x = screenSize.width - width;
+              }
+
+            y = screenSize.height - height;
+          }
+        else if (cWidth > width || cHeight > height)
+          {
+            // If right side of component is cut off
+            if ((x + width) > screenSize.width)
+              x = screenSize.width - width;
+            // If left side of component is cut off
+            else if (x < 0)
+              x = 0;
+            else
+              x += (cWidth - width) / 2;
+            
+            y += (cHeight - height) / 2;
+          }
+        else
+          {
+            // If right side of component is cut off
+            if ((x + width) > screenSize.width)
+              x = screenSize.width - width;
+            // If left side of component is cut off
+            else if (x < 0 || (x - (width - cWidth) / 2) < 0)
+              x = 0;
+            else
+              x -= (width - cWidth) / 2;
+
+            if ((y - (height - cHeight) / 2) > 0)
+              y -= (height - cHeight) / 2;
+            else
+              y = 0;
+          }
+      }
+
+    setLocation(x, y);
 }
 
 }




More information about the kaffe mailing list