2003/12/16 22:35:20
[org.ibex.core.git] / src / org / xwt / Box.java
index a98e052..07c0066 100644 (file)
@@ -227,17 +227,6 @@ public final class Box extends JSScope implements Scheduler.Task {
     Box nextPackedSibling() { Box b = nextSibling(); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
     Box firstPackedChild() { Box b = getChild(0); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
 
-    /** only for use on the root box */
-    void reflow(int new_width, int new_height) {
-        repack();
-        /*
-        new_width = bound(max(contentwidth, minwidth), new_width, test(HSHRINK) ? max(contentwidth, minwidth) : maxwidth);
-        new_height = bound(max(contentheight, minheight), new_height, test(VSHRINK) ? max(contentheight, minheight) : maxheight);
-        */
-        resize(x, y, new_width, new_height);
-        resize_children();
-    }
-
     /** pack the boxes into rows and columns; also computes contentwidth */
     void repack() {
         for(Box child = getChild(0); child != null; child = child.nextSibling()) child.repack();
@@ -271,7 +260,7 @@ public final class Box extends JSScope implements Scheduler.Task {
         //#end               
     }
     
-    private void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
+    void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
         // FEATURE reimplement, but we're destroying this
         // FIXME: uncommenting this breaks; see http://bugs.xwt.org/show_bug.cgi?id=345
         //if (x != this.x || y != this.y || width != this.width || height != this.height) {
@@ -287,7 +276,7 @@ public final class Box extends JSScope implements Scheduler.Task {
             //}
     }
 
-    private void resize_children() {
+    void resize_children() {
 
         //#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height colMaxWidth/rowMaxHeight colWidth/rowHeight \
         //        HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight x_slack/y_slack
@@ -465,6 +454,9 @@ public final class Box extends JSScope implements Scheduler.Task {
         throw new Error("unreachable"); // unreachable
     }
 
+    void setMaxWidth(Object value) { do { CHECKSET_INT(maxwidth); MARK_RESIZE; } while(false); }
+    void setMaxHeight(Object value) { do { CHECKSET_INT(maxheight); MARK_RESIZE; } while(false); }
+
     public void put(Object name, Object value) throws JSExn {
         if (name instanceof Number) { put(toInt(name), value); return; }
         //#switch(name)
@@ -476,11 +468,11 @@ public final class Box extends JSScope implements Scheduler.Task {
         case "shrink": put("hshrink", value); put("vshrink", value);
         case "hshrink": CHECKSET_FLAG(HSHRINK); MARK_RESIZE;
         case "vshrink": CHECKSET_FLAG(VSHRINK); MARK_RESIZE;
-        case "width": if (parent==null&&Surface.fromBox(this)!=null) { Surface.fromBox(this).setWidth(toInt(value)); } else { put("maxwidth", value); put("minwidth", value); MARK_RESIZE; }
-        case "height": if (parent == null&&Surface.fromBox(this)!=null) { Surface.fromBox(this).setHeight(toInt(value)); } else { put("maxheight", value); put("minheight", value); MARK_RESIZE; }
-        case "maxwidth": CHECKSET_INT(maxwidth); MARK_RESIZE;
+        case "width": put("maxwidth", value); put("minwidth", value); MARK_RESIZE;
+        case "height": put("maxheight", value); put("minheight", value); MARK_RESIZE;
+        case "maxwidth": setMaxWidth(value);
         case "minwidth": CHECKSET_INT(minwidth); MARK_RESIZE;
-        case "maxheight": CHECKSET_INT(maxheight); MARK_RESIZE;
+        case "maxheight": setMaxHeight(value);
         case "minheight": CHECKSET_INT(minheight); MARK_RESIZE;
         case "colspan": CHECKSET_SHORT(colspan); MARK_REPACK_parent;
         case "rowspan": CHECKSET_SHORT(rowspan); MARK_REPACK_parent;