diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-01-28 10:22:16 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-01-28 10:22:16 +0000 |
commit | d48f8a80f403e0ebb21cf6fa7aafde091e43d35b (patch) | |
tree | 67646c1518ea2a92a3e5df50c4d9ba07e9c39d8c /src/com/itmill/toolkit/ui/AbstractComponent.java | |
parent | afc95e6c9482fc0611449d3d0be7c33ac7daa82b (diff) | |
download | vaadin-framework-d48f8a80f403e0ebb21cf6fa7aafde091e43d35b.tar.gz vaadin-framework-d48f8a80f403e0ebb21cf6fa7aafde091e43d35b.zip |
component implements sizeable and simple general terminal implementation
svn changeset:3662/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/AbstractComponent.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/AbstractComponent.java | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 90099eecc7..137e48a0c2 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -115,6 +115,13 @@ public abstract class AbstractComponent implements Component, MethodEventSource private String testingId; + /* Sizeable fields */ + + private int width = SIZE_UNDEFINED; + private int height = SIZE_UNDEFINED; + private int widthUnit = UNITS_PIXELS; + private int heightUnit = UNITS_PIXELS; + /* Constructor ***************************************************** */ /** @@ -576,6 +583,15 @@ public abstract class AbstractComponent implements Component, MethodEventSource // Paint the contents of the component + if (getHeight() >= 0) { + target.addAttribute("height", "" + getHeight() + + UNIT_SYMBOLS[getHeightUnits()]); + } + if (getWidth() >= 0) { + target.addAttribute("width", "" + getWidth() + + UNIT_SYMBOLS[getWidthUnits()]); + } + if (styles != null && styles.size() > 0) { target.addAttribute("style", getStyle()); } @@ -979,4 +995,118 @@ public abstract class AbstractComponent implements Component, MethodEventSource public Object getData() { return applicationData; } + + /* Sizeable and other size related methods */ + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#getHeight() + */ + public int getHeight() { + return height; + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits() + */ + public int getHeightUnits() { + return heightUnit; + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#getWidth() + */ + public int getWidth() { + return width; + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits() + */ + public int getWidthUnits() { + return widthUnit; + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#setHeight(int) + */ + public void setHeight(int height) { + this.height = height; + requestRepaint(); + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int) + */ + public void setHeightUnits(int unit) { + heightUnit = unit; + requestRepaint(); + } + + public void setHeight(int height, int unit) { + setHeight(height); + setHeightUnits(unit); + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull() + */ + public void setSizeFull() { + height = 100; + width = 100; + heightUnit = UNITS_PERCENTAGE; + widthUnit = UNITS_PERCENTAGE; + requestRepaint(); + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined() + */ + public void setSizeUndefined() { + height = -1; + width = -1; + heightUnit = UNITS_PIXELS; + widthUnit = UNITS_PIXELS; + requestRepaint(); + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#setWidth(int) + */ + public void setWidth(int width) { + this.width = width; + requestRepaint(); + } + + /* + * (non-Javadoc) + * + * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int) + */ + public void setWidthUnits(int unit) { + widthUnit = unit; + requestRepaint(); + } + + public void setWidth(int width, int unit) { + setWidth(width); + setWidthUnits(unit); + } }
\ No newline at end of file |