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
12 this.mouseListener = null;
\r
13 this.bgcolor = null;
\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
24 Clazz.makeConstructor (c$,
\r
26 this.id = javajs.awt.Component.newID (type);
\r
27 if (type == null) return;
\r
29 SwingController.register(this, type);
\r
31 c$.newID = Clazz.defineMethod (c$, "newID",
\r
33 return type + ("" + Math.random ()).substring (3, 10);
\r
35 Clazz.defineMethod (c$, "setBackground",
\r
37 this.bgcolor = color;
\r
38 }, "javajs.api.GenericColor");
\r
39 Clazz.defineMethod (c$, "setText",
\r
43 SwingController.setText(this);
\r
45 Clazz.defineMethod (c$, "setName",
\r
49 Clazz.defineMethod (c$, "getName",
\r
53 Clazz.defineMethod (c$, "getParent",
\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
66 Clazz.defineMethod (c$, "getText",
\r
70 Clazz.defineMethod (c$, "isEnabled",
\r
72 return this.enabled;
\r
74 Clazz.defineMethod (c$, "setEnabled",
\r
75 function (enabled) {
\r
76 this.enabled = enabled;
\r
78 SwingController.setEnabled(this);
\r
80 Clazz.defineMethod (c$, "isVisible",
\r
82 return this.visible;
\r
84 Clazz.defineMethod (c$, "setVisible",
\r
85 function (visible) {
\r
86 this.visible = visible;
\r
88 SwingController.setVisible(this);
\r
90 Clazz.defineMethod (c$, "getHeight",
\r
94 Clazz.defineMethod (c$, "getWidth",
\r
98 Clazz.defineMethod (c$, "setMinimumSize",
\r
100 this.minWidth = d.width;
\r
101 this.minHeight = d.height;
\r
102 }, "javajs.awt.Dimension");
\r
103 Clazz.defineMethod (c$, "getSubcomponentWidth",
\r
107 Clazz.defineMethod (c$, "getSubcomponentHeight",
\r
109 return this.height;
\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
117 Clazz.defineMethod (c$, "repaint",
\r