com.extjs.gxt.ui.client.widget
Class BoxComponent

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
Button, ColumnFooter, ColumnFooter.FooterRow, ColumnHeader, ColumnHeader.GridSplitBar, ColumnHeader.Group, ColumnHeader.Head, Composite, Container, DatePicker, Editor, Field, FlashComponent, Grid, Html, HtmlEditor.rte, IconButton, Insert, LabelToolItem, ListView, ModalPanel, ProgressBar, Slider, SplitBar, Status, StatusProxy, TableColumnUI, TableHeader, Text, TreePanel, WidgetComponent

public class BoxComponent
extends Component

Base class for any visual Component that uses a box container. BoxComponent provides automatic box model adjustments for sizing and positioning and will work correctly within the Component rendering model.

Events:
Resize : BoxComponentEvent(boxComponent, width, height)
Fires after the component is resized.
Move : BoxComponentEvent(boxComponent, x, y)
Fires after the component is moved.
Inherited Events:
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  boolean adjustSize
          True to adjust sizes for box model issues to ensure actual size matches set size.
protected  boolean cacheSizes
          True to cache size calculation.
protected  boolean ensureVisibilityOnSizing
          Set this to true if you have sizing issues in initial collapsed or hidden items.
protected  java.lang.String height
           
protected  Size lastSize
           
protected  Layer layer
          A specialized El that provides support for a shadow and shim.
protected  boolean shim
          True to enable a shim which uses a transparent iframe to stop content from bleeding through.
protected  java.lang.String width
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
BoxComponent()
           
 
Method Summary
protected  Point adjustPosition(Point point)
           
protected  Size adjustSize(Size size)
           
protected  void afterRender()
          Called after the component has been rendered and is attached for the first time.
protected  ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
           
 Rectangle getBounds(boolean local)
          Gets the current box measurements of the component's underlying element.
 int getHeight()
          Returns the component's offset height.
 int getHeight(boolean content)
          Return the component's height.
 Point getPosition(boolean local)
          Returns the component's current position.
protected  El getPositionEl()
          Returns the element to be used when positioning the component.
protected  El getResizeEl()
          Returns the element to be used when resizing the component.
 boolean getShadow()
          Returns true if the shadow is enabled.
 int getShadowOffset()
          Returns the shadow offset.
 Layer.ShadowPosition getShadowPosition()
          Returns the shadow position.
 Size getSize()
          Returns the component's size.
 int getWidth()
          Returns the component's width.
 int getWidth(boolean content)
          Returns the component's width.
protected  void hideShadow()
           
protected  void hideShim()
           
protected  void hideUnders()
           
 boolean isAutoHeight()
           
 boolean isAutoWidth()
           
 boolean isDeferHeight()
          Returns true if the height is being deferred
 boolean isShim()
          Returns true if shimming is enabled.
protected  void onHide()
           
protected  void onPosition(int x, int y)
          Called after the component is moved, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a move occurs.
protected  void onResize(int width, int height)
          Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.
protected  void onShow()
           
protected  void onUnload()
           
 void setAutoHeight(boolean autoHeight)
          Sets the component's auto height value (defaults to false).
 void setAutoWidth(boolean autoWidth)
          True to use width:'auto', false to use fixed width (defaults to false).
 void setBounds(int x, int y, int width, int height)
          Sets the component's size.
 void setBounds(Rectangle bounds)
          Sets the component's size.
 void setDeferHeight(boolean deferHeight)
          True to defer height calculations to an external component, false to allow this component to set its own height (defaults to false).
 void setHeight(int height)
          Sets the component's height.
 void setHeight(java.lang.String height)
          Sets the height of the component.
 void setPagePosition(int x, int y)
          Sets the page XY position of the component.
 void setPagePosition(Point point)
          Sets the page XY position of the component.
 void setPixelSize(int width, int height)
          Sets the width and height of the component.
 void setPosition(int left, int top)
          Sets the left and top of the component.
 void setShadow(boolean shadow)
          True to enable a shadow that will be displayed behind the component (defaults to false).
 void setShadowOffset(int shadowOffset)
          Sets the shadow offset (defaults to 4).
 void setShadowPosition(Layer.ShadowPosition shadowPosition)
          Sets the shadow position (defaults to SIDES).
 void setShim(boolean shim)
          True to enable a shim which uses a transparent iframe to stop content from bleeding through.
 void setSize(int width, int height)
          Sets the width and height of the component.
 void setSize(java.lang.String width, java.lang.String height)
          Sets the width and height of the component.
 void setWidth(int width)
          Sets the width of the component.
 void setWidth(java.lang.String width)
          Sets the width of the component.
 void sync(boolean show)
          Syncs the layer of the component.
 void syncSize()
          Clears the size cache and resets to the last known size.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disable, disableContextMenu, disableEvents, disableTextSelection, doAttachChildren, doDetachChildren, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusEl, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, notifyHide, notifyShow, onAttach, onBrowserEvent, onComponentEvent, onDetach, onDetachHelper, onDisable, onEnable, onEnsureDebugId, onHideContextMenu, onLoad, onRender, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

