setModal(!modal);
}
- // Initialize the width from UIDL
+ // Initialize the size from UIDL
+ // FIXME relational size is for outer size, others are applied for
+ // content
if (uidl.hasVariable("width")) {
final String width = uidl.getStringVariable("width");
- setWidth(width);
- }
- if (uidl.hasVariable("height")) {
- final String height = uidl.getStringVariable("height");
- setHeight(height);
+ if (width.indexOf("px") < 0) {
+ DOM.setStyleAttribute(getElement(), "width", width);
+ } else {
+ setWidth(width);
+ }
}
// Initialize the position form UIDL
show();
}
+ // Height set after show so we can detect space used by decorations
+ if (uidl.hasVariable("height")) {
+ final String height = uidl.getStringVariable("height");
+ if (height.indexOf("%") > 0) {
+ int winHeight = Window.getClientHeight();
+ float percent = Float.parseFloat(height.substring(0, height
+ .indexOf("%"))) / 100.0f;
+ int contentPixels = (int) (winHeight * percent);
+ contentPixels -= (DOM.getElementPropertyInt(getElement(),
+ "offsetHeight") - DOM.getElementPropertyInt(contents,
+ "offsetHeight"));
+ // FIXME hardcoded contents elements border size
+ contentPixels -= 2;
+
+ setHeight(contentPixels + "px");
+ } else {
+ setHeight(height);
+ }
+ }
+
if (uidl.hasAttribute("caption")) {
setCaption(uidl.getStringAttribute("caption"));
}
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.ParameterHandler;
import com.itmill.toolkit.terminal.Resource;
-import com.itmill.toolkit.terminal.Sizeable;
import com.itmill.toolkit.terminal.Terminal;
import com.itmill.toolkit.terminal.URIHandler;
terminal = type;
}
- /**
- * Window only supports pixels as unit.
- *
- * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
- */
- public void setHeightUnits(int units) {
- if (units != Sizeable.UNITS_PIXELS) {
- throw new IllegalArgumentException("Only pixels are supported");
- }
- }
-
- /**
- * Window only supports pixels as unit.
- *
- * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
- */
- public void setWidthUnits(int units) {
- if (units != Sizeable.UNITS_PIXELS) {
- throw new IllegalArgumentException("Only pixels are supported");
- }
- }
-
/**
* Private data structure for storing opening window properties.
*/