Revision: 4786
          http://sourceforge.net/p/vexi/code/4786
Author:   clrg
Date:     2015-04-30 22:43:10 +0000 (Thu, 30 Apr 2015)
Log Message:
-----------
Remove BoxVisual, re-integrate properties back into Box

Modified Paths:
--------------
    
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java
    
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp
    
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp

Removed Paths:
-------------
    
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/BoxVisual.java

Deleted: 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/BoxVisual.java
===================================================================
--- 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/BoxVisual.java
      2015-04-28 17:06:14 UTC (rev 4785)
+++ 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/BoxVisual.java
      2015-04-30 22:43:10 UTC (rev 4786)
@@ -1,441 +0,0 @@
-// Copyright 2000-2008 the Contributors, as shown in the revision logs.
-// Licensed under the GNU General Public License version 2 ("the License").
-// You may not use this file except in compliance with the License.
-
-package org.vexi.core;
-
-import org.ibex.js.Fountain;
-import org.ibex.js.JS;
-import org.ibex.js.JSExn;
-import org.ibex.js.JSString;
-import org.ibex.js.JSU;
-import org.vexi.graphics.Color;
-import org.vexi.graphics.Font;
-import org.vexi.graphics.Picture;
-import org.vexi.graphics.Texture;
-
-/**
- *  Amalgamates Box's visual properties for memory/runtime efficiency:
- *  - text properties font, fontsize, text, textcolor
- *  - fill properties texture, fillcolor
- **/
-final class BoxVisual implements Constants {
-
-    //////// INSTANCE PROPERTIES /////////////////////////////////////
-
-    private short flags = 0;
-    int fontsize = 0;
-    int fillcolor = DEFAULT_FILLCOLOR;
-    int textcolor = DEFAULT_COLOR;
-    short textwidth = 0;
-    short textheight = 0;
-    Font font = DEFAULT_FONT;
-    JSString text = EMPTY_STRING;
-    Texture texture = null;
-
-
-    //////// CONSTRUCTORS /////////////////////////////////////////////
-
-    /** construct default text */
-    BoxVisual() { }
-
-    /** construct new text object based on font from 'stream' of size 
'pointsize' */
-    BoxVisual(JS stream) {
-        set(FONTSTREAM_SET);
-        setFont(stream, MEDIUM_SIZE);
-    }
-
-    /** construct new text object based on font from 'stream' of size 
'pointsize' */
-    BoxVisual(int pointsize) {
-        set(FONTSIZE_SET);
-        setFont(DEFAULT_STREAM, pointsize);
-    }
-
-
-    //////// STATIC CONTENT ///////////////////////////////////////////
-
-    private static final short FILLCOLOR_SET  = 0x0001;
-    private static final short FONTCOLOR_SET  = 0x0002;
-    private static final short FONTSIZE_SET   = 0x0004;
-    private static final short FONTSTREAM_SET = 0x0008;
-
-    private static final short FONT_TRAP      = 0x0010;
-    private static final short FONTSIZE_TRAP  = 0x0020;
-
-    static int XXSMALL_OFFSET = -8;
-    static int XSMALL_OFFSET = -4;
-    static int SMALL_OFFSET = -2;
-    static int MEDIUM_SIZE = 10;
-    static int LARGE_OFFSET = 4;
-    static int XLARGE_OFFSET = 8;
-    static int XXLARGE_OFFSET = 14;
-    
-    static int DEFAULT_COLOR = 0xFF000000;
-    static int DEFAULT_FILLCOLOR = 0x00000000;
-    static Fountain DEFAULT_STREAM = Main.vera;
-    static Font DEFAULT_FONT = Font.getFont(DEFAULT_STREAM, MEDIUM_SIZE);
-    static BoxVisual DEFAULT = new BoxVisual();
-    static JSString EMPTY_STRING = (JSString) JSU.S("", true);
-    
-    static int getDefaultFontSize() { return MEDIUM_SIZE; }
-    static Fountain getDefaultStream() { return DEFAULT_STREAM; }
-    static Font getDefaultFont() { return DEFAULT_FONT; }
-
-    /** access for controlling default pointsize */
-    static boolean setDefaultPointsize(int pointsize) {
-        if (pointsize == MEDIUM_SIZE) {
-            return false;
-        }
-        MEDIUM_SIZE = pointsize;
-        DEFAULT_FONT = Font.getFont(DEFAULT_STREAM, MEDIUM_SIZE);
-        return true;
-    }
-
-    /** access for controlling default stream */
-    static boolean setDefaultStream(Fountain stream) {
-        if (stream == DEFAULT_STREAM) {
-            return false;
-        }
-        DEFAULT_STREAM = stream;
-        DEFAULT_FONT = Font.getFont(DEFAULT_STREAM, MEDIUM_SIZE);
-        return true;
-    }
-    
-    /** return appropriate JS constant for size */
-    static JS sizeToJS(int pointsize) {
-        switch (pointsize) {
-        case -3: return SC_xxsmall;
-        case -2: return SC_xsmall;
-        case -1: return SC_small;
-        case 0: return SC_medium;
-        case 1: return SC_large;
-        case 2: return SC_xlarge;
-        case 3: return SC_xxlarge;
-        default: return JSU.N(pointsize);
-        }
-    }
-
-    /** convert size represented in JS to appropriate pointsize */
-    static int jsToPointsize(JS size) throws JSExn {
-        return normalizeSize(jsToSize(size));
-    }
-    
-    /** convert size represented in JS to appropriate integer value */
-    static int jsToSize(JS size) throws JSExn {
-        if (size==null) {
-            return MEDIUM_SIZE;
-        }
-        if (size.type()==SC_number) {
-            int ps = JSU.toInt(size);
-            if (ps<6) {
-                throw new JSExn("Minimum fontsize is 6 - set to null or 
'medium' for default size");
-            }
-            return ps;
-        } else {
-            if (size.type()!=SC_string) {
-                throw new JSExn("type not applicable for fontsize: 
'"+size.type()+"'");
-            }
-        }
-        String sizeStr = JSU.toString(size);
-        try {
-            switch (sizeStr.charAt(0)) {
-            case 'm':
-                if (sizeStr.equals("medium")) {
-                    return 0;
-                }
-            case 's':
-                if (sizeStr.equals("small")) {
-                    return -1;
-                }
-            case 'l': 
-                if (sizeStr.equals("large")) {
-                    return 1;
-                }
-            case 'x':
-                if (sizeStr.charAt(1) == 'x') {
-                    if (sizeStr.equals("xxsmall")) {// || 
sizeStr.equals("xx-small")) {
-                        return -3;
-                    }
-                    if (sizeStr.equals("xxlarge")) {// || 
sizeStr.equals("xx-large")) {
-                        return 3;
-                    }
-                } else {
-                    if (sizeStr.equals("xsmall")) {// || 
sizeStr.equals("x-small")) {
-                        return -2;
-                    }
-                    if (sizeStr.equals("xlarge")) {// || 
sizeStr.equals("x-large")) {
-                        return 2;
-                    }
-                }
-            default:
-                return Integer.parseInt(sizeStr, 10);
-            }
-        } catch (Exception e) {
-            throw new JSExn("illegal fontsize: "+sizeStr+"");
-        }
-    }
-    
-    /** check/convert offset pointsize to literal pointsize */
-    static final int normalizeSize(int pointsize) {
-        if (pointsize>5) {
-            return pointsize;
-        }
-        int ps = MEDIUM_SIZE;
-        switch (pointsize) {
-        case -3: ps += XXSMALL_OFFSET; break;
-        case -2: ps += XSMALL_OFFSET; break;
-        case -1: ps += SMALL_OFFSET; break;
-        case 0: break;
-        case 1: ps += LARGE_OFFSET; break;
-        case 2: ps += XLARGE_OFFSET; break;
-        case 3: ps += XXLARGE_OFFSET; break;
-        }
-        return ps>5 ? ps : 6;
-    }
-    
-    
-    //////// HELPER FUNCTIONS /////////////////////////////////////////
-
-    // FLAGS helper functions
-    private final void set(short mask) { flags |= mask; }
-    private final void clear(short mask) { flags &= ~mask; }
-    private final boolean test(short mask) { return ((flags & mask) == mask); }
-
-    boolean activeTrapFontsize() { return test(FONTSIZE_TRAP); }
-    void clearTrapFont() { clear(FONT_TRAP); }
-    void clearTrapFontsize() { clear(FONTSIZE_TRAP); }
-    void setTrapFont(Box box) {
-        if (this == DEFAULT) {
-            BoxVisual t = new BoxVisual();
-            t.set(FONT_TRAP);
-            box.visual = t;
-        } else {
-            set(FONT_TRAP);
-        }
-    }
-    void setTrapFontsize(Box box) {
-        if (this == DEFAULT) {
-            BoxVisual t = new BoxVisual();
-            t.set(FONTSIZE_TRAP);
-            box.visual = t;
-        } else {
-            set(FONTSIZE_TRAP);
-        }
-    }
-    
-    private final void setFont(JS stream, int pointsize) {
-        if (stream == font.stream && pointsize == this.fontsize) {
-            return;
-        }
-        font = Font.getFont(stream, normalizeSize(pointsize));
-        this.fontsize = pointsize;
-        calculateDimensions();
-    }
-
-
-    //////// INSTANCE FUNCTIONS ///////////////////////////////////////
-    
-    boolean isEmpty() { return text == EMPTY_STRING; }
-    boolean isDefaultSize() { return !test(FONTSIZE_SET); }
-    boolean isDefaultColor() { return !test(FONTCOLOR_SET); }
-    boolean isDefaultStream() { return !test(FONTSTREAM_SET); }
-    
-    /** set textcolor to default color
-     * @return boolean stating if textcolor has changed */
-    boolean resetTextcolor() {
-        if (this != DEFAULT && test(FONTCOLOR_SET)) {
-            textcolor = DEFAULT_COLOR;
-            clear(FONTCOLOR_SET);
-            return true;
-        }
-        return false;
-    }
-    
-    /** set textcolor using arbitrary string, converting as necessary
-     * @return boolean stating if textcolor has changed */
-    boolean setTextcolor(JS jstextcolor, Box box) throws JSExn {
-        int c = Color.stringToColor(JSU.toString(jstextcolor));
-        return setTextcolor(c, box);
-    }
-    
-    /** set textcolor to integer value 
-     * @return boolean stating if textcolor has changed */
-    boolean setTextcolor(int textcolor, Box box) {
-        if (test(FONTCOLOR_SET) && textcolor == this.textcolor) {
-            return false;
-        }
-        if (this == DEFAULT) {
-            BoxVisual t = new BoxVisual();
-            t.set(FONTCOLOR_SET);
-            t.textcolor = textcolor;
-            box.visual = t;
-        } else {
-            set(FONTCOLOR_SET);
-            this.textcolor = textcolor;
-        }
-        return true;
-    }
-
-    /** set fillcolor to arbitrary value */
-    private boolean setFillcolor(int fillcolor, Box box) {
-        if (test(FILLCOLOR_SET) && fillcolor == this.fillcolor) {
-            return false;
-        }
-        if (this == DEFAULT) {
-            BoxVisual t = new BoxVisual();
-            t.fillcolor = fillcolor;
-            t.set(FILLCOLOR_SET);
-            box.visual = t;
-        } else {
-            set(FILLCOLOR_SET);
-            this.fillcolor = fillcolor;
-            if (texture != null) {
-                texture = null;
-            }
-        }
-        return true;
-    }
-    
-    private boolean setTexture(Texture texture, Box box) {
-        if (texture == this.texture) {
-            return false;
-        }
-        if (this == DEFAULT) {
-            BoxVisual t =  new BoxVisual();
-            t.texture = texture;
-            box.visual = t;
-        } else {
-            this.texture = texture;
-            // set fillcolor to be transparent
-            fillcolor = DEFAULT_FILLCOLOR;
-            clear(FILLCOLOR_SET);
-        }
-        return true;
-    }
-    
-    /** set the fill of a box according to 'value', converting as necessary */
-    boolean setFill(JS value, Box box) throws JSExn {
-        if (value == null) {
-            return resetFill();
-        } else if (JSU.isString(value)) {
-            // use as a hex colour value
-            int newfillcolor = Color.stringToColor(JSU.toString(value));
-            return setFillcolor(newfillcolor, box);
-        } else {
-            // stream fill - load texture
-            Picture newtex = Picture.load(value, box);
-            // REMARK - Box.run() depends on visual
-            // so we need to call setTexture() before it
-            boolean textureChanged = setTexture(newtex, box);
-            if (textureChanged && newtex.isLoaded) {
-                box.run(null);
-            }
-            return textureChanged;
-        }
-    }
-    
-    /** set fillcolor to default fillcolor */
-    boolean resetFill() {
-        if (texture==null && !test(FILLCOLOR_SET)) {
-            return false;
-        }
-        // set fillcolor to be transparent
-        fillcolor = DEFAULT_FILLCOLOR;
-        clear(FILLCOLOR_SET);
-        texture = null;
-        return true;
-    }
-
-    /** set pointsize of this text object */
-    boolean resetFontsize() {
-        if (test(FONTSIZE_SET) && this != DEFAULT) {
-            if (fontsize != MEDIUM_SIZE) {
-                setFont(font.stream, MEDIUM_SIZE);
-            }
-            clear(FONTSIZE_SET);
-            return true;
-        }
-        return false;
-    }
-    
-    /** set pointsize to arbitary value */
-    boolean setFontsize(JS jsfontsize, Box box) throws JSExn {
-        int ps = jsToSize(jsfontsize);
-        return setFontsize(ps, box);
-    }
-    boolean setFontsize(int fontsize, Box box) {
-        if (test(FONTSIZE_SET) && fontsize == this.fontsize) {
-            return false;
-        }
-        if (this == DEFAULT) {
-            box.visual = new BoxVisual(fontsize);
-        } else {
-            set(FONTSIZE_SET);
-            if (fontsize<6 || fontsize != this.fontsize) {
-                setFont(font.stream, fontsize);
-            }
-        }
-        return true;
-    }
-
-    /** set font stream of this text object */
-    boolean resetStream() {
-        if (this != DEFAULT && test(FONTSTREAM_SET)) {
-            if (font.stream != DEFAULT_STREAM) {
-                setFont(DEFAULT_STREAM, fontsize);
-            }
-            clear(FONTSTREAM_SET);
-            return true;
-        }
-        return false;
-    }
-    
-    /** set stream to arbitrary font stream */
-    boolean setStream(JS stream, Box box) {
-        if (test(FONTSTREAM_SET) && stream == font.stream) {
-            return false;
-        }
-        if (this == DEFAULT) {
-            box.visual = new BoxVisual(stream);
-        } else {
-            set(FONTSTREAM_SET);
-            setFont(stream, fontsize);
-        }
-        return true;
-    }
-
-    /** set string representing text object */
-    //void resetString() { return setString(EMPTY_STRING); }
-    boolean setString(JSString text, Box box) {
-        if (text==null) {
-            text = EMPTY_STRING;
-        }
-        if (text.equals(this.text)) {
-            return false;
-        }
-        if (this == DEFAULT) {
-            BoxVisual t = new BoxVisual();
-            box.visual = t;
-            t.text = text;
-            t.calculateDimensions();
-        } else {
-            this.text = text;
-            calculateDimensions();
-        }
-        return true;
-    }
-
-    /** establish dimensions of rendered text contents */
-    private void calculateDimensions() {
-        if (text == EMPTY_STRING) {
-            textwidth = 0;
-            textheight = 0;
-            return;
-        }
-        long textsize = font.textsize(text.toString());
-        int iwidth = (int)((textsize >>> 32) & 0xffffffff);
-        int iheight = (int)(textsize & 0xffffffffL);
-        textwidth = iwidth > Short.MAX_VALUE ? Short.MAX_VALUE : (short)iwidth;
-        textheight = iheight > Short.MAX_VALUE ? Short.MAX_VALUE : 
(short)iheight;
-    }
-}

Modified: 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java
===================================================================
--- 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java
 2015-04-28 17:06:14 UTC (rev 4785)
+++ 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java
 2015-04-30 22:43:10 UTC (rev 4786)
@@ -33,8 +33,7 @@
        private boolean antialias = true;
        
        public Canvas(){
-               visual = new BoxVisual();
-               visual.texture = this;
+               texture = this;
                // REMARK necessary otherwise box will attempt to scale the 
image
                // It is confusing because there is no tiling. In a normal
                // vexi box tile=true shrink=true will result in a box the size 
of

Modified: 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp
===================================================================
--- 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp
      2015-04-28 17:06:14 UTC (rev 4785)
+++ 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp
      2015-04-30 22:43:10 UTC (rev 4786)
@@ -18,7 +18,10 @@
 import org.ibex.util.Callable;
 import org.ibex.util.Logger;
 import org.vexi.graphics.Color;
+import org.vexi.graphics.Font;
+import org.vexi.graphics.Picture;
 import org.vexi.graphics.PixelBuffer;
+import org.vexi.graphics.Texture;
 import org.vexi.plat.Platform;
 import org.vexi.util.BasicTree;
 import org.vexi.util.Log;
@@ -164,7 +167,7 @@
     //#pragma tokens SC_ width Width WIDTH
     
     //#define PUT_BOX_FIELD(NAME,VAL,CODE,FLAG)    \
-    //  if (test(FLAG)) {\
+    //  if (trap_test(FLAG)) {\
     //      Trap _t_ = wtrap(NAME);\
     //      JSExn _e_ = prePutTriggerTrapsAndCatchExceptions(_t_, NAME, VAL);\
     //      CODE;\
@@ -172,13 +175,6 @@
     //  } else {\
     //      CODE;\
     //  }
-    
-    // check and set functions
-    //#define CHECKSET_SHORT(prop) ((short)JSU.toInt(value) != prop && (((prop 
= (short)JSU.toInt(value)) > -1) || true))
-    //#define CHECKSET_INT(prop) (JSU.toInt(value) != prop && (((prop = 
JSU.toInt(value)) > -1) || true))
-    //#define CHECKSET_FLAG(_flag) (JSU.toBoolean(value) != test(_flag) && 
((JSU.toBoolean(value) && (flags |= _flag) > 0) || ((flags &= ~_flag) > 0) || 
true))
-    //#define CHECKSET_BOOLEAN(prop) (JSU.toBoolean(value) == prop && ((prop = 
JSU.toBoolean(value)) || true))
-    //#define CHECKSET_STRING(prop) (!(value==null && prop==null) && !(value 
!= null && JSU.toString(value).equals(prop))) && (((prop = JSU.toString(value)) 
!= null) || true) 
 
 
     // Trivial Helper Methods (should be inlined) 
