initial checkin
[org.ibex.widgets.git] / src / ibex / lib / polarizable.t
1 <!-- Copyleft 2004 - see COPYING for details [LGPL] -->
2
3 <ibex>
4     <meta:doc>
5         Author: Charles Goodwin
6     </meta:doc>
7
8     static.flip = function(f) {
9         if (f == "width") return "height";
10         else if (f == "height") return "width";
11         else if (f == "x") return "y";
12         else if (f == "y") return "x";
13         else if (f == "maxwidth") return "maxheight";
14         else if (f == "maxheight") return "maxwidth";
15         else if (f == "minwidth") return "minheight";
16         else if (f == "minheight") return "minwidth";
17         else if (f == "horizontal") return "vertical";
18         else if (f == "vertical") return "horizontal";
19         else if (f == "hshrink") return "vshrink";
20         else if (f == "vshrink") return "hshrink";
21         else if (f == "cols") return "rows";
22         else if (f == "rows") return "cols";
23         return null;
24     }
25
26     <ui:box>
27
28         thisbox.dim = "width";
29         thisbox.globalpos = "globalx";
30         thisbox.mindim = "minwidth";
31         thisbox.maxdim = "maxwidth";
32         thisbox.pos = "x";
33         thisbox.shr = "hshrink";
34         thisbox.flip = static.flip;
35
36         thisbox.orient ++= function(v) {
37             if (v == "horizontal") {
38                 if (cols) rows = cols;
39                 dim       = "width";
40                 maxdim    = "maxwidth";
41                 mindim    = "minwidth";
42                 pos       = "x";
43                 shr       = "hshrink";
44             }
45             else {
46                 if (rows) cols = rows;
47                 dim       = "height";
48                 maxdim    = "maxheight";
49                 mindim    = "minheight";
50                 pos       = "y";
51                 shr       = "vshrink";
52             }
53         }
54
55     </ui:box>
56 </ibex>