public enum LayoutPolicy extends java.lang.Enum<LayoutPolicy> implements ValueEnum
Note that, by default, Layouts do not automatically expand the size of all members
to match a member that overflows the layout on the breadth axis. This means that a
DynamicForm
or other component that can't shrink beyond a minimum width will
"stick out" of the Layout, wider than any other member and wider than automatically
generated components like resizeBars or sectionHeaders (in a SectionStack
).
This is by design: matching the size of overflowing members would cause expensive redraws of all members in the Layout, and with two or more members potentially overflowing, could turn minor browser size reporting bugs or minor glitches in custom components into infinite resizing loops.
If you run into this situation, you can either:
overflow
: "auto", so that it
scrolls if it needs more space
overflow
:"auto", so that the
whole Layout scrolls when the member overflows
resized()
handler to manually update the
breadth
of the layout
For the last approach, given the VLayout myLayout
and a member
myWideMember
, then we could define the following resized()
handler on myLayout
:
myLayout.addResizedHandler(new ResizedHandler() { @Override public void onResized(ResizedEvent event) { int memberWidth = myWideMember.getVisibleWidth(); myLayout.setWidth(Math.max(myLayout.getWidth(), memberWidth + offset)); }where
offset
reflects the difference in width (due to margins, padding,
etc.) between the layout and its widest member. In most cases, a fixed offset can
be used, but it can also be computed via the calculation:
myLayout.getWidth() - myLayout.getViewportWidth()by adding a
draw handler
for myLayout
. (That calculation is not always valid inside the
resized()
handler itself.)
Note: the HLayout case is similar- just substitute height where width appears above.
See also Layout.overflow
.
Enum Constant and Description |
---|
FILL
Layout sizes members so that they fill the specified size of the layout.
|
NONE
Layout does not try to size members on the axis at all, merely stacking them (length axis) and leaving them at default
breadth.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getValue() |
static LayoutPolicy |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static LayoutPolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final LayoutPolicy NONE
If this enumerated value is used in a Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "none".
public static final LayoutPolicy FILL
autofits
is given exactly the
space it needs, never forced to take up more.
If this enumerated value is used in a Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "fill".
public static LayoutPolicy[] values()
for (LayoutPolicy c : LayoutPolicy.values()) System.out.println(c);
public static LayoutPolicy valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null