JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / javajs / swing / JSplitPane.js
1 Clazz.declarePackage ("javajs.swing");
2 Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JSplitPane", ["javajs.swing.JComponentImp", "javajs.util.SB"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.isH = true;
5 this.split = 1;
6 this.right = null;
7 this.left = null;
8 Clazz.instantialize (this, arguments);
9 }, javajs.swing, "JSplitPane", javajs.swing.JComponent);
10 Clazz.makeConstructor (c$, 
11 function (split) {
12 Clazz.superConstructor (this, javajs.swing.JSplitPane, ["JSpP"]);
13 this.split = split;
14 this.isH = (split == 1);
15 }, "~N");
16 Clazz.defineMethod (c$, "setRightComponent", 
17 function (r) {
18 this.right =  new javajs.swing.JComponentImp (null);
19 this.right.add (r);
20 }, "javajs.swing.JComponent");
21 Clazz.defineMethod (c$, "setLeftComponent", 
22 function (l) {
23 this.left =  new javajs.swing.JComponentImp (null);
24 this.left.add (l);
25 }, "javajs.swing.JComponent");
26 Clazz.defineMethod (c$, "getSubcomponentWidth", 
27 function () {
28 var w = this.width;
29 if (w == 0) {
30 var wleft = this.left.getSubcomponentWidth ();
31 var wright = this.right.getSubcomponentWidth ();
32 if (wleft > 0 && wright > 0) {
33 if (this.isH) w = wleft + wright;
34  else w = Math.max (wleft, wright);
35 }}return w;
36 });
37 Clazz.defineMethod (c$, "getSubcomponentHeight", 
38 function () {
39 var h = this.height;
40 if (h == 0) {
41 var hleft = this.left.getSubcomponentHeight ();
42 var hright = this.right.getSubcomponentHeight ();
43 if (hleft > 0 && hright > 0) {
44 if (this.isH) h = Math.max (hleft, hright);
45  else h = hleft + hright;
46 }}return h;
47 });
48 Clazz.defineMethod (c$, "toHTML", 
49 function () {
50 if (this.left == null || this.right == null) return "";
51 var isH = (this.split == 1);
52 if (this.width == 0) this.width = this.getSubcomponentWidth ();
53 if (this.height == 0) this.height = this.getSubcomponentHeight ();
54 var sb =  new javajs.util.SB ();
55 sb.append ("<div id='" + this.id + "' class='JSplitPane' style='" + this.getCSSstyle (100, 100) + "'>");
56 if (isH) sb.append ("<div id='" + this.id + "_left' style='width:50%;height:100%;position:absolute;top:0%;left:0%'>");
57  else sb.append ("<div id='" + this.id + "_top' style='width:100%;height:50%;position:absolute;top:0%;left:0%'>");
58 sb.append (this.left.getComponents ()[0].toHTML ());
59 if (isH) sb.append ("</div><div id='" + this.id + "_right' style='width:50%;height:100%;position:absolute;top:0%;left:50%'>");
60  else sb.append ("</div><div id='" + this.id + "_bottom' style='width:100%;height:50%;position:absolute;top:50%;left:0%'>");
61 sb.append (this.right.getComponents ()[0].toHTML ());
62 sb.append ("</div></div>\n");
63 return sb.toString ();
64 });
65 Clazz.defineStatics (c$,
66 "HORIZONTAL_SPLIT", 1);
67 });