I am using SC_SNAPSHOT-2011-01-31/PowerEdition and FireFox 3.6.13.
When I add a widgets.Window object to a widgets.Canvas, it creates two children (a widgets.Window and a widgets.Canvas). I would expect only the widgets.Window to be added.
This causes a problem for me since I'm trying to get the Window widgets on the parent Canvas to tile. Also, it can cause the Window and Canvas to get out of sync with each other. There are other little problems, including when the background color is set, the color paints over the Window title bar.
Here is code to reproduce what I am seeing:
Click 'add' button, then 'tile' button to see the Window and its Canvas get separated. I expected the Canvas to be a child of Window and only the Window object to be added to the parent.
Also, I would expect when the background color is set for a Window, it would not overpaint the title.
When I add a widgets.Window object to a widgets.Canvas, it creates two children (a widgets.Window and a widgets.Canvas). I would expect only the widgets.Window to be added.
This causes a problem for me since I'm trying to get the Window widgets on the parent Canvas to tile. Also, it can cause the Window and Canvas to get out of sync with each other. There are other little problems, including when the background color is set, the color paints over the Window title bar.
Here is code to reproduce what I am seeing:
Code:
public void onModuleLoad() { final Canvas mainCanvas = new Canvas(); mainCanvas.setHeight100(); mainCanvas.setWidth100(); mainCanvas.setBackgroundColor("palegreen"); mainCanvas.addChild(doubleWindowTest()); mainCanvas.draw(); } private HLayout doubleWindowTest() { final VLayout left = new VLayout(); left.setHeight100(); left.setWidth("20%"); left.setBackgroundColor("whitesmoke"); left.setMembersMargin(10); final Canvas targetCanvas = new Canvas(); targetCanvas.setWidth100(); targetCanvas.setHeight100(); targetCanvas.setBackgroundColor("azure"); final VLayout right = new VLayout(); right.setHeight100(); right.setWidth("*"); right.addMember(targetCanvas); IButton addBtn = new IButton("add"); addBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final Window window = new Window(); final String title = "window " + count++; window.setTitle(title); window.setHeight(120); window.setWidth(120); window.setBackgroundColor("pink"); SC.logWarn("Number of children in layout :" + targetCanvas.getChildren().length); targetCanvas.addChild(window); SC.logWarn("Number of children in layout :" + targetCanvas.getChildren().length); } }); left.addMember(addBtn); IButton button = new IButton("tile"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Canvas canvases[] = targetCanvas.getChildren(); int canvasCount = canvases.length; SC.logWarn("canvasCount:" + canvasCount); if (canvasCount == 0) return; for (Canvas k : canvases) { SC.logWarn(">>class:" + k.getClass()); } int cols = (int) java.lang.Math.sqrt(canvasCount); int rows = canvases.length / cols; SC.logWarn("cols:" + cols + " rows:" + rows); int windowWidth = targetCanvas.getWidth() / cols; int windowHeight = targetCanvas.getHeight() / rows; int top = 0; int left = 0; int onCanvas = 0; for (int col = 0; col < cols; col++) { for (int row = 0; row < rows; row++) { top = (row * windowHeight); left = (col * windowWidth); Canvas canvas = canvases[onCanvas]; final String text = "wH:" + windowHeight + " wW:" + windowWidth + " top:" + top + " left:" + left + " col:" + col + " cols: " + cols + " row:" + row + " rows:" + rows + " onCanvas:" + onCanvas + " canvasCount:" + canvasCount + " class:" + canvas.getClass(); final Label label = new Label(text); canvas.addChild(label); canvas.setTop(top); canvas.setLeft(left); canvas.setHeight(windowHeight); canvas.setWidth(windowWidth); onCanvas++; if (onCanvas >= canvasCount) break; } } } }); left.addMember(button); final HLayout hlayout = new HLayout(); hlayout.setMargin(10); hlayout.setWidth100(); hlayout.setHeight100(); hlayout.addMember(left); hlayout.addMember(right); return hlayout; }
Also, I would expect when the background color is set for a Window, it would not overpaint the title.
Comment