Class Index | File Index

Classes


Class zwt.ui.Widget


Extends zwt.Object.

This is the base class of all ZWT widgets.

A widget is basically formed by two elements: a container and an element.

When implementing a widget, the implementor must defined the widget's element defining the component UI and append it to the container.


Defined in: Widget.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Construct a widget.
Field Summary
Field Attributes Field Name and Description
<static>  
zwt.ui.Widget.FILL_BOTH
Indicate the Widget should be resized to fill the space both horizontally and vertically
<static>  
zwt.ui.Widget.FILL_HORIZONTAL
Indicate the Widget should be resized to fill the space horizontally
<static>  
zwt.ui.Widget.FILL_NONE
Indicate the Widget shouldn't be resized
<static>  
zwt.ui.Widget.FILL_VERTICAL
Indicate the Widget should be resized to fill the space vertically
<static>  
zwt.ui.Widget.RELATIVE_CONTAINER
Indicate that positions should be relative to the parent container
<static>  
zwt.ui.Widget.RELATIVE_PART
Indicate that positions should be relative to the parent part
<static>  
zwt.ui.Widget.RELATIVE_WINDOW
Indicate that positions should be relative to the window
Method Summary
Method Attributes Method Name and Description
 
addStyle(string_style)
Add the specified style to the widget element class name if it doesn't already have it.
 
draw()
This method is used by containers to resize the widget content to fit in the layout.
 
Return the value of the fill property taking the context into account.
 
Return the dimension of the widget's container.
 
Return the widget's HTML element.
 
Return the dimension of the widget's element.
 
Return the fill property.
 
Return the focus event manager attached to the widget.
 
Return the Widget's id.
 
Return the keyboard event manager attached to the widget.
 
Return the parent widget (likely to be a zwt.ui.container.Container) of the widget.
 
getRelativeLeft(int_relativeTo)
Return the top position relative to the container element specified by int_relativeTo.
 
getRelativeTop(int_relativeTo)
Return the top position relative to the container element specified by int_relativeTo.
 
Return the widget's style class name.
 
Return the wheel event manager attached to the widget.
 
Determine whether the widget has the focus.
 
hasStyle(string_style)
Determine whether the widget element has the specified style.
 
Determine whether this widget is focusable.
 
Determine whether this Widget is visible.
 
onEvent(zwt_event_Event_event)
Executed by a zwt.event.UIEventManager or directly to handle the specified event in the widget.
 
processContentEvent(zwt_ui_container_ContentEvent_event)
Process the specified content event.
 
processEvent(zwt_event_Event_event)
Process the specified event.
 
processFocusEvent(zwt_event_FocusEvent_event)
Process the specified focus event.
 
processKeyboardEvent(zwt_event_KeyboardEvent_event)
Process the specified keyboard event.
 
processWheelEvent(zwt_event_WheelEvent_event)
Process the specified wheel event.
 
This method is called by containers to redraw the widget.
 
removeStyle(string_style)
Remove the specified style from the widget element class name.
 
replaceStyle(string_style, string_newStyle)
Replace the specified style from the widget element class name by the specified new style if the widget element doesn't already have it.
 
setFill(int_fill)
Set the fill property.
 
setFocusable(boolean_focusable)
Set the widget focusable flag.
 
setId(string_id)
Set the id of the underlying container element.
 
setStyle(The)
Set the widget's style class name.
 
setVisible(boolean_flag)
Make this widget visible.
Class Detail
zwt.ui.Widget()
Construct a widget.
Author: Jeremy KUHN.
Field Detail
<static> {Integer} zwt.ui.Widget.FILL_BOTH
Indicate the Widget should be resized to fill the space both horizontally and vertically

<static> {Integer} zwt.ui.Widget.FILL_HORIZONTAL
Indicate the Widget should be resized to fill the space horizontally

<static> {Integer} zwt.ui.Widget.FILL_NONE
Indicate the Widget shouldn't be resized

<static> {Integer} zwt.ui.Widget.FILL_VERTICAL
Indicate the Widget should be resized to fill the space vertically

<static> {Integer} zwt.ui.Widget.RELATIVE_CONTAINER
Indicate that positions should be relative to the parent container

