2003/11/13 09:15:11
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:41:17 +0000 (07:41 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:41:17 +0000 (07:41 +0000)
darcs-hash:20040130074117-2ba56-be84d19bc0fd56a575ff827b2abc45834d01ba99.gz

src/org/xwt/Box.java
src/org/xwt/Res.java
src/org/xwt/Surface.java
src/org/xwt/Template.java
src/org/xwt/XWT.java
src/org/xwt/builtin/splash.xwt

index a76c25d..dce1f27 100644 (file)
@@ -223,7 +223,7 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
             colWidth[child.col] = max(colWidth[child.col], child.contentwidth / child.colspan);
         for(int i=0; i<cols; i++) { contentwidth += colWidth[i]; colWidth[i] = 0; }
 
-        contentwidth = bound(minwidth, max(font.textwidth(text), contentwidth), maxwidth);
+        contentwidth = bound(minwidth, max(font == null ? 0 : font.textwidth(text), contentwidth), maxwidth);
         //#end               
     }
     
@@ -237,11 +237,11 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
             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; }
             catch (Exception e) { Log.log(this, e); }
             try { if (poschange) putAndTriggerJSTraps("PosChange", T); Surface.abort = true; }
             catch (Exception e) { Log.log(this, e); }
-            /*
         }
             */
         if (numchildren > 0) resize_children();
index df0813f..53da6ff 100644 (file)
@@ -171,6 +171,7 @@ public abstract class Res extends JS {
     public static class Ref extends Res {
         Res parent;
         Object key;
+        public String toString() { return parent.toString() + "/" + key; }
         Ref(Res parent, Object key) { this.parent = parent; this.key = key; }
         public String getCacheKey() throws NotCacheableException { return parent.getCacheKey() + "/" + key; }
         public Res addExtension(String extension) {
index b0b8df1..1ba2d65 100644 (file)
@@ -291,7 +291,6 @@ public abstract class Surface extends PixelBuffer {
     }
 
     public Surface(Box root) {
-
         this.root = root;
         Surface old = fromBox(root);
         if (old != null) old.dispose(false);
index 9a324d2..4cd3851 100644 (file)
@@ -280,7 +280,9 @@ public class Template {
         private JSFunction parseScript(boolean isstatic) {
             JSFunction thisscript = null;
             try {
-                thisscript = JS.parse(t.fileName + (isstatic ? "._" : ""), t.content_start, new StringReader(t.content.toString()));
+                String contentString = t.content.toString();
+                if (contentString.trim().length() > 0)
+                    thisscript = JS.parse(t.fileName + (isstatic ? "._" : ""), t.content_start, new StringReader(contentString));
             } catch (IOException ioe) {
                 if (Log.on) Log.log(this, "  ERROR: " + ioe.getMessage());
                 thisscript = null;
index f8b9c6d..a9feb45 100644 (file)
@@ -32,6 +32,7 @@ public final class XWT extends JSCallable {
         case "date": return new JSDate();
         case "origin": return Main.origin;
         case "box": return new BoxTree();
+        case "log": return new Sub("log");
         case "ui": return new Sub("ui");
         case "ui.key": return new Sub("ui.key");
         case "ui.key.alt": return Surface.alt ? Boolean.TRUE : Boolean.FALSE;
@@ -47,6 +48,7 @@ public final class XWT extends JSCallable {
         case "fs.home": return System.getProperty("user.home");
         case "fs.temp": return System.getProperty("java.io.tempdir");
         case "ui.mouse": return new Sub("ui.mouse");
+        case "res": return new Sub("res");
         case "ui.mouse.button":
             if (Surface.button1 && !Surface.button2 && !Surface.button3) return new Integer(1);
             else if (!Surface.button1 && Surface.button2 && !Surface.button3) return new Integer(2);
@@ -103,7 +105,7 @@ public final class XWT extends JSCallable {
             case "res.uncab": return new Res.Cab((Res)a);
             case "res.cache": try { return new Res.CachedRes((Res)a, "resources", true); }
                               catch (Res.NotCacheableException e) { throw new JS.Exn("this resource cannot be cached"); }
-            case "res.fromURL": return Res.fromString((String)a);
+            case "res.url": return Res.fromString((String)a);
             case "thread.sleep": sleep(JS.toInt(a)); return null;
             case "log.println": Log.logJS(this, a== null ? "**null**" : a.toString()); return null;
             case "log.dump": Log.recursiveLog("","",a); return null;
index a99bb00..a6693b0 100644 (file)
         }
 
         xwt.thread = function() {
+xwt.log.println("1");
 //            $text.font = xwt.fonts.vera["Vera.ttf"];
-            $text.font = xwt.cache(xwt.uncab(xwt.load("http://master.dist.xwt.org/msfonts/arial32.exe"))["Arial.TTF"]);
+            var cab = xwt.res.uncab(xwt.res.url("http://master.dist.xwt.org/msfonts/arial32.exe"));
+//            $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.window = thisbox;
-            x = (xwt.screenWidth - width) / 2;
-            y = (xwt.screenHeight - height) / 2;
+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;
             var origin = xwt.origin;
             if (origin.substring(0, 21) == "http://launch.xwt.org") {
                 origin = origin.substring(22);
                 origin = "http://" + origin.substring(origin.indexOf('/') + 1);
             }
-            xwt.println("origin is " + origin);
-            var new_rr = xwt.unzip(xwt.watchProgress(xwt.load(origin), progress));
+            xwt.log.println("origin is " + origin);
+            var new_rr = xwt.res.unzip(xwt.watchProgress(xwt.load(origin), progress));
             var new_xwt = xwt.clone(new_rr);
 
             xwt.thread = function() {
-xwt.sleep(1000); // let the fonts get pulled in
+xwt.thread.sleep(1000); // let the fonts get pulled in
 for(var i=0; 100>i; i++) {
 progress(i, 100);
-xwt.yield();
+xwt.thread.yield();
 }
                 new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
                 thisbox = null;