fixed bug 555
[org.ibex.core.git] / src / org / ibex / core / Box.java
index 8cf6271..4116c30 100644 (file)
@@ -126,8 +126,8 @@ public final class Box extends JSScope implements Task {
     private int contentwidth = 0;      // == max(minwidth, textwidth, sum(child.contentwidth))
     private int contentheight = 0;
 
+    private Path path = null;
     /*
-    private VectorGraphics.VectorPath path = null;
     private Affine transform = null;
     private VectorGraphics.RasterPath rpath = null;
     private Affine rtransform = null;
@@ -143,8 +143,8 @@ public final class Box extends JSScope implements Task {
     public void perform() throws JSExn {
         if (texture == null) { Log.warn(Box.class, "perform() called with null texture"); return; }
         if (texture.isLoaded) {
-            setWidth(max(texture.width, maxwidth), maxwidth); 
-            setHeight(max(texture.height, maxheight), maxheight); 
+            setWidth(max(texture.width, minwidth), maxwidth); 
+            setHeight(max(texture.height, minheight), maxheight); 
             DIRTY; }
         else { JS res = texture.stream; texture = null; throw new JSExn("image not found: "+res.unclone()); }
     }
@@ -420,6 +420,8 @@ public final class Box extends JSScope implements Task {
             font.rasterizeGlyphs(text, buf, strokecolor, text_x, text_y, cx1, cy1, cx2, cy2);
         }
 
+        if (path != null) path.realize(Affine.translate(globalx, globaly)).stroke(buf, 1, strokecolor);
+
         for(Box b = getChild(0); b != null; b = b.nextSibling())
             b.render(globalx, globaly, cx1, cy1, cx2, cy2, buf, null);
     }
@@ -443,8 +445,8 @@ public final class Box extends JSScope implements Task {
                 case "distanceto":
                     Box b = (Box)a0;
                     JS ret = new JS();
-                    ret.put("x", N(b.localToGlobalX(0) - localToGlobalX(0)));
-                    ret.put("y", N(b.localToGlobalY(0) - localToGlobalY(0)));
+                    ret.put("x", N(localToGlobalX(0) - b.localToGlobalX(0)));
+                    ret.put("y", N(localToGlobalY(0) - b.localToGlobalY(0)));
                     return ret;
 
                 //#end
@@ -545,6 +547,7 @@ public final class Box extends JSScope implements Task {
         case "shrink":      CHECKSET_FLAG(HSHRINK | VSHRINK); RECONSTRAIN();
         case "hshrink":     CHECKSET_FLAG(HSHRINK); RECONSTRAIN();
         case "vshrink":     CHECKSET_FLAG(VSHRINK); RECONSTRAIN();
+        case "path":        path = Path.parse(toString(value)); DIRTY;
         case "width":       setWidth(toInt(value), toInt(value));
         case "height":      setHeight(toInt(value), toInt(value));
         case "maxwidth":    setWidth(minwidth, toInt(value));