propose-patch
[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 settext = function(t) {
8             $text.text = t;
9             $text1.text = t;
10             $text2.text = t;
11             $text3.text = t;
12             $text4.text = t;
13         }
14
15         var progress = function(n, d) {
16             var t = "downloaded " + xwt.math.ceil(100 * n/d) + "%";
17             xwt.log.println("downloaded " + t);
18             $innerbar.width = $bar.width * n / d + 1;
19             settext(t);
20        } 
21
22         xwt.thread = function() {
23             $text.font = xwt.font.sansserif;
24             $text.fontsize = 14;
25             $text1.font = xwt.font.sansserif;
26             $text1.fontsize = 14;
27             $text2.font = xwt.font.sansserif;
28             $text2.fontsize = 14;
29             $text3.font = xwt.font.sansserif;
30             $text3.fontsize = 14;
31             $text4.font = xwt.font.sansserif;
32             $text4.fontsize = 14;
33             settext("downloading...");
34             fill = .org.xwt.builtin["splash.png"];
35             xwt.ui.window = thisbox;
36             thisbox.width=394;
37             thisbox.height=276;
38             x = (xwt.ui.screen.width - width) / 2;
39             y = (xwt.ui.screen.height - height) / 2;
40             var origin = xwt.origin;
41             if (origin.substring(0, 21) == "http://launch.xwt.org") {
42                 origin = origin.substring(22);
43                 origin = "http://" + origin.substring(origin.indexOf('/') + 1);
44             }
45             xwt.log.println("origin is " + origin);
46             var new_rr = xwt.res.unzip(xwt.res.watch(xwt.res.url(origin), progress));
47             var new_xwt = xwt.clone(new_rr);
48
49             xwt.thread = function() {
50                 for(var i=0; 100>i; i++) {
51                 progress(i, 100);
52                 xwt.thread.yield();
53             }
54             new_xwt.apply(xwt.box, new_xwt["main.xwt"]);
55             thisbox = null;
56         }
57 xwt.log.println("leaving");
58         }
59
60         <box height="236" align="bottomleft" packed="false" x="20" y="0">
61             <box vshrink="true">
62                 <box packed="false" textcolor="black" x="2" y="2" id="text1"/>
63                 <box packed="false" textcolor="black" x="0" y="2" id="text2"/>
64                 <box packed="false" textcolor="black" x="2" y="0" id="text3"/>
65                 <box packed="false" textcolor="black" x="0" y="0" id="text4"/>
66                 <box cols="2">
67                     <box height="1" colspan="2"/>
68                     <box width="1"/>
69                     <box textcolor="white" id="text"/>
70                 </box>
71             </box>
72         </box>
73         <box packed="false" id="bar" x="20" y="236" width="354" height="20" align="left">
74             <box id="innerbar" fill="blue" width="10" height="20"/>
75         </box>
76
77     </template>
78
79 </xwt>