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