aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2008-11-04 13:54:28 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2008-11-04 13:54:28 +0000
commitbaaa2aa0a515c600aac78bb200ed547395fbb71f (patch)
treedb2cd564864914571472620d2f7c2659074fa01a
parent1da325dc08f30291c910cca3d8eabbbaf0a53090 (diff)
downloadvaadin-framework-baaa2aa0a515c600aac78bb200ed547395fbb71f.tar.gz
vaadin-framework-baaa2aa0a515c600aac78bb200ed547395fbb71f.zip
refactored getAllocatedSpace in IWindow
svn changeset:5810/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java85
1 files changed, 42 insertions, 43 deletions
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 5507157c96..aef26b0802 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
@@ -15,6 +15,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Frame;
+import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollListener;
import com.google.gwt.user.client.ui.ScrollPanel;
@@ -114,6 +115,12 @@ public class IWindow extends IToolkitOverlay implements Container,
private boolean readonly;
+ private RenderSpace renderSpace = new RenderSpace(0, 0, true);
+
+ private String width;
+
+ private String height;
+
public IWindow() {
super(false, false, true); // no autohide, not modal, shadow
// Different style of shadow for windows
@@ -660,7 +667,7 @@ public class IWindow extends IToolkitOverlay implements Container,
// Update child widget dimensions
if (client != null) {
client.handleComponentRelativeSize((Widget) layout);
- client.runDescendentsLayout(this);
+ client.runDescendentsLayout((HasWidgets) layout);
}
}
@@ -672,29 +679,33 @@ public class IWindow extends IToolkitOverlay implements Container,
* throw an exception)
*/
public void setWidth(String width) {
+ this.width = width;
if (!isAttached()) {
return;
}
- if (!"".equals(width)) {
+ if (width != null && !"".equals(width)) {
+ int pixelWidth;
// Convert non-pixel values to pixels
if (width.indexOf("px") < 0) {
DOM.setStyleAttribute(getElement(), "width", width);
- width = getElement().getOffsetWidth() + "px";
+ pixelWidth = getElement().getOffsetWidth();
+ width = pixelWidth + "px";
}
+ if (BrowserInfo.get().isIE6()) {
+ getElement().getStyle().setProperty("overflow", "hidden");
+ }
+ getElement().getStyle().setProperty("width", width);
+
+ pixelWidth = getElement().getOffsetWidth() - borderWidth;
- DOM.setStyleAttribute(getElement(), "width", width);
+ renderSpace.setWidth(pixelWidth);
// IE6 needs the actual inner content width on the content element,
// otherwise it won't wrap the content properly (no scrollbars
// appear, content flows out of window)
if (BrowserInfo.get().isIE6()) {
- int contentWidth = (Integer.parseInt(width.substring(0, width
- .length() - 2)) - borderWidth);
- if (contentWidth < 0) {
- contentWidth = 0;
- }
DOM.setStyleAttribute(contentPanel.getElement(), "width",
- contentWidth + "px");
+ pixelWidth + "px");
}
updateShadowSizeAndPosition();
}
@@ -708,30 +719,29 @@ public class IWindow extends IToolkitOverlay implements Container,
* throw an exception)
*/
public void setHeight(String height) {
+ this.height = height;
if (!isAttached()) {
return;
}
- if (!"".equals(height)) {
- // Convert non-pixel values to pixels
- if (height.indexOf("px") < 0) {
- DOM.setStyleAttribute(getElement(), "height", height);
- height = getElement().getOffsetHeight() + "px";
+ if (height != null && !"".equals(height)) {
+ DOM.setStyleAttribute(getElement(), "height", height);
+ int pixels = getElement().getOffsetHeight() - getExtraHeight();
+ if (pixels < 0) {
+ pixels = 0;
}
+ renderSpace.setHeight(pixels);
+ height = pixels + "px";
+ contentPanel.getElement().getStyle().setProperty("height", height);
+ updateShadowSizeAndPosition();
- DOM.setStyleAttribute(contentPanel.getElement(), "position",
- "absolute");
- final int usedHeight = getElement().getOffsetHeight();
- DOM.setStyleAttribute(contentPanel.getElement(), "position",
- "relative");
-
- height = (Integer
- .parseInt(height.substring(0, height.length() - 2)) - usedHeight)
- + "px";
+ }
+ }
- DOM.setStyleAttribute(contentPanel.getElement(), "height", height);
+ private int extraH = 0;
- updateShadowSizeAndPosition();
- }
+ private int getExtraHeight() {
+ extraH = header.getOffsetHeight() + footer.getOffsetHeight();
+ return extraH;
}
private void onDragEvent(Event event) {
@@ -835,26 +845,15 @@ public class IWindow extends IToolkitOverlay implements Container,
"offsetWidth");
borderWidth = windowWidth - contentWidth;
}
+
+ setWidth(width);
+ setHeight(height);
+
}
public RenderSpace getAllocatedSpace(Widget child) {
if (child == layout) {
- return new RenderSpace() {
- @Override
- public int getHeight() {
- return contentPanel.getOffsetHeight();
- }
-
- @Override
- public int getWidth() {
- return contentPanel.getOffsetWidth();
- }
-
- @Override
- public int getScrollbarSize() {
- return Util.getNativeScrollbarSize();
- }
- };
+ return renderSpace;
} else {
// Exception ??
return null;