aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Koivuviita <jouni.koivuviita@itmill.com>2007-12-14 07:38:54 +0000
committerJouni Koivuviita <jouni.koivuviita@itmill.com>2007-12-14 07:38:54 +0000
commite294decedef3925ccd8bd0e1582409478825a0ab (patch)
treec41f7eba5c02ecc025b3850807053501a659735d
parentee957b1b9710ec771be407414c5c67ffed49f5a0 (diff)
downloadvaadin-framework-e294decedef3925ccd8bd0e1582409478825a0ab.tar.gz
vaadin-framework-e294decedef3925ccd8bd0e1582409478825a0ab.zip
Implemented layout spacing in IOrderedLayout.
svn changeset:3236/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java51
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css7
-rw-r--r--src/com/itmill/toolkit/ui/OrderedLayout.java1
3 files changed, 45 insertions, 14 deletions
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 e491e101b8..3a4b5d6f89 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
@@ -52,6 +52,8 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
protected Element root;
protected Element margin;
+ private boolean hasComponentSpacing;
+
public IOrderedLayout(int orientation) {
orientationMode = orientation;
constructDOM();
@@ -65,7 +67,8 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
if (orientationMode == ORIENTATION_HORIZONTAL) {
final String structure = "<table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr></tr></tbody></table>";
DOM.setInnerHTML(margin, structure);
- childContainer = DOM.getFirstChild(DOM.getFirstChild(DOM.getFirstChild(margin)));
+ childContainer = DOM.getFirstChild(DOM.getFirstChild(DOM
+ .getFirstChild(margin)));
} else {
childContainer = margin;
}
@@ -81,6 +84,9 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
return;
}
+ //
+ hasComponentSpacing = uidl.getBooleanAttribute("spacing");
+
// Update contained components
final ArrayList uidlWidgets = new ArrayList();
@@ -312,14 +318,14 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
protected void handleMargins(UIDL uidl) {
final MarginInfo margins = new MarginInfo(uidl
.getIntAttribute("margins"));
- setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins
- .hasTop());
- setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, margins
- .hasRight());
+ setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP,
+ margins.hasTop());
+ setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT,
+ margins.hasRight());
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM,
margins.hasBottom());
- setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, margins
- .hasLeft());
+ setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT,
+ margins.hasLeft());
}
protected void handleAlignments(UIDL uidl) {
@@ -330,30 +336,47 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
int alignmentIndex = 0;
// Insert alignment attributes
final Iterator it = getPaintables().iterator();
+ boolean first = true;
while (it.hasNext()) {
// Calculate alignment info
final AlignmentInfo ai = new AlignmentInfo(
alignments[alignmentIndex++]);
- final Element td = DOM.getParent(((Widget) it.next()).getElement());
+ final Element wrapper = DOM.getParent(((Widget) it.next())
+ .getElement());
if (Util.isIE()) {
- DOM
- .setElementAttribute(td, "vAlign", ai
- .getVerticalAlignment());
+ DOM.setElementAttribute(wrapper, "vAlign", ai
+ .getVerticalAlignment());
} else {
- DOM.setStyleAttribute(td, "verticalAlign", ai
+ DOM.setStyleAttribute(wrapper, "verticalAlign", ai
.getVerticalAlignment());
}
// TODO use one-cell table to implement horizontal alignments
if (Util.isIE()) {
- DOM.setElementAttribute(td, "align", ai
+ DOM.setElementAttribute(wrapper, "align", ai
.getHorizontalAlignment());
} else {
- DOM.setStyleAttribute(td, "textAlign", ai
+ DOM.setStyleAttribute(wrapper, "textAlign", ai
.getHorizontalAlignment());
}
+
+ if (first) {
+ setSpacingEnabled(wrapper, false);
+ first = false;
+ } else {
+ setSpacingEnabled(wrapper, hasComponentSpacing);
+ }
}
}
+ private void setSpacingEnabled(Element e, boolean b) {
+ setStyleName(
+ e,
+ CLASSNAME
+ + "-"
+ + (orientationMode == ORIENTATION_HORIZONTAL ? StyleConstants.HORIZONTAL_SPACING
+ : StyleConstants.VERTICAL_SPACING), b);
+ }
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css b/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css
index c94584332d..1a429b2af0 100644
--- a/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css
+++ b/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css
@@ -9,4 +9,11 @@
}
.i-orderedlayout-margin-left {
padding-left: 18px;
+}
+
+.i-orderedlayout-vspacing {
+ margin-top: 8px;
+}
+.i-orderedlayout-hspacing {
+ padding-left: 8px;
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/ui/OrderedLayout.java b/src/com/itmill/toolkit/ui/OrderedLayout.java
index 7bdf0611a2..7b2f116300 100644
--- a/src/com/itmill/toolkit/ui/OrderedLayout.java
+++ b/src/com/itmill/toolkit/ui/OrderedLayout.java
@@ -346,6 +346,7 @@ public class OrderedLayout extends AbstractLayout {
*/
public void setSpacing(boolean enabled) {
spacing = enabled;
+ requestRepaint();
}
/**