initial checkin
[org.ibex.widgets.git] / src / org / ibex / test / alpha1.t
1 <ibex xmlns:theme="ibex.theme" xmlns="ibex.widget">
2     <theme:surface />
3     <ui:box cols="1" fill="#d4d0c8" maxwidth="400" maxheight="300">
4
5         ibex.ui.frame = thisbox;
6
7         // $r4.group = $r3.group = $r2.group = $r1.group;
8         $r2.group = $r1.group;
9         $r3.group = $r1.group;
10         $r4.group = $r1.group;
11
12         $bg.fill ++= function(v) {
13             cascade = v;
14             if (v == "white") $r1.selected = true;
15             else if (v == "red") $r2.selected = true;
16             else if (v == "green") $r3.selected = true;
17             else if (v == "blue") $r4.selected = true;
18             else if (v == null and $r1.group.selected) $r1.group.selected.selected = false;
19         }
20
21         $b1.action ++= function(v) {
22             if ($r1.group.selected and $r1.group.selected.nextselect)
23                 $r1.group.selected.nextselect.selected = true;
24             else for (var i=0; $radios.numchildren > i; i++)
25                 if ($radios[i].enabled) { $radios[i].selected = true; break; }
26         }
27         
28         $b2.action ++= function(v) {
29             var targets = [];
30             for (var i=0; 4 > i; i++) if ($radios[i].enabled) targets[targets.length] = $radios[i];
31
32             if (targets.length > 0) {
33                 var n = ibex.math.floor(targets.length * ibex.math.random());
34                 targets[n].selected = true;
35             }
36             else ibex.log.info("No enabled colors to choose from!");
37         }
38
39         $b3.action ++= function(v) { $bg.fill = null; }
40
41         $c1.selected ++= function(v) { $r1.enabled = !v; }
42         $c2.selected ++= function(v) { $r2.enabled = !v; }
43         $c3.selected ++= function(v) { $r3.enabled = !v; }
44         $c4.selected ++= function(v) { $r4.enabled = !v; }
45
46         $r1.selected ++= function(v) { if (v and $bg.fill != "#ffffff") $bg.fill = "white"; }
47         $r2.selected ++= function(v) { if (v and $bg.fill != "#ff0000") $bg.fill = "red"; }
48         $r3.selected ++= function(v) { if (v and $bg.fill != "#008000") $bg.fill = "green"; }
49         $r4.selected ++= function(v) { if (v and $bg.fill != "#0000ff") $bg.fill = "blue"; }
50
51         <ui:box>
52             <ui:box id="buttons" cols="1">
53                 <button id="b1" margin="10 5 0 5" text="cycle" />
54                 <button id="b2" margin="10 5 0 5" text="random" />
55                 <button id="b3" margin="10 5 0 5" text="reset" />
56             </ui:box>
57
58             <ui:box id="checks" cols="1">
59                 <check id="c1" margin="10 5 0 5" text="disable white button" />
60                 <check id="c2" margin="10 5 0 5" text="disable red button" />
61                 <check id="c3" margin="10 5 0 5" text="disable green button" />
62                 <check id="c4" margin="10 5 0 5" text="disable blue button" />
63             </ui:box>
64  
65             <ui:box id="radios" cols="1">
66                 <radio id="r1" margin="10 5 0 5" text="white bg" />
67                 <radio id="r2" margin="10 5 0 5" text="red bg" />
68                 <radio id="r3" margin="10 5 0 5" text="green bg" />
69                 <radio id="r4" margin="10 5 0 5" text="blue bg" />
70             </ui:box>
71         </ui:box>
72         <bevel id="bg" form="down" margin="10" />
73     </ui:box>
74 </ibex>