2003/11/13 10:23:10
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:41:21 +0000 (07:41 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:41:21 +0000 (07:41 +0000)
darcs-hash:20040130074121-2ba56-66926936fbd0575d2f399b3cc1fa6775f5f68f51.gz

src/org/xwt/Box.java
src/org/xwt/XWT.java
src/org/xwt/builtin/splash.xwt
src/org/xwt/js/JSFunction.java

index 2f6a322..60f1fbd 100644 (file)
@@ -179,10 +179,11 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
 
     // static stuff so we don't have to keep reallocating
     private static int[] numRowsInCol = new int[65535];
-    private LENGTH[] colWidth = new LENGTH[65535];
-    private LENGTH[] colMaxWidth = new LENGTH[65535];
-    private LENGTH[] rowHeight = new LENGTH[65535];
-    private LENGTH[] rowMaxHeight = new LENGTH[65535];
+    private static LENGTH[] colWidth = new LENGTH[65535];
+    private static LENGTH[] colMaxWidth = new LENGTH[65535];
+    private static LENGTH[] rowHeight = new LENGTH[65535];
+    private static LENGTH[] rowMaxHeight = new LENGTH[65535];
+    static { for(int i=0; i<rowMaxHeight.length; i++) { rowMaxHeight[i] = MAX_LENGTH; colMaxWidth[i] = MAX_LENGTH; } }
 
     final Box nextPackedSibling() { Box b = nextSibling(); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
     final Box firstPackedChild() { Box b = getChild(0); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
@@ -193,6 +194,7 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
         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 */
@@ -229,29 +231,24 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
     
     private void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
         // FEATURE reimplement, but we're destroying this
-        /*
         if (x != this.x || y != this.y || width != this.width || height != this.height) {
-        */
             (parent == null ? this : parent).dirty(this.x, this.y, this.width, this.height);
             boolean sizechange = (this.width != width || this.height != height) && getTrap("SizeChange") != null;
             boolean poschange = (this.x != x || this.y != y) && getTrap("PosChange") != null;
             this.width = width; this.height = height; this.x = x; this.y = y;
             dirty();
-            /*
-            try { if (sizechange) putAndTriggerJSTraps("SizeChange", T); Surface.abort = true; }
+            try { if (sizechange) putAndTriggerJSTraps("SizeChange", T); /*Surface.abort = true;*/ }
             catch (Exception e) { Log.log(this, e); }
-            try { if (poschange) putAndTriggerJSTraps("PosChange", T); Surface.abort = true; }
+            try { if (poschange) putAndTriggerJSTraps("PosChange", T); /*Surface.abort = true;*/ }
             catch (Exception e) { Log.log(this, e); }
         }
-            */
-        if (numchildren > 0) resize_children();
     }
 
     private void resize_children() {
         int slack;
-        //#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height \
-        //        HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight
 
+        //#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height colMaxWidth/rowMaxHeight \
+        //        HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight
         // PHASE 1: compute column min/max sizes
         slack = 0;
         for(Box child = firstPackedChild(); child != null; child = child.nextPackedSibling())
@@ -272,29 +269,37 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
                 colWidth[col] += diff;
             }
         }   
+        //#end
 
-        for(Box child = getChild(0); child != null; child = child.nextPackedSibling()) {
-            int unbounded = 0;
+        // Phase 3: assign childrens' actual sizes
+        for(Box child = getChild(0); child != null; child = child.nextSibling()) {
+            if (!child.test(VISIBLE)) continue;
+            if (!child.test(PACKED)) {
+                child.resize(child.x, child.y,
+                             child.test(HSHRINK) ? child.contentwidth : min(child.maxwidth, width - child.x),
+                             child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height - child.y));
+                continue;
+            }
+            int unbounded;
+            //#repeat col/row colspan/rowspan contentwidth/contentheight width/height colMaxWidth/rowMaxHeight child_x/child_y \
+            //    x/y HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight child_width/child_height
+            unbounded = 0;
             for(int i = child.col; i < child.col + child.colspan; i++) unbounded += colWidth[i];
-            child.width = bound(child.contentwidth, unbounded, child.test(HSHRINK) ? child.contentwidth : child.maxwidth);
-            child.x = test(ALIGN_RIGHT) ? slack : test(ALIGN_LEFT) ? slack / 2 : 0;
-            for(int i=0; i < child.col; i++) child.x += colWidth[i];
-            if (child.width < unbounded) child.x += (child.width - unbounded) / 2;
+            int child_width = bound(child.contentwidth, unbounded, child.test(HSHRINK) ? child.contentwidth : child.maxwidth);
+            int child_x = test(ALIGN_RIGHT) ? slack : test(ALIGN_LEFT) ? slack / 2 : 0;
+            for(int i=0; i < child.col; i++) child_x += colWidth[i];
+            if (child_width < unbounded) child_x += (child_width - unbounded) / 2;
+            //#end
+            child.resize(child_x, child_y, child_width, child_height);
         }
 
         // cleanup
