Class zebkit.layout.Layoutable
mixed with <zebkit.layout.Layout> <zebkit.EventProducer> <zebkit.PathSearch>
<zebkit.layout>

Layoutable class defines rectangular component that has elementary metrical properties like width, height and location and can be a participant of layout management process. Layoutable component is container that can contains other layoutable component as its children. The children components are ordered by applying a layout manager of its parent component.

Constructor:
zebkit.layout.Layoutable ( )



protected chainable $setConstraints (c)

Set the component constraints without invalidating the component and its parents components layouts and metrics. It is supposed to be used for internal use


Parameters:
public <zebkit.layout.Layoutable> add (constr, d)

Add the new children component with the given constraints


Parameters:
Returns: <zebkit.layout.Layoutable>

added layoutable component

public <zebkit.layout.Layoutable> byConstraints ([p], c)

Get a children layoutable component by the given path (optionally) and the specified constraints.


Parameters:
Returns: <zebkit.layout.Layoutable>

a children component

@Override zebkit.layout.Layout
private <Object> calcPreferredSize (target)

Internal implementation of the component preferred size calculation.


Parameters:
Returns: <Object>

a preferred size. The method always returns { width:10, height:10 } as the component preferred size

@Override zebkit.layout.Layout
private void doLayout ( )

By default layoutbable component itself implements layout manager to order its children components. This method implementation does nothing, so children component will placed according locations and sizes they have set.

public <Integer> getBottom ( )

Get bottom padding.


Returns: <Integer>

bottom padding in pixel

public <Integer> getHorPadding ( )

Get accumulated horizontal (top and bottom) padding.


Returns: <Integer>

a horizontal padding

public <Integer> getLeft ( )

Get left padding.


Returns: <Integer>

left padding in pixel

public <Object> getPreferredSize ( )

Get preferred size. The preferred size includes top, left, bottom and right paddings and the size the component wants to have


Returns: <Object>

return size object the component wants to have as the following structure:

        {width:{Integer}, height:{Integer}} object
public <Integer> getRight ( )

Get right padding.


Returns: <Integer>

right padding in pixel

public <Integer> getTop ( )

Get top padding.


Returns: <Integer>

top padding in pixel

public <Integer> getVerPadding ( )

Get accumulated vertical (top and bottom) padding.


Returns: <Integer>

a vertical padding

public <Integer> indexOf (c)

Detect index of a children component.


Parameters:
  • c <zebkit.ui.Layoutbale>

    a children component


Returns: <Integer>
public <zebkit.layout.Layoutable> insert (i, constr, d)

Insert the new children component at the given index with the specified layout constraints. The passed constraints can be set via a layoutable component that is inserted. Just set "constraints" property of in inserted component.


Parameters:
  • i <Integer>

    an index at that the new children component has to be inserted

  • constr <Object>

    layout constraints of the new children component

  • d <zebkit.layout.Layoutbale>

    a new children layoutable component to be added


Returns: <zebkit.layout.Layoutable>

an inserted children layoutable component

public void invalidate ( )

Invalidate component layout and metrics.

protected void invalidateLayout ( )

Invalidate the component layout. Layout invalidation means the component children components have to be placed with the component layout manager. Layout invalidation causes a parent component layout is also invalidated.

public void kidAdded (i, constr, d)

The method can be implemented to be informed every time a new component has been inserted into the component


Parameters:
  • i <Integer>

    an index at that the new children component has been inserted

  • constr <Object>

    layout constraints of the new children component

  • d <zebkit.layout.Layoutbale>

    a new children layoutable component that has been added

public void kidRemoved (i, c)

The method can be implemented to be informed every time a children component has been removed


Parameters:
  • i <Integer>

    a children component index at which it has been removed

  • c <zebkit.layout.Layoutable>

    a children component that has been removed

public void laidout ( )

The method can be implemented to be informed every time the component has completed to layout its children components

public chainable properties ([path], props)

Apply the given set of properties to the given component or a number of children its components.


Parameters:
  • [path] <String>

    a path to find children components

  • props <Object>

    a dictionary of properties to be applied


Example:
var c = new zebkit.layout.Layoutable();
c.properties({
    width: [100, 100],
    location: [10,10],
    layout: new zebkit.layout.BorderLayout()
})

c.add(new zebkit.layout.Layoutable()).add(zebkit.layout.Layoutable())
                                     .add(zebkit.layout.Layoutable());
c.properties("//*", {
    size: [100, 200]
});
public chainable property ([path], name, value)

Set the given property to the component or children component specified by the given path (optionally).


Parameters:
  • [path] <String>

    a path to find children components

  • name <String>

    a property name

  • value <Object>

    a property value

protected void recalc ( )

