2003/10/28 10:10:17
[org.ibex.core.git] / src / org / xwt / Box.java.pp
index 2df28b0..81439f7 100644 (file)
@@ -451,7 +451,7 @@ public final class Box extends JS.Scope {
 
         if (image != null)
             if ((flags & TILE_FLAG) != 0) renderTiledImage(globalx, globaly, clipx, clipy, clipw, cliph, buf);
-            else renderStretchedImage(globalx, globaly, clipx, clipy, clipw, cliph, buf);
+            else buf.drawPicture(image, globalx, globaly, clipx, clipy, clipx + clipw, clipy + cliph);
 
        if (text != null && !text.equals(""))
             renderText(globalx, globaly, clipx, clipy, clipw, cliph, buf);
@@ -480,12 +480,9 @@ public final class Box extends JS.Scope {
         }
     }
 
-    void renderStretchedImage(int globalx, int globaly, int clipx, int clipy, int clipw, int cliph, PixelBuffer buf) {
-        // FIXME: wrong
-        buf.drawPicture(image, clipx, clipy, clipx + clipw, clipy + cliph, 0, 0, image.getWidth(), image.getHeight());
-    }
-
     void renderTiledImage(int globalx, int globaly, int x, int y, int w, int h, PixelBuffer buf) {
+        /*
+          FIXME
         int iw = image.getWidth();
         int ih = image.getHeight();
         for(int i=(x - x)/iw; i <= (x + w - x)/iw; i++) {
@@ -505,6 +502,7 @@ public final class Box extends JS.Scope {
                     buf.drawPicture(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);
             }
         }
+        */
     }
 
     void renderText(int x, int y, int clipx, int clipy, int clipw, int cliph, PixelBuffer buf) {
@@ -516,10 +514,10 @@ public final class Box extends JS.Scope {
                 buf.drawPictureAlphaOnly(g.p,
                                          x,
                                          y + g.max_ascent - g.baseline + g.max_descent,
+                                         x,
+                                         y + g.max_ascent - g.baseline + g.max_descent,
                                          x + g.p.getWidth(),
                                          y + g.max_ascent - g.baseline + g.max_descent + g.p.getHeight(),
-                                         0, 0,
-                                         g.p.getWidth(), g.p.getHeight(),
                                          textcolor);
             x += g.advance;
         }
@@ -1111,7 +1109,6 @@ public final class Box extends JS.Scope {
                     public Object get(Box b) { return b; }
                     public void put(Box b, Object value) {
                         if (value == null) b.remove();
-                        else if (value.equals("window") || value.equals("frame")) Platform.createSurface(b, value.equals("frame"), true);
                         else if (Log.on) Log.log(this, "put invalid value to 'thisbox' property: " + value);
                     }
                 });
@@ -1178,18 +1175,20 @@ public final class Box extends JS.Scope {
                 });
             //#end
         
-            //#repeat width/height minwidth/minheight maxwidth/maxheight
+            //#repeat width/height height/width minwidth/minheight maxwidth/maxheight true/false
             specialBoxProperties.put("width", new SpecialBoxProperty() {
                     public Object get(Box b) { return new Integer(b.width); }
                     public void put(Box b, Object value) {
-                        int width = stoi(value);
+                        int newval = stoi(value);
                         if (b.parent == null && b.surface != null) {
-                            b.width = width;
-                            b.surface.setSize();
+                            // hack to circumvent #repeat
+                            int other = b.height;
+                            if (true) b.surface.setSize(newval, other);
+                            else b.surface.setSize(other, newval);
                             MARK_FOR_REFLOW_b;
                         } else {
-                            if (b.minwidth == width && b.maxwidth == width) return;
-                            b.minwidth = b.maxwidth = width;
+                            if (b.minwidth == newval && b.maxwidth == newval) return;
+                            b.minwidth = b.maxwidth = newval;
                             MARK_FOR_REFLOW_b;
                         }
                     } });
@@ -1263,11 +1262,8 @@ public final class Box extends JS.Scope {
                     } });
         
             specialBoxProperties.put("image", new SpecialBoxProperty() {
-                    /* FIXME
-                    public Object get(Box b) { return b.image == null ? null : ImageDecoder.imageToNameMap.get(b.image); }
-                    */
+                    public Object get(Box b) { return b.image == null ? null : b.image.res; }
                     public void put(Box b, Object value) {
-                        //if (image != null) System.out.println("hit");
                         if (value == null) {
                             b.image = null;
                         } else if (value instanceof Res) {