* trigger a 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 Task {
+public final class Box extends JS.O implements Task {
// Macros //////////////////////////////////////////////////////////////////////
//#define CHECKSET_BOOLEAN(prop) boolean nu = toBoolean(value); if (nu == prop) break; prop = nu;
//#define CHECKSET_STRING(prop) if ((value==null&&prop==null)||(value!=null&&JS.toString(value).equals(prop))) break; prop=JS.toString(value);
- public Box() { super(null); }
-
// FIXME memory leak
static Hash boxToCursor = new Hash(500, 3);
static final Font DEFAULT_FONT;
static {
- try { DEFAULT_FONT = Font.getFont(Main.builtin.get(JS.S("fonts/vera/Vera.ttf")), 10); }
+ try { DEFAULT_FONT = Font.getFont((JS)Main.builtin.get(JS.S("fonts/vera/Vera.ttf")), 10); }
catch(JSExn e) { throw new Error("Error loading default font: " + e); }
}
Box redirect = this;
int flags = VISIBLE | PACKED | REPACK | RECONSTRAIN | REPLACE | FIXED | STOP_UPWARD_PROPAGATION | CLIP | MOVED;
+ private BalancedTree bt;
+
private String text = null;
private Font font = DEFAULT_FONT;
private Picture texture = null;
case "rowspan": if (toInt(value) > 0) { CHECKSET_SHORT(rowspan); if (parent != null) parent.REPACK(); }
case "visible": CHECKSET_FLAG(VISIBLE); RECONSTRAIN(); dirty();
case "packed": CHECKSET_FLAG(PACKED); if (parent != null) { parent.REPACK(); } else { REPACK(); }
- case "align": clear(ALIGNS); setAlign(value == null ? "center" : JS.toString(value)); REPLACE();
+ case "align": clear(ALIGNS); setAlign(value); REPLACE();
case "cursor": setCursor(JS.toString(value));
case "fill": setFill(value);
case "clip": CHECKSET_FLAG(CLIP); if (parent == null) dirty(); else parent.dirty();
}
}
- private void setAlign(String value) {
+ private void setAlign(JS value) throws JSExn {
clear(ALIGNS);
- //#switch(value)
+ //#switch(JS.toString(value))
case "topleft": set(ALIGN_TOP | ALIGN_LEFT);
case "bottomleft": set(ALIGN_BOTTOM | ALIGN_LEFT);
case "topright": set(ALIGN_TOP | ALIGN_RIGHT);
case "bottom": set(ALIGN_BOTTOM);
case "left": set(ALIGN_LEFT);
case "right": set(ALIGN_RIGHT);
- default: JS.log("invalid alignment \"" + value + "\"");
+ default: JS.log("invalid alignment \"" + JS.debugToString(value) + "\"");
//#end
}
JS.log(e);
}
}
+
+ // BalancedTree functions
+ private void insertNode(int p, Box b) {
+ if(bt == null) bt = new BalancedTree();
+ bt.insertNode(p,b);
+ }
+
+ private int treeSize() { return bt == null ? 0 : bt.treeSize(); }
+ private int indexNode(Box b) { return bt == null ? -1 : bt.indexNode(b); }
+ private void deleteNode(int p) { bt.deleteNode(p); }
+ private Box getNode(int p) { return (Box)bt.getNode(p); }
}