-        for(int i=0; i<colWidth.length; i++) colWidth[i] = 0;
-        for(int i=0; i<colMaxWidth.length; i++) colMaxWidth[i] = MAX_LENGTH;
-        //#end
+        for(int i=0; i<cols; i++) { colWidth[i] = 0; colMaxWidth[i] = MAX_LENGTH; }
+        for(int i=0; i<rows; i++) { rowHeight[i] = 0; rowMaxHeight[i] = MAX_LENGTH; }
 
-        // Phase 3: assign childrens' actual sizes
         for(Box child = getChild(0); child != null; child = child.nextSibling())
-            if (!test(VISIBLE)) continue;
-            else if (!child.test(PACKED))
-                child.resize(child.x, child.y,
-                             child.test(HSHRINK) ? child.contentwidth : min(child.maxwidth, width - child.x),
-                             child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height - child.y));
-            else child.resize(child.x, child.y, child.width, child.height);
+            if (test(VISIBLE))
+                child.resize_children();
     }
 
 
@@ -311,9 +316,9 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
         if (!test(NOCLIP)) {
             cx1 = max(cx1, parent == null ? 0 : globalx);
             cy1 = max(cy1, parent == null ? 0 : globaly);
-            cx2 = min(cx2, parent == null ? 0 : globalx + width);
-            cy2 = min(cy2, parent == null ? 0 : globaly + height);
-            if (cx2 <= cx1 || cy2 <= cy1) return;
+            cx2 = min(cx2, globalx + width);
+            cy2 = min(cy2, globaly + height);
+            //if (cx2 <= cx1 || cy2 <= cy1) return;
         }
 
         if ((fillcolor & 0xFF000000) != 0x00000000)
index a9feb45..bd9ebaf 100644 (file)
@@ -34,6 +34,7 @@ public final class XWT extends JSCallable {
         case "box": return new BoxTree();
         case "log": return new Sub("log");
         case "ui": return new Sub("ui");
+        case "thread": return new Sub("thread");
         case "ui.key": return new Sub("ui.key");
         case "ui.key.alt": return Surface.alt ? Boolean.TRUE : Boolean.FALSE;
         case "ui.key.control": return Surface.control ? Boolean.TRUE : Boolean.FALSE;
index a6693b0..40ed34e 100644 (file)
         }
 
         xwt.thread = function() {
-xwt.log.println("1");
 //            $text.font = xwt.fonts.vera["Vera.ttf"];
-            var cab = xwt.res.uncab(xwt.res.url("http://master.dist.xwt.org/msfonts/arial32.exe"));
+            $text.font = xwt.res.uncab(xwt.res.url("http://master.dist.xwt.org/msfonts/arial32.exe"))["Arial.TTF"];
 //            $text.font = xwt.res.cache(cab["Arial.TTF"]);
-xwt.log.println("2");
-            $text.font = cab["Arial.TTF"];
-xwt.log.println("3");
             $text.fontsize = 18;
-xwt.log.println("4");
             $text.text = "downloading...";
-xwt.log.println("5");
             fill = xwt.org.xwt.builtin["splash.png"];
-xwt.log.println("6");
             xwt.ui.window = thisbox;
-xwt.log.println("7");
             thisbox.width = 100;
             thisbox.height = 100;
-xwt.log.println("8");
-            x = (xwt.screen.width - width) / 2;
-            y = (xwt.screen.height - height) / 2;
+            x = (xwt.ui.screen.width - width) / 2;
+            y = (xwt.ui.screen.height - height) / 2;
             var origin = xwt.origin;
             if (origin.substring(0, 21) == "http://launch.xwt.org") {
                 origin = origin.substring(22);
@@ -48,6 +39,7 @@ xwt.thread.yield();
                 new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
                 thisbox = null;
             }
+xwt.log.println("leaving");
         }
 
         <box height="233" align="bottomleft" packed="false" x="20" y="0">
index 11f8031..0aabebf 100644 (file)
@@ -327,13 +327,9 @@ public class JSFunction extends JSCallable implements ByteCodes, Tokens {
                     method = o;
                     if (method == null) throw new JS.Exn("cannot call the null method");
                     o = cx.stack.pop();
-                    System.out.println("o == " + o);
-                    System.out.println("method == " + method);
                     if(o instanceof String || o instanceof Number || o instanceof Boolean) {
                         arguments = new JSArray();
                         for(int j=numArgs - 1; j >= 0; j--) arguments.setElementAt(cx.stack.pop(), j);
-                        System.out.println(cx.f.dump());
-                        System.out.println(cx.pc);
                         ret = Internal.callMethodOnPrimitive(o, method, arguments);
                         cx.stack.push(ret);
                         cx.pc += 2;  // skip the GET and CALL