[seam-commits] Seam SVN: r11435 - in sandbox/trunk/modules/xwidgets: src/main/javascript and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Aug 26 18:51:54 EDT 2009
Author: shane.bryzak at jboss.com
Date: 2009-08-26 18:51:54 -0400 (Wed, 26 Aug 2009)
New Revision: 11435
Added:
sandbox/trunk/modules/xwidgets/examples/helloworld/helloworld.xw
Removed:
sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw
Modified:
sandbox/trunk/modules/xwidgets/examples/helloworld/index.html
sandbox/trunk/modules/xwidgets/examples/helloworld/xw.Panel.js
sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js
sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
Log:
BorderLayout refinements
Added: sandbox/trunk/modules/xwidgets/examples/helloworld/helloworld.xw
===================================================================
--- sandbox/trunk/modules/xwidgets/examples/helloworld/helloworld.xw (rev 0)
+++ sandbox/trunk/modules/xwidgets/examples/helloworld/helloworld.xw 2009-08-26 22:51:54 UTC (rev 11435)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<view xmlns="http://jboss.com/products/xwidgets">
+ <panel align="client">
+ <label value="Hello World!"/>
+
+ <button value="Click me!">
+ <event type="onclick">
+ <action type="script">
+ <![CDATA[alert("Hi there!");]]>
+ </action>
+ </event>
+ </button>
+ </panel>
+</view>
Modified: sandbox/trunk/modules/xwidgets/examples/helloworld/index.html
===================================================================
--- sandbox/trunk/modules/xwidgets/examples/helloworld/index.html 2009-08-26 21:51:22 UTC (rev 11434)
+++ sandbox/trunk/modules/xwidgets/examples/helloworld/index.html 2009-08-26 22:51:54 UTC (rev 11435)
@@ -2,7 +2,7 @@
<body style="background-color:#eeeeee">
<h1>Hello World Example</h1>
- <div id="container" style="border:1px solid black;width:50%;height:50%"></div>
+ <div id="container" style="border:1px solid black;width:75%;height:75%"></div>
<script src="../../src/main/javascript/xw.js"></script>
@@ -11,7 +11,7 @@
// because of browser security restrictions
//xw.setResourceBase("../../src/main/javascript");
- xw.openView("test.xw", "container");
+ xw.openView("helloworld.xw", "container");
</script>
</body>
</html>
Deleted: sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw
===================================================================
--- sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw 2009-08-26 21:51:22 UTC (rev 11434)
+++ sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw 2009-08-26 22:51:54 UTC (rev 11435)
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<view xmlns="http://jboss.com/products/xwidgets">
- <panel align="top" height="100">
- <label value="Hello World!"/>
-
- <button value="Click me!">
- <event type="onclick">
- <action type="script">
- <![CDATA[alert("Hi there!");]]>
- </action>
- </event>
- </button>
- </panel>
- <panel align="right" width="100">
- <label value="right"/>
- </panel>
-
- <panel align="bottom" height="30">
- <label value="bottom"/>
- </panel>
-
- <panel align="left" width="40">
- <label value="left"/>
- </panel>
-
- <panel align="left" width="40">
- <label value="left2"/>
- </panel>
-
- <panel align="client">
- <label value="client"/>
- </panel>
-</view>
Modified: sandbox/trunk/modules/xwidgets/examples/helloworld/xw.Panel.js
===================================================================
--- sandbox/trunk/modules/xwidgets/examples/helloworld/xw.Panel.js 2009-08-26 21:51:22 UTC (rev 11434)
+++ sandbox/trunk/modules/xwidgets/examples/helloworld/xw.Panel.js 2009-08-26 22:51:54 UTC (rev 11435)
@@ -6,7 +6,7 @@
this.height = 100;
this.parent = null;
this.control = null;
- this.align = null;
+ this.align = null;
xw.controls.Panel.prototype.setParent = function(parent)
{
@@ -34,7 +34,9 @@
{
this.control = document.createElement("div");
this.control.widget = this;
- this.control.style.backgroundColor = "#ece9d6";
+ this.control.style.backgroundColor = "#ece9d6";
+
+ // TODO make the border more configurable (or allow it to be turned off etc)
this.control.style.borderTop = "1px solid white";
this.control.style.borderLeft = "1px solid white";
this.control.style.borderBottom = "1px solid #555555";
@@ -53,7 +55,7 @@
this.parent.control.appendChild(this.control);
}
-
+
for (var i = 0; i < this.children.length; i++)
{
this.children[i].paint();
Modified: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js 2009-08-26 21:51:22 UTC (rev 11434)
+++ sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js 2009-08-26 22:51:54 UTC (rev 11435)
@@ -6,7 +6,7 @@
this.height = 100;
this.parent = null;
this.control = null;
- this.align = null;
+ this.align = null;
xw.controls.Panel.prototype.setParent = function(parent)
{
@@ -28,44 +28,32 @@
this.height = height;
}
- xw.controls.Panel.prototype.paint = function()
+ xw.controls.Panel.prototype.paint = function(layout)
{
if (this.control == null)
{
this.control = document.createElement("div");
- this.control.widget = this;
- this.parent.control.appendChild(this.control);
+ this.control.widget = this;
+ this.control.style.backgroundColor = "#ece9d6";
- if (this.align == "top")
+ // TODO make the border more configurable (or allow it to be turned off etc)
+ this.control.style.borderTop = "1px solid white";
+ this.control.style.borderLeft = "1px solid white";
+ this.control.style.borderBottom = "1px solid #555555";
+ this.control.style.borderRight = "1px solid #555555";
+
+ if (layout != null)
{
- this.control.style.float = "top";
- this.control.style.height = this.height;
+ layout.setBounds(this);
}
- else if (this.align = "bottom")
+ else
{
- this.control.style.float = "bottom";
- this.control.style.height = this.height;
- }
- else if (this.align = "left")
- {
- this.control.style.float = "left";
this.control.style.width = this.width;
+ this.control.style.height = this.height;
+ this.control.style.display = "inline";
}
- else if (this.align = "right")
- {
- this.control.style.float = "right";
- this.control.style.width = this.width;
- }
- else if (this.align = "client")
- {
- this.control.style.height = "100%";
- }
-
- this.control.style.backgroundColor = "#ece9d6";
- this.control.style.borderTop = "1px solid white";
- this.control.style.borderLeft = "1px solid white";
- this.control.style.borderBottom = "1px solid #555555";
- this.control.style.borderRight = "1px solid #555555";
+
+ this.parent.control.appendChild(this.control);
}
for (var i = 0; i < this.children.length; i++)
Modified: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js 2009-08-26 21:51:22 UTC (rev 11434)
+++ sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js 2009-08-26 22:51:54 UTC (rev 11435)
@@ -74,7 +74,7 @@
}
};
- req.open("GET", url, true);
+ req.open("GET", url, true);
req.send(null);
}
@@ -116,6 +116,23 @@
}
}
+xw.Sys.getStyle = function(element, cssRule)
+{
+ var strValue = "";
+ if (document.defaultView && document.defaultView.getComputedStyle)
+ {
+ strValue = document.defaultView.getComputedStyle(element, "").getPropertyValue(cssRule);
+ }
+ else if (element.currentStyle)
+ {
+ cssRule = cssRule.replace(/\-(\w)/g, function (strMatch, p1){
+ return p1.toUpperCase();
+ });
+ strValue = element.currentStyle[cssRule];
+ }
+ return strValue;
+}
+
/**
* A Map implementation
*/
@@ -503,12 +520,20 @@
}
xw.Bounds.prototype.applyToControl = function(control)
- {
- if (this.height != null) control.style.height = this.height;
- if (this.width != null) control.style.width = this.width;
- if (this.height != null) control.style.height = this.height;
- if (this.width != null) control.style.width = this.width;
- for (var i in this.style) control.style[i] = this.style[i];
+ {
+ if (this.left != null) control.style.left = this.left;
+ if (this.top != null) control.style.top = this.top;
+
+ for (var i in this.style) control.style[i] = this.style[i];
+
+ var hWidth = parseInt(xw.Sys.getStyle(control, "border-left-width")) +
+ parseInt(xw.Sys.getStyle(control, "border-right-width"));
+ var vWidth = parseInt(xw.Sys.getStyle(control, "border-top-width")) +
+ parseInt(xw.Sys.getStyle(control, "border-bottom-width"));
+
+ if (this.height != null) control.style.height = this.height - vWidth;
+ if (this.width != null) control.style.width = this.width - hWidth;
+
}
}
@@ -542,9 +567,7 @@
var bottomSpace = 0;
var leftSpace = 0;
var rightSpace = 0;
-
- // TODO - take border widths into account so we don't need all the +2's everywhere
-
+
for (var i = 0; i < topControls.length; i++)
{
this.bounds.put(topControls[i], new xw.Bounds(null, null, topControls[i].height, null)
@@ -571,9 +594,9 @@
{
this.bounds.put(leftControls[i], new xw.Bounds(null, null, null, leftControls[i].width)
.addStyleProperty("position", "absolute")
- .addStyleProperty("left", leftSpace + (leftSpace > 0 ? 2 : 0))
- .addStyleProperty("top", topSpace + 2)
- .addStyleProperty("bottom", bottomSpace + 2)
+ .addStyleProperty("left", leftSpace)
+ .addStyleProperty("top", topSpace)
+ .addStyleProperty("bottom", bottomSpace)
);
leftSpace += 1.0 * leftControls[i].width;
}
@@ -583,8 +606,8 @@
this.bounds.put(rightControls[i], new xw.Bounds(null, null, null, rightControls[i].width)
.addStyleProperty("position", "absolute")
.addStyleProperty("right", rightSpace)
- .addStyleProperty("top", topSpace + 2)
- .addStyleProperty("bottom", bottomSpace + 2)
+ .addStyleProperty("top", topSpace)
+ .addStyleProperty("bottom", bottomSpace)
);
rightSpace += 1.0 * rightControls[i].width;
}
@@ -593,10 +616,10 @@
{
this.bounds.put(clientControls[i], new xw.Bounds(null, null, null, null)
.addStyleProperty("position", "absolute")
- .addStyleProperty("left", leftSpace + 4)
- .addStyleProperty("right", rightSpace + 2)
- .addStyleProperty("top", topSpace + 2)
- .addStyleProperty("bottom", bottomSpace + 2)
+ .addStyleProperty("left", leftSpace)
+ .addStyleProperty("right", rightSpace)
+ .addStyleProperty("top", topSpace)
+ .addStyleProperty("bottom", bottomSpace)
);
}
More information about the seam-commits
mailing list