* SizeChanges trigger an Surface.abort; if rendering were done in the same
* pass, rendering work done prior to the Surface.abort would be wasted.
*/
-public final class Box extends JSScope implements JSTrap.JSTrappable {
+public final class Box extends JSScope {
// Macros //////////////////////////////////////////////////////////////////////
}
}
- public void putAndTriggerJSTraps(Object key, Object value) {
- JSContext.invokeTrap(this, key, value);
- }
-
/** update MOUSEINSIDE, check for Enter/Leave/Move */
void Move(int oldmousex, int oldmousey, int mousex, int mousey) { Move(oldmousex, oldmousey, mousex, mousey, false); }
void Move(int oldmousex, int oldmousey, int mousex, int mousey, boolean forceleave) {
if (!wasinside && !isinside) return;
if (isinside && test(CURSOR)) Surface.fromBox(getRoot()).cursor = (String)boxToCursor.get(this);
- if (!wasinside && isinside && getTrap("Enter") != null) putAndTriggerJSTraps("Enter", T);
- else if (wasinside && !isinside && getTrap("Leave") != null) putAndTriggerJSTraps("Leave", T);
+ if (!wasinside && isinside && getTrap("Enter") != null) putAndTriggerTraps("Enter", T);
+ else if (wasinside && !isinside && getTrap("Leave") != null) putAndTriggerTraps("Leave", T);
else if (wasinside && isinside && (mousex != oldmousex || mousey != oldmousey) && getTrap("Move")!= null)
- putAndTriggerJSTraps("Move", T);
+ putAndTriggerTraps("Move", T);
for(Box b = getChild(numchildren - 1); b != null; b = b.prevSibling()) {
b.Move(oldmousex - b.x, oldmousey - b.y, mousex - b.x, mousey - b.y, forceleave);
if (b.inside(mousex - b.x, mousey - b.y)) forceleave = true;
boolean poschange = (this.x != x || this.y != y) && getTrap("PosChange") != null;
this.width = width; this.height = height; this.x = x; this.y = y;
dirty();
- try { if (sizechange) putAndTriggerJSTraps("SizeChange", T); /*Surface.abort = true;*/ }
+ try { if (sizechange) putAndTriggerTraps("SizeChange", T); /*Surface.abort = true;*/ }
catch (Exception e) { Log.log(this, e); }
- try { if (poschange) putAndTriggerJSTraps("PosChange", T); /*Surface.abort = true;*/ }
+ try { if (poschange) putAndTriggerTraps("PosChange", T); /*Surface.abort = true;*/ }
catch (Exception e) { Log.log(this, e); }
}
}
public int localToGlobalX(int x) { return parent == null ? x : parent.globalToLocalX(x + this.x); }
public int localToGlobalY(int y) { return parent == null ? y : parent.globalToLocalY(y + this.y); }
- public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JS.Exn {
+ public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
if (nargs != 1 || !"indexof".equals(method)) return super.callMethod(method, a0, a1, a2, rest, nargs);
Box b = (Box)a0;
if (b.parent != this)
/** to be filled in by the Tree implementation */
public int numchildren = 0;
- public Object get(Object name) { return get(name, false); }
- public Object get(Object name, boolean ignoretraps) {
+ protected boolean isTrappable() { return true; }
+ public Object get(Object name) {
if (name instanceof Number)
return redirect == null ? null : redirect == this ? getChild(toInt(name)) : redirect.get(name);
//#switch(name)
case "indexof": return METHOD;
case "text": return text;
- case "path": throw new JS.Exn("cannot read from the path property");
+ case "path": throw new JSExn("cannot read from the path property");
case "fill": return colorToString(fillcolor);
case "strokecolor": return colorToString(strokecolor);
case "textcolor": return colorToString(strokecolor);
return null;
}
- public void put(Object name, Object value) { put(name, value, false); }
- public void put(Object name, Object value, boolean ignoretraps) {
+ public void put(Object name, Object value) {
if (name instanceof Number) { put(toInt(name), value); return; }
//#switch(name)
int mousex = globalToLocalX(surface.mousex);
int mousey = globalToLocalY(surface.mousey);
for(Box c = prevSibling(); c != null; c = c.prevSibling())
- if (c.inside(mousex - c.x, mousey - c.y)) { c.putAndTriggerJSTraps(name, value); return; }
- if (parent != null) parent.putAndTriggerJSTraps(name, value);
+ if (c.inside(mousex - c.x, mousey - c.y)) { c.putAndTriggerTraps(name, value); return; }
+ if (parent != null) parent.putAndTriggerTraps(name, value);
}
private static int stringToColor(String s) {
removeNode();
parent = null;
if (oldparent != null) { Box b = oldparent; MARK_REFLOW_b; }
- if (oldparent != null) oldparent.putAndTriggerJSTraps("childremoved", this);
+ if (oldparent != null) oldparent.putAndTriggerTraps("childremoved", this);
}
/** Returns ith child */
}
if (redirect == null) {
- if (value == null) putAndTriggerJSTraps("childremoved", getChild(i));
+ if (value == null) putAndTriggerTraps("childremoved", getChild(i));
else Log.logJS(this, "attempt to add/remove children to/from a node with a null redirect");
} else if (redirect != this) {
- if (value != null) putAndTriggerJSTraps("childadded", value);
+ if (value != null) putAndTriggerTraps("childadded", value);
redirect.put(i, value);
if (value == null) {
Box b = (Box)redirect.get(new Integer(i));
- if (b != null) putAndTriggerJSTraps("childremoved", b);
+ if (b != null) putAndTriggerTraps("childremoved", b);
}
} else if (value == null) {
if (i < 0 || i > numchildren) return;
Box b = getChild(i);
b.remove();
- putAndTriggerJSTraps("childremoved", b);
+ putAndTriggerTraps("childremoved", b);
} else {
Box b = (Box)value;
MARK_REFLOW;
b.dirty();
- putAndTriggerJSTraps("childadded", b);
+ putAndTriggerTraps("childadded", b);
}
}