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