public override void Add(Widget widget) { if (this.widget != null) { throw new Exception("SimplePanel can only contain one child widget"); } this.Widget = widget; }
protected void Orphan(Widget child) { //assert (child.getParent() == this); child.Parent = null; }
protected void Adopt(Widget child) { //assert(child.getParent() == null); child.Parent = this; }
public abstract bool Remove(Widget widget);
public virtual void Add(Widget widget) { throw new NotImplementedException(); }
public override bool Remove(Widget widget) { if (this.widget != widget) { return false; } Orphan(widget); this.Element.removeChild(widget.Element); this.widget = null; return true; }
protected virtual void InitWidget(Widget widget) { if (this.Widget != null) { throw new /*IllegalState*/Exception("Composite.initWidget() may only be called once."); } //widget.removeFromParent(); // Use the contained widget's element as the composite's element, // effectively merging them within the DOM. this.Element = widget.Element; this.Widget = widget; widget.Parent = this; }