<static> {Integer} zwt.ui.Widget.RELATIVE_PART
Indicate that positions should be relative to the parent part

<static> {Integer} zwt.ui.Widget.RELATIVE_WINDOW
Indicate that positions should be relative to the window
Method Detail
addStyle(string_style)
Add the specified style to the widget element class name if it doesn't already have it.
Parameters:
{String} string_style
The CSS style to add

draw()
This method is used by containers to resize the widget content to fit in the layout. It uses the fill property to determine how to resize the root element of the widget based on the dimension of the container. The static fields zwt.ui.Widget.FILL_NONE, zwt.ui.Widget.FILL_HORIZONTAL, zwt.ui.Widget.FILL_VERTICAL and zwt.ui.Widget.FILL_BOTH are used to adapt the behavior of the method.

This method typically resizes the root element of the Widget but not the widget's container which should be resized by the parent widget. If it includes descendant widgets it also resizes the container of the descendant Widgets and calls their redraw method. Calling the draw method instead of the redraw method on descendant widgets may lead to unnecessary processing, it should be up to the redraw method to determine whether a widget needs to be drawn.

You may want to override this method if you want to draw the widget in a specific way.


{Integer} getContextFill()
Return the value of the fill property taking the context into account.

The parent container always defines the context in which the widget is displayed. Basically there's no point in filling all the vertical space if the parent container is vertically elastic (ie. it takes the height of its content).

For all these reasons, the value returned by this method should always be used in draw operations.

Returns:
The fill value to use during draw operations, One of zwt.ui.Widget.FILL_NONE, zwt.ui.Widget.FILL_VERTICAL, zwt.ui.Widget.FILL_HORIZONTAL or zwt.ui.Widget.FILL_BOTH

{zwt.ui.Dimension} getDimension()
Return the dimension of the widget's container. The widget's dimension is cached for performance reason to avoid recreating it each time we need it.
Returns:
The dimension

{Element} getElement()
Return the widget's HTML element.
Returns:
The element.

{zwt.ui.Dimension} getElementDimension()
Return the dimension of the widget's element.
Returns:
The element's dimension

{Integer} getFill()
Return the fill property.

The fill property is used during draw operation to determine how the widget should fill the available space. This value is never used directly as it may be overridden depending on the context defined by the parent container.

Returns:
The value of the fill property, one of zwt.ui.Widget.FILL_NONE, zwt.ui.Widget.FILL_VERTICAL, zwt.ui.Widget.FILL_HORIZONTAL or zwt.ui.Widget.FILL_BOTH
See:
zwt.ui.Widget#getContextFill

{zwt.event.FocusEventManager} getFocusEventManager()
Return the focus event manager attached to the widget.
Returns:
The focus event manager

{String} getId()
Return the Widget's id.
Returns:
The id

{zwt.event.KeyboardEventManager} getKeyboardEventManager()
Return the keyboard event manager attached to the widget.
Returns:
The keyboard event manager

{zwt.ui.Widget} getParent()
Return the parent widget (likely to be a zwt.ui.container.Container) of the widget.
Returns:
The parent widget

{Integer} getRelativeLeft(int_relativeTo)
Return the top position relative to the container element specified by int_relativeTo.
Parameters:
{Integer} int_relativeTo
One of zwt.ui.Widget.RELATIVE_CONTAINER, zwt.ui.Widget.RELATIVE_PART or zwt.ui.Widget.RELATIVE_WINDOW.
Returns:
The top position.

{Integer} getRelativeTop(int_relativeTo)
Return the top position relative to the container element specified by int_relativeTo.
Parameters:
{Integer} int_relativeTo
One of zwt.ui.Widget.RELATIVE_CONTAINER, zwt.ui.Widget.RELATIVE_PART or zwt.ui.Widget.RELATIVE_WINDOW.
Returns:
The top position.

{String} getStyle()
Return the widget's style class name.
Returns:
The CSS className

{zwt.event.WheelEventManager} getWheelEventManager()
Return the wheel event manager attached to the widget.
Returns:
The wheel event manager

{Boolean} hasFocus()
Determine whether the widget has the focus.

It actually tests if the widget's style contains a 'focus' selector.

Returns:
true if the widget has the focus, false otherwise

