JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / javajs / awt / Container.js
1 Clazz.declarePackage ("javajs.awt");\r
2 Clazz.load (["javajs.awt.Component"], "javajs.awt.Container", ["javajs.util.Lst"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.list = null;\r
5 this.cList = null;\r
6 Clazz.instantialize (this, arguments);\r
7 }, javajs.awt, "Container", javajs.awt.Component);\r
8 Clazz.defineMethod (c$, "getComponent", \r
9 function (i) {\r
10 return this.list.get (i);\r
11 }, "~N");\r
12 Clazz.defineMethod (c$, "getComponentCount", \r
13 function () {\r
14 return (this.list == null ? 0 : this.list.size ());\r
15 });\r
16 Clazz.defineMethod (c$, "getComponents", \r
17 function () {\r
18 if (this.cList == null) {\r
19 if (this.list == null) return  new Array (0);\r
20 this.cList = this.list.toArray ();\r
21 }return this.cList;\r
22 });\r
23 Clazz.defineMethod (c$, "add", \r
24 function (component) {\r
25 return this.addComponent (component);\r
26 }, "javajs.awt.Component");\r
27 Clazz.defineMethod (c$, "addComponent", \r
28 function (component) {\r
29 if (this.list == null) this.list =  new javajs.util.Lst ();\r
30 this.list.addLast (component);\r
31 this.cList = null;\r
32 component.parent = this;\r
33 return component;\r
34 }, "javajs.awt.Component");\r
35 Clazz.defineMethod (c$, "insertComponent", \r
36 function (component, index) {\r
37 if (this.list == null) return this.addComponent (component);\r
38 this.list.add (index, component);\r
39 this.cList = null;\r
40 component.parent = this;\r
41 return component;\r
42 }, "javajs.awt.Component,~N");\r
43 Clazz.defineMethod (c$, "remove", \r
44 function (i) {\r
45 var c = this.list.remove (i);\r
46 c.parent = null;\r
47 this.cList = null;\r
48 }, "~N");\r
49 Clazz.defineMethod (c$, "removeAll", \r
50 function () {\r
51 if (this.list != null) {\r
52 for (var i = this.list.size (); --i >= 0; ) this.list.get (i).parent = null;\r
53 \r
54 this.list.clear ();\r
55 }this.cList = null;\r
56 });\r
57 Clazz.defineMethod (c$, "getSubcomponentWidth", \r
58 function () {\r
59 return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentWidth () : 0);\r
60 });\r
61 Clazz.defineMethod (c$, "getSubcomponentHeight", \r
62 function () {\r
63 return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentHeight () : 0);\r
64 });\r
65 });\r