2003/10/25 07:50:20
[org.ibex.core.git] / src / org / xwt / builtin / splash.xwt
index aba4a34..9d6ef80 100644 (file)
@@ -1,41 +1,33 @@
 <xwt>
 
-    <template thisbox="window" orient="vertical">
+    <template thisbox="window" orient="vertical" width="394" height="276">
 
-        width = $inner.width;
-        height = $inner.height;
-        x = (xwt.screenWidth - width) / 2;
-        y = (xwt.screenHeight - height) / 2;
+        KeyPressed += function(k) { if (k == "escape") thisbox = null; }
+
+        var progress = function(n, d) {
+            $innerbar.width = $bar.width * n / d;
+            xwt.yield();
+        }
 
         xwt.thread = function() {
+            var img = xwt.org.xwt.builtin["splash.png"];
+            fill = img;
+            xwt.yield();
+            x = (xwt.screenWidth - width) / 2;
+            y = (xwt.screenHeight - height) / 2;
             var origin = xwt.origin;
-            if (origin.substring(0, 21) == "http://launch.xwt.org")
+            if (origin.substring(0, 21) == "http://launch.xwt.org") {
                 origin = origin.substring(22);
-
-            xwt.loadArchive(origin, function(num, den) {
-                    $left.flex = 50 * (num / den);
-                    $right.flex = 50 + 50 * (1.0 - num /den);
-                    $status.text = "Downloading: " + xwt.math.ceil(num * 100 / den) + "% [" + num + " bytes]";
-                });
-
-            xwt.newBox("main", function(num, den) {
-                    $left.flex = 50 + 50 * (num / den);
-                    $right.flex = 50 * (1.0 - num / den);
-                    $status.text = "Initializing: " + xwt.math.ceil(num * 100 / den) + "%";
-                    xwt.yield();
-                });
-
-            thisbox = null;
+                origin = "http://" + origin.substring(origin.indexOf('/') + 1);
+            }
+            xwt.println("origin is " + origin);
+            var new_rr = xwt.unzip(xwt.watchProgress(xwt.load(origin), progress));
+            var new_xwt = xwt.clone(new_rr);
+            new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
         }
 
-        <box absolute="true" sizetoimage="true" id="inner" image="org.xwt.builtin.lithium"/>
-
-        <box/>
-        <box text="Downloading user interface..." vshrink="true" hpad="20" vpad="3" id="status" textcolor="white"/>
-
-        <box vpad="5" hpad="30" height="20">
-            <box color="red" flex="0.0" id="left"/>
-            <box flex="100.0" id="right" color="blue"/>
+        <box packed="false" id="bar" x="20" y="236" width="354" height="18" align="left">
+            <box id="innerbar" fill="blue" width="10"/>
         </box>
 
     </template>