| 1 | <html dir="rtl"> |
| 2 | <head> |
| 3 | <title>Testing textpath</title> |
| 4 | <style type="text/css"> |
| 5 | @import "../../../../../dojo/resources/dojo.css"; |
| 6 | @import "../../../../../dijit/tests/css/dijitTests.css"; |
| 7 | </style> |
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 9 | <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="isDebug: true, gfxRenderer:'silverlight'"></script> |
| 10 | <script type="text/javascript"> |
| 11 | |
| 12 | dojo.require("dojox.gfx"); |
| 13 | dojo.require("dojox.gfx._gfxBidiSupport"); |
| 14 | dojo.require("doh.runner"); |
| 15 | |
| 16 | |
| 17 | var CPD = 30, tp3, t1, t2, t3, t4, t5, t6; |
| 18 | var g1 = null, g2 = null, g3, g4; |
| 19 | |
| 20 | var surfaceLTR = null, surfaceRTL = null, surfaceAUTO = null; |
| 21 | |
| 22 | var placeAnchor = function(surface, x, y){ |
| 23 | surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}); |
| 24 | surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}); |
| 25 | }; |
| 26 | var makeText = function(surface, text, font, fill, stroke){ |
| 27 | var t = surface.createText(text); |
| 28 | if(font) t.setFont(font); |
| 29 | if(fill) t.setFill(fill); |
| 30 | if(stroke) t.setStroke(stroke); |
| 31 | placeAnchor(surface, text.x, text.y); |
| 32 | return t; |
| 33 | }; |
| 34 | |
| 35 | makeShapes = function(){ |
| 36 | var m = dojox.gfx.matrix; |
| 37 | surfaceLTR = dojox.gfx.createSurface("testLTR", 500, 170, "ltr"); |
| 38 | console.debug("surfaceLTR created"); |
| 39 | var p = surfaceLTR.createPath({}) |
| 40 | .moveTo(0, 15) |
| 41 | .setAbsoluteMode(false) |
| 42 | .curveTo(CPD, 0, 0, 0, 50, 0) |
| 43 | ; |
| 44 | console.debug("p created"); |
| 45 | g1 = surfaceLTR.createGroup(); |
| 46 | g1.setTextDir("rtl"); |
| 47 | // surfaceLTR.setTextDir("ltr"); |
| 48 | t1 = makeText(g1, {id: "t1",x: 0, y: 100, text: "1.) \u05e9\u05dc\u05d5\u05dd world!"}, |
| 49 | {family: "Times", size: "18pt"}, "black", "blue") |
| 50 | .setTransform(m.rotategAt(0, 250, 150)); |
| 51 | |
| 52 | t2 = makeText(surfaceLTR, {x: 0, y: 140, text: "1.) Hello \u05e2\u05d5\u05dc\u05dd!"}, |
| 53 | {family: "Times", size: "18pt"}, "black", "blue") |
| 54 | .setTransform(m.rotategAt(0, 250, 100)); |
| 55 | |
| 56 | surfaceRTL = dojox.gfx.createSurface("testRTL", 500, 170); |
| 57 | console.debug("surfaceRTL created"); |
| 58 | var p2 = surfaceRTL.createPath({}) |
| 59 | .moveTo(0, 15) |
| 60 | .setAbsoluteMode(false) |
| 61 | .curveTo(CPD, 0, 0, 0, 100, 0) |
| 62 | ; |
| 63 | console.debug("p2 created"); |
| 64 | tp3 = makeText(surfaceRTL, {x: 0, y: 160, text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end. "}, |
| 65 | {family: "Times", size: "18pt"}, "black", "blue") |
| 66 | .setTransform(m.rotategAt(0, 250, 100)); |
| 67 | |
| 68 | g2 = surfaceRTL.createGroup(); |
| 69 | g2.add(tp3); |
| 70 | g2.setTextDir("ltr"); |
| 71 | |
| 72 | g3 = g2.createGroup("rtl"); |
| 73 | |
| 74 | g4 = surfaceRTL.createGroup("auto"); |
| 75 | console.debug("tp3 created"); |
| 76 | |
| 77 | t3 = makeText(g3, {id: "t1",x: 0, y: 100, text: "1.) \u05e9\u05dc\u05d5\u05dd world!"}, |
| 78 | {family: "Times", size: "18pt"}, "black", "red") |
| 79 | .setTransform(m.rotategAt(0, 250, 150)); |
| 80 | |
| 81 | t4 = makeText(surfaceRTL, {x: 0, y: 140, text: "1.) Hello \u05e2\u05d5\u05dc\u05dd!"}, |
| 82 | {family: "Times", size: "18pt"}, "black", "red") |
| 83 | .setTransform(m.rotategAt(0, 250, 100)); |
| 84 | |
| 85 | surfaceAUTO = dojox.gfx.createSurface("testAUTO", 500, 170,"auto"); |
| 86 | console.debug("surfaceAUTO created"); |
| 87 | var p3 = surfaceAUTO.createPath({}) |
| 88 | .moveTo(0, 15) |
| 89 | .setAbsoluteMode(false) |
| 90 | .curveTo(CPD, 0, 0, 0, 100, 0) |
| 91 | ; |
| 92 | console.debug("p3 created"); |
| 93 | |
| 94 | t5 = makeText(surfaceAUTO, {id: "t1",x: 0, y: 100, text: "1.) \u05e9\u05dc\u05d5\u05dd world!"}, |
| 95 | {family: "Times", size: "18pt"}, "black", "red") |
| 96 | .setTransform(m.rotategAt(0, 250, 150)); |
| 97 | |
| 98 | t6 = makeText(surfaceAUTO, {x: 0, y: 140, text: "1.) Hello \u05e2\u05d5\u05dc\u05dd!"}, |
| 99 | {family: "Times", size: "18pt"}, "black", "blue") |
| 100 | .setTransform(m.rotategAt(0, 250, 100)); |
| 101 | |
| 102 | }; |
| 103 | |
| 104 | dojo.addOnLoad(function(){ |
| 105 | makeShapes(); |
| 106 | |
| 107 | |
| 108 | doh.register("Test inheritance", [ |
| 109 | function surfaces_TextDir(){ |
| 110 | doh.is("ltr", surfaceLTR.getTextDir(), "surfaceLTR.getTextDir"); |
| 111 | doh.is("rtl", surfaceRTL.getTextDir(), "surfaceRTL.getTextDir"); |
| 112 | doh.is("auto", surfaceAUTO.getTextDir(), "surfaceAUTO.getTextDir"); |
| 113 | }, |
| 114 | function groups_TextDir(){ |
| 115 | doh.is("rtl", g1.getTextDir(), "g1.getTextDir"); |
| 116 | doh.is("ltr", g2.getTextDir(), "g2.getTextDir"); |
| 117 | doh.is("rtl", g3.getTextDir(), "g3.getTextDir"); |
| 118 | doh.is("auto", g4.getTextDir(), "g4.getTextDir"); |
| 119 | }, |
| 120 | function gfxText_TextDir(){ |
| 121 | doh.is("rtl", t1.textDir, "t1.getTextDir"); |
| 122 | doh.is("ltr", t2.textDir, "t2.getTextDir"); |
| 123 | doh.is("rtl", t3.textDir, "t3.getTextDir"); |
| 124 | doh.is("rtl", t4.textDir, "t4.getTextDir"); |
| 125 | doh.is("auto", t5.textDir, "t5.getTextDir"); |
| 126 | doh.is("auto", t6.textDir, "t6.getTextDir"); |
| 127 | doh.is("ltr", tp3.textDir, "tp3.getTextDir"); |
| 128 | }, |
| 129 | function changeSurfaceRTLextDir(){ |
| 130 | surfaceRTL.setTextDir("ltr"); |
| 131 | |
| 132 | doh.is("ltr", surfaceRTL.getTextDir(), "surfaceRTL.getTextDir"); |
| 133 | |
| 134 | doh.is("ltr", g2.getTextDir(), "g2.getTextDir"); |
| 135 | doh.is("ltr", g3.getTextDir(), "g3.getTextDir"); |
| 136 | doh.is("ltr", g4.getTextDir(), "g4.getTextDir"); |
| 137 | |
| 138 | |
| 139 | doh.is("ltr", t3.textDir, "t3.getTextDir"); |
| 140 | doh.is("ltr", t4.textDir, "t4.getTextDir"); |
| 141 | |
| 142 | doh.is("ltr", tp3.textDir, "tp3.getTextDir"); |
| 143 | }, |
| 144 | function changeGroupTextDir(){ |
| 145 | // add doesn't work for silverlight because of the rawNode call. |
| 146 | // g3.add(t5); |
| 147 | // g3.add(t2); |
| 148 | |
| 149 | g2.setTextDir("rtl"); |
| 150 | |
| 151 | doh.is("rtl", g2.getTextDir(), "g2.getTextDir"); |
| 152 | // son of g2 |
| 153 | doh.is("rtl", g3.getTextDir(), "g3.getTextDir"); |
| 154 | |
| 155 | // doh.is("rtl", t2.textDir, "t2.getTextDir"); |
| 156 | doh.is("rtl", t3.textDir, "t3.getTextDir"); |
| 157 | |
| 158 | // doh.is("rtl", t5.textDir, "t5.getTextDir"); |
| 159 | } |
| 160 | ]); |
| 161 | |
| 162 | doh.run(); |
| 163 | |
| 164 | }); |
| 165 | |
| 166 | </script> |
| 167 | </head> |
| 168 | <body> |
| 169 | <h1>dojox.gfx Text on a Path test</h1> |
| 170 | <h2>LTR TextPath and Text first two are TextPath and two others are Text</h2> |
| 171 | <div id="testLTR" style="width: 500px;"></div> |
| 172 | <h2>RTL Text Path and Text first two are TextPath and two others are Text</h2> |
| 173 | <div id="testRTL" style="width: 500px;"></div> |
| 174 | <h2>AUTO Text Path and Text first two are TextPath and two others are Text</h2> |
| 175 | <div id="testAUTO" style="width: 500px;"></div> |
| 176 | |
| 177 | <p>That's all Folks!</p> |
| 178 | </body> |
| 179 | </html> |