/////////////////////////////////////////
@@ -208,10 +204,10 @@
     private final boolean inside(int x, int y) { return test(DISPLAY) && x >= 
0 && y >= 0 && x < width && y < height; }
 
     // TRAPFLAGS helper functions
-    private final void setclear(short mask, boolean set) { if (set) set(mask); 
else clear(mask); }
-    private final void set(short mask) { trapflags |= mask; }
-    private final void clear(short mask) { trapflags &= ~mask; }
-    private final boolean test(short mask) { return ((trapflags & mask) == 
mask); }
+    private final void trap_setclear(int mask, boolean set) { if (set) 
set(mask); else clear(mask); }
+    private final void trap_set(int mask) { trapflags |= mask; }
+    private final void trap_clear(int mask) { trapflags &= ~mask; }
+    private final boolean trap_test(int mask) { return ((trapflags & mask) == 
mask); }
 
     // FLAGS helper functions
     final private void setclear(int mask, boolean set) { if (set) set(mask); 
else clear(mask); }
@@ -220,7 +216,7 @@
     final private boolean test(int mask) { return ((flags & mask) == mask); }
     
     public final int getIntFillcolor() {
-        return visual.fillcolor;
+        return fillcolor;
     }
     
     /** for Surface to set the x/y properties of the root box */