adjustSize

protected boolean adjustSize
True to adjust sizes for box model issues to ensure actual size matches set size.


shim

protected boolean shim
True to enable a shim which uses a transparent iframe to stop content from bleeding through.


cacheSizes

protected boolean cacheSizes
True to cache size calculation.


lastSize

protected Size lastSize

layer

protected Layer layer
A specialized El that provides support for a shadow and shim. Will be created if either shadow or shim is set to true.


height

protected java.lang.String height

width

protected java.lang.String width

ensureVisibilityOnSizing

protected boolean ensureVisibilityOnSizing
Set this to true if you have sizing issues in initial collapsed or hidden items. It defaults to false for performance reasons. You should not set this to true for all components. If this is enabled than components are made visible for the browser during a call to setSize if they were hidden or collapsed. The user wont see this change. In the end of setSize the status of the component is reverted again to the normal state. (defaults to false)

Constructor Detail

BoxComponent

public BoxComponent()
Method Detail

getBounds

public Rectangle getBounds(boolean local)
Gets the current box measurements of the component's underlying element. The component must be attached to return page coordinates.

Parameters:
local - if true the element's left and top are returned instead of page coordinates
Returns:
the component's bounds

getHeight

public int getHeight()
Returns the component's offset height.

Returns:
the height

getHeight

public int getHeight(boolean content)
Return the component's height.

Parameters:
content - true to get the height minus borders and padding
Returns:
the height

getPosition

public Point getPosition(boolean local)
Returns the component's current position. The component must be attached to return page coordinates.

Parameters:
local - true to return the element's left and top rather than page coordinates
Returns:
the position

getShadow

public boolean getShadow()
Returns true if the shadow is enabled.

Returns:
the shadow the shadow state

getShadowPosition

public Layer.ShadowPosition getShadowPosition()
Returns the shadow position.

Returns:
the shadow position

getShadowOffset

public int getShadowOffset()
Returns the shadow offset.

Returns:
the shadow offset

getSize

public Size getSize()
Returns the component's size.

Returns:
the size

getWidth

public int getWidth()
Returns the component's width.

Returns:
the width

getWidth

public int getWidth(boolean content)
Returns the component's width.

Parameters:
content - true to get width minus borders and padding
Returns:
the width

isAutoHeight

public boolean isAutoHeight()
Returns:
the autoHeight

isAutoWidth

public boolean isAutoWidth()
Returns:
the autoWidth

isDeferHeight

public boolean isDeferHeight()
Returns true if the height is being deferred

Returns:
the defer height state

isShim

public boolean isShim()
Returns true if shimming is enabled.

Returns:
the shim state

setAutoHeight

public void setAutoHeight(boolean autoHeight)
Sets the component's auto height value (defaults to false).

Parameters:
autoHeight - true to enable auto height

setAutoWidth

public void setAutoWidth(boolean autoWidth)
True to use width:'auto', false to use fixed width (defaults to false).

Parameters:
autoWidth - the auto width state

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Sets the component's size. This method fires the Move and Resize events. element.

Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height

setBounds

public void setBounds(Rectangle bounds)
Sets the component's size. This method fires the Move and Resize events. element.

Parameters:
bounds - the update box

