From 8acbd07628ecbfb99326dd1086bf1e9f1b28dd64 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 13 Feb 2009 11:04:43 +0000 Subject: [PATCH] Testcase and fix for #2579 - Invalid window size calculation for small windows svn changeset:6830/svn branch:trunk --- .../terminal/gwt/client/ui/IWindow.java | 6 +++ .../window/TestTooSmallSubwindowSize.java | 44 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/window/TestTooSmallSubwindowSize.java diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java index c033766309..7de1f81349 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -778,6 +778,8 @@ public class IWindow extends IToolkitOverlay implements Container, pixelWidth = getElement().getOffsetWidth() - borderWidth; if (pixelWidth < MIN_WIDTH) { pixelWidth = MIN_WIDTH; + int rootWidth = pixelWidth + borderWidth; + DOM.setStyleAttribute(getElement(), "width", rootWidth + "px"); } renderSpace.setWidth(pixelWidth); @@ -810,6 +812,10 @@ public class IWindow extends IToolkitOverlay implements Container, int pixels = getElement().getOffsetHeight() - getExtraHeight(); if (pixels < MIN_HEIGHT) { pixels = MIN_HEIGHT; + int rootHeight = pixels + getExtraHeight(); + DOM.setStyleAttribute(getElement(), "height", (rootHeight) + + "px"); + } renderSpace.setHeight(pixels); height = pixels + "px"; diff --git a/src/com/itmill/toolkit/tests/components/window/TestTooSmallSubwindowSize.java b/src/com/itmill/toolkit/tests/components/window/TestTooSmallSubwindowSize.java new file mode 100644 index 0000000000..47f8309da3 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/window/TestTooSmallSubwindowSize.java @@ -0,0 +1,44 @@ +package com.itmill.toolkit.tests.components.window; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Window; + +public class TestTooSmallSubwindowSize extends TestBase { + + @Override + protected String getDescription() { + return "The size of the subwindow (outer size) is set to 60x60 pixels. Minimum size for the content area is 150x100, which means the window and shadow should be around 155x155 and the content area 150x100. The decoration at the lower left corner of the window must not be missing either."; + } + + @Override + protected Integer getTicketNumber() { + return 2579; + } + + @Override + protected void setup() { + Window w = new Window("Scroll"); + Label desc = new Label( + "This is a new child window with a preset" + + " width, height and position. Resizing has been" + + " disabled for this window. Additionally, this text label" + + " is intentionally too large to fit the window. You can" + + " use the scrollbars to view different parts of the window content."); + w.addComponent(desc); + + // Set window position + w.setPositionX(100); + w.setPositionY(100); + + // Set window size + w.setWidth(60, Window.UNITS_PIXELS); + w.setHeight(60, Window.UNITS_PIXELS); + + // Disable resizing + w.setResizable(true); + + getMainWindow().addWindow(w); + } + +} -- 2.39.5