org.zkoss.zul
Class Box

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.Box
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl, Box, XulElement
Direct Known Subclasses:
Hbox, Vbox

public class Box
extends XulElement
implements Box

A box.

Default getZclass(): z-vbox.(since 3.5.0)

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrl
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_height, _left, _top, _width, _zclass
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
Box()
          Default: vertical (Vbox).
Box(Component[] children)
          Constructor a box by assigning an array of children.
Box(java.lang.String orient)
           
Box(java.lang.String orient, Component[] children)
          Constructor a box by assigning an array of children.
 
Method Summary
 java.lang.String getAlign()
          Returns the alignment of cells of a box in the 'opposite' direction (null, start, center, end).
 java.lang.String getHeights()
          Deprecated. As of release 5.0.0, use Cell instead.
 java.lang.String getOrient()
          Returns the orient (the same as AbstractComponent.getMold()).
 java.lang.String getPack()
          Returns the pack alignment of cells of this box (start, center, end) plus an indication stretch option.
 java.lang.String getSpacing()
          Returns the spacing between adjacent children, or null if the default spacing is used.
 java.lang.String getWidths()
          Deprecated. As of release 5.0.0, use Cell instead.
 java.lang.String getZclass()
          Returns the ZK Cascading Style class(es) for this component.
 boolean isHorizontal()
          Returns whether it is a horizontal box.
 boolean isVertical()
          Returns whether it is a vertical box.
protected  void renderProperties(ContentRenderer renderer)
          Renders the content of this component, excluding the enclosing tags and children.
 void setAlign(java.lang.String align)
          Sets the alignment of cells of this box in the 'opposite' direction (start, center, end, stretch).
 void setHeights(java.lang.String heights)
          Deprecated. As of release 5.0.0, use Cell instead.
 void setOrient(java.lang.String orient)
          Sets the orient.
 void setPack(java.lang.String pack)
          Sets the alignment of cells of this box (start, center, end) plus an stretch option.
 void setSpacing(java.lang.String spacing)
          Sets the spacing between adjacent children.
 void setWidths(java.lang.String widths)
          Deprecated. As of release 5.0.0, use Cell instead.
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getDraggable, getDroppable, getHeight, getHflex, getLeft, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, newExtraCtrl, service, setClass, setDraggable, setDroppable, setFocus, setHeight, setHflex, setLeft, setSclass, setStyle, setTooltiptext, setTop, setVflex, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, clone, containsVariable, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getClientEvents, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, newChildren, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, unsetVariable, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zul.impl.api.XulElement
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from interface org.zkoss.zk.ui.Component
addEventListener, addForward, addForward, addForward, addForward, appendChild, applyProperties, clone, containsVariable, detach, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getDefinition, getDesktop, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setAuService, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, setWidgetListener, setWidgetOverride, unsetVariable
 
Methods inherited from interface org.zkoss.zk.ui.ext.Scope
addScopeListener, getAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute
 

Constructor Detail

Box

public Box()
Default: vertical (Vbox).


Box

public Box(java.lang.String orient)
Parameters:
orient - either "horizontal" or "vertical".

Box

public Box(Component[] children)
Constructor a box by assigning an array of children.

Parameters:
children - an array of children to be added
Since:
2.4.0

Box

public Box(java.lang.String orient,
           Component[] children)
Constructor a box by assigning an array of children.

Parameters:
children - an array of children to be added
Since:
2.4.0
Method Detail

isHorizontal

public boolean isHorizontal()
Returns whether it is a horizontal box.

Specified by:
isHorizontal in interface Box
Since:
3.0.0

isVertical

public boolean isVertical()
Returns whether it is a vertical box.

Specified by:
isVertical in interface Box
Since:
3.0.0

getOrient

public java.lang.String getOrient()
Returns the orient (the same as AbstractComponent.getMold()).

Default: "vertical".

Specified by:
getOrient in interface Box

setOrient

public void setOrient(java.lang.String orient)
               throws WrongValueException
Sets the orient.

Specified by:
setOrient in interface Box
Parameters:
orient - either "horizontal" or "vertical".
Throws:
WrongValueException

getSpacing

public java.lang.String getSpacing()
Returns the spacing between adjacent children, or null if the default spacing is used.

The default spacing depends on the definition of the style class called "xxx-sp", where xxx is

  1. HtmlBasedComponent.getSclass() if it is not null.
  2. hbox if HtmlBasedComponent.getSclass() is null and it is a horizontal box.
  3. vbox if HtmlBasedComponent.getSclass() is null and it is a vertical box.

Default: null (means to use the default spacing).

Specified by:
getSpacing in interface Box

setSpacing

public void setSpacing(java.lang.String spacing)
Sets the spacing between adjacent children.

Specified by:
setSpacing in interface Box
Parameters:
spacing - the spacing (such as "0", "5px", "3pt" or "1em"), or null to use the default spacing
See Also:
getSpacing()

getAlign

public java.lang.String getAlign()
Returns the alignment of cells of a box in the 'opposite' direction (null, start, center, end).

Default: start

The align attribute specifies how child elements of the box are aligned, when the size of the box is larger than the total size of the children. For boxes that have horizontal orientation, it specifies how its children will be aligned vertically. For boxes that have vertical orientation, it is used to specify how its children are aligned horizontally. The pack attribute (getPack()) is related to the alignment but is used to specify the position in the opposite direction.

