2002/08/07 04:32:20
[org.ibex.core.git] / src / org / xwt / builtin / splash.xwt
1 <xwt>
2
3     <template thisbox="window" orient="vertical">
4
5         minwidth = maxwidth = $inner.width;
6         minheight = maxheight = $inner.height;
7         x = (xwt.screenWidth - width) / 2;
8         y = (xwt.screenHeight - height) / 2;
9
10         _KeyPressed = function(k) {
11             if (k == "escape") thisbox = null;
12         }
13
14         xwt.thread = function() {
15             var origin = xwt.origin;
16             if (origin.substring(0, 21) == "http://launch.xwt.org") {
17                 origin = origin.substring(22);
18                 origin = "http://" + origin.substring(origin.indexOf('/') + 1);
19             }
20             xwt.println("origin is " + origin);
21
22             xwt.loadArchive(origin, function(num, den) {
23                     $left.flex = 50 * (num / den);
24                     $right.flex = 50 + 50 * (1.0 - num /den);
25                     var pct = xwt.math.ceil(num * 100 / den);
26                     if (1024 > num) {
27                         num = "" + num + " bytes";
28                     } else if (1024 * 1024 > num) {
29                         num = "" + xwt.math.ceil(num / 1024) + "kb";
30                     } else {
31                         num = "" + xwt.math.ceil(num / (1024 * 1024)) + "Mb";
32                     }
33                     $status.text = "Downloading: " + pct + "% [" + num + "]";
34                 });
35
36             xwt.newBox("main", function(num, den) {
37                     $left.flex = 50 + 50 * (num / den);
38                     $right.flex = 50 * (1.0 - num / den);
39                     if ($right.flex == 0) $right.width = 0;
40                     $status.text = "Initializing: " + xwt.math.ceil(num * 100 / den) + "%";
41                 });
42
43             thisbox = null;
44         }
45
46         <box absolute="true" sizetoimage="true" id="inner" image="org.xwt.builtin.lithium"/>
47
48         <box/>
49         <box text="Downloading user interface..." vshrink="true" hpad="4" vpad="3" id="status" textcolor="white"/>
50         <box hpad="4" height="10">
51             <box flex="0.0" image="org.xwt.builtin.progress" tile="true" id="left"/>
52             <box flex="100.0" id="right"/>
53         </box>
54         <box height="5"/>
55
56     </template>
57