summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2008-10-07 11:24:39 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2008-10-07 11:24:39 +0000
commit40f83f7815202ff21aef2d768b069b409429b8a4 (patch)
treee819e8f6dac1749007688d09e1beb14d2cd31433 /src
parent27393b2ea82204c42f0f2fe94f9e2f5e6c116f9f (diff)
downloadvaadin-framework-40f83f7815202ff21aef2d768b069b409429b8a4.tar.gz
vaadin-framework-40f83f7815202ff21aef2d768b069b409429b8a4.zip
enabled scrolling in toolkit + some other minor changes
svn changeset:5602/svn branch:trunk
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java115
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/Container.java3
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/RenderInformation.java7
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/RenderSpace.java51
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/Util.java33
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java35
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICoordinateLayout.java17
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java8
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java192
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java12
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java46
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java121
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java42
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java69
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java50
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/IAbsoluteGrid.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/ISizeableGridLayout.java4
23 files changed, 512 insertions, 331 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
index e6499e6408..6e0b4e3493 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
@@ -101,8 +101,8 @@ public class ApplicationConnection {
*
* Used in JSNI functions
*
- * @SuppressWarnings
*/
+ @SuppressWarnings("unused")
private final JavaScriptObject ttClientWrapper = null;
private int activeRequests = 0;
@@ -203,6 +203,7 @@ public class ApplicationConnection {
/**
* Helper for tt initialization
*/
+ @SuppressWarnings("unused")
private JavaScriptObject getVersionInfo() {
return configuration.getVersionInfoJSObject();
}
@@ -288,7 +289,7 @@ public class ApplicationConnection {
endRequest();
if (!applicationRunning) {
// start failed, let's try to start the next app
- configuration.startNextApplication();
+ ApplicationConfiguration.startNextApplication();
}
}
@@ -299,7 +300,7 @@ public class ApplicationConnection {
} else {
applicationRunning = true;
handleWhenCSSLoaded(response);
- configuration.startNextApplication();
+ ApplicationConfiguration.startNextApplication();
}
}
@@ -998,6 +999,14 @@ public class ApplicationConnection {
float relativeWidth = Util.parseRelativeSize(w);
float relativeHeight = Util.parseRelativeSize(h);
+ // first set absolute sizes
+ if (relativeHeight < 0.0) {
+ component.setHeight(h);
+ }
+ if (relativeWidth < 0.0) {
+ component.setWidth(w);
+ }
+
if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
// One or both is relative
FloatSize relativeSize = new FloatSize(relativeWidth,
@@ -1009,12 +1018,6 @@ public class ApplicationConnection {
componentRelativeSizes.remove(component);
}
- if (relativeHeight < 0.0) {
- component.setHeight(h);
- }
- if (relativeWidth < 0.0) {
- component.setWidth(w);
- }
}
/**
@@ -1054,46 +1057,86 @@ public class ApplicationConnection {
return;
}
- Size availPixels = Util.getLayout(widget).getAllocatedSpace(widget);
- if (relativeSize.getWidth() >= 0) {
+ boolean horizontalScrollBar = false;
+ boolean verticalScrollBar = false;
- if (availPixels != null) {
+ RenderSpace renderSpace = Util.getLayout(widget).getAllocatedSpace(
+ widget);
+
+ if (relativeSize.getHeight() >= 0) {
+ if (renderSpace != null) {
+
+ if (renderSpace.getScrollbarSize() > 0) {
+ if (relativeSize.getWidth() > 100) {
+ horizontalScrollBar = true;
+ } else if (relativeSize.getWidth() < 0
+ && renderSpace.getWidth() > 0) {
+ int offsetWidth = widget.getOffsetWidth();
+ int width = renderSpace.getWidth();
+ if (offsetWidth > width) {
+ horizontalScrollBar = true;
+ }
+ }
+ }
- int width = availPixels.getWidth();
- width *= relativeSize.getWidth() / 100.0;
+ int height = renderSpace.getHeight();
+ if (horizontalScrollBar) {
+ height -= renderSpace.getScrollbarSize();
+ }
+ height = (int) (height * relativeSize.getHeight() / 100.0);
- if (width >= 0) {
- // getConsole().log(
- // "Widget " + widget.getClass().getName() + "/"
- // + widget.hashCode() + " relative width "
- // + relativeSize.getWidth() + "%: " + width
- // + "px");
- widget.setWidth(width + "px");
+ if (height < 0) {
+ height = 0;
}
+ // getConsole().log(
+ // "Widget " + widget.getClass().getName() + "/"
+ // + widget.hashCode() + " relative height "
+ // + relativeSize.getHeight() + "%: " + height
+ // + "px");
+ widget.setHeight(height + "px");
} else {
- widget.setWidth(relativeSize.getWidth() + "%");
+ widget.setHeight(relativeSize.getHeight() + "%");
ApplicationConnection.getConsole().error(
Util.getLayout(widget).getClass().getName()
+ " did not produce allocatedSpace for "
+ widget.getClass().getName());
}
}
- if (relativeSize.getHeight() >= 0) {
- if (availPixels != null) {
-
- int height = availPixels.getHeight();
- height *= relativeSize.getHeight() / 100.0;
-
- if (height >= 0) {
- // getConsole().log(
- // "Widget " + widget.getClass().getName() + "/"
- // + widget.hashCode() + " relative height "
- // + relativeSize.getHeight() + "%: " + height
- // + "px");
- widget.setHeight(height + "px");
+
+ if (relativeSize.getWidth() >= 0) {
+
+ if (renderSpace != null) {
+
+ int width = renderSpace.getWidth();
+
+ if (renderSpace.getScrollbarSize() > 0) {
+ if (relativeSize.getHeight() > 100) {
+ verticalScrollBar = true;
+ } else if (relativeSize.getHeight() < 0
+ && renderSpace.getHeight() > 0
+ && widget.getOffsetHeight() > renderSpace
+ .getHeight()) {
+ verticalScrollBar = true;
+ }
}
+
+ if (verticalScrollBar) {
+ width -= renderSpace.getScrollbarSize();
+ }
+ width = (int) (width * relativeSize.getWidth() / 100.0);
+
+ if (width < 0) {
+ width = 0;
+ }
+
+ // getConsole().log(
+ // "Widget " + widget.getClass().getName() + "/"
+ // + widget.hashCode() + " relative width "
+ // + relativeSize.getWidth() + "%: " + width
+ // + "px");
+ widget.setWidth(width + "px");
} else {
- widget.setHeight(relativeSize.getHeight() + "%");
+ widget.setWidth(relativeSize.getWidth() + "%");
ApplicationConnection.getConsole().error(
Util.getLayout(widget).getClass().getName()
+ " did not produce allocatedSpace for "
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Container.java b/src/com/itmill/toolkit/terminal/gwt/client/Container.java
index f6303c584c..1a22a87d18 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/Container.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Container.java
@@ -7,7 +7,6 @@ package com.itmill.toolkit.terminal.gwt.client;
import java.util.Set;
import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public interface Container extends Paintable {
@@ -69,6 +68,6 @@ public interface Container extends Paintable {
* @param child
* @return
*/
- Size getAllocatedSpace(Widget child);
+ RenderSpace getAllocatedSpace(Widget child);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/RenderInformation.java b/src/com/itmill/toolkit/terminal/gwt/client/RenderInformation.java
index 060d7044e7..d30afca1fc 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/RenderInformation.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/RenderInformation.java
@@ -10,7 +10,7 @@ import com.google.gwt.user.client.Element;
*/
public class RenderInformation {
- private Size contentArea = new Size(0, 0);
+ private RenderSpace contentArea = new RenderSpace();
private Size renderedSize = new Size(-1, -1);
public void setContentAreaWidth(int w) {
@@ -21,7 +21,7 @@ public class RenderInformation {
contentArea.setHeight(h);
}
- public Size getContentAreaSize() {
+ public RenderSpace getContentAreaSize() {
return contentArea;
}
@@ -92,6 +92,9 @@ public class RenderInformation {
return other.width == width && other.height == height;
}
+ public Size() {
+ }
+
public Size(int width, int height) {
this.height = height;
this.width = width;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/RenderSpace.java b/src/com/itmill/toolkit/terminal/gwt/client/RenderSpace.java
new file mode 100644
index 0000000000..9e16f16e9e
--- /dev/null
+++ b/src/com/itmill/toolkit/terminal/gwt/client/RenderSpace.java
@@ -0,0 +1,51 @@
+package com.itmill.toolkit.terminal.gwt.client;
+
+import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
+
+/**
+ * Contains information about render area.
+ */
+public class RenderSpace extends Size {
+
+ private int scrollBarSize = 0;
+
+ public RenderSpace(int width, int height) {
+ super(width, height);
+ }
+
+ public RenderSpace() {
+ }
+
+ public RenderSpace(int width, int height, boolean useNativeScrollbarSize) {
+ super(width, height);
+ if (useNativeScrollbarSize) {
+ scrollBarSize = Util.getNativeScrollbarSize();
+ }
+ }
+
+ /**
+ * Returns pixels available vertically for contained widget, including
+ * possible scrollbars.
+ */
+ public int getHeight() {
+ return super.getHeight();
+ }
+
+ /**
+ * Returns pixels available horizontally for contained widget, including
+ * possible scrollbars.
+ */
+ public int getWidth() {
+ return super.getWidth();
+ }
+
+ /**
+ * In case containing block has oveflow: auto, this method must return
+ * number of pixels used by scrollbar. Returning zero means either that no
+ * scrollbar will be visible.
+ */
+ public int getScrollbarSize() {
+ return scrollBarSize;
+ }
+
+}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Util.java b/src/com/itmill/toolkit/terminal/gwt/client/Util.java
index 396a2fd326..97f92abda6 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/Util.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Util.java
@@ -11,6 +11,7 @@ import java.util.Set;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
public class Util {
@@ -28,18 +29,6 @@ public class Util {
}-*/;
/**
- * Nulls oncontextmenu function on given element. We need to manually clear
- * context menu events due bad browsers memory leaks, since GWT don't
- * support them.
- *
- * @param el
- */
- public native static void removeContextMenuEvent(Element el)
- /*-{
- el.oncontextmenu = null;
- }-*/;
-
- /**
* Called when the size of one or more widgets have changed during
* rendering. Finds parent container and notifies them of the size change.
*
@@ -233,4 +222,24 @@ public class Util {
}
+ private static int detectedScrollbarSize = -1;
+
+ public static int getNativeScrollbarSize() {
+ if (detectedScrollbarSize < 0) {
+ Element scroller = DOM.createDiv();
+ scroller.getStyle().setProperty("width", "50px");
+ scroller.getStyle().setProperty("height", "50px");
+ scroller.getStyle().setProperty("overflow", "scroll");
+ scroller.getStyle().setProperty("position", "absolute");
+ scroller.getStyle().setProperty("marginLeft", "-5000px");
+ RootPanel.getBodyElement().appendChild(scroller);
+ detectedScrollbarSize = scroller.getOffsetWidth()
+ - scroller.getPropertyInt("clientWidth");
+ assert detectedScrollbarSize != 0;
+ RootPanel.getBodyElement().removeChild(scroller);
+
+ }
+ return detectedScrollbarSize;
+ }
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java
index b09b851051..e73f4e5bc8 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAccordion.java
@@ -10,6 +10,7 @@ import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -18,8 +19,8 @@ import com.itmill.toolkit.terminal.gwt.client.BrowserInfo;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class IAccordion extends ITabsheetBase implements
ContainerResizedListener {
@@ -34,6 +35,8 @@ public class IAccordion extends ITabsheetBase implements
private HashMap lazyUpdateMap = new HashMap();
+ private RenderSpace renderSpace = new RenderSpace(0, 0, true);
+
public IAccordion() {
super(CLASSNAME);
// IE6 needs this to calculate offsetHeight correctly
@@ -157,6 +160,25 @@ public class IAccordion extends ITabsheetBase implements
}
client.runDescendentsLayout(item);
+
+ if (BrowserInfo.get().getWebkitVersion() > 0) {
+ final Element selectedTabContent = getSelectedStack()
+ .getContainerElement();
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ // Dough, safari scoll auto means actually just a moped
+ selectedTabContent.getStyle().setProperty("overflow",
+ "hidden");
+ (new Timer() {
+ @Override
+ public void run() {
+ selectedTabContent.getStyle().setProperty(
+ "overflow", "auto");
+ }
+ }).schedule(1);
+ }
+ });
+ }
}
/**
@@ -177,6 +199,8 @@ public class IAccordion extends ITabsheetBase implements
fixContentNodeSize(contentSpace);
} else {
DOM.setStyleAttribute(content, "height", "");
+ renderSpace.setHeight(0);
+ renderSpace.setWidth(content.getOffsetWidth());
}
}
@@ -187,6 +211,10 @@ public class IAccordion extends ITabsheetBase implements
DOM
.setStyleAttribute(content, "width", getOffsetWidth()
+ "px");
+ } else {
+ // update render information
+ renderSpace.setHeight(contentHeight);
+ renderSpace.setWidth(content.getOffsetWidth());
}
}
@@ -335,9 +363,8 @@ public class IAccordion extends ITabsheetBase implements
return false;
}
- public Size getAllocatedSpace(Widget child) {
- // TODO Auto-generated method stub
- return null;
+ public RenderSpace getAllocatedSpace(Widget child) {
+ return renderSpace;
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICoordinateLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICoordinateLayout.java
index 3588333dc4..3e4ebf58c7 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICoordinateLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICoordinateLayout.java
@@ -18,8 +18,8 @@ import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class ICoordinateLayout extends ComplexPanel implements Container,
ContainerResizedListener {
@@ -868,8 +868,8 @@ public class ICoordinateLayout extends ComplexPanel implements Container,
* @return
*/
protected native String getMargin(Element e, String CSSProp)/*-{
- return $wnd.getComputedStyle(e,null).getPropertyValue(CSSProp);
- }-*/;
+ return $wnd.getComputedStyle(e,null).getPropertyValue(CSSProp);
+ }-*/;
/**
* Retrieves margin info in IE
@@ -878,8 +878,8 @@ public class ICoordinateLayout extends ComplexPanel implements Container,
* @return
*/
protected native String getIEMargin(Element e)/*-{
- return e.currentStyle.margin;
- }-*/;
+ return e.currentStyle.margin;
+ }-*/;
/**
* @return all components that are not captions
@@ -898,12 +898,13 @@ public class ICoordinateLayout extends ComplexPanel implements Container,
return true;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
Element area = componentToArea.get(child);
if (area != null) {
- return new Size(area.getOffsetWidth(), area.getOffsetHeight());
+ return new RenderSpace(area.getOffsetWidth(), area
+ .getOffsetHeight());
} else {
- return new Size(layout[WIDTH], layout[HEIGHT]);
+ return new RenderSpace(layout[WIDTH], layout[HEIGHT]);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
index 207005635f..2907a5e82f 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
@@ -11,8 +11,8 @@ import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class ICustomComponent extends SimplePanel implements Container {
@@ -69,11 +69,9 @@ public class ICustomComponent extends SimplePanel implements Container {
return false;
}
- public Size getAllocatedSpace(Widget child) {
- Size space = new Size(getElement().getOffsetWidth(), getElement()
+ public RenderSpace getAllocatedSpace(Widget child) {
+ return new RenderSpace(getElement().getOffsetWidth(), getElement()
.getOffsetHeight());
-
- return space;
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
index c5a73c788d..5a87897067 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
@@ -19,8 +19,8 @@ import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.ICaptionWrapper;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
/**
* Custom Layout implements complex layout defined with HTML template.
@@ -478,7 +478,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable,
return false;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
index 6ec950c5f0..92d3fd712e 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
@@ -24,9 +24,9 @@ import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.StyleConstants;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
/**
* @author IT Mill Ltd
@@ -848,7 +848,7 @@ public class IExpandLayout extends ComplexPanel implements
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
int width = 0, height = 0;
if (orientationMode == ORIENTATION_HORIZONTAL) {
@@ -869,7 +869,7 @@ public class IExpandLayout extends ComplexPanel implements
}
}
- return new Size(width, height);
+ return new RenderSpace(width, height, child == expandedWidget);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
index c68d6c854a..8acb767098 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
@@ -17,8 +17,8 @@ import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.IErrorMessage;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class IForm extends ComplexPanel implements Container,
ContainerResizedListener {
@@ -167,7 +167,7 @@ public class IForm extends ComplexPanel implements Container,
client.runDescendentsLayout(this);
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
return renderInformation.getContentAreaSize();
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
index cbff24e00d..1260f07454 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
@@ -17,10 +17,10 @@ import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.StyleConstants;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.Util;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
/**
* Two col Layout that places caption on left col and field on right col
@@ -309,7 +309,7 @@ public class IFormLayout extends FlexTable implements Container {
return false;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
index fba04b6d8f..e7d4dd3c82 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
@@ -26,9 +26,9 @@ import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaptionWrapper;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.StyleConstants;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class IGridLayout extends SimplePanel implements Paintable, Container,
ContainerResizedListener {
@@ -295,7 +295,7 @@ public class IGridLayout extends SimplePanel implements Paintable, Container,
return false;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
// TODO Auto-generated method stub
return null;
}
@@ -327,7 +327,7 @@ public class IGridLayout extends SimplePanel implements Paintable, Container,
return false;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
index 7e39db07c0..788e50def5 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
@@ -20,6 +20,7 @@ import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
@@ -657,6 +658,7 @@ public class IOrderedLayout extends Panel implements Container,
* Furthermore, enable/disable fixed mode
*/
public void setWidth(String newWidth) {
+ super.setWidth(newWidth);
if (newWidth == null || newWidth.equals("")) {
width = null;
@@ -1589,17 +1591,17 @@ public class IOrderedLayout extends Panel implements Container,
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
final int index = childWidgets.indexOf(child);
if (index >= 0) {
WidgetWrapper wrapper = childWidgetWrappers.get(index);
int w = wrapper.getAllocatedWidth();
int h = wrapper.getAllocatedHeight();
- return new Size(w, h);
+ return new RenderSpace(w, h);
+ } else {
+ return new RenderSpace();
}
-
- return new Size(0, 0);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
index be8655f9f4..d4d6719082 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
@@ -6,22 +6,24 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.Set;
+import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo;
-import com.itmill.toolkit.terminal.gwt.client.ClientExceptionHandler;
import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.IErrorMessage;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.Util;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class IPanel extends SimplePanel implements Container,
ContainerResizedListener {
@@ -62,7 +64,9 @@ public class IPanel extends SimplePanel implements Container,
private RenderInformation renderInformation = new RenderInformation();
- private int borderPaddingHorizontal = 0;
+ private int borderPaddingHorizontal = -1;
+
+ private int borderPaddingVertical = -1;
public IPanel() {
super();
@@ -278,74 +282,6 @@ public class IPanel extends SimplePanel implements Container,
}
- if (height != null && height != "") {
- final boolean hasChildren = getWidget() != null;
- Element contentEl = null;
- String origPositioning = null;
-
- if (hasChildren) {
- // Remove children temporary form normal flow to detect proper
- // size
- contentEl = getWidget().getElement();
- origPositioning = DOM.getStyleAttribute(contentEl, "position");
- DOM.setStyleAttribute(contentEl, "position", "absolute");
- }
-
- // Set defaults
- DOM.setStyleAttribute(contentNode, "overflow", "hidden");
- DOM.setStyleAttribute(contentNode, "height", "");
-
- // Calculate target height
- super.setHeight(height);
- final int targetHeight = getOffsetHeight();
-
- // Calculate used height
- super.setHeight("");
- if (BrowserInfo.get().isIE() && !hasChildren) {
- DOM.setStyleAttribute(contentNode, "height", "0px");
- }
-
- final int bottomTop = DOM.getElementPropertyInt(bottomDecoration,
- "offsetTop");
- final int bottomHeight = DOM.getElementPropertyInt(
- bottomDecoration, "offsetHeight");
- final int elementTop = DOM.getElementPropertyInt(getElement(),
- "offsetTop");
-
- final int usedHeight = bottomTop + bottomHeight - elementTop;
-
- // Calculate content area height (don't allow negative values)
- int contentAreaHeight = targetHeight - usedHeight;
- if (contentAreaHeight < 0) {
- contentAreaHeight = 0;
- }
-
- renderInformation.setContentAreaHeight(contentAreaHeight);
-
- // Set proper values for content element
- DOM.setStyleAttribute(contentNode, "height", contentAreaHeight
- + "px");
- DOM.setStyleAttribute(contentNode, "overflow", "auto");
-
- // Restore content to flow
- if (hasChildren) {
- DOM.setStyleAttribute(contentEl, "position", origPositioning);
- }
-
- // restore scroll position
- DOM.setElementPropertyInt(contentNode, "scrollTop", scrollTop);
- DOM.setElementPropertyInt(contentNode, "scrollLeft", scrollLeft);
-
- } else {
- DOM.setStyleAttribute(contentNode, "height", "");
- }
-
- if (width != null && !width.equals("")) {
- renderInformation.setContentAreaWidth(renderInformation
- .getRenderedSize().getWidth()
- - borderPaddingHorizontal);
- }
-
if (runGeckoFix && BrowserInfo.get().isGecko()) {
// workaround for #1764
if (width == null || width.equals("")) {
@@ -370,6 +306,22 @@ public class IPanel extends SimplePanel implements Container,
}
}
+ if (BrowserInfo.get().getWebkitVersion() > 0) {
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ // Dough, safari scoll auto means actually just a moped
+ contentNode.getStyle().setProperty("overflow", "hidden");
+ (new Timer() {
+ @Override
+ public void run() {
+ contentNode.getStyle().setProperty("overflow",
+ "auto");
+ }
+ }).schedule(1);
+ }
+ });
+ }
+
client.runDescendentsLayout(this);
}
@@ -394,7 +346,7 @@ public class IPanel extends SimplePanel implements Container,
client.updateVariable(id, "scrollLeft", scrollLeft, false);
}
} else if (errorIndicatorElement != null
- && DOM.compare(target, errorIndicatorElement)) {
+ && target == errorIndicatorElement) {
switch (type) {
case Event.ONMOUSEOVER:
if (errorMessage != null) {
@@ -416,36 +368,58 @@ public class IPanel extends SimplePanel implements Container,
}
}
- /**
- * Panel handles dimensions by itself.
- */
@Override
public void setHeight(String height) {
this.height = height;
+ super.setHeight(height);
+ if (height != null && height != "") {
+ final int targetHeight = getOffsetHeight();
+ int containerHeight = targetHeight - captionNode.getOffsetHeight()
+ - bottomDecoration.getOffsetHeight()
+ - getContainerBorderHeight();
+ if (containerHeight < 0) {
+ containerHeight = 0;
+ }
+ DOM
+ .setStyleAttribute(contentNode, "height", containerHeight
+ + "px");
+ } else {
+ DOM.setStyleAttribute(contentNode, "height", "");
+ }
+ }
+
+ private int getContainerBorderHeight() {
+ if (borderPaddingVertical < 0) {
+ detectContainerBorders();
+ }
+ return borderPaddingVertical;
}
- /**
- * Panel handles dimensions by itself.
- */
@Override
public void setWidth(String width) {
this.width = width;
super.setWidth(width);
- if (width.endsWith("px")) {
- try {
- // FIXME: More sane implementation
- borderPaddingHorizontal = Util.measureHorizontalPadding(
- contentNode, -2);
- if (borderPaddingHorizontal < 0) {
- borderPaddingHorizontal = -borderPaddingHorizontal;
- }
- } catch (Exception e) {
- ClientExceptionHandler.displayError(e);
- }
+ }
+
+ private int getContainerBorderWidth() {
+ if (borderPaddingHorizontal < 0) {
+ detectContainerBorders();
}
+ return borderPaddingHorizontal;
+ }
+ private void detectContainerBorders() {
+ DOM.setStyleAttribute(contentNode, "overflow", "hidden");
+ borderPaddingHorizontal = contentNode.getOffsetWidth()
+ - contentNode.getPropertyInt("clientWidth");
+ assert borderPaddingHorizontal >= 0;
+ borderPaddingVertical = contentNode.getOffsetHeight()
+ - contentNode.getPropertyInt("clientHeight");
+ assert borderPaddingVertical >= 0;
+
+ DOM.setStyleAttribute(contentNode, "overflow", "auto");
}
public boolean hasChildComponent(Widget component) {
@@ -460,31 +434,47 @@ public class IPanel extends SimplePanel implements Container,
// TODO
}
- public Size getAllocatedSpace(Widget child) {
- return renderInformation.getContentAreaSize();
+ private RenderSpace contentNodeSize;
+
+ public RenderSpace getAllocatedSpace(Widget child) {
+ if (contentNodeSize == null) {
+ contentNodeSize = new RenderSpace(-1, -1) {
+
+ @Override
+ public int getHeight() {
+ return contentNode.getOffsetHeight()
+ - getContainerBorderHeight();
+ }
+
+ @Override
+ public int getWidth() {
+ return contentNode.getOffsetWidth()
+ - getContainerBorderWidth();
+ }
+
+ @Override
+ public int getScrollbarSize() {
+ return Util.getNativeScrollbarSize();
+ }
+
+ };
+ }
+ return contentNodeSize;
}
public boolean requestLayout(Set<Paintable> child) {
-
if (height != null && width != null) {
/*
* If the height and width has been specified the child components
* cannot make the size of the layout change
*/
-
return true;
}
-
- if (renderInformation.updateSize(getElement())) {
- return false;
- } else {
- return true;
- }
-
+ return !renderInformation.updateSize(getElement());
}
public void updateCaption(Paintable component, UIDL uidl) {
- // TODO
+ // NOP: layouts caption, errors etc not rendered in Panel
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java
index 2ab507bd8c..f0a0254f30 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java
@@ -20,8 +20,8 @@ import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.ICaptionWrapper;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class IPopupView extends HTML implements Paintable {
@@ -170,10 +170,10 @@ public class IPopupView extends HTML implements Paintable {
}
public static native void nativeBlur(Element e) /*-{
- if(e.focus) {
- e.blur();
- }
- }-*/;
+ if(e.focus) {
+ e.blur();
+ }
+ }-*/;
private class CustomPopup extends IToolkitOverlay implements Container {
@@ -316,7 +316,7 @@ public class IPopupView extends HTML implements Paintable {
return false;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
index fb279b48ab..30661d4354 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
@@ -20,9 +20,9 @@ import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.Util;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class ISplitPanel extends ComplexPanel implements Container,
ContainerResizedListener {
@@ -70,8 +70,10 @@ public class ISplitPanel extends ComplexPanel implements Container,
private String height = null;
- private RenderInformation renderInformationFirst = new RenderInformation();
- private RenderInformation renderInformationSecond = new RenderInformation();
+ private RenderSpace firstRenderSpace = new RenderSpace(0, 0, true);
+ private RenderSpace secondRenderSpace = new RenderSpace(0, 0, true);
+
+ RenderInformation renderInformation = new RenderInformation();
public ISplitPanel() {
this(ORIENTATION_HORIZONTAL);
@@ -114,7 +116,7 @@ public class ISplitPanel extends ComplexPanel implements Container,
DOM.setStyleAttribute(firstContainer, "overflow", "auto");
DOM.setStyleAttribute(secondContainer, "overflow", "auto");
- if (Util.isIE7()) {
+ if (BrowserInfo.get().isIE7()) {
/*
* Part I of IE7 weirdness hack, will be set to auto in layout phase
*
@@ -151,7 +153,7 @@ public class ISplitPanel extends ComplexPanel implements Container,
return;
}
- renderInformationFirst.updateSize(getElement());
+ renderInformation.updateSize(getElement());
setSplitPosition(uidl.getStringAttribute("position"));
@@ -211,7 +213,7 @@ public class ISplitPanel extends ComplexPanel implements Container,
return;
}
- renderInformationFirst.updateSize(getElement());
+ renderInformation.updateSize(getElement());
int wholeSize;
int pixelPosition;
@@ -249,12 +251,11 @@ public class ISplitPanel extends ComplexPanel implements Container,
DOM.setStyleAttribute(secondContainer, "left",
(pixelPosition + getSplitterSize()) + "px");
- int contentHeight = renderInformationFirst.getRenderedSize()
- .getHeight();
- renderInformationFirst.setContentAreaHeight(contentHeight);
- renderInformationFirst.setContentAreaWidth(pixelPosition);
- renderInformationSecond.setContentAreaHeight(contentHeight);
- renderInformationSecond.setContentAreaWidth(secondContainerWidth);
+ int contentHeight = renderInformation.getRenderedSize().getHeight();
+ firstRenderSpace.setHeight(contentHeight);
+ firstRenderSpace.setWidth(pixelPosition);
+ secondRenderSpace.setHeight(contentHeight);
+ secondRenderSpace.setWidth(secondContainerWidth);
break;
case ORIENTATION_VERTICAL:
@@ -283,12 +284,11 @@ public class ISplitPanel extends ComplexPanel implements Container,
DOM.setStyleAttribute(secondContainer, "top",
(pixelPosition + getSplitterSize()) + "px");
- int contentWidth = renderInformationFirst.getRenderedSize()
- .getWidth();
- renderInformationFirst.setContentAreaHeight(pixelPosition);
- renderInformationFirst.setContentAreaWidth(contentWidth);
- renderInformationSecond.setContentAreaHeight(secondContainerHeight);
- renderInformationSecond.setContentAreaWidth(contentWidth);
+ int contentWidth = renderInformation.getRenderedSize().getWidth();
+ firstRenderSpace.setHeight(pixelPosition);
+ firstRenderSpace.setWidth(contentWidth);
+ secondRenderSpace.setHeight(secondContainerHeight);
+ secondRenderSpace.setWidth(contentWidth);
break;
}
@@ -310,7 +310,7 @@ public class ISplitPanel extends ComplexPanel implements Container,
}
}
- renderInformationFirst.updateSize(getElement());
+ renderInformation.updateSize(getElement());
}
@@ -480,11 +480,11 @@ public class ISplitPanel extends ComplexPanel implements Container,
super.setWidth(width);
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
if (child == firstChild) {
- return renderInformationFirst.getContentAreaSize();
+ return firstRenderSpace;
} else if (child == secondChild) {
- return renderInformationSecond.getContentAreaSize();
+ return secondRenderSpace;
}
return null;
@@ -508,7 +508,7 @@ public class ISplitPanel extends ComplexPanel implements Container,
return true;
}
- if (renderInformationFirst.updateSize(getElement())) {
+ if (renderInformation.updateSize(getElement())) {
return false;
} else {
return true;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
index 161c2e8091..cee2cebe4a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
@@ -13,17 +13,19 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
+import com.itmill.toolkit.terminal.gwt.client.BrowserInfo;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
public class ITabsheet extends ITabsheetBase implements
ContainerResizedListener {
@@ -115,8 +117,8 @@ public class ITabsheet extends ITabsheetBase implements
private final Element scrollerPrev; // tab-scroller prev button element
private int scrollerIndex = 0;
- private final TabBar tb;
- private final ITabsheetPanel tp;
+ private final TabBar tb = new TabBar();
+ private final ITabsheetPanel tp = new ITabsheetPanel();
private final Element contentNode, deco;
private final HashMap captions = new HashMap();
@@ -183,8 +185,6 @@ public class ITabsheet extends ITabsheetBase implements
DOM.appendChild(getElement(), tabs);
// Tabs
- tb = new TabBar();
- tp = new ITabsheetPanel();
tp.setStyleName(CLASSNAME + "-tabsheetpanel");
contentNode = DOM.createDiv();
@@ -216,8 +216,7 @@ public class ITabsheet extends ITabsheetBase implements
public void onBrowserEvent(Event event) {
// Tab scrolling
- if (isScrolledTabs()
- && DOM.compare(DOM.eventGetTarget(event), scrollerPrev)) {
+ if (isScrolledTabs() && DOM.eventGetTarget(event) == scrollerPrev) {
if (scrollerIndex > 0) {
scrollerIndex--;
DOM.setStyleAttribute(DOM.getChild(DOM.getFirstChild(DOM
@@ -225,8 +224,7 @@ public class ITabsheet extends ITabsheetBase implements
"display", "");
updateTabScroller();
}
- } else if (isClippedTabs()
- && DOM.compare(DOM.eventGetTarget(event), scrollerNext)) {
+ } else if (isClippedTabs() && DOM.eventGetTarget(event) == scrollerNext) {
int tabs = tb.getTabCount();
if (scrollerIndex + 1 <= tabs) {
DOM.setStyleAttribute(DOM.getChild(DOM.getFirstChild(DOM
@@ -351,68 +349,67 @@ public class ITabsheet extends ITabsheetBase implements
}
public void setHeight(String height) {
- if (this.height == null && height == null) {
- return;
- }
- String oldHeight = this.height;
+ super.setHeight(height);
this.height = height;
- if ((this.height != null && height == null)
- || (this.height == null && height != null)
- || !height.equals(oldHeight)) {
- iLayout();
- }
- }
-
- public void setWidth(String width) {
- String oldWidth = this.width;
- this.width = width;
- if ("100%".equals(width)) {
- // Allow browser to calculate width
- super.setWidth("");
- } else {
- super.setWidth(width);
- }
- if ((this.width != null && width == null)
- || (this.width == null && width != null)
- || !width.equals(oldWidth)) {
- // Run descendant layout functions
- client.runDescendentsLayout(this);
- }
- }
-
- public void iLayout() {
- renderInformation.updateSize(getElement());
-
- if (height != null && height != "") {
- super.setHeight(height);
-
+ if (height != null && !"".equals(height)) {
int contentHeight = getOffsetHeight()
- DOM.getElementPropertyInt(deco, "offsetHeight")
- - tb.getOffsetHeight();
+ - tb.getOffsetHeight() - 5;
if (contentHeight < 0) {
contentHeight = 0;
}
// Set proper values for content element
DOM.setStyleAttribute(contentNode, "height", contentHeight + "px");
+ renderSpace.setHeight(contentHeight);
DOM.setStyleAttribute(contentNode, "overflow", "auto");
- tp.setHeight("100%");
-
} else {
DOM.setStyleAttribute(contentNode, "height", "");
DOM.setStyleAttribute(contentNode, "overflow", "");
+ renderSpace.setHeight(0);
+ }
+ iLayout();
+ }
+
+ public void setWidth(String width) {
+ super.setWidth(width);
+ this.width = width;
+ if ("".equals(width)) {
+ renderSpace.setWidth(0);
+ contentNode.getStyle().setProperty("width", "");
+ } else {
+ int contentWidth = getOffsetWidth() - getContentAreaBorderWidth();
+ contentNode.getStyle().setProperty("width", contentWidth + "px");
+ renderSpace.setWidth(contentWidth);
}
+ iLayout();
+ }
+
+ public void iLayout() {
+ renderInformation.updateSize(getElement());
if (client != null) {
client.runDescendentsLayout(this);
}
- renderInformation.setContentAreaWidth(tp.getElement().getOffsetWidth());
- renderInformation.setContentAreaHeight(tp.getElement()
- .getOffsetHeight());
-
updateTabScroller();
+ if (BrowserInfo.get().getWebkitVersion() > 0) {
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ // Dough, safari scoll auto means actually just a moped
+ contentNode.getStyle().setProperty("overflow", "hidden");
+ (new Timer() {
+ @Override
+ public void run() {
+ contentNode.getStyle().setProperty("overflow",
+ "auto");
+ }
+ }).schedule(100);
+ }
+ });
+ }
+
}
/**
@@ -517,9 +514,27 @@ public class ITabsheet extends ITabsheetBase implements
}
- public Size getAllocatedSpace(Widget child) {
- // All tabs have equal amount of space allocated
+ private int borderW = -1;
+
+ private void detectBorder() {
+ String property = contentNode.getStyle().getProperty("overflow");
+ contentNode.getStyle().setProperty("overflow", "hidden");
+ borderW = contentNode.getOffsetWidth()
+ - contentNode.getPropertyInt("clientWidth");
+ contentNode.getStyle().setProperty("overflow", property);
+ }
- return renderInformation.getContentAreaSize();
+ private int getContentAreaBorderWidth() {
+ if (borderW < 0) {
+ detectBorder();
+ }
+ return borderW;
+ }
+
+ private RenderSpace renderSpace = new RenderSpace(0, 0, true);
+
+ public RenderSpace getAllocatedSpace(Widget child) {
+ // All tabs have equal amount of space allocated
+ return renderSpace;
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
index 0f18345da2..8ace8121aa 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
@@ -21,7 +21,7 @@ import com.google.gwt.user.client.ui.Widget;
public class ITabsheetPanel extends ComplexPanel {
private Widget visibleWidget;
- private boolean fullheight = false;
+ private int contentHeight;
/**
* Creates an empty tabsheet panel.
@@ -44,9 +44,6 @@ public class ITabsheetPanel extends ComplexPanel {
private Element createContainerElement() {
Element el = DOM.createDiv();
- if (fullheight) {
- DOM.setStyleAttribute(el, "height", "100%");
- }
hide(el);
return el;
}
@@ -109,33 +106,9 @@ public class ITabsheetPanel extends ComplexPanel {
}
}
- /*
- * Gets only called with 100% or ""
- */
- public void setHeight(String height) {
- super.setHeight(height);
- if ("100%".equals(height)) {
- if (!fullheight) {
- int childCount = DOM.getChildCount(getElement());
- for (int i = 0; i < childCount; i++) {
- DOM.setStyleAttribute(DOM.getChild(getElement(), i),
- "height", "100%");
- }
- fullheight = true;
- }
- } else if (fullheight) {
- int childCount = DOM.getChildCount(getElement());
- for (int i = 0; i < childCount; i++) {
- DOM.setStyleAttribute(DOM.getChild(getElement(), i), "height",
- "");
- }
- fullheight = false;
- }
- }
-
private void hide(Element e) {
- DOM.setStyleAttribute(e, "width", getOffsetWidth() + "px");
- DOM.setStyleAttribute(e, "height", getOffsetHeight() + "px");
+ DOM.setStyleAttribute(e, "width", "0px");
+ DOM.setStyleAttribute(e, "height", "0px");
DOM.setStyleAttribute(e, "overflow", "hidden");
DOM.setStyleAttribute(e, "visibility", "hidden");
DOM.setStyleAttribute(e, "position", "absolute");
@@ -144,17 +117,16 @@ public class ITabsheetPanel extends ComplexPanel {
}
private void unHide(Element e) {
+ DOM.setStyleAttribute(e, "marginLeft", "0px");
+ DOM.setStyleAttribute(e, "marginTop", "0px");
DOM.setStyleAttribute(e, "position", "");
DOM.setStyleAttribute(e, "top", "");
DOM.setStyleAttribute(e, "left", "");
DOM.setStyleAttribute(e, "visibility", "");
DOM.setStyleAttribute(e, "width", "");
- if (fullheight) {
- DOM.setStyleAttribute(e, "height", "100%");
- } else {
- DOM.setStyleAttribute(e, "height", "");
- }
+ DOM.setStyleAttribute(e, "height", "");
DOM.setStyleAttribute(e, "overflow", "");
}
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
index d41062b10c..8e601bd140 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
@@ -26,10 +26,9 @@ import com.itmill.toolkit.terminal.gwt.client.BrowserInfo;
import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.Focusable;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.Util;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
/**
*
@@ -65,8 +64,6 @@ public class IView extends SimplePanel implements Container,
*/
private Timer resizeTimer;
- private RenderInformation renderInformation = new RenderInformation();
-
public IView(String elementId) {
super();
setStyleName(CLASSNAME);
@@ -186,8 +183,6 @@ public class IView extends SimplePanel implements Container,
layout = lo;
}
- updateContentAreaSize();
-
layout.updateFromUIDL(childUidl, client);
// Update subwindows
@@ -289,14 +284,6 @@ public class IView extends SimplePanel implements Container,
}
- private void updateContentAreaSize() {
- renderInformation.setContentAreaWidth(getElement().getOffsetWidth());
-
- // For some reason IView has a 1 pixel padding
- renderInformation
- .setContentAreaHeight(getElement().getOffsetHeight() - 1);
- }
-
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
@@ -331,8 +318,6 @@ public class IView extends SimplePanel implements Container,
"window h" + IView.this.height);
}
if (changed) {
- updateContentAreaSize();
-
ApplicationConnection
.getConsole()
.log(
@@ -363,7 +348,6 @@ public class IView extends SimplePanel implements Container,
ApplicationConnection.getConsole().log(
"Running layout functions due window resize");
- updateContentAreaSize();
connection.runDescendentsLayout(this);
DOM.setStyleAttribute(getElement(), "overflow", overflow);
@@ -387,17 +371,54 @@ public class IView extends SimplePanel implements Container,
connection.sendPendingVariableChangesSync();
}
- private static native void focusElement(Element e)
- /*-{
- e.focus();
- }-*/;
-
public String onWindowClosing() {
return null;
}
- public Size getAllocatedSpace(Widget child) {
- return renderInformation.getContentAreaSize();
+ private final RenderSpace myRenderSpace = new RenderSpace() {
+ private int excessHeight = -1;
+ private int excessWidth = -1;
+
+ @Override
+ public int getHeight() {
+ return getElement().getOffsetHeight() - getExcessHeight();
+ }
+
+ private int getExcessHeight() {
+ if (excessHeight < 0) {
+ detetExessSize();
+ }
+ return excessHeight;
+ }
+
+ private void detetExessSize() {
+ getElement().getStyle().setProperty("overflow", "hidden");
+ excessHeight = getElement().getOffsetHeight()
+ - getElement().getPropertyInt("clientHeight");
+ excessWidth = getElement().getOffsetWidth()
+ - getElement().getPropertyInt("clientWidth");
+ }
+
+ @Override
+ public int getWidth() {
+ return getElement().getOffsetWidth() - getExcessWidth();
+ }
+
+ private int getExcessWidth() {
+ if (excessWidth < 0) {
+ detetExessSize();
+ }
+ return excessWidth;
+ }
+
+ @Override
+ public int getScrollbarSize() {
+ return Util.getNativeScrollbarSize();
+ }
+ };
+
+ public RenderSpace getAllocatedSpace(Widget child) {
+ return myRenderSpace;
}
public boolean hasChildComponent(Widget component) {
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 8de7a9e366..77d2573f54 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
@@ -5,6 +5,7 @@
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.Iterator;
+import java.util.Set;
import java.util.Vector;
import com.google.gwt.user.client.Command;
@@ -20,7 +21,9 @@ import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo;
+import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.Util;
@@ -31,7 +34,7 @@ import com.itmill.toolkit.terminal.gwt.client.Util;
*
* @author IT Mill Ltd
*/
-public class IWindow extends IToolkitOverlay implements Paintable,
+public class IWindow extends IToolkitOverlay implements Container,
ScrollListener {
private static final int MIN_HEIGHT = 60;
@@ -329,6 +332,7 @@ public class IWindow extends IToolkitOverlay implements Paintable,
}
} else if (!showingUrl) {
contentPanel.setWidget((Widget) lo);
+ layout = lo;
}
lo.updateFromUIDL(childUidl, client);
@@ -774,4 +778,48 @@ public class IWindow extends IToolkitOverlay implements Paintable,
borderWidthHorizontal = windowWidth - contentWidth;
}
+ 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();
+ }
+ };
+ } else {
+ // Exception ??
+ return null;
+ }
+ }
+
+ public boolean hasChildComponent(Widget component) {
+ if (component == layout) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
+ contentPanel.setWidget(newComponent);
+ }
+
+ public boolean requestLayout(Set<Paintable> child) {
+ return true;
+ }
+
+ public void updateCaption(Paintable component, UIDL uidl) {
+ // NOP, window has own caption, layout captio not rendered
+ }
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/IAbsoluteGrid.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/IAbsoluteGrid.java
index 54f81f44b2..38ce97192d 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/IAbsoluteGrid.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/IAbsoluteGrid.java
@@ -286,7 +286,9 @@ public class IAbsoluteGrid extends Composite implements
cell.render();
cell.vAling();
}
- client.runDescendentsLayout(ap);
+ if (client != null) {
+ client.runDescendentsLayout(ap);
+ }
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/ISizeableGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/ISizeableGridLayout.java
index e639c99b48..ed07b06f2a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/ISizeableGridLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/absolutegrid/ISizeableGridLayout.java
@@ -14,8 +14,8 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.ICaption;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
+import com.itmill.toolkit.terminal.gwt.client.RenderSpace;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
import com.itmill.toolkit.terminal.gwt.client.ui.MarginInfo;
/**
@@ -255,7 +255,7 @@ public class ISizeableGridLayout extends IAbsoluteGrid implements Paintable,
return false;
}
- public Size getAllocatedSpace(Widget child) {
+ public RenderSpace getAllocatedSpace(Widget child) {
// TODO Auto-generated method stub
return null;
}