start
Child elements are aligned starting from the left or top edge of the box. If the box is larger than the total size of the children, the extra space is placed on the right or bottom side.
center
Extra space is split equally along each side of the child elements, resulting in the children being placed in the center of the box.
end
Child elements are placed on the right or bottom edge of the box. If the box is larger than the total size of the children, the extra space is placed on the left or top side.
stretch(since 5.0)
Child elements are stretched to fill the box.

Specified by:
getAlign in interface Box
Since:
3.0.0

setAlign

public void setAlign(java.lang.String align)
Sets the alignment of cells of this box in the 'opposite' direction (start, center, end, stretch).

Specified by:
setAlign in interface Box
Parameters:
align - the alignment in the 'opposite' direction. Allowed values: start, center, end, stretch. If empty or null, the browser's default is used (IE center and FF left, if vertical).
Since:
3.0.0

getPack

public java.lang.String getPack()
Returns the pack alignment of cells of this box (start, center, end) plus an indication stretch option.

Default: start.

The pack attribute specifies where child elements of the box are placed when the box is larger that the size of the children. For boxes with horizontal orientation, it is used to indicate the position of children horizontally. For boxes with vertical orientation, it is used to indicate the position of children vertically. The align attribute (getAlign())is used to specify the position in the opposite direction.

start
Child elements are aligned starting from the left or top edge of the box. If the box is larger than the total size of the children, the Extra space is placed on the right or bottom side.
center
Extra space is split equally along each side of the child elements, resulting in the children being placed in the center of the box.
end
Child elements are placed on the right or bottom edge of the box. If the box is larger than the total size of the children, the extra space is placed on the left or top side.
stretch(since 5.0)
This is an extra option in addition to the (start, center, end) options. When add this extra option in the pack attribute, the Extra space is placed proportionally and evenly along each child elements. If you specify "stretch,start", then the Extra proportionally and evenly allocated space for each child is placed on the right or bottom side of the child. If you specify "stretch,center", then the Extra proportionally and evenly allocated space for each child is split equally along each side of the child. If you specify "stretch,end", then the Extra proportionally and evenly allocated space for each child is placed on the left or top side of the child. Note that if there are Splitter child inside this Box, then this Box behaves as if the pack attribute has been set the "stretch" option; no matter you really specify "stretch" in pack attribute or not. If given null or simply "stretch" to this pack attribute then it is the same as "stretch,start"

Specified by:
getPack in interface Box
Since:
3.0.0

setPack

public void setPack(java.lang.String pack)
Sets the alignment of cells of this box (start, center, end) plus an stretch option.

Specified by:
setPack in interface Box
Parameters:
pack - the alignment. Allowed values: (start, center, end) plus an stretch option. If empty or null, it defaults to "stretch,start".
Since:
3.0.0
See Also:
getPack()

getWidths

public java.lang.String getWidths()
Deprecated. As of release 5.0.0, use Cell instead.

Returns the widths/heights, which is a list of numbers separated by comma to denote the width/height of each cell in a box. If Hbox (i.e., getOrient() is horizontal), it is a list of widths. If Vbox (i.e., getOrient() is vertical), it is a list of heights.

It is the same as getHeights().

Default: empty.

Specified by:
getWidths in interface Box

getHeights

public java.lang.String getHeights()
Deprecated. As of release 5.0.0, use Cell instead.

Returns the heights/widths, which is a list of numbers separated by comma to denote the height/width of each cell in a box. If Hbox (i.e., getOrient() is horizontal), it is a list of widths. If Vbox (i.e., getOrient() is vertical), it is a list of heights.

It is the same as getWidths().

Default: empty.

Specified by:
getHeights in interface Box

setWidths

public void setWidths(java.lang.String widths)
               throws WrongValueException
Deprecated. As of release 5.0.0, use Cell instead.

Sets the widths/heights, which is a list of numbers separated by comma to denote the width/height of each cell in a box.

It is the same as setHeights(java.lang.String).

For example, "10%,20%,30%" means the second cell shall occupy 10% width, the second cell 20%, the third cell 30%, and the following cells don't specify any width.

Note: the splitters are ignored, i.e., they are not cells.

Another example, ",,30%" means the third cell shall occupy 30% width, and the rest of cells don't specify any width. Of course, the real widths depend on the interpretation of the browser.

Specified by:
setWidths in interface Box
Throws:
WrongValueException

setHeights

public void setHeights(java.lang.String heights)
                throws WrongValueException
Deprecated. As of release 5.0.0, use Cell instead.

Sets the widths/heights, which is a list of numbers separated by comma to denote the width/height of each cell in a box.

It is the same as setWidths(java.lang.String).

Specified by:
setHeights in interface Box
Throws:
WrongValueException

renderProperties

protected void renderProperties(ContentRenderer renderer)
                         throws java.io.IOException
Description copied from class: HtmlBasedComponent
Renders the content of this component, excluding the enclosing tags and children.

See also Render Special Properties

Overrides:
renderProperties in class XulElement
Throws:
java.io.IOException

getZclass

public java.lang.String getZclass()
Description copied from class: HtmlBasedComponent
Returns the ZK Cascading Style class(es) for this component. It usually depends on the implementation of the mold (@{link #getMold}).

Default: null (the default value depends on element).

HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

Specified by:
getZclass in interface HtmlBasedComponent
Overrides:
getZclass in class HtmlBasedComponent
See Also:
HtmlBasedComponent.getSclass()


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo