| 1 | <html> |
| 2 | <head> |
| 3 | <title>Testing text</title> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | <style type="text/css"> |
| 6 | @import "../../../../dojo/resources/dojo.css"; |
| 7 | @import "../../../../dijit/tests/css/dijitTests.css"; |
| 8 | </style> |
| 9 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
| 10 | |
| 11 | <script type="text/javascript"> |
| 12 | dojo.require("dojox.gfx"); |
| 13 | dojo.require("dojox.gfx._gfxBidiSupport"); |
| 14 | |
| 15 | var ROTATION = 30; |
| 16 | |
| 17 | var surface = null, t1; |
| 18 | |
| 19 | var placeAnchor = function(surface, x, y){ |
| 20 | surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}); |
| 21 | surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}); |
| 22 | }; |
| 23 | |
| 24 | var makeText = function(surface, text, font, fill, stroke){ |
| 25 | var t = surface.createText(text); |
| 26 | if(font) t.setFont(font); |
| 27 | if(fill) t.setFill(fill); |
| 28 | if(stroke) t.setStroke(stroke); |
| 29 | placeAnchor(surface, text.x, text.y); |
| 30 | return t; |
| 31 | }; |
| 32 | |
| 33 | makeShapes = function(){ |
| 34 | surface = dojox.gfx.createSurface("test", 500, 200); |
| 35 | var m = dojox.gfx.matrix; |
| 36 | //surface.createLine({x1: 250, y1: 0, x2: 250, y2: 500}).setStroke("green"); |
| 37 | t1 = makeText(surface, {id: "t1",x: 250, y: 50, text:"Hello!", textDir:"ltr"}, |
| 38 | {family: "Times", size: "24pt"}, "black", "red") |
| 39 | .setTransform(m.rotategAt(0, 250, 50)); |
| 40 | |
| 41 | |
| 42 | } |
| 43 | |
| 44 | dojo.addOnLoad(makeShapes); |
| 45 | |
| 46 | </script> |
| 47 | </head> |
| 48 | <body> |
| 49 | <h1>dojox.gfx Text test</h1> |
| 50 | <div id="test" style="width: 500px; height: 200px;"></div> |
| 51 | |
| 52 | <label>write inside to test dojox.gfx.Text with BidiEngine</label> |
| 53 | <br> |
| 54 | <textarea id="inputF" |
| 55 | onkeyup="dealInput();" |
| 56 | >write in me to test dojox.gfx.Text with BidiEngine</textarea> |
| 57 | |
| 58 | <script> |
| 59 | function dealInput(){ |
| 60 | var v = inputF.value ? inputF.value : ""; |
| 61 | t1.setShape({text: v}); |
| 62 | } |
| 63 | </script> |
| 64 | |
| 65 | <br> |
| 66 | <input id="SHALOM" type="button" value="click on me to write a Hebrew word!" |
| 67 | onclick="t1.setShape({text:'\u05e9\u05dc\u05d5\u05dd!'}); inputF.value = '\u05e9\u05dc\u05d5\u05dd!'" |
| 68 | /> |
| 69 | |
| 70 | <br> |
| 71 | <br> |
| 72 | |
| 73 | <input id="textDirLTR" type="button" value="change textDir to 'LTR'" |
| 74 | onclick="t1.setShape({textDir:'ltr'});" |
| 75 | /> |
| 76 | <input id="textDirRTL" type="button" value="change textDir to 'RTL'" |
| 77 | onclick="t1.setShape({textDir:'rtl'});" |
| 78 | /> |
| 79 | <input id="textDirAUTO" type="button" value="change textDir to 'AUTO'" |
| 80 | onclick="t1.setShape({textDir:'auto'});" |
| 81 | /> |
| 82 | |
| 83 | </body> |
| 84 | </html> |