<xwt>
- <template thisbox="window" orient="vertical">
+ <template orient="vertical" width="394" height="276" color="white">
- minwidth = maxwidth = $inner.width;
- minheight = maxheight = $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 + 1;
+ $text.text = "downloaded " + (xwt.math.ceil(100 * n/d)) + "%";
+ }
xwt.thread = function() {
+// $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"]);
+ $text.fontsize = 18;
+ $text.text = "downloading...";
+ fill = xwt.org.xwt.builtin["splash.png"];
+ xwt.window = thisbox;
+ 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);
- var pct = xwt.math.ceil(num * 100 / den);
- if (1024 > num) {
- num = "" + num + " bytes";
- } else if (1024 * 1024 > num) {
- num = "" + xwt.math.ceil(num / 1024) + "kb";
- } else {
- num = "" + xwt.math.ceil(num / (1024 * 1024)) + "Mb";
- }
- $status.text = "Downloading: " + pct + "% [" + num + "]";
- });
-
- xwt.newBox("main", function(num, den) {
- $left.flex = 50 + 50 * (num / den);
- $right.flex = 50 * (1.0 - num / den);
- if ($right.flex == 0) $right.width = 0;
- $status.text = "Initializing: " + xwt.math.ceil(num * 100 / den) + "%";
- });
-
- 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);
+
+ xwt.thread = function() {
+xwt.sleep(1000); // let the fonts get pulled in
+for(var i=0; 100>i; i++) {
+progress(i, 100);
+xwt.yield();
+}
+ new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
+ thisbox = null;
+ }
}
- <box absolute="true" sizetoimage="true" id="inner" image="org.xwt.builtin.lithium"/>
-
- <box/>
- <box text="Downloading user interface..." vshrink="true" hpad="30" vpad="3" id="status" textcolor="white"/>
- <box hpad="4" height="10">
- <box width="25"/>
- <box flex="0.0" image="org.xwt.builtin.progress" tile="true" id="left"/>
- <box flex="100.0" id="right"/>
+ <box height="233" align="bottomleft" packed="false" x="20" y="0">
+ <box textcolor="white" id="text" shrink="true"/>
+ </box>
+ <box packed="false" id="bar" x="20" y="236" width="354" height="20" align="left">
+ <box id="innerbar" fill="blue" width="10"/>
</box>
- <box height="5"/>
</template>