freebsd-ports/devel/charva/files/patch-java_src_charva_awt_Container.java
Alex Dupre bc0fd99eb9 - Add CardLayout and VerticalFlowLayout classes
- A lot of bug fixes

Submitted by:	Lapo Luchini <lapo@lapo.it>
2007-01-29 08:53:12 +00:00

100 lines
3.7 KiB
Java

--- java/src/charva/awt/Container.java.orig Mon Aug 7 12:07:52 2006
+++ java/src/charva/awt/Container.java Mon Jan 29 09:39:30 2007
@@ -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));
}
/**