aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2008-09-29 09:02:51 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2008-09-29 09:02:51 +0000
commit656d5f210cd96837ec6aa41ed737048a3cbb1325 (patch)
tree6ed3ad24f78aa76c3d18d1f041844212ad8708f3
parent575ca40f133a15fc54f1797fd1a1e97300b4b2df (diff)
downloadvaadin-framework-656d5f210cd96837ec6aa41ed737048a3cbb1325.tar.gz
vaadin-framework-656d5f210cd96837ec6aa41ed737048a3cbb1325.zip
added CSS formatting for sizes, so we don't get decimals for pixel sizes
svn changeset:5536/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/ui/AbstractComponent.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java
index b4a33468b3..a80d79cb56 100644
--- a/src/com/itmill/toolkit/ui/AbstractComponent.java
+++ b/src/com/itmill/toolkit/ui/AbstractComponent.java
@@ -604,12 +604,10 @@ public abstract class AbstractComponent implements Component, MethodEventSource
if (isVisible()) {
if (getHeight() >= 0) {
- target.addAttribute("height", "" + getHeight()
- + UNIT_SYMBOLS[getHeightUnits()]);
+ target.addAttribute("height", "" + getCSSHeight());
}
if (getWidth() >= 0) {
- target.addAttribute("width", "" + getWidth()
- + UNIT_SYMBOLS[getWidthUnits()]);
+ target.addAttribute("width", "" + getCSSWidth());
}
if (styles != null && styles.size() > 0) {
@@ -656,6 +654,32 @@ public abstract class AbstractComponent implements Component, MethodEventSource
}
/**
+ * Build CSS compatible string representation of height.
+ *
+ * @return CSS height
+ */
+ private String getCSSHeight() {
+ if (getHeightUnits() == UNITS_PIXELS) {
+ return ((int) getHeight()) + UNIT_SYMBOLS[getHeightUnits()];
+ } else {
+ return getHeight() + UNIT_SYMBOLS[getHeightUnits()];
+ }
+ }
+
+ /**
+ * Build CSS compatible string representation of width.
+ *
+ * @return CSS width
+ */
+ private String getCSSWidth() {
+ if (getWidthUnits() == UNITS_PIXELS) {
+ return ((int) getWidth()) + UNIT_SYMBOLS[getWidthUnits()];
+ } else {
+ return getWidth() + UNIT_SYMBOLS[getWidthUnits()];
+ }
+ }
+
+ /**
* Paints any needed component-specific things to the given UIDL stream. The
* more general {@link #paint(PaintTarget)} method handles all general
* attributes common to all components, and it calls this method to paint