Revision: 4592 http://sourceforge.net/p/vexi/code/4592 Author: clrg Date: 2013-11-21 14:41:09 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Box redirect properties extended to: - text properties: font, fontsize, text, textcolor - child control: align, layout, orient
Modified Paths: -------------- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Constants.java branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/TestBox.java branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/redirect.t Modified: branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Constants.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Constants.java 2013-11-21 14:33:24 UTC (rev 4591) +++ branches/vexi4c/org.vexi-core.main/src/main/java/org/vexi/core/Constants.java 2013-11-21 14:41:09 UTC (rev 4592) @@ -6,6 +6,7 @@ public interface Constants extends org.ibex.js.Constants { static final JS SC_0 = JSU.S("0",true); static final JS SC_add = JSU.S("add",true); + static final JS SC_align = JSU.S("align",true); static final JS SC_align_topleft = JSU.S("topleft",true); static final JS SC_align_top = JSU.S("top",true); static final JS SC_align_topright = JSU.S("topright",true); @@ -38,7 +39,9 @@ static final JS SC_hshrink = JSU.S("hshrink",true); static final JS SC_html = JSU.S("html",true); static final JS SC_indexof = JSU.S("indexof",true); + static final JS SC_orient = JSU.S("orient",true); static final JS SC_layer = JSU.S("layer",true); + static final JS SC_layout = JSU.S("layout",true); static final JS SC_maxheight = JSU.S("maxheight",true); static final JS SC_maxwidth = JSU.S("maxwidth",true); static final JS SC_minheight = JSU.S("minheight",true); @@ -52,6 +55,8 @@ static final JS SC_stringify = JSU.S("stringify",true); static final JS SC_subComponents = JSU.S("subComponents",true); static final JS SC_surface = JSU.S("surface",true); + static final JS SC_text = JSU.S("text",true); + static final JS SC_textcolor = JSU.S("textcolor",true); static final JS SC_thisobj = JSU.S("thisobj",true); static final JS SC_vertical = JSU.S("vertical",true); static final JS SC_visible = JSU.S("visible",true); Modified: branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp =================================================================== --- branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2013-11-21 14:33:24 UTC (rev 4591) +++ branches/vexi4c/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2013-11-21 14:41:09 UTC (rev 4592) @@ -1782,7 +1782,7 @@ case "path": if (path != null) return JSU.S(path.toString()); String ret = ""; - for(int i=0; i<visual.str.length(); i++) ret += font.glyphs[visual.str.charAt(i)].path; + for(int i=0; i<visual.text.length(); i++) ret += font.glyphs[visual.text.charAt(i)].path; return JSU.S(ret); case "strokecolor": return JSU.S(Color.colorToString(strokecolor)); case "strokewidth": return JSU.N(strokewidth); @@ -1833,7 +1833,10 @@ * @initial_value(vexi.ui.font.vera) * @nofollow * */ - case "font": return visual.font.stream; + case "font": + if (redirect == null) return null; + if (redirect == this) return visual.font.stream; + return redirect.getAndTriggerTraps(SC_font); /* <p>The size, either in points or relative size, to render the text.</p> * @@ -1854,7 +1857,10 @@ * @type(Number) * @initial_value("medium") * */ - case "fontsize": return BoxVisual.sizeToJS(visual.fontsize); + case "fontsize": + if (redirect == null) return null; + if (redirect == this) return BoxVisual.sizeToJS(visual.fontsize); + return redirect.getAndTriggerTraps(SC_fontsize); /* <p>The text of a box. Visually <code>null</code> renders the same as the text to "" * (i.e as nothing).</p> @@ -1863,7 +1869,10 @@ * @type(String) * @nofollow * */ - case "text": return visual.text; + case "text": + if (redirect == null) return null; + if (redirect == this) return visual.text; + return redirect.getAndTriggerTraps(SC_text); /* <p>If the value is a 5-character hex string (#RGB), 7-character hex string (#RRGGBB), * 9-character hex string (#AARRGGBB), a box's text color will be set to that color.</p> @@ -1877,7 +1886,10 @@ * @initial_value("#ffffff") * @type(String) * */ - case "textcolor": return JSU.S(Color.colorToString(visual.textcolor)); + case "textcolor": + if (redirect == null) return null; + if (redirect == this) return JSU.S(Color.colorToString(visual.textcolor)); + return redirect.getAndTriggerTraps(SC_textcolor); /* <p>This property can be set to any of the values specified for textcolor. If the value * written is a stream then it will interpreted as a PNG, GIF, or JPEG image, which will @@ -1913,6 +1925,30 @@ * @type(Box) */ //also "<em>numeric properties</em>": + + /* <p>Determines a box's alignment point. This affects the position of:</p> + * + * <div class="itemizedlist"><ul type="disc"> + * <li>the box's textual content</li> + * <li>a tiled texture</li> + * <li>children within the space allocated to them by the layout method of the box</li> + * </ul></div> + * + * <p>Valid values are:</p> + * + * <ul><li><code>"center"</code>, <code>"left"</code>, <code>"right"</code>, <code>"top"</code>, <code>"bottom"</code>, + * <code>"bottomleft"</code>, <code>"bottomright"</code>, <code>"topleft"</code>, <code>"topright"</code></li></ul> + * + * <p>If this box has a redirect, it will return the align of the redirect. + * If redirect is set to null, it will return null.</p> + * + * @type(String) + * @initial_value("center") + * */ + case "align": + if (redirect == null) return null; + if (redirect == this) return alignToJS(); + return redirect.getAndTriggerTraps(SC_align); /* <p>The layout strategy for a box - how it lays out it's children.</p> * @@ -1928,13 +1964,22 @@ * <p>Layered children behaved like placed children, only the parent box will respect * the contentsizes of it's children.</p> * + * <p>If this box has a redirect, it will return the layout of the redirect. + * If redirect is set to null, it will return null.</p> + * * @type(String) * @initial_value("pack") * */ - case "layout": return test(PACK) ? SC_pack : (test(CLIP) ? SC_place : SC_layer); + case "layout": + if (redirect == null) return null; + if (redirect == this) return test(PACK) ? SC_pack : (test(CLIP) ? SC_place : SC_layer); + return redirect.getAndTriggerTraps(SC_layout); /* <p><em>Read only</em> reflecting the number of children a box has.</p> * + * <p>If this box has a redirect, it will return the number of children of the + * redirect. If redirect is set to null, it will return 0.</p> + * * @initial_value(varies,code=false) * @type(Number) * */ @@ -1946,10 +1991,16 @@ /* <p>The direction the children are layed out in the box when <code>layout="pack"</code>. * Valid values are <code>"horizontal"</code> or <code>"vertical"</code>.</p> * + * <p>If this box has a redirect, it will return the orient of the redirect. + * If redirect is set to null, it will return null.</p> + * * @type(String) * @initial_value("horizontal") * */ - case "orient": return test(ORIENT) ? SC_horizontal : SC_vertical; + case "orient": + if (redirect == null) return null; + if (redirect == this) return test(ORIENT) ? SC_horizontal : SC_vertical; + return redirect.getAndTriggerTraps(SC_orient); /* <p>Writing to this property sets a box's redirect target. Reading from this property * will return a boolean instead of the redirect target - <code>true</code> if redirect @@ -2157,24 +2208,6 @@ case "contentwidth": return JSU.N(contentwidth); case "contentheight": return JSU.N(contentheight); - /* <p>Determines a box's alignment point. This affects the position of:</p> - * - * <div class="itemizedlist"><ul type="disc"> - * <li>the box's textual content</li> - * <li>a tiled texture</li> - * <li>children within the space allocated to them by the layout method of the box</li> - * </ul></div> - * - * <p>Valid values are:</p> - * - * <ul><li><code>"center"</code>, <code>"left"</code>, <code>"right"</code>, <code>"top"</code>, <code>"bottom"</code>, - * <code>"bottomleft"</code>, <code>"bottomright"</code>, <code>"topleft"</code>, <code>"topright"</code></li></ul> - * - * @type(String) - * @initial_value("center") - * */ - case "align": return alignToJS(); - /* <p>Whether to display a box and it's contents.</p> * * <p>If this box is the root box of a window, its display property will determine whether @@ -2436,6 +2469,13 @@ throw new JSExn("Attempt to put non-null value to the 'thisbox' property"); } case "font": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } // We do not convert to a fountain straight away as if it is a Blessing then // the fountain won't work as it will refer to the file/url without .ttf. For // the moment we handle Blessings separately for this reason. @@ -2457,6 +2497,13 @@ dirty(); } case "fontsize": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } if (value==null) { if (!visual.resetFontsize()) { return; @@ -2471,6 +2518,13 @@ dirty(); } case "text": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } JSString s = value == null ? null : value instanceof JSString ? (JSString)value : (JSString)JSU.S(JSU.toString(value)); if (visual.setString(s, this)) { @@ -2478,6 +2532,13 @@ dirty(); } case "textcolor": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } try { if (value==null) { if (!visual.resetTextcolor()) { @@ -2593,7 +2654,6 @@ // checks for and invokes cursor update s.processMousePosition(); } - case "align": setAlign(value); case "fill": if (value == null && visual.texture != null && test(TILE_IMAGE)) { setConstrain(); @@ -2612,7 +2672,23 @@ } } } + case "align": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } + setAlign(value); case "layout": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } if (SC_place.equals(value)) { if (!test(PACK) && test(CLIP)) { return; @@ -2641,6 +2717,13 @@ throw new JSExn("Attempt to set Box property 'layout' to unsupported value '"+JSU.toString(value)+"'"); } case "orient": + if (redirect == null) { + throw new JSExn("Attempt to set "+name+" on a box with a null redirect"); + } + if (redirect != this) { + redirect.putAndTriggerTraps(name, value); + return; + } if (SC_horizontal.equals(value)) { if (test(ORIENT)) { return; Modified: branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/TestBox.java =================================================================== --- branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/TestBox.java 2013-11-21 14:33:24 UTC (rev 4591) +++ branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/TestBox.java 2013-11-21 14:41:09 UTC (rev 4592) @@ -40,7 +40,7 @@ public static void main(String[] args) throws Throwable { CoreTestSuite cts = new CoreTestSuite(TestBox.class); - TestCase t = cts.createTestCase(cts.getResourceDirs(), "pis_method.t"); + TestCase t = cts.createTestCase(cts.getResourceDirs(), "redirect.t"); t.runBare(); } Modified: branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/redirect.t =================================================================== --- branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/redirect.t 2013-11-21 14:33:24 UTC (rev 4591) +++ branches/vexi4c/org.vexi-core.main/src/test/java/test/core/box/redirect.t 2013-11-21 14:41:09 UTC (rev 4592) @@ -10,11 +10,26 @@ b2[1] = lib..newBox("b"); b1[2] = lib..newBox("c"); b1[3] = lib..newBox("d"); + + var isEq = .util..assertEquals; - //.util..assertEquals("a",b2[0].text); - .util..assertEquals("b",b1[1].text); - //.util..assertEquals("c",b2[2].text); - //.util..assertEquals("d",b1[3].text); + //isEq("a",b2[0].text); + isEq("b",b1[1].text); + //isEq("c",b2[2].text); + //isEq("d",b1[3].text); + + b1.text = "foo"; + isEq(b2.text, "foo"); + b1.fontsize = 16; + isEq(b2.fontsize, 16); + //b1.font = font; + //isEq(b2.font, font); + b1.align = "top"; + isEq(b2.align, "top"); + b1.layout = "place"; + isEq(b2.layout, "place"); + b1.orient = "vertical"; + isEq(b2.orient, "vertical"); <ui:box/> </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn