Class zebkit.layout.GridLayout
mixed with <zebkit.layout.Layout>
<zebkit.layout>

Grid layout manager. can be used to split a component area to number of virtual cells where children components can be placed. The way how the children components have to be laid out in the cells can be customized by using "zebkit.layout.Constraints" class:

// create constraints
var ctr = new zebkit.layout.Constraints();

// specify cell top, left, right, bottom paddings
ctr.setPadding(8);
// say the component has to be left aligned in a
// virtual cell of grid layout
ctr.ax = "left";

// create panel and set grid layout manager with two
// virtual rows and columns
var p = new zebkit.ui.Panel();
p.setLayout(new zebkit.layout.GridLayout(2, 2));

// add children component
p.add(ctr, new zebkit.ui.Label("Cell 1, 1"));
p.add(ctr, new zebkit.ui.Label("Cell 1, 2"));
p.add(ctr, new zebkit.ui.Label("Cell 2, 1"));
p.add(ctr, new zebkit.ui.Label("Cell 2, 2"));
Constructor:
zebkit.layout.GridLayout (rows, cols, [stretchRows], [stretchCols])

Parameters:
  • rows <Integer>

    a number of virtual rows to layout children components

  • cols <Integer>

    a number of virtual columns to layout children components

  • [stretchRows] <Boolean>

    true if virtual cell height has to be stretched to occupy the whole vertical container component space

  • [stretchCols] <Boolean>

    true if virtual cell width has to be stretched to occupy the whole horizontal container component space




protected <Integer> calcCol (col, c)
protected <Array> calcCols (c)
protected <Integer> calcRow (row, c)
protected <Array> calcRows (c)
public void setDefaultConstraints (c)
public void setPadding (p)
public void setPadding (t, l, b, r)


Inherited methods:

protected <Integer> calcCol (col, c)

Calculate the given column width


Parameters:
Returns: <Integer>

a size of the column

protected <Array> calcCols (c)

Calculate columns metrics


Parameters:
Returns: <Array>

a columns widths

protected <Integer> calcRow (row, c)

Calculate the given row height


Parameters:
Returns: <Integer>

a size of the row

protected <Array> calcRows (c)

Calculate rows metrics


Parameters:
Returns: <Array>

a rows heights

public chainable setDefaultConstraints (c)

Set default constraints.


Parameters:
public chainable setPadding (p)

Set default grid layout cell paddings (top, left, bottom, right) to the given value


Parameters:
  • p <Integer>

    a padding

public chainable setPadding (t, l, b, r)

Set default grid layout cell paddings: top, left, bottom, right


Parameters:
  • t <Integer>

    a top padding

  • l <Integer>

    a left padding

  • b <Integer>

    a bottom padding

  • r <Integer>

    a right padding


public <Integer> cols

Number of virtual columns to place children components

private <Array> colSizes

Computed columns sizes.

public <zebkit.layout.Constraints> constraints

Default constraints that is applied for children components that doesn't define own constraints

public <Integer> rows

Number of virtual rows to place children components

private <Array> rowSizes

Computed rows sizes.

public <Boolean> stretchCols

Attributes that indicates if component has to be stretched horizontally to occupy the whole space of a virtual cell.

public <Boolean> stretchRows

Attributes that indicates if component has to be stretched vertically to occupy the whole space of a virtual cell.