OSDN Git Service

2006-08-14 Mark Wielaard <mark@klomp.org>
[pf3gnuchains/gcc-fork.git] / libjava / classpath / javax / swing / SwingUtilities.java
index 5d02d9b..ccd37d0 100644 (file)
@@ -1045,8 +1045,7 @@ public class SwingUtilities
    */
   public static boolean isLeftMouseButton(MouseEvent event)
   {
-    return ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK)
-            == InputEvent.BUTTON1_DOWN_MASK);
+    return ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0);
   }
 
   /**
@@ -1599,4 +1598,27 @@ public class SwingUtilities
         throw new IllegalArgumentException("Unrecognised code: " + code);
     }
   }
+
+  /**
+   * Converts a rectangle in the coordinate system of a child component into
+   * a rectangle of one of it's Ancestors. The result is stored in the input
+   * rectangle.
+   *
+   * @param comp the child component
+   * @param r the rectangle to convert
+   * @param ancestor the ancestor component
+   */
+  static void convertRectangleToAncestor(Component comp, Rectangle r,
+                                         Component ancestor)
+  {
+    if (comp == ancestor)
+      return;
+
+    r.x += comp.getX();
+    r.y += comp.getY();
+
+    Component parent = comp.getParent();
+    if (parent != null && parent != ancestor)
+      convertRectangleToAncestor(parent, r, ancestor);
+  }
 }