JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / javajs / awt / Component.js
1 Clazz.declarePackage ("javajs.awt");\r
2 Clazz.load (null, "javajs.awt.Component", ["javajs.util.CU"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.visible = false;\r
5 this.enabled = true;\r
6 this.text = null;\r
7 this.name = null;\r
8 this.width = 0;\r
9 this.height = 0;\r
10 this.id = null;\r
11 this.parent = null;\r
12 this.mouseListener = null;\r
13 this.bgcolor = null;\r
14 this.minWidth = 30;\r
15 this.minHeight = 30;\r
16 this.renderWidth = 0;\r
17 this.renderHeight = 0;\r
18 Clazz.instantialize (this, arguments);\r
19 }, javajs.awt, "Component");\r
20 Clazz.defineMethod (c$, "setParent", \r
21 function (p) {\r
22 this.parent = p;\r
23 }, "~O");\r
24 Clazz.makeConstructor (c$, \r
25 function (type) {\r
26 this.id = javajs.awt.Component.newID (type);\r
27 if (type == null) return;\r
28 {\r
29 SwingController.register(this, type);\r
30 }}, "~S");\r
31 c$.newID = Clazz.defineMethod (c$, "newID", \r
32 function (type) {\r
33 return type + ("" + Math.random ()).substring (3, 10);\r
34 }, "~S");\r
35 Clazz.defineMethod (c$, "setBackground", \r
36 function (color) {\r
37 this.bgcolor = color;\r
38 }, "javajs.api.GenericColor");\r
39 Clazz.defineMethod (c$, "setText", \r
40 function (text) {\r
41 this.text = text;\r
42 {\r
43 SwingController.setText(this);\r
44 }}, "~S");\r
45 Clazz.defineMethod (c$, "setName", \r
46 function (name) {\r
47 this.name = name;\r
48 }, "~S");\r
49 Clazz.defineMethod (c$, "getName", \r
50 function () {\r
51 return this.name;\r
52 });\r
53 Clazz.defineMethod (c$, "getParent", \r
54 function () {\r
55 return this.parent;\r
56 });\r
57 Clazz.defineMethod (c$, "setPreferredSize", \r
58 function (dimension) {\r
59 this.width = dimension.width;\r
60 this.height = dimension.height;\r
61 }, "javajs.awt.Dimension");\r
62 Clazz.defineMethod (c$, "addMouseListener", \r
63 function (listener) {\r
64 this.mouseListener = listener;\r
65 }, "~O");\r
66 Clazz.defineMethod (c$, "getText", \r
67 function () {\r
68 return this.text;\r
69 });\r
70 Clazz.defineMethod (c$, "isEnabled", \r
71 function () {\r
72 return this.enabled;\r
73 });\r
74 Clazz.defineMethod (c$, "setEnabled", \r
75 function (enabled) {\r
76 this.enabled = enabled;\r
77 {\r
78 SwingController.setEnabled(this);\r
79 }}, "~B");\r
80 Clazz.defineMethod (c$, "isVisible", \r
81 function () {\r
82 return this.visible;\r
83 });\r
84 Clazz.defineMethod (c$, "setVisible", \r
85 function (visible) {\r
86 this.visible = visible;\r
87 {\r
88 SwingController.setVisible(this);\r
89 }}, "~B");\r
90 Clazz.defineMethod (c$, "getHeight", \r
91 function () {\r
92 return this.height;\r
93 });\r
94 Clazz.defineMethod (c$, "getWidth", \r
95 function () {\r
96 return this.width;\r
97 });\r
98 Clazz.defineMethod (c$, "setMinimumSize", \r
99 function (d) {\r
100 this.minWidth = d.width;\r
101 this.minHeight = d.height;\r
102 }, "javajs.awt.Dimension");\r
103 Clazz.defineMethod (c$, "getSubcomponentWidth", \r
104 function () {\r
105 return this.width;\r
106 });\r
107 Clazz.defineMethod (c$, "getSubcomponentHeight", \r
108 function () {\r
109 return this.height;\r
110 });\r
111 Clazz.defineMethod (c$, "getCSSstyle", \r
112 function (defaultPercentW, defaultPercentH) {\r
113 var width = (this.renderWidth > 0 ? this.renderWidth : this.getSubcomponentWidth ());\r
114 var height = (this.renderHeight > 0 ? this.renderHeight : this.getSubcomponentHeight ());\r
115 return (width > 0 ? "width:" + width + "px;" : defaultPercentW > 0 ? "width:" + defaultPercentW + "%;" : "") + (height > 0 ? "height:" + height + "px;" : defaultPercentH > 0 ? "height:" + defaultPercentH + "%;" : "") + (this.bgcolor == null ? "" : "background-color:" + javajs.util.CU.toCSSString (this.bgcolor) + ";");\r
116 }, "~N,~N");\r
117 Clazz.defineMethod (c$, "repaint", \r
118 function () {\r
119 });\r
120 });\r