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