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