By default there is no any implementation of "recalc" method in the layoutable component. In other words the method doesn't exist. Developer should implement the method if the need a proper and efficient place to calculate component properties that have influence to the component preferred size. The "recalc" method is called only when it is really necessary to compute the component metrics.

public void relocated (px, py)

The method can be implemented to be informed every time the component has been moved


Parameters:
  • px <Integer>

    x previous coordinate of moved children component

  • py <Integer>

    y previous coordinate of moved children component

public <zebkit.layout.Layoutable> remove (c)

Remove the given children component.


Parameters:
Returns: <zebkit.layout.Layoutable>

a removed children component

public <zebkit.layout.Layoutable> removeAt (i)

Remove a children component at the specified position.


Parameters:
  • i <Integer>

    a children component index at which it has to be removed


Returns: <zebkit.layout.Layoutable>

a removed children component

public <zebkit.layout.Layoutable> removeByConstraints (ctr)

Remove a component by the given constraints.


Parameters:
Returns: <zebkit.layout.Layoutable>

a removed component

public void removeMe ([after])

Remove the component from its parent if it has a parent


Parameters:
  • [after] <Integer>

    timeout in milliseconds the component has to be removed

public void resized (w, h)

The method can be implemented to be informed every time the component has been resized


Parameters:
  • w <Integer>

    a previous width of the component

  • h <Integer>

    a previous height of the component

public <zebkit.layout.Layoutable> setAt (i, d)

Replace a children component at the specified index with the given new children component


Parameters:
Returns: <zebkit.layout.Layoutable>

a previous component that has been re-set with the new one

public chainable setBounds (x, y, w, h)

Set the layoutable component bounds. Bounds defines the component location and size.


Parameters:
  • x <Integer>

    x coordinate relatively to the layoutable component parent

  • y <Integer>

    y coordinate relatively to the layoutable component parent

  • w <Integer>

    a width of the component

  • h <Integer>

    a height of the component

public <zebkit.layout.Layoutable> setByConstraints (constr, c)

Set the component by the given constraints or add new one with the given constraints


Parameters:
Returns: <zebkit.layout.Layoutable>

a previous component that has been re-set with the new one

public chainable setId (id)

Set the given id for the component


Parameters:
public chainable setLayout (m)

Set the given layout manager that is used to place children component. Layout manager is simple class that defines number of rules concerning the way children components have to be ordered on its parent surface.


Parameters:
  • m <zebkit.ui.Layout>

    a layout manager

public chainable setLocation (xx, yy)

Set the layoutable component location. Location is x, y coordinates relatively to a parent component


Parameters:
  • xx <Integer>

    x coordinate relatively to the layoutable component parent

  • yy <Integer>

    y coordinate relatively to the layoutable component parent

protected void setParent (o)

Set the parent component.


Parameters:
public chainable setPreferredSize (w, h)

Set the specified preferred size the component has to have. Component preferred size is important thing that is widely used to layout the component. Usually the preferred size is calculated by a concrete component basing on its metrics. For instance, label component calculates its preferred size basing on text size. But if it is required the component preferred size can be fixed with the desired value.


Parameters:
  • w <Integer>

    a preferred width. Pass "-1" as the argument value to not set preferred width

  • h <Integer>

    a preferred height. Pass "-1" as the argument value to not set preferred height

public void setProperties ([path], props)

Set the component properties. This is wrapper for "properties" method to supply properties setter method.


Parameters:
  • [path] <String>

    a path to find children components

  • props <Object>

    a dictionary of properties to be applied

public chainable setSize (w, h)

Set the layoutable component size.


Parameters:
  • w <Integer>

    a width of the component

  • h <Integer>

    a height of the component

public void validate ( )

Force validation of the component metrics and layout if it is not valid

protected void validateMetric ( )

Validate the component metrics. The method is called as a one step of the component validation procedure. The method causes "recalc" method execution if the method has been implemented and the component is in invalid state. It is supposed the "recalc" method has to be implemented by a component as safe place where the component metrics can be calculated. Component metrics is individual for the given component properties that has influence to the component preferred size value. In many cases the properties calculation has to be minimized what can be done by moving the calculation in "recalc" method


public <Object> constraints

The component layout constraints. The constraints is specific to the parent component layout manager value that customizes the children component layouting on the parent component.

public <Integer> height

Height of rectangular area

public <Boolean> isValid

Indicate a layoutable component validity

public <Boolean> isVisible

Indicate a layoutable component visibility

public <Array> kids

Reference to children components

public <zebkit.layout.Layout> layout

Layout manager that is used to order children layoutable components

public <zebkit.layout.Layoutable> parent

Reference to a parent layoutable component

public <Integer> width

Width of rectangular area

public <Integer> x

x coordinate

public <Integer> y

y coordinate