2003/10/29 03:48:14
[org.ibex.core.git] / src / org / xwt / builtin / splash.xwt
1 <xwt>
2
3     <template orient="vertical" width="394" height="276" color="white">
4
5         KeyPressed += function(k) { if (k == "escape") thisbox = null; }
6
7         var progress = function(n, d) {
8             $innerbar.width = $bar.width * n / d + 1;
9             $text.text = "downloaded " + (xwt.math.ceil(100 * n/d)) + "%";
10         }
11
12         xwt.thread = function() {
13             $text.font = xwt.fonts.vera["Vera.ttf"];
14             $text.fontsize = 14;
15             $text.text = "downloading...";
16             fill = xwt.org.xwt.builtin["splash.png"];
17             xwt.window = thisbox;
18             x = (xwt.screenWidth - width) / 2;
19             y = (xwt.screenHeight - height) / 2;
20             var origin = xwt.origin;
21             if (origin.substring(0, 21) == "http://launch.xwt.org") {
22                 origin = origin.substring(22);
23                 origin = "http://" + origin.substring(origin.indexOf('/') + 1);
24             }
25             xwt.println("origin is " + origin);
26             var new_rr = xwt.unzip(xwt.watchProgress(xwt.load(origin), progress));
27             var new_xwt = xwt.clone(new_rr);
28
29             xwt.thread = function() {
30 for(var i=0; 100>i; i++) { progress(i, 100); xwt.sleep(100); }
31                 xwt.yield();
32                 new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
33                 thisbox = null;
34             }
35         }
36
37         <box height="236" align="bottomleft" packed="false" x="20" y="0">
38             <box textcolor="white" id="text" shrink="true"/>
39         </box>
40         <box packed="false" id="bar" x="20" y="236" width="354" height="20" align="left">
41             <box id="innerbar" fill="blue" width="10"/>
42         </box>
43
44     </template>
45