summaryrefslogtreecommitdiff
path: root/devel/charva/files/patch-java_src_charva_awt_Container.java
blob: ebec529e5fe0b83e37a6f0a75d6c509d5287c3ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--- java/src/charva/awt/Container.java.orig	2016-06-20 12:40:44 UTC
+++ java/src/charva/awt/Container.java
@@ -89,6 +89,23 @@ public abstract class Container
         invalidate();
     }
 
+    public void setBounds(int top_, int left_, int bottom_, int right_) {
+	super.setBounds(top_, left_, bottom_, right_);
+	setSize(right_ - left_ + 1, bottom_ - top_ + 1);
+    }
+
+    public void setBounds(Point topleft_, Dimension size_) {
+	super.setBounds(topleft_, size_);
+	setSize(size_);
+    }
+
+    public void setBounds(Rectangle bounds) {
+	super.setBounds(bounds);
+	setSize(
+	    bounds.getRight() - bounds.getLeft() + 1,
+	    bounds.getBottom() - bounds.getTop() + 1);
+    }
+
     public Dimension minimumSize() {
         if (_layoutMgr == null)
             return _size;
@@ -105,13 +122,30 @@ public abstract class Container
         return (Component) _components.elementAt(n);
     }
 
+    protected Component getComponentAt(int x, int y, boolean checkVisibility) {
+        Enumeration e = _components.elements();
+        while (e.hasMoreElements()) {
+            Component c = (Component) e.nextElement();
+            if ((!checkVisibility || c.isVisible()) && c.contains(x, y)) {
+                if (c instanceof Container) {
+                    // Calculate the coordinates of the point relative
+                    // to the origin of the container
+                    Point origin = c.getLocation();
+                    return ((Container) c).getComponentAt(x - origin.x, y - origin.y, checkVisibility);
+                } else
+                    return c;
+            }
+        }
+        return null;
+    }
+
     /**
      * Returns the component that contains the specified point, or null
      * if no component contains the point. The x and y coordinates of
      * the point are relative to the origin of this container.
      */
     public Component getComponentAt(Point p) {
-        return getComponentAt(p.x, p.y);
+        return getComponentAt(p.x, p.y, false);
     }
 
     /**
@@ -120,20 +154,27 @@ public abstract class Container
      * the point are relative to the origin of this container.
      */
     public Component getComponentAt(int x, int y) {
-        Enumeration e = _components.elements();
-        while (e.hasMoreElements()) {
-            Component c = (Component) e.nextElement();
-            if (c.contains(x, y)) {
-                if (c instanceof Container) {
-                    // Calculate the coordinates of the point relative
-                    // to the origin of the container
-                    Point origin = c.getLocation();
-                    return ((Container) c).getComponentAt(x - origin.x, y - origin.y);
-                } else
-                    return c;
-            }
-        }
-        return null;
+        return getComponentAt(x, y, false);
+    }
+
+    /**
+     * Returns the visible component that contains the specified point,
+     * or null if no visible component contains the point. The x and y
+     * coordinates of the point are relative to the origin of this container.
+     */
+    public final Component findComponentAt(Point p) {
+        return findComponentAt(p.x, p.y);
+    }
+
+    /**
+     * Returns the visible component that contains the specified point,
+     * or null if no visible component contains the point. The x and y
+     * coordinates of the point are relative to the origin of this container.
+     */
+    public final Component findComponentAt(int x, int y) {
+	if (!isRecursivelyVisible())
+	    return null;
+	return(getComponentAt(x, y, true));
     }
 
     /**