|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WLayout
eu.webtoolkit.jwt.WGridLayout
public class WGridLayout
A layout manager which arranges widgets in a grid.
This is a layout class that arranges widgets in a grid, to span the entire
area of the parent container. Each grid location (row, column) may contain
one widget or nested layout. Horizontal and vertical space are divided so
that each column/row is given its minimum size and the remaining space is
dived according to stretch factors among the columns/rows. The minimum width
of a column/row is based on the minimum dimensions of contained widgets or
nested layouts. The default minimum height and width may be overridden using
WWidget#setMinimumSize().
If you want to use the layout manager for a container which does not have a
height that is constrained somehow, you need to specify AlignTop in the
alignment flags of WContainerWidget#setLayout(). Otherwise the behavior is undefined (the
parent container will continue to increase in size as it tries to satisfy the
constraints assuming a contrained height).
You can use
WContainerWidget::setOverflow(OverflowAuto) or use a WScrollArea to
automatically show scrollbars on a widget inserted in the layout.
A caveat with layout managers is that you cannot reliably use a stylesheet to
add borders (or margin) to a widget inserted in a layout: this is broken on
Internet Explorer. To provide the layout, the layout manager needs to set
sizes on the contained widget but these sizes also need to take into account
the border/margin width. Since on IE, this value will be 0 if the border or
margin is provided by a stylesheet (as opposed to by inline CSS by using
WWidget#getDecorationStyle()), the
result will be wrong behaviour like widgets that keep growing in size.
A layout manager may provide resize handles between columns or rows which
allow the user to change the automatic layout provided by the layout manager
(see setRowResizable() and
setColumnResizable()). Resize handles between rows only work when the layout
fills the parent vertical space (i.e. is not aligned to the top). Likewise,
resize handles between columns only work when the layout fills the parent
horiziontal space (i.e. is not aligned left, right or centered).
Columns and rows are separated using a constant spacing, which defaults to 6
pixels by default, and can be changed using
setHorizontalSpacing() and
setVerticalSpacing(). In
addition, when this layout is a top-level layout (i.e. is not nested inside
another layout), a margin is set around the contents, which thus replaces
padding defined for the container. It is not allowed to define padding for
the container widget using its CSS 'padding' property or the
WContainerWidget#setPadding(). This margin also defaults to 9 pixels, and
can be changed using
WLayout#setContentsMargins().
For each column or row, a stretch factor may be defined, which controls how remaining horizontal or vertical space is used. Each column and row is stretched using the stretch factor to fill the remaining space. When the stretch factor is 0, the height of the row and its contents is not actively managed. As a consequence, the contents of each cell will not fill the cell. You may use a special stretch factor of -1 to indicate that the height of the row should not stretch but the contents height should be actively managed. This has as draw-back that the height of the row will no longer reduce in size when any of the cell contents reduces in size.
Usage example:
{
@code
WContainerWidget w = new WContainerWidget(this);
w.resize(WLength.Auto, new WLength(600));
WGridLayout layout = new WGridLayout();
layout.addWidget(new WText("Item 0 0"), 0, 0);
layout.addWidget(new WText("Item 0 1"), 0, 1);
layout.addWidget(new WText("Item 1 0"), 1, 0);
layout.addWidget(new WText("Item 1 1"), 1, 1);
w.setLayout(layout);
}
Note: When JavaScript support is not available, only Safari and Firefox properly implement this layout. For other browsers, only the horizontal layout is properly implemented, while vertically all widgets use their minimum size.
When set on a WContainerWidget, this layout manager accepts the
following hints (see WLayout#setLayoutHint()):
| Constructor Summary | |
|---|---|
WGridLayout()
Create a new grid layout. |
|
WGridLayout(WWidget parent)
Create a new grid layout. |
|
| Method Summary | |
|---|---|
void |
addItem(WLayoutItem item)
Adds a layout item. |
void |
addItem(WLayoutItem item,
int row,
int column)
Adds a layout item to the grid. |
void |
addItem(WLayoutItem item,
int row,
int column,
int rowSpan)
Adds a layout item to the grid. |
void |
addItem(WLayoutItem item,
int row,
int column,
int rowSpan,
int columnSpan)
Adds a layout item to the grid. |
void |
addItem(WLayoutItem item,
int row,
int column,
int rowSpan,
int columnSpan,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Adds a layout item to the grid. |
void |
addItem(WLayoutItem item,
int row,
int column,
int rowSpan,
int columnSpan,
java.util.EnumSet<AlignmentFlag> alignment)
Adds a layout item to the grid. |
void |
addLayout(WLayout layout,
int row,
int column)
Adds a nested layout item to the grid. |
void |
addLayout(WLayout layout,
int row,
int column,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Adds a nested layout item to the grid. |
void |
addLayout(WLayout layout,
int row,
int column,
java.util.EnumSet<AlignmentFlag> alignment)
Adds a nested layout item to the grid. |
void |
addLayout(WLayout layout,
int row,
int column,
int rowSpan,
int columnSpan)
Adds a nested layout item to the grid. |
void |
addLayout(WLayout layout,
int row,
int column,
int rowSpan,
int columnSpan,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Adds a nested layout item to the grid. |
void |
addLayout(WLayout layout,
int row,
int column,
int rowSpan,
int columnSpan,
java.util.EnumSet<AlignmentFlag> alignment)
Adds a nested layout item to the grid. |
void |
addWidget(WWidget widget,
int row,
int column)
Adds a widget to the grid. |
void |
addWidget(WWidget widget,
int row,
int column,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Adds a widget to the grid. |
void |
addWidget(WWidget widget,
int row,
int column,
java.util.EnumSet<AlignmentFlag> alignment)
Adds a widget to the grid. |
void |
addWidget(WWidget widget,
int row,
int column,
int rowSpan,
int columnSpan)
Adds a widget to the grid. |
void |
addWidget(WWidget widget,
int row,
int column,
int rowSpan,
int columnSpan,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Adds a widget to the grid. |
void |
addWidget(WWidget widget,
int row,
int column,
int rowSpan,
int columnSpan,
java.util.EnumSet<AlignmentFlag> alignment)
Adds a widget to the grid. |
void |
clear()
Removes and deletes all child widgets and nested layouts. |
boolean |
columnIsResizable(int column)
Returns whether the user may drag a particular column border. |
int |
getColumnCount()
Returns the column count. |
int |
getColumnStretch(int column)
Returns the column stretch. |
int |
getCount()
Returns the number of items in this layout. |
int |
getHorizontalSpacing()
Returns the horizontal spacing. |
WLayoutItem |
getItemAt(int index)
Returns the layout item at a specific index. |
int |
getRowCount()
Returns the row count. |
int |
getRowStretch(int row)
Returns the column stretch. |
int |
getVerticalSpacing()
Returns the vertical spacing. |
void |
removeItem(WLayoutItem item)
Removes a layout item (widget or nested layout). |
boolean |
rowIsResizable(int row)
Returns whether the user may drag a particular row border. |
void |
setColumnResizable(int column)
Sets whether the user may drag a particular column border. |
void |
setColumnResizable(int column,
boolean enabled)
Sets whether the user may drag a particular column border. |
void |
setColumnStretch(int column,
int stretch)
Sets the column stretch. |
void |
setHorizontalSpacing(int size)
Sets the horizontal spacing. |
void |
setRowResizable(int row)
Sets whether the user may drag a particular row border. |
void |
setRowResizable(int row,
boolean enabled)
Sets whether the user may drag a particular row border. |
void |
setRowStretch(int row,
int stretch)
Sets the row stretch. |
void |
setVerticalSpacing(int size)
Sets the vertical spacing. |
| Methods inherited from class eu.webtoolkit.jwt.WLayout |
|---|
addWidget, clearLayoutItem, findWidgetItem, getContentsMargin, getImpl, getLayout, getParentLayout, getWidget, indexOf, removeWidget, setContentsMargins, setLayoutHint, setLayoutInParent, setParentLayout, setParentWidget, update, update, updateAddItem, updateRemoveItem |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getId, getObjectName, remove, setObjectName, tr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WGridLayout(WWidget parent)
The grid will grow dynamically as items are added.
Use parent = null to create a layout manager
that can be nested inside other layout managers or to specify a specific
alignment when setting the layout to a WContainerWidget.
public WGridLayout()
Calls this((WWidget)null)
| Method Detail |
|---|
public void addItem(WLayoutItem item)
WLayoutThe item may be a widget or nested layout.
How the item is layed out with respect to siblings is implementation specific to the layout manager. In some cases, a layout manager will overload this method with extra arguments that specify layout options.
addItem in class WLayoutWLayout.removeItem(WLayoutItem item),
WLayout.addWidget(WWidget w)public void removeItem(WLayoutItem item)
WLayout
removeItem in class WLayoutWLayout.addItem(WLayoutItem item),
WLayout.removeWidget(WWidget w)public WLayoutItem getItemAt(int index)
WLayout
If there is no item at the index, null is
returned.
getItemAt in class WLayoutWLayout.indexOf(WLayoutItem item),
WLayout.getCount()public int getCount()
WLayout
This may be a theoretical number, which is greater than the actual number
of items. It can be used to iterate over the items in the layout, in
conjunction with getItemAt().
getCount in class WLayoutpublic void clear()
WLayout
This is similar to WContainerWidget#clear(), with the exception that the layout itself is
not deleted.
clear in class WLayout
public void addItem(WLayoutItem item,
int row,
int column,
int rowSpan,
int columnSpan,
java.util.EnumSet<AlignmentFlag> alignment)
Adds the item at (row, column). If an item was
already added to that location, it is replaced (but not deleted).
An item may span several more rows or columns, which is controlled by
rowSpan and columnSpan.
The alignment specifies the vertical and horizontal
alignment of the item. The default value 0 indicates that the item is
stretched to fill the entire grid cell. The alignment can be specified as
a logical combination of a horizontal alignment (
AlignmentFlag.AlignLeft, AlignmentFlag.AlignCenter, or
AlignmentFlag.AlignRight) and a vertical alignment (
AlignmentFlag.AlignTop, AlignmentFlag.AlignMiddle, or
AlignmentFlag.AlignBottom).
addLayout(WLayout layout, int row, int column, EnumSet
alignment),
addWidget(WWidget widget, int row, int column, EnumSet
alignment)
public final void addItem(WLayoutItem item,
int row,
int column,
int rowSpan,
int columnSpan,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Calls
addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen,
alignment))
public final void addItem(WLayoutItem item,
int row,
int column)
Calls
addItem(item, row, column, 1, 1, EnumSet.noneOf(AlignmentFlag.class))
public final void addItem(WLayoutItem item,
int row,
int column,
int rowSpan)
Calls
addItem(item, row, column, rowSpan, 1,
EnumSet.noneOf(AlignmentFlag.class))
public final void addItem(WLayoutItem item,
int row,
int column,
int rowSpan,
int columnSpan)
Calls
addItem(item, row, column, rowSpan, columnSpan,
EnumSet.noneOf(AlignmentFlag.class))
public void addLayout(WLayout layout,
int row,
int column,
java.util.EnumSet<AlignmentFlag> alignment)
Adds the layout at (row, column). If an item
was already added to that location, it is replaced (but not deleted).
The alignment specifies the vertical and horizontal
alignment of the item. The default value 0 indicates that the item is
stretched to fill the entire grid cell. The alignment can be specified as
a logical combination of a horizontal alignment (
AlignmentFlag.AlignLeft, AlignmentFlag.AlignCenter, or
AlignmentFlag.AlignRight) and a vertical alignment (
AlignmentFlag.AlignTop, AlignmentFlag.AlignMiddle, or
AlignmentFlag.AlignBottom).
addLayout(WLayout layout, int row, int column, int
rowSpan, int columnSpan, EnumSet alignment)
public final void addLayout(WLayout layout,
int row,
int column,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Calls
addLayout(layout, row, column, EnumSet.of(alignmen, alignment))
public final void addLayout(WLayout layout,
int row,
int column)
Calls
addLayout(layout, row, column, EnumSet.noneOf(AlignmentFlag.class))
public void addLayout(WLayout layout,
int row,
int column,
int rowSpan,
int columnSpan,
java.util.EnumSet<AlignmentFlag> alignment)
Adds the layout at (row, column). If an item
was already added to that location, it is replaced (but not deleted).
An item may span several more rows or columns, which is controlled by
rowSpan and columnSpan.
The alignment specifies the vertical and horizontal
alignment of the item. The default value 0 indicates that the item is
stretched to fill the entire grid cell. The alignment can be specified as
a logical combination of a horizontal alignment (
AlignmentFlag.AlignLeft, AlignmentFlag.AlignCenter, or
AlignmentFlag.AlignRight) and a vertical alignment (
AlignmentFlag.AlignTop, AlignmentFlag.AlignMiddle, or
AlignmentFlag.AlignBottom).
addLayout(WLayout layout, int row, int column, EnumSet
alignment)
public final void addLayout(WLayout layout,
int row,
int column,
int rowSpan,
int columnSpan,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Calls
addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen,
alignment))
public final void addLayout(WLayout layout,
int row,
int column,
int rowSpan,
int columnSpan)
Calls
addLayout(layout, row, column, rowSpan, columnSpan,
EnumSet.noneOf(AlignmentFlag.class))
public void addWidget(WWidget widget,
int row,
int column,
java.util.EnumSet<AlignmentFlag> alignment)
Adds the widget at (row, column). If an item
was already added to that location, it is replaced (but not deleted).
The alignment specifies the vertical and horizontal
alignment of the item. The default value 0 indicates that the item is
stretched to fill the entire grid cell. The alignment can be specified as
a logical combination of a horizontal alignment (
AlignmentFlag.AlignLeft, AlignmentFlag.AlignCenter, or
AlignmentFlag.AlignRight) and a vertical alignment (
AlignmentFlag.AlignTop, AlignmentFlag.AlignMiddle, or
AlignmentFlag.AlignBottom).
addWidget(WWidget widget, int row, int column, int
rowSpan, int columnSpan, EnumSet alignment)
public final void addWidget(WWidget widget,
int row,
int column,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Calls
addWidget(widget, row, column, EnumSet.of(alignmen, alignment))
public final void addWidget(WWidget widget,
int row,
int column)
Calls
addWidget(widget, row, column, EnumSet.noneOf(AlignmentFlag.class))
public void addWidget(WWidget widget,
int row,
int column,
int rowSpan,
int columnSpan,
java.util.EnumSet<AlignmentFlag> alignment)
Adds the widget at (row, column). If an item
was already added to that location, it is replaced (but not deleted).
The widget may span several more rows or columns, which is controlled by
rowSpan and columnSpan.
The alignment specifies the vertical and horizontal
alignment of the item. The default value 0 indicates that the item is
stretched to fill the entire grid cell. The alignment can be specified as
a logical combination of a horizontal alignment (
AlignmentFlag.AlignLeft, AlignmentFlag.AlignCenter, or
AlignmentFlag.AlignRight) and a vertical alignment (
AlignmentFlag.AlignTop, AlignmentFlag.AlignMiddle, or
AlignmentFlag.AlignBottom).
addWidget(WWidget widget, int row, int column, EnumSet
alignment)
public final void addWidget(WWidget widget,
int row,
int column,
int rowSpan,
int columnSpan,
AlignmentFlag alignmen,
AlignmentFlag... alignment)
Calls
addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen,
alignment))
public final void addWidget(WWidget widget,
int row,
int column,
int rowSpan,
int columnSpan)
Calls
addWidget(widget, row, column, rowSpan, columnSpan,
EnumSet.noneOf(AlignmentFlag.class))
public void setHorizontalSpacing(int size)
The default horizontal spacing is 9 pixels.
setVerticalSpacing(int size)public int getHorizontalSpacing()
setHorizontalSpacing(int size)public void setVerticalSpacing(int size)
The default vertical spacing is 9 pixels.
setHorizontalSpacing(int size)public int getVerticalSpacing()
setVerticalSpacing(int size)public int getColumnCount()
The grid dimensions change dynamically when adding contents to the grid.
getRowCount()public int getRowCount()
The grid dimensions change dynamically when adding contents to the grid.
getColumnCount()
public void setColumnStretch(int column,
int stretch)
Sets the stretch factor for column column.
getColumnStretch(int column)public int getColumnStretch(int column)
setColumnStretch(int column, int stretch)
public void setRowStretch(int row,
int stretch)
Sets the stretch factor for row row. See the
description for the special value of -1.
getRowStretch(int row)public int getRowStretch(int row)
setRowStretch(int row, int stretch)
public void setColumnResizable(int column,
boolean enabled)
This method sets whether the border that separates column column from the next column may be resized by the user, depending on the value of enabled.
The default value is false.
public final void setColumnResizable(int column)
Calls setColumnResizable(column, true)
public boolean columnIsResizable(int column)
This method returns whether the border that separates column column from the next column may be resized by the user.
setColumnResizable(int column, boolean enabled)
public void setRowResizable(int row,
boolean enabled)
This method sets whether the border that separates row row from the next row may be resized by the user, depending on the value of enabled.
The default value is false.
public final void setRowResizable(int row)
Calls setRowResizable(row, true)
public boolean rowIsResizable(int row)
This method returns whether the border that separates row row from the next row may be resized by the user.
setRowResizable(int row, boolean enabled)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||