public class SimpleDock extends Container
The three children are laid out on the same horizontal or vertical line, one at the center and the two others on each side.
In a horizontal simple dock, the first and last widgets will have the height of the available space and will have their optimal width. In a vertical simple dock, the first and last widgets will have the width of the available space and will have their optimal height. Regardless of the orientation of the simple dock, the center widget will have the size of the remaining space.
Horizontal:
Vertical:
NO_CONSTRAINT
Constructor and Description |
---|
SimpleDock(boolean orientation)
Creates a simple dock specifying its orientation.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeContentOptimalSize(Size size)
Computes the optimal size of the widget.
|
Widget |
getCenterChild()
Gets the center widget of this simple dock.
|
Widget |
getFirstChild()
Gets the first widget of this simple dock.
|
Widget |
getLastChild()
Gets the last widget of this simple dock.
|
boolean |
getOrientation()
Gets the orientation of this simple dock.
|
protected void |
layOutChildren(int contentWidth,
int contentHeight)
Lays out the children of this container.
|
void |
removeAllChildren()
Removes all the children of this container.
|
void |
removeChild(Widget widget)
Removes the specified widget from the list of children of this container.
|
void |
setCenterChild(Widget child)
Sets the center widget of this simple dock.
|
void |
setFirstChild(Widget child)
Sets the first widget of this simple dock.
|
void |
setLastChild(Widget child)
Sets the last widget of this simple dock.
|
void |
setOrientation(boolean orientation)
Sets the orientation of this simple dock.
|
addChild, changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, insertChild, layOutAlignedChild, layOutChild, renderChild, renderContent, replaceChild, setHiddenChild, setHiddenChildren, setShownChild, setShownChildren, updateStyle
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getDesktop, getHeight, getParent, getStyle, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onAttached, onDetached, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle
public SimpleDock(boolean orientation)
orientation
- the orientation of the simple dock (see LayoutOrientation
).protected void computeContentOptimalSize(Size size)
Widget
This method does not consider the border, margin, padding and dimension specified in the style.
The given size is the available size for this widget in its parent. A width or a height equal to
Widget#NO_CONSTRAINT
means that there is no constraint on this dimension.
The given size is modified to set the optimal size.
computeContentOptimalSize
in class Widget
size
- the size available for the content.@Nullable public Widget getCenterChild()
null
is it has not been set.@Nullable public Widget getFirstChild()
null
is it has not been set.@Nullable public Widget getLastChild()
null
is it has not been set.public boolean getOrientation()
LayoutOrientation
).protected void layOutChildren(int contentWidth, int contentHeight)
Container
The given size is the size of this container minus the border, margin and padding specified in the style.
When this method returns the children of this container have been lay out using
Container.layOutChild(Widget, int, int, int, int)
.
layOutChildren
in class Container
contentWidth
- the width available for the content.contentHeight
- the height available for the content.public void removeAllChildren()
Container
The container needs to be laid out again.
Should be called in the display thread to avoid concurrency issues.
removeAllChildren
in class Container
Widget.requestLayOut()
public void removeChild(Widget widget)
Container
The container needs to be laid out again.
If the widget is not in the list of children of the container, nothing is done.
Should be called in the display thread to avoid concurrency issues.
removeChild
in class Container
widget
- the widget to remove.Widget.requestLayOut()
public void setCenterChild(Widget child)
child
- the widget to add.NullPointerException
- if the given widget is null
.IllegalArgumentException
- if the specified widget is already in a hierarchy (already contained in a container or desktop).Container.addChild(Widget)
public void setFirstChild(Widget child)
child
- the widget to add.NullPointerException
- if the given widget is null
.IllegalArgumentException
- if the specified widget is already in a hierarchy (already contained in a container or desktop).Container.addChild(Widget)
public void setLastChild(Widget child)
child
- the widget to add.NullPointerException
- if the given widget is null
.IllegalArgumentException
- if the specified widget is already in a hierarchy (already contained in a container or desktop).Container.addChild(Widget)
public void setOrientation(boolean orientation)
orientation
- the orientation to set (see LayoutOrientation
).