initial checkin
[org.ibex.widgets.git] / src / org / ibex / theme / base / margin.t
1 <!-- Copyleft 2004  see COPYING for details [LGPL] -->
2
3 <ibex>
4     <meta:doc>
5         Author: Charles Goodwin
6
7         TODO:
8             - ? differentiate between pt and px
9             - ? proper child and property redirection
10     </meta:doc>
11
12     <ui:box redirect="$content">
13
14         thisbox.margin = 0;
15         thisbox["margin-top"] = 0;
16         thisbox["margin-right"] = 0;
17         thisbox["margin-bottom"] = 0;
18         thisbox["margin-left"] = 0;
19
20         margin ++= function(v) {
21             var p = v.split(' ');
22
23             if (p.length == 1) {
24                 thisbox["margin-top"] = v;
25                 thisbox["margin-right"] = v;
26                 thisbox["margin-bottom"] = v;
27                 thisbox["margin-left"] = v;
28             }
29             else if (p.length == 2) {
30                 thisbox["margin-top"] = p[0];
31                 thisbox["margin-right"] = p[1];
32                 thisbox["margin-bottom"] = p[0];
33                 thisbox["margin-left"] = p[1];
34             }
35             else if (p.length == 4) {
36                 thisbox["margin-top"] = p[0];
37                 thisbox["margin-right"] = p[1];
38                 thisbox["margin-bottom"] = p[2];
39                 thisbox["margin-left"] = p[3];
40             }
41             else ibex.log.warn("Invalid number of values for margin: " + p.length);
42         }
43
44         thisbox["margin-top"] ++= function(v) { $top.height = v; }
45         thisbox["margin-right"] ++= function(v) { $right.width = v; }
46         thisbox["margin-bottom"] ++= function(v) { $bottom.height = v; }
47         thisbox["margin-left"] ++= function(v) { $left.width = v; }
48
49         <ui:box id="left" width="0" />
50         <ui:box cols="1">
51             <ui:box id="top" height="0" />
52             <ui:box id="content" />
53             <ui:box id="bottom" height="0" />
54         </ui:box>
55         <ui:box id="right" width="0" />
56     </ui:box>
57 </ibex>