hasStyle(string_style)
Determine whether the widget element has the specified style.
Parameters:
{String} string_style
The CSS style to check
Returns:
true if the widget has the specified style

{Boolean} isFocusable()
Determine whether this widget is focusable. This implementation is not focusable by default.
Returns:
true if the widget is focusable, false otherwise

{Boolean} isVisible()
Determine whether this Widget is visible. This implementation takes ancestors visibility into account.
Returns:
true if the widget and its ancestors are visible, false otherwise

onEvent(zwt_event_Event_event)
Executed by a zwt.event.UIEventManager or directly to handle the specified event in the widget.

This method touches the event to indicates it has consume it. It then calls the zwt.ui.Widget#processEvent to process the event and finally propagates the event to the parent widget if the event is set to propagate.

This method should never be overridden unless you know what you are doing.

Parameters:
{zwt.event.Event} zwt_event_Event_event
The event
See:
zwt.event.Event
zwt.event.UIEventManager

processContentEvent(zwt_ui_container_ContentEvent_event)
Process the specified content event. This method will simply flag this widget to indicate that its content has changed and needs to be redrawn.
Parameters:
{zwt.ui.container.ContentEvent} zwt_ui_container_ContentEvent_event
The content event to process

processEvent(zwt_event_Event_event)
Process the specified event.

This method basically dispatch the specified event to the appropriate processXXXEvent method. You may need to override this method to process other types of event. If you do you should explicitly call this implementation.

This implementation process focus, keyboard and wheel events which are the default ones for any widgets.

It also process content event to flag that the widget's content has changed before the event is propagated to the parent container.

Parameters:
{zwt.event.Event} zwt_event_Event_event
The event to process

processFocusEvent(zwt_event_FocusEvent_event)
Process the specified focus event. This method acquires the focus for the widget on a focus event and clear the focus on a blur event.

This method should always be called when you choose to override it.

Parameters:
{zwt.event.FocusEvent} zwt_event_FocusEvent_event
The focus event to process

processKeyboardEvent(zwt_event_KeyboardEvent_event)
Process the specified keyboard event. Keyboard event are only dispatch to a widget when it has the focus.
Parameters:
{zwt.event.KeyboardEvent} zwt_event_KeyboardEvent_event
The keyboard event to process

processWheelEvent(zwt_event_WheelEvent_event)
Process the specified wheel event. Wheel event are only dispatch to a widget when it has the focus.
Parameters:
{zwt.event.WheelEvent} zwt_event_WheelEvent_event
The wheel event to process

redraw()
This method is called by containers to redraw the widget. This method actually calls the draw method if the widget needs to be resized.

Basically a Widget needs to be resized in the following cases:

Note that if the Widget is not visible, it is not redrawn.


removeStyle(string_style)
Remove the specified style from the widget element class name.
Parameters:
{String} string_style
The CSS style to remove

replaceStyle(string_style, string_newStyle)
Replace the specified style from the widget element class name by the specified new style if the widget element doesn't already have it.
Parameters:
{String} string_style
The CSS style to replace
{String} string_newStyle
The new CSS style

setFill(int_fill)
Set the fill property.
Parameters:
{Integer} int_fill
One of zwt.ui.Widget.FILL_NONE, zwt.ui.Widget.FILL_VERTICAL, zwt.ui.Widget.FILL_HORIZONTAL or zwt.ui.Widget.FILL_BOTH

setFocusable(boolean_focusable)
Set the widget focusable flag.

This method actually set the focusable flag, depending on the context other parameters may be considered to determine whether a widget is focusable or not. As a result the value that is set here is not completely linked to the zwt.ui.Widget#isFocusable method.

Parameters:
{Boolean} boolean_focusable
true to make the widget focusable, otherwise false.

setId(string_id)
Set the id of the underlying container element.
Parameters:
{String} string_id
The id

setStyle(The)
Set the widget's style class name.
Parameters:
{String} The
CSS className to set

setVisible(boolean_flag)
Make this widget visible. This method triggers a redraw operation when the Widget is made visible.
Parameters:
{Boolean} boolean_flag
true to make the widget visible, otherwise false

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Jan 12 2012 02:07:54 GMT+0100 (CET)