diff options
Diffstat (limited to 'src/com/itmill/toolkit/ui/SplitPanel.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/SplitPanel.java | 140 |
1 files changed, 137 insertions, 3 deletions
diff --git a/src/com/itmill/toolkit/ui/SplitPanel.java b/src/com/itmill/toolkit/ui/SplitPanel.java index cb9adc5eef..3ae1a90c73 100644 --- a/src/com/itmill/toolkit/ui/SplitPanel.java +++ b/src/com/itmill/toolkit/ui/SplitPanel.java @@ -45,7 +45,7 @@ import com.itmill.toolkit.terminal.Sizeable; * @VERSION@ * @since 5.0 */ -public class SplitPanel extends AbstractLayout { +public class SplitPanel extends AbstractLayout implements Sizeable { /* Predefined orientations ***************************************** */ @@ -73,6 +73,30 @@ public class SplitPanel extends AbstractLayout { private int posUnit = UNITS_PERCENTAGE; /** + * Height of the layout. Set to -1 for undefined height. + */ + private int height = -1; + + /** + * Height unit. + * + * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS; + */ + private int heightUnit = UNITS_PIXELS; + + /** + * Width of the layout. Set to -1 for undefined width. + */ + private int width = -1; + + /** + * Width unit. + * + * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS; + */ + private int widthUnit = UNITS_PIXELS; + + /** * Creates a new split panel. The orientation of the panels is * <code>ORIENTATION_VERTICAL</code>. */ @@ -210,13 +234,20 @@ public class SplitPanel extends AbstractLayout { * if the paint operation failed. */ public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); String position = pos + UNIT_SYMBOLS[posUnit]; target.addAttribute("position", position); + // Add size info + if (getHeight() > -1) + target.addAttribute("height", getHeight() + + UNIT_SYMBOLS[getHeightUnits()]); + if (getWidth() > -1) + target.addAttribute("width", getWidth() + + UNIT_SYMBOLS[getWidthUnits()]); + if (firstComponent != null) firstComponent.paint(target); else @@ -278,11 +309,114 @@ public class SplitPanel extends AbstractLayout { * * @param pos * size of the first region - * @param unit the unit (from {@link Sizeable}) in which the size is given. + * @param unit + * the unit (from {@link Sizeable}) in which the size is given. */ public void setSplitPosition(int pos, int unit) { this.pos = pos; this.posUnit = unit; } + /* + * (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 units) { + this.heightUnit = units; + requestRepaint(); + } + + /* + * (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 units) { + this.widthUnit = units; + requestRepaint(); + } + } |