}
void setSpacingEnabled(boolean b) {
- setStyleName(getElement(), CLASSNAME + "-" + StyleConstants.VERTICAL_SPACING, b);
+ setStyleName(getElement(), CLASSNAME + "-"
+ + StyleConstants.VERTICAL_SPACING, b);
}
}
class HorizontalWidgetWrapper extends WidgetWrapper {
- Element td;
- String valign = "top";
+ private Element td;
+ private String valign = "top";
+ private String align = "left";
public HorizontalWidgetWrapper(Element element) {
if (DOM.getElementProperty(element, "nodeName").equals("TD")) {
}
valign = verticalAlignment;
}
+ if (!align.equals(horizontalAlignment)) {
+ DOM.setStyleAttribute(getContainerElement(), "textAlign",
+ horizontalAlignment);
+ align = horizontalAlignment;
+ }
}
public Element getContainerElement() {
}
void setSpacingEnabled(boolean b) {
- setStyleName(getElement(), CLASSNAME + "-" + StyleConstants.HORIZONTAL_SPACING, b);
+ setStyleName(getElement(), CLASSNAME + "-"
+ + StyleConstants.HORIZONTAL_SPACING, b);
}
}
pixels = 0;
}
DOM.setStyleAttribute(me, "height", pixels + "px");
+ DOM.setStyleAttribute(me, "overflow", "hidden");
}
if (expandedWidget == null) {
private int getTopMargin() {
if (topMargin < 0) {
- topMargin = DOM.getElementPropertyInt(childContainer, "offsetTop");
+ topMargin = DOM.getElementPropertyInt(childContainer, "offsetTop")
+ - DOM.getElementPropertyInt(getElement(), "offsetTop");
+ }
+ if (topMargin < 0) {
+ // FIXME shouldn't happen
+ return 0;
+ } else {
+ return topMargin;
}
- return topMargin;
}
private int getBottomMargin() {
if (bottomMargin < 0) {
- bottomMargin = DOM.getElementPropertyInt(me, "offsetHeight")
+ bottomMargin = DOM.getElementPropertyInt(me, "offsetTop")
+ + DOM.getElementPropertyInt(me, "offsetHeight")
- DOM.getElementPropertyInt(breakElement, "offsetTop");
+ if (bottomMargin < 0) {
+ // FIXME shouldn't happen
+ return 0;
+ }
}
return bottomMargin;
}
--- /dev/null
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
+package com.itmill.toolkit.tests;\r
+\r
+import com.itmill.toolkit.terminal.Size;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.CustomComponent;\r
+import com.itmill.toolkit.ui.ExpandLayout;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.Panel;\r
+\r
+/**\r
+ * \r
+ * @author IT Mill Ltd.\r
+ */\r
+public class TestForExpandLayout2 extends CustomComponent {\r
+\r
+ ExpandLayout main;\r
+\r
+ public TestForExpandLayout2() {\r
+ createNewView();\r
+ setCompositionRoot(main);\r
+ }\r
+\r
+ public void createNewView() {\r
+ main = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);\r
+\r
+ Panel left = new Panel("Left column");\r
+ left.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
+ left.getSize().setWidth(150);\r
+ main.addComponent(left);\r
+\r
+ ExpandLayout center = new ExpandLayout();\r
+ center.addComponent(new Label("header"));\r
+ Panel mainContent = new Panel();\r
+ center.addComponent(mainContent);\r
+ center.expand(mainContent);\r
+ mainContent.getSize().setSizeFull();\r
+\r
+ ExpandLayout buttons = new ExpandLayout(\r
+ ExpandLayout.ORIENTATION_HORIZONTAL);\r
+ buttons.getSize().setHeight(30, Size.UNITS_PIXELS);\r
+ Button b1 = new Button("Save");\r
+ Button b2 = new Button("Cancel");\r
+ Button b3 = new Button("Logout");\r
+ buttons.addComponent(b1);\r
+ buttons.setComponentAlignment(b1, ExpandLayout.ALIGNMENT_RIGHT,\r
+ ExpandLayout.ALIGNMENT_TOP);\r
+ buttons.addComponent(b2);\r
+ buttons.addComponent(b3);\r
+ center.addComponent(buttons);\r
+\r
+ main.addComponent(center);\r
+ main.expand(center);\r
+\r
+ Panel right = new Panel("Right column");\r
+ right.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
+ right.getSize().setWidth(200);\r
+\r
+ main.addComponent(right);\r
+\r
+ }\r
+}\r
--- /dev/null
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
+package com.itmill.toolkit.tests;\r
+\r
+import com.itmill.toolkit.terminal.Size;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.CustomComponent;\r
+import com.itmill.toolkit.ui.DateField;\r
+import com.itmill.toolkit.ui.ExpandLayout;\r
+\r
+/**\r
+ * \r
+ * @author IT Mill Ltd.\r
+ */\r
+public class TestForExpandLayout3 extends CustomComponent {\r
+\r
+ ExpandLayout main = new ExpandLayout();\r
+\r
+ DateField df;\r
+\r
+ public TestForExpandLayout3() {\r
+ setCompositionRoot(main);\r
+ createNewView();\r
+ }\r
+\r
+ public void createNewView() {\r
+ main.removeAllComponents();\r
+\r
+ ExpandLayout el;\r
+ Button b;\r
+ Button b2;\r
+\r
+ el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);\r
+\r
+ b = new Button("SDFS");\r
+ b2 = new Button("DSFSDFDFSSDF");\r
+\r
+ el.addComponent(b);\r
+ el.addComponent(b2);\r
+\r
+ el.expand(b);\r
+ el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_RIGHT,\r
+ ExpandLayout.ALIGNMENT_VERTICAL_CENTER);\r
+ main.addComponent(el);\r
+\r
+ el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);\r
+\r
+ b = new Button("SDFS");\r
+ b2 = new Button("DSFSDFDFSSDF");\r
+\r
+ el.addComponent(b);\r
+ el.addComponent(b2);\r
+\r
+ el.expand(b);\r
+ el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_HORIZONTAL_CENTER,\r
+ ExpandLayout.ALIGNMENT_VERTICAL_CENTER);\r
+ el.getSize().setHeight(60, Size.UNITS_PIXELS);\r
+ el.setMargin(true);\r
+ main.addComponent(el);\r
+\r
+ el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);\r
+\r
+ b = new Button("SDFS");\r
+ b2 = new Button("DSFSDFDFSSDF");\r
+\r
+ el.addComponent(b);\r
+ el.addComponent(b2);\r
+\r
+ el.expand(b);\r
+ el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_RIGHT,\r
+ ExpandLayout.ALIGNMENT_BOTTOM);\r
+ el.getSize().setHeight(100, Size.UNITS_PIXELS);\r
+ el.setSpacing(true);\r
+\r
+ main.addComponent(el);\r
+\r
+ }\r
+}\r