case "redirect": if (redirect == this) redirect = (Box)value; else Log.log(this, "redirect can only be set once");
case "font": font = value == null ? null : Font.getFont((Res)value, font == null ? 10 : font.pointsize); MARK_RESIZE; dirty();
case "fontsize": font = Font.getFont(font == null ? null : font.res, toInt(value)); MARK_RESIZE; dirty();
- case "x": if (test(PACKED) && parent != null) return; CHECKSET_INT(x); dirty(); MARK_RESIZE; dirty();
- case "y": if (test(PACKED) && parent != null) return; CHECKSET_INT(y); dirty(); MARK_RESIZE; dirty();
+ case "x": if (parent==null && Surface.fromBox(this)!=null) { CHECKSET_INT(x); } else { if (test(PACKED) && parent != null) return; CHECKSET_INT(x); dirty(); MARK_RESIZE; dirty(); }
+ case "y": if (parent==null && Surface.fromBox(this)!=null) { CHECKSET_INT(y); } else { if (test(PACKED) && parent != null) return; CHECKSET_INT(y); dirty(); MARK_RESIZE; dirty(); }
case "KeyPressed": return; // prevent stuff from hitting the Hash
case "KeyReleased": return; // prevent stuff from hitting the Hash
case "PosChange": return; // prevent stuff from hitting the Hash
// Tree Handling //////////////////////////////////////////////////////////////////////
- // FIXME inefficient
- public final Box nextSibling() {
- int index = parent.indexNode(this);
- if (index >= parent.treeSize() - 1) return null;
- return parent.getChild(index + 1);
- }
-
- // FIXME inefficient
- public final Box prevSibling() {
- int index = parent.indexNode(this);
- if (index <= 0) return null;
- return parent.getChild(index - 1);
- }
-
+ public final int getIndexInParent() { return parent == null ? 0 : parent.indexNode(this); }
+ public final Box nextSibling() { return parent == null ? null : parent.getChild(parent.indexNode(this) + 1); }
+ public final Box prevSibling() { return parent == null ? null : parent.getChild(parent.indexNode(this) - 1); }
public final Box getChild(int i) {
if (i < 0) return null;
if (i >= treeSize()) return null;
return (Box)getNode(i);
}
- public final int getIndexInParent() { return parent == null ? 0 : parent.indexNode(this); }
// Tree Manipulation /////////////////////////////////////////////////////////////////////