public WidgetCanvas(Widget widget) { this.widget = widget; setRedrawOnResize(false); setAttribute("_redrawWithParent", false, false); setAttribute("_clearWithRemoveChild", true, false); setOverflow(Overflow.VISIBLE); String width = DOM.getStyleAttribute(widget.getElement(), "width"); String height = DOM.getStyleAttribute(widget.getElement(), "height"); if (width != null && !width.equals("")) { setWidth(width); } if (height != null && !height.equals("")) { setHeight(height); } }
protected void onDraw() { //a GWT widget must be attached to a GWT Panel for its events to fire. boolean attached = widget.isAttached(); if (!attached) { RootPanel rp = RootPanel.get(this.getID() + "_widget"); rp.add(widget); String width = DOM.getStyleAttribute(widget.getElement(), "width"); if (width != null && !width.equals("")) { setWidth(width); } String height = DOM.getStyleAttribute(widget.getElement(), "height"); if (height != null && !height.equals("")) { setHeight(height); } } } }
/** * Adds a widget to the window. * * @param widget the widget to be added */ public void addItem(Widget widget) { if (widget instanceof Canvas) { addItem((Canvas) widget); } else { addItem(new WidgetCanvas(widget)); } }
public String getInnerHTML() { //if this canvas is being redrawn, detach underlying gwt widget so that onDraw() //can correctly reassociate it with container div if(widget.isAttached()) widget.removeFromParent(); return "<DIV STYLE='width:100%;height:100%' ID=" + this.getID() + "_widget></DIV>"; }
public void addMember(Widget widget, int position) { if (widget instanceof Canvas) { addMember((Canvas) widget, position); } else { addMember(new WidgetCanvas(widget), position); } }
/** * Add a canvas to the layout, optionally at a specific position. * * @param widget the canvas object to be added to the layout */ public void addMember(Widget widget) { if (widget instanceof Canvas) { addMember((Canvas) widget); } else { addMember(new WidgetCanvas(widget)); } }
/** * Adds newChild as a child of this widget, set up a named object reference (i.e., this[name]) to the new widget if * name argument is provided, and draw the child if this widget has been drawn already. <P> If newChild has a parent * it will be removed from it. If it has a master, it will be detached from it if the master is a child of a * different parent. If newChild has peers, they'll be added to this widget as children as well. * * @param newChild new child canvas to add */ public void addChild(Widget widget) { if (widget instanceof Canvas) { addChild((Canvas) widget); } else { addChild(new WidgetCanvas(widget)); } }