JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / javajs / swing / JDialog.js
1 Clazz.declarePackage ("javajs.swing");\r
2 Clazz.load (["javajs.awt.Container"], "javajs.swing.JDialog", ["javajs.awt.Color", "javajs.swing.JContentPane", "javajs.util.SB"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.defaultWidth = 600;\r
5 this.defaultHeight = 300;\r
6 this.contentPane = null;\r
7 this.title = null;\r
8 this.html = null;\r
9 this.zIndex = 9000;\r
10 this.loc = null;\r
11 Clazz.instantialize (this, arguments);\r
12 }, javajs.swing, "JDialog", javajs.awt.Container);\r
13 Clazz.defineMethod (c$, "setZIndex", \r
14 function (zIndex) {\r
15 this.zIndex = zIndex;\r
16 }, "~N");\r
17 Clazz.makeConstructor (c$, \r
18 function () {\r
19 Clazz.superConstructor (this, javajs.swing.JDialog, ["JD"]);\r
20 this.add (this.contentPane =  new javajs.swing.JContentPane ());\r
21 this.setBackground (javajs.awt.Color.get3 (210, 210, 240));\r
22 this.contentPane.setBackground (javajs.awt.Color.get3 (230, 230, 230));\r
23 });\r
24 Clazz.defineMethod (c$, "setLocation", \r
25 function (loc) {\r
26 this.loc = loc;\r
27 }, "~A");\r
28 Clazz.defineMethod (c$, "getContentPane", \r
29 function () {\r
30 return this.contentPane;\r
31 });\r
32 Clazz.defineMethod (c$, "setTitle", \r
33 function (title) {\r
34 this.title = title;\r
35 }, "~S");\r
36 Clazz.defineMethod (c$, "pack", \r
37 function () {\r
38 this.html = null;\r
39 });\r
40 Clazz.defineMethod (c$, "validate", \r
41 function () {\r
42 this.html = null;\r
43 });\r
44 Clazz.defineMethod (c$, "setVisible", \r
45 function (tf) {\r
46 if (tf && this.html == null) this.setDialog ();\r
47 Clazz.superCall (this, javajs.swing.JDialog, "setVisible", [tf]);\r
48 }, "~B");\r
49 Clazz.defineMethod (c$, "dispose", \r
50 function () {\r
51 {\r
52 {\r
53 SwingController.dispose(this);\r
54 }}});\r
55 Clazz.overrideMethod (c$, "repaint", \r
56 function () {\r
57 this.setDialog ();\r
58 });\r
59 Clazz.defineMethod (c$, "setDialog", \r
60 ($fz = function () {\r
61 this.html = this.toHTML ();\r
62 {\r
63 SwingController.setDialog(this);\r
64 }}, $fz.isPrivate = true, $fz));\r
65 Clazz.overrideMethod (c$, "toHTML", \r
66 function () {\r
67 this.renderWidth = this.getSubcomponentWidth ();\r
68 if (this.renderWidth == 0) this.renderWidth = this.defaultWidth;\r
69 this.renderHeight = this.contentPane.getSubcomponentHeight ();\r
70 if (this.renderHeight == 0) this.renderHeight = this.defaultHeight;\r
71 var h = this.renderHeight - 25;\r
72 var sb =  new javajs.util.SB ();\r
73 sb.append ("\n<div id='" + this.id + "' class='JDialog' style='" + this.getCSSstyle (0, 0) + "z-index:" + this.zIndex + ";position:relative;top:0px;left:0px;reize:both;'>\n");\r
74 sb.append ("\n<div id='" + this.id + "_title' class='JDialogTitle' style='width:100%;height:25px;padding:5px 5px 5px 5px;height:" + 25 + "px'>" + "<span style='text-align:center;'>" + this.title + "</span><span style='position:absolute;text-align:right;right:1px;'>" + "<input type=button id='" + this.id + "_closer' onclick='SwingController.windowClosing(this)' value='x' /></span></div>\n");\r
75 sb.append ("\n<div id='" + this.id + "_body' class='JDialogBody' style='width:100%;height:" + h + "px;" + "position: relative;left:0px;top:0px'>\n");\r
76 sb.append (this.contentPane.toHTML ());\r
77 sb.append ("\n</div></div>\n");\r
78 return sb.toString ();\r
79 });\r
80 Clazz.defineStatics (c$,\r
81 "headerHeight", 25);\r
82 });\r