summaryrefslogtreecommitdiffstats
path: root/ksvg/test/ecma/bbox/bbox.js
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /ksvg/test/ecma/bbox/bbox.js
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksvg/test/ecma/bbox/bbox.js')
-rw-r--r--ksvg/test/ecma/bbox/bbox.js103
1 files changed, 103 insertions, 0 deletions
diff --git a/ksvg/test/ecma/bbox/bbox.js b/ksvg/test/ecma/bbox/bbox.js
new file mode 100644
index 00000000..2d692694
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox.js
@@ -0,0 +1,103 @@
+function clear_test(evt, number)
+{
+ for(var i = 0; i < number; i++)
+ {
+ var element = evt.target.getOwnerDocument().getElementById("bbox" + (i + 1));
+ element.getParentNode().removeChild(element);
+ }
+}
+
+function bbox_loop(drawit, number)
+{
+ var doc = evt.target.getOwnerDocument();
+
+ for(var i = 0; i < number; i++)
+ {
+ var shape = doc.getElementById("test-" + i);
+ var bbox = shape.getBBox();
+
+ if(drawit == "true")
+ {
+ draw_it(doc, bbox, shape, i + 1);
+ }
+ else
+ {
+ do_string(bbox, i + 1);
+ }
+ }
+}
+
+function do_string(shape, number)
+{
+ var string = "\nShape " + number + "\nX = " + shape.x + "\nY = " + shape.y + "\nW = " + shape.width + "\nH = " + shape.height;
+ alert(string);
+}
+
+function draw_it(doc, bbox, shape, number)
+{
+ var element = doc.createElement("rect");
+ element.setAttribute("x", bbox.x);
+ element.setAttribute("y", bbox.y);
+ element.setAttribute("width", bbox.width);
+ element.setAttribute("height", bbox.height);
+ element.setAttribute("fill", "none");
+ element.setAttribute("stroke", "red");
+ element.setAttribute("stroke-width", "3");
+ element.setAttribute("id", "bbox" + number);
+
+ shape.getParentNode().appendChild(element);
+}
+
+function gen_buttons(evt, number)
+{
+ var doc = evt.target.getOwnerDocument();
+ var main = doc.getElementById("svg-root");
+
+ var aone = doc.createElement("a");
+ var atwo = doc.createElement("a");
+ var athree = doc.createElement("a");
+
+ var rect = doc.createElement("rect");
+ var text = doc.createElement("text");
+
+ aone.setAttribute("onclick", "bbox_loop('false'," + number + ")");
+
+ atwo.setAttribute("onclick", "bbox_loop('true'," + number + ")");
+ atwo.setAttribute("transform", "translate(0,22)");
+
+ athree.setAttribute("onclick", "clear_test(evt," + number + ")");
+ athree.setAttribute("transform", "translate(0,44)");
+
+ rect.setAttribute("x", "0");
+ rect.setAttribute("y", "0");
+ rect.setAttribute("width", "110");
+ rect.setAttribute("height", "20");
+
+ text.setAttribute("x", "0");
+ text.setAttribute("y", "15");
+ text.setAttribute("fill", "white");
+
+ // First button
+ aone.appendChild(rect.cloneNode(1));
+ var aonetext = text.cloneNode(1);
+ aonetext.appendChild(doc.createTextNode("Calculate bbox"));
+ aone.appendChild(aonetext);
+
+ main.appendChild(aone);
+
+ // Second button
+ atwo.appendChild(rect.cloneNode(1));
+ var atwotext = text.cloneNode(1);
+ atwotext.appendChild(doc.createTextNode("Draw bbox"));
+ atwo.appendChild(atwotext);
+
+ main.appendChild(atwo);
+
+ // Third button
+ athree.appendChild(rect.cloneNode(1));
+ var athreetext = text.cloneNode(1);
+ athreetext.appendChild(doc.createTextNode("Clear bbox drawing"));
+ athree.appendChild(athreetext);
+
+ main.appendChild(athree);
+}