cabcf156e199fd4fb78787fd5562b77fc360bdf5
[jalviewjs.git] / site / j2s / swingjs / plaf / JSButtonUI.js
1 Clazz.declarePackage ("swingjs.plaf");\r
2 Clazz.load (["swingjs.plaf.JSComponentUI"], "swingjs.plaf.JSButtonUI", ["javax.swing.LookAndFeel", "$.UIManager", "javax.swing.plaf.UIResource", "swingjs.api.DOMNode", "swingjs.plaf.JSButtonListener"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.domBtn = null;\r
5 this.shiftOffset = 0;\r
6 this.defaultTextShiftOffset = 0;\r
7 Clazz.instantialize (this, arguments);\r
8 }, swingjs.plaf, "JSButtonUI", swingjs.plaf.JSComponentUI);\r
9 Clazz.overrideMethod (c$, "getDOMObject", \r
10 function () {\r
11 if (this.domNode == null) this.domBtn = this.enableNode = this.valueNode = this.domNode = this.createDOMObject ("input", this.id, ["type", "button"]);\r
12 this.setCssFont (swingjs.api.DOMNode.setAttr (this.domNode, "value", (this.c).getText ()), this.c.getFont ());\r
13 return this.domNode;\r
14 });\r
15 Clazz.defineMethod (c$, "verifyButtonClick", \r
16 function (isRelease) {\r
17 return true;\r
18 }, "~B");\r
19 Clazz.overrideMethod (c$, "installJSUI", \r
20 function () {\r
21 this.installDefaults (this.c);\r
22 this.installListeners (this.c);\r
23 this.installKeyboardActions (this.c);\r
24 });\r
25 Clazz.overrideMethod (c$, "uninstallJSUI", \r
26 function () {\r
27 this.uninstallKeyboardActions (this.c);\r
28 this.uninstallListeners (this.c);\r
29 });\r
30 Clazz.defineMethod (c$, "installListeners", \r
31 function (b) {\r
32 var listener =  new swingjs.plaf.JSButtonListener (b);\r
33 if (listener != null) {\r
34 b.addMouseListener (listener);\r
35 b.addMouseMotionListener (listener);\r
36 b.addFocusListener (listener);\r
37 b.addPropertyChangeListener (listener);\r
38 b.addChangeListener (listener);\r
39 }}, "javax.swing.AbstractButton");\r
40 Clazz.defineMethod (c$, "uninstallListeners", \r
41 function (b) {\r
42 var listener = this.getButtonListener (b);\r
43 if (listener != null) {\r
44 b.removeMouseListener (listener);\r
45 b.removeMouseMotionListener (listener);\r
46 b.removeFocusListener (listener);\r
47 b.removeChangeListener (listener);\r
48 b.removePropertyChangeListener (listener);\r
49 }}, "javax.swing.AbstractButton");\r
50 Clazz.defineMethod (c$, "installKeyboardActions", \r
51 function (b) {\r
52 var listener = this.getButtonListener (b);\r
53 if (listener != null) {\r
54 listener.installKeyboardActions (b);\r
55 }}, "javax.swing.AbstractButton");\r
56 Clazz.defineMethod (c$, "uninstallKeyboardActions", \r
57 function (b) {\r
58 var listener = this.getButtonListener (b);\r
59 if (listener != null) {\r
60 listener.uninstallKeyboardActions (b);\r
61 }}, "javax.swing.AbstractButton");\r
62 Clazz.defineMethod (c$, "getButtonListener", \r
63 function (b) {\r
64 var listeners = b.getMouseMotionListeners ();\r
65 if (listeners != null) {\r
66 for (var counter = 0; counter < listeners.length; counter++) {\r
67 if (Clazz.instanceOf (listeners[counter], swingjs.plaf.JSButtonListener)) {\r
68 return listeners[counter];\r
69 }}\r
70 }return null;\r
71 }, "javax.swing.AbstractButton");\r
72 Clazz.defineMethod (c$, "getPropertyPrefix", \r
73 function () {\r
74 return "Button.";\r
75 });\r
76 Clazz.defineMethod (c$, "installDefaults", \r
77 function (b) {\r
78 var pp = this.getPropertyPrefix ();\r
79 this.defaultTextShiftOffset = javax.swing.UIManager.getInt (pp + "textShiftOffset");\r
80 if (b.getMargin () == null || (Clazz.instanceOf (b.getMargin (), javax.swing.plaf.UIResource))) {\r
81 b.setMargin (javax.swing.UIManager.getInsets (pp + "margin"));\r
82 }javax.swing.LookAndFeel.installColorsAndFont (b, pp + "background", pp + "foreground", pp + "font");\r
83 javax.swing.LookAndFeel.installProperty (b, "iconTextGap",  new Integer (4));\r
84 }, "javax.swing.AbstractButton");\r
85 });\r