@@ -276,43 +272,93 @@
     private static final int ALIGN_BOTTOMLEFT = ALIGN_BOTTOM | ALIGN_LEFT;
     private static final int ALIGN_BOTTOMRIGHT = ALIGN_BOTTOM | ALIGN_RIGHT;
 
-    private static final int ENTER_TRAP              = 0x00100000;
-    private static final int LEAVE_TRAP              = 0x00200000;
-    private static final int _MOVE_TRAP              = 0x00400000;
-    private static final int MOVE_TRAP               = 0x00800000;
+    private static final int FILLCOLOR_SET           = 0x00100000;
+    private static final int FONTCOLOR_SET           = 0x00200000;
+    private static final int FONTSIZE_SET            = 0x00400000;
+    private static final int FONTSTREAM_SET          = 0x00800000;
+    
+    private static final int PLACE_CLEAN             = 0x01000000;
 
-    private static final int CHILDREN_READ_TRAP      = 0x01000000;
-    private static final int CHILDREN_TRAP           = 0x02000000;
-    private static final int PLACE_CLEAN             = 0x03000000;
-    private static final int RESIZE_TRAP             = 0x04000000;
+    //private static final int UNUSED                = 0x02000000 - 0x8000000;
 
-    private static final int SHRINK_TRAP             = 0x10000000;
-    private static final int HSHRINK_TRAP            = 0x20000000;
-    private static final int VSHRINK_TRAP            = 0x40000000;
+    
+    // Trap Flags 
/////////////////////////////////////////////////////////////////
 
-    //private static final int UNUSED                = 0x80000000;
+    private static final int MINWIDTH_TRAP           = 0x00000001;
+    private static final int MINHEIGHT_TRAP          = 0x00000002;
+    private static final int MAXWIDTH_TRAP           = 0x00000004;
+    private static final int MAXHEIGHT_TRAP          = 0x00000008;
 
-    private static final short MINWIDTH_TRAP         = 0x0001;
-    private static final short MINHEIGHT_TRAP        = 0x0002;
-    private static final short MAXWIDTH_TRAP         = 0x0004;
-    private static final short MAXHEIGHT_TRAP        = 0x0008;
+    private static final int WIDTH_TRAP              = 0x00000010;
+    private static final int HEIGHT_TRAP             = 0x00000020;
+    private static final int CONTENTWIDTH_TRAP       = 0x00000040;
+    private static final int CONTENTHEIGHT_TRAP      = 0x00000080;
 
-    private static final short WIDTH_TRAP            = 0x0010;
-    private static final short HEIGHT_TRAP           = 0x0020;
-    private static final short CONTENTWIDTH_TRAP     = 0x0040;
-    private static final short CONTENTHEIGHT_TRAP    = 0x0080;
+    private static final int SURFACE_READ_TRAP       = 0x00000100;
+    private static final int SURFACE_TRAP            = 0x00000200;
+    private static final int VISIBLE_READ_TRAP       = 0x00000400;
+    private static final int VISIBLE_TRAP            = 0x00000800;
 
-    private static final short SURFACE_READ_TRAP     = 0x0100;
-    private static final short SURFACE_TRAP          = 0x0200;
-    private static final short VISIBLE_READ_TRAP     = 0x0400;
-    private static final short VISIBLE_TRAP          = 0x0800;
+    private static final int X_TRAP                  = 0x00001000;
+    private static final int Y_TRAP                  = 0x00002000;
+//    private static final int FONT_TRAP               = 0x00004000;
+//    private static final int FONTSIZE_TRAP           = 0x00008000;
 
-    private static final short X_TRAP                = 0x1000;
-    private static final short Y_TRAP                = 0x2000;
-    //private static final int UNUSED                = 0x4000;
-    // NOTE: 0x8000 is not a usable value
+    private static final int ENTER_TRAP              = 0x00010000;
+    private static final int LEAVE_TRAP              = 0x00020000;
+    private static final int _MOVE_TRAP              = 0x00040000;
+    private static final int MOVE_TRAP               = 0x00080000;
 
+    private static final int CHILDREN_READ_TRAP      = 0x00100000;
+    private static final int CHILDREN_TRAP           = 0x00200000;
+    private static final int RESIZE_TRAP             = 0x00400000;
+    //private static final int UNUSED                = 0x08000000;
 
+    private static final int SHRINK_TRAP             = 0x01000000;
+    private static final int HSHRINK_TRAP            = 0x02000000;
+    private static final int VSHRINK_TRAP            = 0x04000000;
+
+    //private static final int UNUSED                = 0x08000000 - 0x8000000;
+
+    static int XXSMALL_OFFSET = -8;
+    static int XSMALL_OFFSET = -4;
+    static int SMALL_OFFSET = -2;
+    static int MEDIUM_SIZE = 10;
+    static int LARGE_OFFSET = 4;
+    static int XLARGE_OFFSET = 8;
+    static int XXLARGE_OFFSET = 14;
+    
+    static int DEFAULT_COLOR = 0xFF000000;
+    static int DEFAULT_FILLCOLOR = 0x00000000;
+    static Fountain DEFAULT_STREAM = Main.vera;
+    static Font DEFAULT_FONT = Font.getFont(DEFAULT_STREAM, MEDIUM_SIZE);
+    static JSString EMPTY_STRING = (JSString) JSU.S("", true);
+    
+    static int getDefaultFontSize() { return MEDIUM_SIZE; }
+    static Fountain getDefaultStream() { return DEFAULT_STREAM; }
+    static Font getDefaultFont() { return DEFAULT_FONT; }
+
+    /** access for controlling default pointsize */
+    static boolean setDefaultPointsize(int pointsize) {
+        if (pointsize == MEDIUM_SIZE) {
+            return false;
+        }
+        MEDIUM_SIZE = pointsize;
+        DEFAULT_FONT = Font.getFont(DEFAULT_STREAM, MEDIUM_SIZE);
+        return true;
+    }
+
+    /** access for controlling default stream */
+    static boolean setDefaultStream(Fountain stream) {
+        if (stream == DEFAULT_STREAM) {
+            return false;
+        }
+        DEFAULT_STREAM = stream;
+        DEFAULT_FONT = Font.getFont(DEFAULT_STREAM, MEDIUM_SIZE);
+        return true;
+    }
+
+
     // Box Properties 
////////////////////////////////////////////////////////////
 
     public Box() { super(ConstructorTail); }
@@ -328,10 +374,18 @@
     private Box parent = null;
     private Box redirect = this;
     private int flags = DISPLAY | REFLOW | ORIENT | TILE_IMAGE | PACK | 
PLACE_CLEAN;
-    private short trapflags = 0;
+    private int trapflags = 0;
     private BasicTree bt = null;
+    
     // rendering properties
-    BoxVisual visual = BoxVisual.DEFAULT;
+    int fontsize = 0;
+    int fillcolor = DEFAULT_FILLCOLOR;
+    int textcolor = DEFAULT_COLOR;
+    int textwidth = 0;
+    int textheight = 0;
+    Font font = DEFAULT_FONT;
+    JSString text = EMPTY_STRING;
+    Texture texture = null;
 
     // FEATURE: path support
     //private Path path = null;
@@ -356,7 +410,7 @@
     protected int y = 0;
     public int width = 0;
     public int height = 0;
-    protected int contentwidth = 0; // == min(maxwidth, max(minwidth, 
visual.textwidth, sum(child.contentwidth)))
+    protected int contentwidth = 0; // == min(maxwidth, max(minwidth, 
textwidth, sum(child.contentwidth)))
     protected int contentheight = 0;
 
 
@@ -376,7 +430,7 @@
                 return;
             }
             // get around sub-sampling of enlarged textures
-            if (cur.visual.texture != null && !cur.test(TILE_IMAGE)) {
+            if (cur.texture != null && !cur.test(TILE_IMAGE)) {
                 // REMARK: inefficient but otherwise the consistency of
                 // translating enlarged pixels to on-screen coordinates
                 // can not be guaranteed as it depends upon first
@@ -413,23 +467,24 @@
 
     /** invoked when a resource needed to render ourselves finishes loading */
     public Object run(Object o) throws JSExn {
-        if (visual.texture == null) {
+        if (texture == null) {
             // Pictures are loaded asynchronously, then the Box is scheduled.
             // It is possible that the texture has been removed inbetween,
             // not an error though it may indicate bad Vexi code.
             Log.system.debug(Box.class, "Called run() on a Box with a null 
texture");
-        } else if (visual.texture.isLoaded()) {
+        } else if (texture.isLoaded()) {
             dirty();
             // Tiled images affect contentsize
             if (test(TILE_IMAGE)) {
-               setMinWidth(visual.texture.getWidth(), true);
-               setMinHeight(visual.texture.getHeight(), true);
+               setMinWidth(texture.getWidth(), true);
+               setMinHeight(texture.getHeight(), true);
                 setConstrain();
             }
-        } else if (visual.texture.getLoadFailed()!=null) {
-            //JS res = visual.texture.stream;
-            justTriggerTraps(SC_fill, 
visual.texture.getLoadFailed().asObject());
-            visual.resetFill();
+        } else if (texture.getLoadFailed()!=null) {
+            //JS res = texture.stream;
+            justTriggerTraps(SC_fill, texture.getLoadFailed().asObject());
+            clear(FILLCOLOR_SET);
+            texture = null;
             // just in case of previous image / fill
             dirty();
             // Tiled images affect contentsize
@@ -544,15 +599,14 @@
     static protected final void reflowTreeTextSize(Box box) throws JSExn {
         box.set(CONSTRAIN_DESCENDENT);
         box.set(PLACE_DESCENDENT);
-        if (box.visual.fontsize<6) {
-            if (box.visual!=BoxVisual.DEFAULT) {
-                box.visual.resetFontsize();
-            }
-            if (box.visual.textwidth!=0) {
+        if (box.fontsize<6) {
+            // fontsize<6 are relative sizes
+            if (box.hasText()) {
                 box.set(CONSTRAIN);
                 box.set(PLACE);
+                box.dirty();
             }
-            box.justTriggerTraps(SC_fontsize, 
BoxVisual.sizeToJS(box.visual.fontsize));
+            box.justTriggerTraps(SC_fontsize, sizeToJS(box.fontsize));
         }
         int i=0;
         for (Box b = box.getChild(i); b!=null; b=box.getChild(++i)) {
@@ -611,7 +665,7 @@
         
         // REMARK: must happen after children's sizes known
         // otherwise any update is immediately invalidated
-        if (test(RESIZE_TRAP)) {
+        if (trap_test(RESIZE_TRAP)) {
                justTriggerTrapsAndCatchExceptions(SC_Resize, JSU.T);
         }
 
@@ -661,13 +715,13 @@
                 clear(HAS_WIDTH_SLACK);
             }
         } else {
-            if (new_contentwidth < maxwidth && (new_contentwidth < minwidth || 
new_contentwidth < visual.textwidth ||
-                       (visual.texture!=null && new_contentwidth < 
visual.texture.getWidth()))) {
+            if (new_contentwidth < maxwidth && (new_contentwidth < minwidth || 
new_contentwidth < textwidth ||
+                       (texture!=null && new_contentwidth < 
texture.getWidth()))) {
                 set(HAS_WIDTH_SLACK);
             } else {
                 clear(HAS_WIDTH_SLACK);
             }
-            new_contentwidth = max(new_contentwidth, visual.textwidth);
+            new_contentwidth = max(new_contentwidth, textwidth);
         }
 
         new_contentwidth = min(maxwidth, max(minwidth, new_contentwidth));
@@ -1034,19 +1088,19 @@
 
         if (parent == null) {
             // disregard transparency for root
-            buf.fillTrapezoid(cx1, cx2, cy1, cx1, cx2, cy2, 
visual.fillcolor|0xFF000000);
-        } else if ((visual.fillcolor & 0xFF000000) != 0x00000000) {
+            buf.fillTrapezoid(cx1, cx2, cy1, cx1, cx2, cy2, 
fillcolor|0xFF000000);
+        } else if ((fillcolor & 0xFF000000) != 0x00000000) {
             // normal color fill, skipping fully transparent fills
-            buf.fillTrapezoid(cx1, cx2, cy1, cx1, cx2, cy2, visual.fillcolor);
+            buf.fillTrapezoid(cx1, cx2, cy1, cx1, cx2, cy2, fillcolor);
         }
 
-        if (visual.texture != null && visual.texture.isLoaded()) {
-            int tw = visual.texture.getWidth();
-            int th = visual.texture.getHeight();
+        if (texture != null && texture.isLoaded()) {
+            int tw = texture.getWidth();
+            int th = texture.getHeight();
             if (test(TILE_IMAGE)) {
                 for (int x = globalx; x < cx2; x += tw) {
                     for (int y = globaly; y < cy2; y += th) {
-                        buf.drawPicture(visual.texture, x, y, cx1, cy1, cx2, 
cy2);
+                        buf.drawPicture(texture, x, y, cx1, cy1, cx2, cy2);
                     }
                 }
             } else {
@@ -1054,18 +1108,16 @@
                 int sy1 = (int)(th * ((float)(cy1-globaly)/height) + 0.5);
                 int sx2 = (int)(tw * ((float)(cx2-globalx)/width)  + 0.5);
                 int sy2 = (int)(th * ((float)(cy2-globaly)/height) + 0.5);
-                buf.drawPicture(visual.texture, cx1, cy1, cx2, cy2, sx1, sy1, 
sx2, sy2);
+                buf.drawPicture(texture, cx1, cy1, cx2, cy2, sx1, sy1, sx2, 
sy2);
             }
         }
         
-        // REMARK: visual.font may still be null at this point so
-        // cannot use visual.isEmpty() but instead use visual.textwidth
-        if (visual.textwidth != 0) {
-            int gap_x = width - visual.textwidth;
-            int gap_y = height - visual.textheight;
+        if (hasText()) {
+            int gap_x = width - textwidth;
+            int gap_y = height - textheight;
             int text_x = globalx + (test(ALIGN_RIGHT) ? gap_x : 
!test(ALIGN_LEFT) ? gap_x/2 : 0);
             int text_y = globaly + (test(ALIGN_BOTTOM) ? gap_y : 
!test(ALIGN_TOP) ? gap_y/2 : 0);
-            visual.font.rasterizeGlyphs(visual.text.toString(), buf, 
visual.textcolor, text_x, text_y, cx1, cy1, cx2, cy2);
+            font.rasterizeGlyphs(text.toString(), buf, textcolor, text_x, 
text_y, cx1, cy1, cx2, cy2);
         }
 
         //if (path != null) path.realize(Affine.translate(globalx, 
globaly)).stroke(buf, 1, strokecolor);
@@ -1213,7 +1265,7 @@
             parent.set(CONSTRAIN);
             parent.set(PLACE);
         }
-        if (firetraps && test(MINWIDTH_TRAP)) {
+        if (firetraps && trap_test(MINWIDTH_TRAP)) {
             Trap t = wtrap(SC_minwidth);
             if (t!=null) {
                 this.minwidth = JSU.toInt(Main.SCHEDULER.runBeforePut(t, 
JSU.N(minwidth)));
@@ -1245,7 +1297,7 @@
             parent.set(CONSTRAIN);
             parent.set(PLACE);
         }
-        if (firetraps && test(MAXWIDTH_TRAP)) {
+        if (firetraps && trap_test(MAXWIDTH_TRAP)) {
             Trap t = wtrap(SC_maxwidth);
             if (t!=null) {
                 this.maxwidth = JSU.toInt(Main.SCHEDULER.runBeforePut(t, 
JSU.N(maxwidth)));
@@ -1316,7 +1368,127 @@
         dirty();
     }
     
+    /** return appropriate JS constant for size */
+    static JS sizeToJS(int pointsize) {
+        switch (pointsize) {
+        case -3: return SC_xxsmall;
+        case -2: return SC_xsmall;
+        case -1: return SC_small;
+        case 0: return SC_medium;
+        case 1: return SC_large;
+        case 2: return SC_xlarge;
+        case 3: return SC_xxlarge;
+        default: return JSU.N(pointsize);
+        }
+    }
+
+    /** convert size represented in JS to appropriate pointsize */
+    static int jsToPointsize(JS size) throws JSExn {
+        return normalizeSize(jsToSize(size));
+    }
     
+    /** convert size represented in JS to appropriate integer value */
+    static int jsToSize(JS size) throws JSExn {
+        if (size==null) {
+            return MEDIUM_SIZE;
+        }
+        if (size.type()==SC_number) {
+            int ps = JSU.toInt(size);
+            if (ps<6) {
+                throw new JSExn("Minimum fontsize is 6 - set to null or 
'medium' for default size");
+            }
+            return ps;
+        } else {
+            if (size.type()!=SC_string) {
+                throw new JSExn("type not applicable for fontsize: 
'"+size.type()+"'");
+            }
+        }
+        String sizeStr = JSU.toString(size);
+        try {
+            switch (sizeStr.charAt(0)) {
+            case 'm':
+                if (sizeStr.equals("medium")) {
+                    return 0;
+                }
+            case 's':
+                if (sizeStr.equals("small")) {
+                    return -1;
+                }
+            case 'l': 
+                if (sizeStr.equals("large")) {
+                    return 1;
+                }
+            case 'x':
+                if (sizeStr.charAt(1) == 'x') {
+                    if (sizeStr.equals("xxsmall")) {// || 
sizeStr.equals("xx-small")) {
+                        return -3;
+                    }
+                    if (sizeStr.equals("xxlarge")) {// || 
sizeStr.equals("xx-large")) {
+                        return 3;
+                    }
+                } else {
+                    if (sizeStr.equals("xsmall")) {// || 
sizeStr.equals("x-small")) {
+                        return -2;
+                    }
+                    if (sizeStr.equals("xlarge")) {// || 
sizeStr.equals("x-large")) {
+                        return 2;
+                    }
+                }
+            default:
+                return Integer.parseInt(sizeStr, 10);
+            }
+        } catch (Exception e) {
+            throw new JSExn("illegal fontsize: "+sizeStr+"");
+        }
+    }
+    
+    /** check/convert offset pointsize to literal pointsize */
+    static final int normalizeSize(int pointsize) {
+        if (pointsize>5) {
+            return pointsize;
+        }
+        int ps = MEDIUM_SIZE;
+        switch (pointsize) {
+        case -3: ps += XXSMALL_OFFSET; break;
+        case -2: ps += XSMALL_OFFSET; break;
+        case -1: ps += SMALL_OFFSET; break;
+        case 0: break;
+        case 1: ps += LARGE_OFFSET; break;
+        case 2: ps += XLARGE_OFFSET; break;
+        case 3: ps += XXLARGE_OFFSET; break;
+        }
+        return ps>5 ? ps : 6;
+    }
+    
+    private final void setFont(JS stream, int pointsize) {
+        if (stream == font.stream && pointsize == fontsize) {
+            return;
+        }
+        font = Font.getFont(stream, normalizeSize(pointsize));
+        fontsize = pointsize;
+        textCalculateDimensions();
+    }
+
+    /** establish dimensions of rendered text contents */
+    private void textCalculateDimensions() {
+        if (text == EMPTY_STRING) {
+            textwidth = 0;
+            textheight = 0;
+            return;
+        }
+        long textsize = font.textsize(text.toString());
+        int iwidth = (int)((textsize >>> 32) & 0xffffffff);
+        int iheight = (int)(textsize & 0xffffffffL);
+        textwidth = iwidth > Short.MAX_VALUE ? Short.MAX_VALUE : (short)iwidth;
+        textheight = iheight > Short.MAX_VALUE ? Short.MAX_VALUE : 
(short)iheight;
+    }
+
+
+    //////// INSTANCE FUNCTIONS ///////////////////////////////////////
+    
+    boolean hasText() { return text != EMPTY_STRING; }
+    
+    
     // Input event handling ///////////////////////////////////////////
 
     /** initiate a move event - should only ever be invoked by surface or 
inputevent */
@@ -1329,8 +1501,8 @@
             }
             if (parent==null) {
                 // root (ONLY) gets motion events outside itself (if trapped)
-                if (!test(_MOVE_TRAP) || (Interpreter.CASCADE_PREVENTED != 
justTriggerTraps(SC__Move, JSU.T))) {
-                    if (test(MOVE_TRAP)) {
+                if (!trap_test(_MOVE_TRAP) || (Interpreter.CASCADE_PREVENTED 
!= justTriggerTraps(SC__Move, JSU.T))) {
+                    if (trap_test(MOVE_TRAP)) {
                         justTriggerTraps(SC_Move, JSU.T);
                     }
                 }
@@ -1356,7 +1528,7 @@
         if (test(MOUSEINSIDE_BLOCKED)) {
             clear(MOUSEINSIDE_BLOCKED);
         } else {
-            if (test(LEAVE_TRAP)) {
+            if (trap_test(LEAVE_TRAP)) {
                 justTriggerTraps(SC_Leave, JSU.T);
             }
         }
@@ -1371,7 +1543,7 @@
      **/
     private final boolean propagateMove(int mousex, int mousey) throws JSExn {
         // start with pre-event _Move which preceeds Enter/Leave
-        if (test(_MOVE_TRAP)) {
+        if (trap_test(_MOVE_TRAP)) {
             if (Interpreter.CASCADE_PREVENTED == justTriggerTraps(SC__Move, 
JSU.T)) {
                 // _Move cascade prevention induces Leave
                 propagateLeave();
@@ -1436,7 +1608,7 @@
                 if (!test(MOUSEINSIDE_BLOCKED)) {
                     // mouse previously inside, now blocked so invoke Leave
                     set(MOUSEINSIDE_BLOCKED);
-                    if (test(LEAVE_TRAP)) {
+                    if (trap_test(LEAVE_TRAP)) {
                         justTriggerTraps(SC_Leave, JSU.T);
                     }
                 }
@@ -1459,13 +1631,13 @@
         // fire Enter traps
         if (!test(MOUSEINSIDE)) {
             set(MOUSEINSIDE);
-            if (test(ENTER_TRAP)) {
+            if (trap_test(ENTER_TRAP)) {
                 justTriggerTraps(SC_Enter, JSU.T);
             }
         }
 
         // finish post-event Move which follows Enter/Leave
-        if (test(MOVE_TRAP)) {
+        if (trap_test(MOVE_TRAP)) {
             if (Interpreter.CASCADE_PREVENTED == justTriggerTraps(SC_Move, 
JSU.T)) {
                 // propagate cascade prevention
                 return true;
@@ -1655,8 +1827,7 @@
         // FIXME: another hack
         // we really should return a re-usable JS stream
         Box b = new Box();
-        BoxVisual r = b.visual = new BoxVisual();
-        r.texture = pb.toPicture();
+        b.texture = pb.toPicture();
         return b;
     }
  
@@ -1785,7 +1956,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<str.length(); i++) ret += 
font.glyphs[str.charAt(i)].path;
             return JSU.S(ret);
         case "strokecolor": return JSU.S(Color.colorToString(strokecolor));
         case "strokewidth": return JSU.N(strokewidth);
@@ -1823,10 +1994,10 @@
          * @type(String<br/>Stream)
          * */
         case "fill":
-            if (visual.texture == null) {
-                return JSU.S(Color.colorToString(visual.fillcolor));
+            if (texture == null) {
+                return JSU.S(Color.colorToString(fillcolor));
             }
-            return visual.texture.getStream();
+            return texture.getStream();
         
         /* <p>When an object is written to this property, its stream is read 
using the 
          * <a href="http://www.freetype.org/"; target="_top">freetype2 
library</a>, and the
@@ -1836,7 +2007,7 @@
          * @initial_value(vexi.ui.font.vera)
          * @nofollow
          * */
-        case "font": return visual.font.stream;
+        case "font": return font.stream;
         
         /* <p>The size, either in points or relative size, to render the 
text.</p>
          * 
@@ -1857,7 +2028,7 @@
          * @type(Number)
          * @initial_value("medium")
          * */
-        case "fontsize": return BoxVisual.sizeToJS(visual.fontsize);
+        case "fontsize": return sizeToJS(fontsize);
         
         /* <p>The text of a box. Visually <code>null</code> renders the same 
as the text to ""
          * (i.e as nothing).</p>
@@ -1866,7 +2037,7 @@
          * @type(String)
          * @nofollow
          * */
-        case "text": return visual.text;
+        case "text": return 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>
@@ -1880,7 +2051,7 @@
          * @initial_value("#ffffff")
          * @type(String)
          * */
-        case "textcolor": return JSU.S(Color.colorToString(visual.textcolor));
+        case "textcolor": return JSU.S(Color.colorToString(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
@@ -2449,54 +2620,72 @@
                 throw new JSExn("Attempt to put a non-stream to the 'font' 
property of a box");
             }
             if (value == null) {
-                if (!visual.resetStream()) {
-                    return;
+                if (test(FONTSTREAM_SET)) {
+                    clear(FONTSTREAM_SET);
+                    if (font.stream == DEFAULT_STREAM)
+                       return;
+                    setFont(DEFAULT_STREAM, fontsize);
                 }
             } else {
                 Fountain fontstream = (Fountain)value.unclone();
-                if (!visual.setStream(fontstream, this)) {
+                set(FONTSTREAM_SET);
+                if (fontstream == font.stream)
                     return;
-                }
+                setFont(fontstream, fontsize);
             }
-            if (!visual.isEmpty()) {
+            if (hasText()) {
                 setConstrain();
                 dirty();
             }
         case "fontsize":
             if (value==null) {
-                if (!visual.resetFontsize()) {
-                    return;
-                }
+                clear(FONTSIZE_SET);
+                if (fontsize != MEDIUM_SIZE)
+                       return;
+                setFont(font.stream, MEDIUM_SIZE);
             } else {
-                if (!visual.setFontsize(value, this)) {
+                int ps = jsToSize(value);
+                set(FONTSIZE_SET);
+                if (ps == fontsize)
                     return;
-                }
+                setFont(font.stream, ps);
             }
-            if (!visual.isEmpty()) {
+            if (hasText()) {
                 setConstrain();
                 dirty();
             }
         case "text":
             JSString s = value == null ? null :
                 value instanceof JSString ? (JSString)value : 
(JSString)JSU.S(JSU.toString(value));
-            if (visual.setString(s, this)) {
-                setConstrain();
-                dirty();
-            }
+               if (value == null || EMPTY_STRING.equals(s)) {
+                       if (text == EMPTY_STRING)
+                               return;
+                text = EMPTY_STRING;
+               } else {
+                   if (text.equals(s)) {
+                       return;
+                   }
+                   text = s;
+               }
+            textCalculateDimensions();
+            setConstrain();
+            dirty();
         case "textcolor":
             try {
                 if (value==null) {
-                    if (!visual.resetTextcolor()) {
-                        return;
-                    }
+                    clear(FONTCOLOR_SET);
+                    if (textcolor == DEFAULT_COLOR)
+                       return;
+                    textcolor = DEFAULT_COLOR;
                 } else {
-                    if (!visual.setTextcolor(value, this)) {
+                    int c = Color.stringToColor(JSU.toString(value));
+                    set(FONTCOLOR_SET);
+                    if (textcolor == c)
                         return;
-                    }
+                    textcolor = c;
                 }
-                if (!visual.isEmpty()) {
+                if (hasText())
                     dirty();
-                }
             } catch (ClassCastException cce) {
                 throw new JSExn("Attempt to put a non-string value to the 
textcolor property");
             }
@@ -2507,7 +2696,7 @@
             }
             // fire other relevant traps and set shrink flags
             if (test(HSHRINK) != set_shrink) {
-                if (test(HSHRINK_TRAP)) {
+                if (trap_test(HSHRINK_TRAP)) {
                     JS ret = justTriggerTraps(SC_hshrink, value);
                     if (ret!=Interpreter.CASCADE_PREVENTED) {
                        setclear(HSHRINK, JSU.toBoolean(ret));
@@ -2517,7 +2706,7 @@
                 }
             }
             if (test(VSHRINK) != set_shrink) {
-                if (test(VSHRINK_TRAP)) {
+                if (trap_test(VSHRINK_TRAP)) {
                     JS ret = justTriggerTraps(SC_vshrink, value);
                     if (ret!=Interpreter.CASCADE_PREVENTED) {
                        setclear(VSHRINK, JSU.toBoolean(ret));
@@ -2533,7 +2722,7 @@
                 setParentPlace();
                 setclear(HSHRINK, set_hshrink);
                 // shrink changes iff vshrink==true
-                if (test(VSHRINK) && test(SHRINK_TRAP)) {
+                if (test(VSHRINK) && trap_test(SHRINK_TRAP)) {
                     justTriggerTraps(SC_shrink, value);
                 }
             }
@@ -2543,7 +2732,7 @@
                 setParentPlace();
                 setclear(VSHRINK, set_hshrink);
                 // shrink changes iff hshrink==true
-                if (test(HSHRINK) && test(SHRINK_TRAP)) {
+                if (test(HSHRINK) && trap_test(SHRINK_TRAP)) {
                     justTriggerTraps(SC_shrink, value);
                 }
             }
@@ -2605,16 +2794,45 @@
             }
         case "align":       setAlign(value);
         case "fill":
-            if (value == null && visual.texture != null && test(TILE_IMAGE)) {
+            if (value == null && texture != null && test(TILE_IMAGE)) {
+               // other cases handled by Box.run()
                 setConstrain();
             }
-            if (visual.setFill(value, this)) {
-                dirty();
+            if (value == null) {
+               if (text == null && !test(FILLCOLOR_SET))
+                       return;
+                clear(FILLCOLOR_SET);
+                fillcolor = DEFAULT_FILLCOLOR;
+               texture = null;
+            } else if (JSU.isString(value)) {
+                // use as a hex colour value
+                int newfillcolor = Color.stringToColor(JSU.toString(value));
+                set(FILLCOLOR_SET);
+                if (newfillcolor == fillcolor && texture == null)
+                    return;
+                texture = null;
+                fillcolor = newfillcolor;
+            } else {
+                // stream fill - load texture
+                Picture newtex = Picture.load(value, this);
+                if (texture == newtex)
+                    return;
+                texture = newtex;
+                // set fillcolor to be transparent
+                fillcolor = DEFAULT_FILLCOLOR;
+                clear(FILLCOLOR_SET);
+                if (newtex.isLoaded)
+                    run(null);
             }
+            dirty();
         case "tile":
-            if (CHECKSET_FLAG(TILE_IMAGE)) {
+               boolean tile = JSU.toBoolean(value);
+            if (test(TILE_IMAGE) != tile) {
+               if (tile)
+                       set(TILE_IMAGE);
+               else clear(TILE_IMAGE);
                 dirty();
-                if (visual.texture != null && visual.texture.isLoaded()) {
+                if (texture != null && texture.isLoaded()) {
                     if (test(TILE_IMAGE)) {
                        // this will cause the Box's minimum dimensions
                        // to be set to the image dimensions when tiled
@@ -2898,36 +3116,34 @@
         // differentiate between read and write traps
         if (function.getFormalArgs().length != 1) {
             //#switch (JSU.toString(key))
-            case "surface": set(SURFACE_READ_TRAP);
-            case "visible": set(VISIBLE_READ_TRAP);
-            case "Children": set(CHILDREN_READ_TRAP);
+            case "surface": trap_set(SURFACE_READ_TRAP);
+            case "visible": trap_set(VISIBLE_READ_TRAP);
+            case "Children": trap_set(CHILDREN_READ_TRAP);
             //#end
             return;
         }
         //#switch (JSU.toString(key))
-        case "x":         set(X_TRAP);
-        case "y":         set(Y_TRAP);
-        case "width":     set(WIDTH_TRAP);
-        case "height":    set(HEIGHT_TRAP);
-        case "minwidth":  set(MINWIDTH_TRAP);
-        case "maxwidth":  set(MAXWIDTH_TRAP);
-        case "minheight": set(MINHEIGHT_TRAP);
-        case "maxheight": set(MAXHEIGHT_TRAP);
-        case "contentwidth": set(CONTENTWIDTH_TRAP);
-        case "contentheight": set(CONTENTHEIGHT_TRAP);
-        case "surface":   set(SURFACE_TRAP); 
-        case "visible":   set(VISIBLE_TRAP);
-        case "Children":  set(CHILDREN_TRAP);
-        case "Enter":     set(ENTER_TRAP);
-        case "Leave":     set(LEAVE_TRAP);
-        case "_Move":     set(_MOVE_TRAP);
-        case "Move":      set(MOVE_TRAP);
-        case "Resize":    set(RESIZE_TRAP);
-        case "fontsize":  visual.setTrapFontsize(this);
-        case "font":      visual.setTrapFont(this);
-        case "shrink":    set(SHRINK_TRAP);
-        case "hshrink":   set(HSHRINK_TRAP);
-        case "vshrink":   set(VSHRINK_TRAP);
+        case "x":         trap_set(X_TRAP);
+        case "y":         trap_set(Y_TRAP);
+        case "width":     trap_set(WIDTH_TRAP);
+        case "height":    trap_set(HEIGHT_TRAP);
+        case "minwidth":  trap_set(MINWIDTH_TRAP);
+        case "maxwidth":  trap_set(MAXWIDTH_TRAP);
+        case "minheight": trap_set(MINHEIGHT_TRAP);
+        case "maxheight": trap_set(MAXHEIGHT_TRAP);
+        case "contentwidth": trap_set(CONTENTWIDTH_TRAP);
+        case "contentheight": trap_set(CONTENTHEIGHT_TRAP);
+        case "surface":   trap_set(SURFACE_TRAP); 
+        case "visible":   trap_set(VISIBLE_TRAP);
+        case "Children":  trap_set(CHILDREN_TRAP);
+        case "Enter":     trap_set(ENTER_TRAP);
+        case "Leave":     trap_set(LEAVE_TRAP);
+        case "_Move":     trap_set(_MOVE_TRAP);
+        case "Move":      trap_set(MOVE_TRAP);
+        case "Resize":    trap_set(RESIZE_TRAP);
+        case "shrink":    trap_set(SHRINK_TRAP);
+        case "hshrink":   trap_set(HSHRINK_TRAP);
+        case "vshrink":   trap_set(VSHRINK_TRAP);
         //#end
     }
 
@@ -2938,37 +3154,35 @@
         // differentiate between read and write traps
         if (function.getFormalArgs().length != 1) {
             //#switch (JSU.toString(key))
-            case "surface": if (rtrap(SC_surface)==null) 
clear(SURFACE_READ_TRAP);
-            case "visible": if (rtrap(SC_visible)==null) 
clear(VISIBLE_READ_TRAP);
-            case "Children": if (rtrap(SC_Children)==null) 
clear(CHILDREN_READ_TRAP);
+            case "surface": if (rtrap(SC_surface)==null) 
trap_clear(SURFACE_READ_TRAP);
+            case "visible": if (rtrap(SC_visible)==null) 
trap_clear(VISIBLE_READ_TRAP);
+            case "Children": if (rtrap(SC_Children)==null) 
trap_clear(CHILDREN_READ_TRAP);
             //#end
             return;
         }
         
         //#switch (JSU.toString(key))
-        case "x":         if (wtrap(SC_x) == null) clear(X_TRAP);
-        case "y":         if (wtrap(SC_y) == null) clear(Y_TRAP);
-        case "width":     if (wtrap(SC_width) == null) clear(WIDTH_TRAP);
-        case "height":    if (wtrap(SC_height) == null) clear(HEIGHT_TRAP);
-        case "minwidth":  if (wtrap(SC_minwidth) == null) clear(MINWIDTH_TRAP);
-        case "maxwidth":  if (wtrap(SC_maxwidth) == null) clear(MAXWIDTH_TRAP);
-        case "minheight": if (wtrap(SC_minheight) == null) 
clear(MINHEIGHT_TRAP);
-        case "maxheight": if (wtrap(SC_maxheight) == null) 
clear(MAXHEIGHT_TRAP);
-        case "contentwidth": if (wtrap(SC_contentwidth) == null) 
clear(CONTENTWIDTH_TRAP);
-        case "contentheight":  if (wtrap(SC_contentheight) == null) 
clear(CONTENTHEIGHT_TRAP);
-        case "surface":   if (wtrap(SC_surface) == null) clear(SURFACE_TRAP);
-        case "visible":   if (wtrap(SC_visible) == null) clear(VISIBLE_TRAP);
-        case "Children":  if (wtrap(SC_Children) == null) clear(CHILDREN_TRAP);
-        case "Enter":     if (wtrap(SC_Enter) == null) clear(ENTER_TRAP);
-        case "Leave":     if (wtrap(SC_Leave) == null) clear(LEAVE_TRAP);
-        case "_Move":     if (wtrap(SC__Move) == null) clear(_MOVE_TRAP);
-        case "Move":      if (wtrap(SC_Move) == null) clear(MOVE_TRAP);
-        case "Resize":    if (wtrap(SC_Resize) == null) clear(RESIZE_TRAP);
-        case "fontsize":  if (wtrap(SC_fontsize) == null && visual != 
BoxVisual.DEFAULT) visual.clearTrapFontsize();
-        case "font":      if (wtrap(SC_font) == null && visual != 
BoxVisual.DEFAULT) visual.clearTrapFont();
-        case "shrink":    if (wtrap(SC_shrink) == null) clear(SHRINK_TRAP);
-        case "hshrink":   if (wtrap(SC_hshrink) == null) clear(HSHRINK_TRAP);
-        case "vshrink":   if (wtrap(SC_vshrink) == null) clear(VSHRINK_TRAP);
+        case "x":         if (wtrap(SC_x) == null) trap_clear(X_TRAP);
+        case "y":         if (wtrap(SC_y) == null) trap_clear(Y_TRAP);
+        case "width":     if (wtrap(SC_width) == null) trap_clear(WIDTH_TRAP);
+        case "height":    if (wtrap(SC_height) == null) 
trap_clear(HEIGHT_TRAP);
+        case "minwidth":  if (wtrap(SC_minwidth) == null) 
trap_clear(MINWIDTH_TRAP);
+        case "maxwidth":  if (wtrap(SC_maxwidth) == null) 
trap_clear(MAXWIDTH_TRAP);
+        case "minheight": if (wtrap(SC_minheight) == null) 
trap_clear(MINHEIGHT_TRAP);
+        case "maxheight": if (wtrap(SC_maxheight) == null) 
trap_clear(MAXHEIGHT_TRAP);
+        case "contentwidth": if (wtrap(SC_contentwidth) == null) 
trap_clear(CONTENTWIDTH_TRAP);
+        case "contentheight":  if (wtrap(SC_contentheight) == null) 
trap_clear(CONTENTHEIGHT_TRAP);
+        case "surface":   if (wtrap(SC_surface) == null) 
trap_clear(SURFACE_TRAP);
+        case "visible":   if (wtrap(SC_visible) == null) 
trap_clear(VISIBLE_TRAP);
+        case "Children":  if (wtrap(SC_Children) == null) 
trap_clear(CHILDREN_TRAP);
+        case "Enter":     if (wtrap(SC_Enter) == null) trap_clear(ENTER_TRAP);
+        case "Leave":     if (wtrap(SC_Leave) == null) trap_clear(LEAVE_TRAP);
+        case "_Move":     if (wtrap(SC__Move) == null) trap_clear(_MOVE_TRAP);
+        case "Move":      if (wtrap(SC_Move) == null) trap_clear(MOVE_TRAP);
+        case "Resize":    if (wtrap(SC_Resize) == null) 
trap_clear(RESIZE_TRAP);
+        case "shrink":    if (wtrap(SC_shrink) == null) 
trap_clear(SHRINK_TRAP);
+        case "hshrink":   if (wtrap(SC_hshrink) == null) 
trap_clear(HSHRINK_TRAP);
+        case "vshrink":   if (wtrap(SC_vshrink) == null) 
trap_clear(VSHRINK_TRAP);
         //#end
     }
 
@@ -2981,7 +3195,7 @@
             if (b == null) {
                 return null;
             }
-            if (b.test(SURFACE_READ_TRAP)) {
+            if (b.trap_test(SURFACE_READ_TRAP)) {
                 return b.getAndTriggerTraps(SC_surface);
             }
             b = b.parent;
@@ -2992,7 +3206,7 @@
     private final boolean isVisible() throws JSExn {
         Box b = this;
         do {
-            if (b.test(VISIBLE_READ_TRAP)) {
+            if (b.trap_test(VISIBLE_READ_TRAP)) {
                 return JSU.toBoolean(b.getAndTriggerTraps(SC_visible));
             }
             if (!b.test(DISPLAY)) {
@@ -3009,7 +3223,7 @@
 
     /** fires surface traps in a root-first traversal of a box tree */
     private final WriteTrapChain fireSurfaceTraps(JS val, WriteTrapChain 
trapchain) {
-        if (test(SURFACE_TRAP)) {
+        if (trap_test(SURFACE_TRAP)) {
             if (trapchain == null) {
                 trapchain = new WriteTrapChain();
             }
@@ -3037,7 +3251,7 @@
 
     /** fires visible traps in a root-first traversal of a box tree */
     private final WriteTrapChain fireVisibleTraps(JS val, WriteTrapChain 
trapchain) {
-        if (test(VISIBLE_TRAP)) {
+        if (trap_test(VISIBLE_TRAP)) {
             if (trapchain == null) {
                 trapchain = new WriteTrapChain();
             }
@@ -3209,7 +3423,7 @@
      * exist!
      */
     private void put(int i, JS value, boolean fireTrapsOnRemove, boolean 
viaRedirect) throws JSExn {
-        Trap rangeTrap = test(CHILDREN_TRAP) ? wtrap(SC_Children) : null;
+        Trap rangeTrap = trap_test(CHILDREN_TRAP) ? wtrap(SC_Children) : null;
         JSExn rangeTrapException = null;
         try {
             if (rangeTrap != null) {
@@ -3293,7 +3507,7 @@
     
     /** get child from position 'i' via redirects and Children trap */
     private final JS get(int i) throws JSExn { 
-        Trap rangeTrap = test(CHILDREN_READ_TRAP) ? rtrap(SC_Children) : null;
+        Trap rangeTrap = trap_test(CHILDREN_READ_TRAP) ? rtrap(SC_Children) : 
null;
         JSExn rangeTrapException = null;
         
         JS value = null;   

Modified: 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
===================================================================
--- 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
     2015-04-28 17:06:14 UTC (rev 4785)
+++ 
branches/vexi3_integrated_layout/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
     2015-04-30 22:43:10 UTC (rev 4786)
@@ -472,7 +472,7 @@
         /* The current default textcolor
          * @initial_value(#000000)
          * @type(String) */
-        case "ui.textcolor": return 
JSU.S(Color.colorToString(BoxVisual.DEFAULT_COLOR));
+        case "ui.textcolor": return 
JSU.S(Color.colorToString(Box.DEFAULT_COLOR));
         
         /* <p>The current default fontsize, in points.</p>
          * 
@@ -483,48 +483,48 @@
          * 
          * @initial_value(10)
          * @type(Number) */
-        case "ui.fontsize.medium": return JSU.N(BoxVisual.MEDIUM_SIZE);
+        case "ui.fontsize.medium": return JSU.N(Box.MEDIUM_SIZE);
         
         /* Extra extra small offset from the current default fontsize, used 
when a box's fontsize
          * is set to <code>"xxsmall"</code>
          * @initial_value(-8)
          * @type(Number) */
-        case "ui.fontsize.xxsmall": return 
JSU.N(BoxVisual.MEDIUM_SIZE+BoxVisual.XXSMALL_OFFSET);
+        case "ui.fontsize.xxsmall": return 
JSU.N(Box.MEDIUM_SIZE+Box.XXSMALL_OFFSET);
         
         /* Extra small offset from the current default fontsize, used when a 
box's fontsize
          * is set to <code>"xsmall"</code>
          * @initial_value(-4)
          * @type(Number) */
-        case "ui.fontsize.xsmall": return 
JSU.N(BoxVisual.MEDIUM_SIZE+BoxVisual.XSMALL_OFFSET);
+        case "ui.fontsize.xsmall": return 
JSU.N(Box.MEDIUM_SIZE+Box.XSMALL_OFFSET);
         
         /* Small offset from the current default fontsize, used when a box's 
fontsize
          * is set to <code>"small"</code>
          * @initial_value(-2)
          * @type(Number) */
-        case "ui.fontsize.small": return 
JSU.N(BoxVisual.MEDIUM_SIZE+BoxVisual.SMALL_OFFSET);
+        case "ui.fontsize.small": return 
JSU.N(Box.MEDIUM_SIZE+Box.SMALL_OFFSET);
         
         /* Large offset from the current default fontsize, used when a box's 
fontsize
          * is set to <code>"large"</code>
          * @initial_value(4)
          * @type(Number) */
-        case "ui.fontsize.large": return 
JSU.N(BoxVisual.MEDIUM_SIZE+BoxVisual.LARGE_OFFSET);
+        case "ui.fontsize.large": return 
JSU.N(Box.MEDIUM_SIZE+Box.LARGE_OFFSET);
         
         /* Extra large offset from the current default fontsize, used when a 
box's fontsize
          * is set to <code>"xlarge"</code>
          * @initial_value(8)
          * @type(Number) */
-        case "ui.fontsize.xlarge": return 
JSU.N(BoxVisual.MEDIUM_SIZE+BoxVisual.XLARGE_OFFSET);
+        case "ui.fontsize.xlarge": return 
JSU.N(Box.MEDIUM_SIZE+Box.XLARGE_OFFSET);
         
         /* Extra extra large offset from the current default fontsize, used 
when a box's fontsize
          * is set to <code>"xxlarge"</code>
          * @initial_value(14)
          * @type(Number) */
-        case "ui.fontsize.xxlarge": return 
JSU.N(BoxVisual.MEDIUM_SIZE+BoxVisual.XXLARGE_OFFSET);
+        case "ui.fontsize.xxlarge": return 
JSU.N(Box.MEDIUM_SIZE+Box.XXLARGE_OFFSET);
         
         /* The current default font stream
          * @initial_value(vexi.ui.font.sansserif)
          * @type(Stream) */
-        case "ui.font.defaultstream": return BoxVisual.DEFAULT_STREAM;
+        case "ui.font.defaultstream": return Box.DEFAULT_STREAM;
         case "ui.font.install": return METHOD;
         /* @nofollow */
         case "ui.font.installed": return Resources.installedFonts;
@@ -662,7 +662,7 @@
         case "ui.textcolor":
             throw new JSExn("not yet implemented");
             /*
-            BoxVisual.DEFAULT_COLOR = Color.stringToColor(JSU.toString(value));
+            Box.DEFAULT_COLOR = Color.stringToColor(JSU.toString(value));
             // dirty all surfaces
             for (int i=0; i<Surface.allSurfaces.size(); i++) {
                 ((Surface)Surface.allSurfaces.elementAt(i)).dirty();
@@ -674,7 +674,7 @@
             if (6>ps && ps!=0) {
                 throw new JSExn("Minimum font pointsize is 6");
             }
-            if (BoxVisual.setDefaultPointsize(ps)) {
+            if (Box.setDefaultPointsize(ps)) {
                 // reflow all surfaces
                 // FIXME: this does not get work for Boxes with text where
                 // the Box's box tree is not currently assigned a Surface
@@ -688,7 +688,7 @@
         case "ui.font.defaultstream":
             throw new JSExn("not yet implemented");
             /*
-            BoxVisual.DEFAULT_STREAM = (Fountain)value.unclone();
+            Box.DEFAULT_STREAM = (Fountain)value.unclone();
             // reflow all surfaces
             for (int i=0; i<Surface.allSurfaces.size(); i++) {
                 
Box.reflowTree(((Surface)Surface.allSurfaces.elementAt(i)).root);
@@ -817,14 +817,14 @@
                 //#switch(JSU.toString(method))
                 case "ui.font.height":
                     try {
-                        return JSU.N(Font.getFont(args[0], 
BoxVisual.jsToPointsize(args[1])).textheight(JSU.toString(args[2])));
+                        return JSU.N(Font.getFont(args[0], 
Box.jsToPointsize(args[1])).textheight(JSU.toString(args[2])));
                     } catch (Exception e) {
                         throw new JSExn("called vexi.ui.font.height with 
illegal arguments");
                     }
                 case "ui.font.wait": throw new Error("FIXME: vexi.ui.font.wait 
not implemented");
                 case "ui.font.width":
                     try {
-                        return JSU.N(Font.getFont(args[0], 
BoxVisual.jsToPointsize(args[1])).textwidth(JSU.toString(args[2])));
+                        return JSU.N(Font.getFont(args[0], 
Box.jsToPointsize(args[1])).textwidth(JSU.toString(args[2])));
                     } catch (Exception e) {
                         throw new JSExn("called vexi.ui.font.width with 
illegal arguments");
                     }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to