setDeferHeight

public void setDeferHeight(boolean deferHeight)
True to defer height calculations to an external component, false to allow this component to set its own height (defaults to false).

Parameters:
deferHeight - true to defer height

setHeight

public void setHeight(int height)
Sets the component's height. This method fires the Resize event. element.

Parameters:
height - the new height

setHeight

public void setHeight(java.lang.String height)
Sets the height of the component. This method fires the Resize event. element.

Overrides:
setHeight in class Component
Parameters:
height - the new height to set

setPagePosition

public void setPagePosition(int x,
                            int y)
Sets the page XY position of the component. To set the left and top instead, use setPosition(int, int). This method fires the Move event.

Parameters:
x - the x coordinate
y - the y coordinate

setPagePosition

public void setPagePosition(Point point)
Sets the page XY position of the component. To set the left and top instead, use setPosition(int, int). This method fires the Move event.

Parameters:
point - the new location

setPixelSize

public void setPixelSize(int width,
                         int height)
Sets the width and height of the component. This method fires the resize event.

Overrides:
setPixelSize in class Component
Parameters:
width - the new width to set
height - the new height to set

setPosition

public void setPosition(int left,
                        int top)
Sets the left and top of the component. To set the page XY position instead, use setPagePosition(int, int). This method fires the move event.

Parameters:
left - the new left
top - the new top

setShadow

public void setShadow(boolean shadow)
True to enable a shadow that will be displayed behind the component (defaults to false).

Parameters:
shadow - true to enable the shadow

setShadowPosition

public void setShadowPosition(Layer.ShadowPosition shadowPosition)
Sets the shadow position (defaults to SIDES).

Parameters:
shadowPosition - the position

setShadowOffset

public void setShadowOffset(int shadowOffset)
Sets the shadow offset (defaults to 4).

Parameters:
shadowOffset - the offset

setShim

public void setShim(boolean shim)
True to enable a shim which uses a transparent iframe to stop content from bleeding through.

Parameters:
shim - true to enable a shim

setSize

public void setSize(int width,
                    int height)
Sets the width and height of the component. This method fires the Resize event.

Parameters:
width - the new width to set
height - the new height to set

setSize

public void setSize(java.lang.String width,
                    java.lang.String height)
Sets the width and height of the component. This method fires the Resize event.

Overrides:
setSize in class Component
Parameters:
width - the new width to set
height - the new height to set

setWidth

public void setWidth(int width)
Sets the width of the component. This method fires the Resize event.

Parameters:
width - the new width to set

setWidth

public void setWidth(java.lang.String width)
Sets the width of the component. This method fires the Resize event.

Overrides:
setWidth in class Component
Parameters:
width - the new width to set

sync

public void sync(boolean show)
Syncs the layer of the component.


syncSize

public void syncSize()
Clears the size cache and resets to the last known size.


adjustPosition

protected Point adjustPosition(Point point)

adjustSize

protected Size adjustSize(Size size)

afterRender

protected void afterRender()
Description copied from class: Component
Called after the component has been rendered and is attached for the first time. At this time, the component will be part of the DOM which is required when retrieving location and offsets.

Overrides:
afterRender in class Component

createComponentEvent

protected ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class Component

getPositionEl

protected El getPositionEl()
Returns the element to be used when positioning the component. Subclasses may override as needed. Default method returns the component's root element.

Returns:
the position element

getResizeEl

protected El getResizeEl()
Returns the element to be used when resizing the component. Subclasses may override as needed. Default method returns the component's root element.

Returns:
the resize element

hideShadow

protected void hideShadow()

hideShim

protected void hideShim()

hideUnders

protected void hideUnders()

onHide

protected void onHide()
Overrides:
onHide in class Component

onPosition

protected void onPosition(int x,
                          int y)
Called after the component is moved, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a move occurs.

Parameters:
x - the new x position
y - the new y position

onResize

protected void onResize(int width,
                        int height)
Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.

Parameters:
width - the width
height - the height

onShow

protected void onShow()
Overrides:
onShow in class Component

onUnload

protected void onUnload()
Overrides:
onUnload in class com.google.gwt.user.client.ui.Widget