-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin
committed
Feb 3, 2020
1 parent
814975d
commit 9190e12
Showing
38 changed files
with
1,159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (null, "JS.ButtonGroup", ["JS.Component"], function () { | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.id = null; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "ButtonGroup"); | ||
Clazz.makeConstructor (c$, | ||
function () { | ||
this.id = JS.Component.newID ("bg"); | ||
}); | ||
Clazz.defineMethod (c$, "add", | ||
function (item) { | ||
(item).htmlName = this.id; | ||
}, "J.api.SC"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Clazz.declarePackage ("JS"); | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.component = null; | ||
this.colspan = 0; | ||
this.rowspan = 0; | ||
this.textAlign = 0; | ||
this.c = null; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "Cell"); | ||
Clazz.makeConstructor (c$, | ||
function (btn, c) { | ||
this.component = btn; | ||
this.colspan = c.gridwidth; | ||
this.rowspan = c.gridheight; | ||
this.c = c; | ||
}, "JS.JComponent,JS.GridBagConstraints"); | ||
Clazz.defineMethod (c$, "toHTML", | ||
function (id) { | ||
var style = this.c.getStyle (false); | ||
return "<td id='" + id + "' " + (this.colspan < 2 ? "" : "colspan='" + this.colspan + "' ") + style + "><span " + this.c.getStyle (true) + ">" + this.component.toHTML () + "</span></td>"; | ||
}, "~S"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (["javajs.api.GenericColor"], "JS.Color", null, function () { | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.argb = 0; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "Color", null, javajs.api.GenericColor); | ||
Clazz.overrideMethod (c$, "getRGB", | ||
function () { | ||
return this.argb & 0x00FFFFFF; | ||
}); | ||
Clazz.overrideMethod (c$, "getOpacity255", | ||
function () { | ||
return ((this.argb >> 24) & 0xFF); | ||
}); | ||
Clazz.overrideMethod (c$, "setOpacity255", | ||
function (a) { | ||
this.argb = this.argb & 0xFFFFFF | ((a & 0xFF) << 24); | ||
}, "~N"); | ||
c$.get1 = Clazz.defineMethod (c$, "get1", | ||
function (rgb) { | ||
var c = new JS.Color (); | ||
c.argb = rgb | 0xFF000000; | ||
return c; | ||
}, "~N"); | ||
c$.get3 = Clazz.defineMethod (c$, "get3", | ||
function (r, g, b) { | ||
return new JS.Color ().set4 (r, g, b, 0xFF); | ||
}, "~N,~N,~N"); | ||
c$.get4 = Clazz.defineMethod (c$, "get4", | ||
function (r, g, b, a) { | ||
return new JS.Color ().set4 (r, g, b, a); | ||
}, "~N,~N,~N,~N"); | ||
Clazz.defineMethod (c$, "set4", | ||
function (r, g, b, a) { | ||
this.argb = ((a << 24) | (r << 16) | (g << 8) | b) & 0xFFFFFFFF; | ||
return this; | ||
}, "~N,~N,~N,~N"); | ||
Clazz.overrideMethod (c$, "toString", | ||
function () { | ||
var s = ("00000000" + Integer.toHexString (this.argb)); | ||
return "[0x" + s.substring (s.length - 8, s.length) + "]"; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (null, "JS.Component", ["JU.CU"], function () { | ||
c$ = Clazz.decorateAsClass (function () { | ||
this._visible = false; | ||
this.enabled = true; | ||
this.text = null; | ||
this.name = null; | ||
this.width = 0; | ||
this.height = 0; | ||
this.id = null; | ||
this.parent = null; | ||
this.mouseListener = null; | ||
this.bgcolor = null; | ||
this.minWidth = 30; | ||
this.minHeight = 30; | ||
this.renderWidth = 0; | ||
this.renderHeight = 0; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "Component"); | ||
Clazz.defineMethod (c$, "setParent", | ||
function (p) { | ||
this.parent = p; | ||
}, "~O"); | ||
Clazz.makeConstructor (c$, | ||
function (type) { | ||
this.id = JS.Component.newID (type); | ||
if (type == null) return; | ||
{ | ||
SwingController.register(this, type); | ||
}}, "~S"); | ||
c$.newID = Clazz.defineMethod (c$, "newID", | ||
function (type) { | ||
return type + ("" + Math.random ()).substring (3, 10); | ||
}, "~S"); | ||
Clazz.defineMethod (c$, "setBackground", | ||
function (color) { | ||
this.bgcolor = color; | ||
}, "javajs.api.GenericColor"); | ||
Clazz.defineMethod (c$, "setText", | ||
function (text) { | ||
this.text = text; | ||
{ | ||
SwingController.setText(this); | ||
}}, "~S"); | ||
Clazz.defineMethod (c$, "setName", | ||
function (name) { | ||
this.name = name; | ||
}, "~S"); | ||
Clazz.defineMethod (c$, "getName", | ||
function () { | ||
return this.name; | ||
}); | ||
Clazz.defineMethod (c$, "getParent", | ||
function () { | ||
return this.parent; | ||
}); | ||
Clazz.defineMethod (c$, "setPreferredSize", | ||
function (dimension) { | ||
this.width = dimension.width; | ||
this.height = dimension.height; | ||
}, "JS.Dimension"); | ||
Clazz.defineMethod (c$, "addMouseListener", | ||
function (listener) { | ||
this.mouseListener = listener; | ||
}, "~O"); | ||
Clazz.defineMethod (c$, "getText", | ||
function () { | ||
return this.text; | ||
}); | ||
Clazz.defineMethod (c$, "isEnabled", | ||
function () { | ||
return this.enabled; | ||
}); | ||
Clazz.defineMethod (c$, "setEnabled", | ||
function (enabled) { | ||
this.enabled = enabled; | ||
{ | ||
SwingController.setEnabled(this); | ||
}}, "~B"); | ||
Clazz.defineMethod (c$, "isVisible", | ||
function () { | ||
return this._visible; | ||
}); | ||
Clazz.defineMethod (c$, "setVisible", | ||
function (visible) { | ||
this._visible = visible; | ||
{ | ||
SwingController.setVisible(this); | ||
}}, "~B"); | ||
Clazz.defineMethod (c$, "getHeight", | ||
function () { | ||
return this.height; | ||
}); | ||
Clazz.defineMethod (c$, "getWidth", | ||
function () { | ||
return this.width; | ||
}); | ||
Clazz.defineMethod (c$, "setMinimumSize", | ||
function (d) { | ||
this.minWidth = d.width; | ||
this.minHeight = d.height; | ||
}, "JS.Dimension"); | ||
Clazz.defineMethod (c$, "getSubcomponentWidth", | ||
function () { | ||
return this.width; | ||
}); | ||
Clazz.defineMethod (c$, "getSubcomponentHeight", | ||
function () { | ||
return this.height; | ||
}); | ||
Clazz.defineMethod (c$, "getCSSstyle", | ||
function (defaultPercentW, defaultPercentH) { | ||
var width = (this.renderWidth > 0 ? this.renderWidth : this.getSubcomponentWidth ()); | ||
var height = (this.renderHeight > 0 ? this.renderHeight : this.getSubcomponentHeight ()); | ||
return (width > 0 ? "width:" + width + "px;" : defaultPercentW > 0 ? "width:" + defaultPercentW + "%;" : "") + (height > 0 ? "height:" + height + "px;" : defaultPercentH > 0 ? "height:" + defaultPercentH + "%;" : "") + (this.bgcolor == null ? "" : "background-color:" + JU.CU.toCSSString (this.bgcolor) + ";"); | ||
}, "~N,~N"); | ||
Clazz.defineMethod (c$, "repaint", | ||
function () { | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (["JS.Component"], "JS.Container", ["JU.Lst"], function () { | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.list = null; | ||
this.cList = null; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "Container", JS.Component); | ||
Clazz.defineMethod (c$, "getComponent", | ||
function (i) { | ||
return this.list.get (i); | ||
}, "~N"); | ||
Clazz.defineMethod (c$, "getComponentCount", | ||
function () { | ||
return (this.list == null ? 0 : this.list.size ()); | ||
}); | ||
Clazz.defineMethod (c$, "getComponents", | ||
function () { | ||
if (this.cList == null) { | ||
if (this.list == null) return new Array (0); | ||
this.cList = this.list.toArray (); | ||
}return this.cList; | ||
}); | ||
Clazz.defineMethod (c$, "add", | ||
function (component) { | ||
return this.addComponent (component); | ||
}, "JS.Component"); | ||
Clazz.defineMethod (c$, "addComponent", | ||
function (component) { | ||
if (this.list == null) this.list = new JU.Lst (); | ||
this.list.addLast (component); | ||
this.cList = null; | ||
component.parent = this; | ||
return component; | ||
}, "JS.Component"); | ||
Clazz.defineMethod (c$, "insertComponent", | ||
function (component, index) { | ||
if (this.list == null) return this.addComponent (component); | ||
this.list.add (index, component); | ||
this.cList = null; | ||
component.parent = this; | ||
return component; | ||
}, "JS.Component,~N"); | ||
Clazz.defineMethod (c$, "remove", | ||
function (i) { | ||
var c = this.list.removeItemAt (i); | ||
c.parent = null; | ||
this.cList = null; | ||
}, "~N"); | ||
Clazz.defineMethod (c$, "removeAll", | ||
function () { | ||
if (this.list != null) { | ||
for (var i = this.list.size (); --i >= 0; ) this.list.get (i).parent = null; | ||
|
||
this.list.clear (); | ||
}this.cList = null; | ||
}); | ||
Clazz.defineMethod (c$, "getSubcomponentWidth", | ||
function () { | ||
return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentWidth () : 0); | ||
}); | ||
Clazz.defineMethod (c$, "getSubcomponentHeight", | ||
function () { | ||
return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentHeight () : 0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Clazz.declarePackage ("JS"); | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.width = 0; | ||
this.height = 0; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "Dimension"); | ||
Clazz.makeConstructor (c$, | ||
function (w, h) { | ||
this.set (w, h); | ||
}, "~N,~N"); | ||
Clazz.defineMethod (c$, "set", | ||
function (w, h) { | ||
this.width = w; | ||
this.height = h; | ||
return this; | ||
}, "~N,~N"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (null, "JS.Grid", ["JU.AU", "$.SB", "JS.Cell"], function () { | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.nrows = 0; | ||
this.ncols = 0; | ||
this.grid = null; | ||
this.renderer = null; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "Grid"); | ||
Clazz.makeConstructor (c$, | ||
function (rows, cols) { | ||
this.grid = Clazz.newArray (0, 0, null); | ||
}, "~N,~N"); | ||
Clazz.defineMethod (c$, "add", | ||
function (btn, c) { | ||
if (c.gridx >= this.ncols) { | ||
this.ncols = c.gridx + 1; | ||
for (var i = 0; i < this.nrows; i++) { | ||
this.grid[i] = JU.AU.ensureLength (this.grid[i], this.ncols * 2); | ||
} | ||
}if (c.gridy >= this.nrows) { | ||
var g = new Array (c.gridy * 2 + 1); | ||
for (var i = 0; i < this.nrows; i++) g[i] = this.grid[i]; | ||
|
||
for (var i = g.length; --i >= this.nrows; ) g[i] = new Array (this.ncols * 2 + 1); | ||
|
||
this.grid = g; | ||
this.nrows = c.gridy + 1; | ||
}this.grid[c.gridy][c.gridx] = new JS.Cell (btn, c); | ||
}, "JS.JComponent,JS.GridBagConstraints"); | ||
Clazz.defineMethod (c$, "toHTML", | ||
function (id) { | ||
var sb = new JU.SB (); | ||
id += "_grid"; | ||
sb.append ("\n<table id='" + id + "' class='Grid' style='width:100%;height:100%'><tr><td style='height:20%;width:20%'></td></tr>"); | ||
for (var i = 0; i < this.nrows; i++) { | ||
var rowid = id + "_" + i; | ||
sb.append ("\n<tr id='" + rowid + "'><td></td>"); | ||
for (var j = 0; j < this.ncols; j++) if (this.grid[i][j] != null) sb.append (this.grid[i][j].toHTML (rowid + "_" + j)); | ||
|
||
sb.append ("</tr>"); | ||
} | ||
sb.append ("\n<tr><td style='height:20%;width:20%'></td></tr></table>\n"); | ||
return sb.toString (); | ||
}, "~S"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (null, "JS.GridBagConstraints", ["JS.Insets"], function () { | ||
c$ = Clazz.decorateAsClass (function () { | ||
this.gridx = 0; | ||
this.gridy = 0; | ||
this.gridwidth = 0; | ||
this.gridheight = 0; | ||
this.weightx = 0; | ||
this.weighty = 0; | ||
this.anchor = 0; | ||
this.fill = 0; | ||
this.insets = null; | ||
this.ipadx = 0; | ||
this.ipady = 0; | ||
Clazz.instantialize (this, arguments); | ||
}, JS, "GridBagConstraints"); | ||
Clazz.makeConstructor (c$, | ||
function (gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, insets, ipadx, ipady) { | ||
this.gridx = gridx; | ||
this.gridy = gridy; | ||
this.gridwidth = gridwidth; | ||
this.gridheight = gridheight; | ||
this.weightx = weightx; | ||
this.weighty = weighty; | ||
this.anchor = anchor; | ||
this.fill = fill; | ||
if (insets == null) insets = new JS.Insets (0, 0, 0, 0); | ||
this.insets = insets; | ||
this.ipadx = ipadx; | ||
this.ipady = ipady; | ||
}, "~N,~N,~N,~N,~N,~N,~N,~N,JS.Insets,~N,~N"); | ||
Clazz.defineMethod (c$, "getStyle", | ||
function (margins) { | ||
return "style='" + (margins ? "margin:" + this.insets.top + "px " + (this.ipady + this.insets.right) + "px " + this.insets.bottom + "px " + (this.ipadx + this.insets.left) + "px;" : "text-align:" + (this.anchor == 13 ? "right" : this.anchor == 17 ? "left" : "center")) + "'"; | ||
}, "~B"); | ||
Clazz.defineStatics (c$, | ||
"NONE", 0, | ||
"CENTER", 10, | ||
"WEST", 17, | ||
"EAST", 13); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.load (["JS.LayoutManager"], "JS.GridBagLayout", null, function () { | ||
c$ = Clazz.declareType (JS, "GridBagLayout", JS.LayoutManager); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.declareInterface (JS, "HTMLElement"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Clazz.declarePackage ("JS"); | ||
Clazz.declareInterface (JS, "HTMLWindowEvent"); |
Oops, something went wrong.