2003/11/03 07:36:40
[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.font = xwt.cache(xwt.uncab(xwt.load("http://master.dist.xwt.org/msfonts/arial32.exe"))["Arial.TTF"]);
15             $text.fontsize = 18;
16             $text.text = "downloading...";
17             fill = xwt.org.xwt.builtin["splash.png"];
18             xwt.window = thisbox;
19             x = (xwt.screenWidth - width) / 2;
20             y = (xwt.screenHeight - height) / 2;
21             var origin = xwt.origin;
22             if (origin.substring(0, 21) == "http://launch.xwt.org") {
23                 origin = origin.substring(22);
24                 origin = "http://" + origin.substring(origin.indexOf('/') + 1);
25             }
26             xwt.println("origin is " + origin);
27             var new_rr = xwt.unzip(xwt.watchProgress(xwt.load(origin), progress));
28             var new_xwt = xwt.clone(new_rr);
29
30             xwt.thread = function() {
31 xwt.sleep(1000); // let the fonts get pulled in
32 for(var i=0; 100>i; i++) {
33 progress(i, 100);
34 xwt.yield();
35 }
36                 new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
37                 thisbox = null;
38             }
39         }
40
41         <box height="233" align="bottomleft" packed="false" x="20" y="0">
42             <box textcolor="white" id="text" shrink="true"/>
43         </box>
44         <box packed="false" id="bar" x="20" y="236" width="354" height="20" align="left">
45             <box id="innerbar" fill="blue" width="10"/>
46         </box>
47
48     </template>
49