Class TextModeLayout
This is a special case layout specifically designed for com.codename1.ui.InputComponent.
When the on top mode of text layout is used this layout acts exactly like a table layout and uses the
given constraints. When this mode is false it uses a regular box Y layout mode and orders the elements one
on top of the other.
One important difference between this layout and the default table layout is that the vertical alignment
here is set to TOP so the error label below doesn't break component alignment if two components
are on the same row and only one has an error message.
The following code demonstrates a simple set of inputs and validation as it appears in iOS, Android and with validation errors
TextModeLayout tl = new TextModeLayout(3, 2);
Form f = new Form("Pixel Perfect", tl);
TextComponent title = new TextComponent().label("Title");
TextComponent price = new TextComponent().label("Price");
TextComponent location = new TextComponent().label("Location");
PickerComponent date = PickerComponent.createDate(new Date()).label("Date");
TextComponent description = new TextComponent().label("Description").multiline(true);
Validator val = new Validator();
val.addConstraint(title, new LengthConstraint(2));
val.addConstraint(price, new NumericConstraint(true));
f.add(tl.createConstraint().widthPercentage(60), title);
f.add(tl.createConstraint().widthPercentage(40), date);
f.add(location);
f.add(price);
f.add(tl.createConstraint().horizontalSpan(2), description);
f.setEditOnShow(title.getField());
f.show();
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal TableLayoutThe underlying table layout can be used freely to create constraints on the fly -
Constructor Summary
ConstructorsConstructorDescriptionTextModeLayout(int rows, int columns) The constructor works like the standard table layout constructor and will behave as such with the on top mode -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(Object value, Component comp, Container c) Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.cc()Creates a new Constraint instance to add to the layoutcc(int row, int column) Creates a new Constraint instance to add to the layoutcloneConstraint(Object constraint) Creates a new Constraint instance to add to the layoutcreateConstraint(int row, int column) Creates a new Constraint instance to add to the layoutReturns the optional component constraintgetPreferredSize(Container parent) Returns the container preferred sizebooleanAutomatically invokes thecom.codename1.ui.InputComponent#group(com.codename1.ui.Component...)method on the text components in a BoxY layout scenariobooleanIf this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the containerbooleanThis method returns true if the Layout allows Components to Overlap.voidlayoutContainer(Container parent) Layout the given parent container childrenbooleanobscuresPotential(Container parent) Some layout managers can obscure their child components in some cases this returns true if the basic underpinnings are in place for that.voidRemoves the component from the layout this operation is only useful if the layout maintains references to components within itvoidsetAutoGrouping(boolean autoGrouping) Automatically invokes thecom.codename1.ui.InputComponent#group(com.codename1.ui.Component...)method on the text components in a BoxY layout scenarioMethods inherited from class Layout
equals, getChildrenInTraversalOrder, hashCode, overridesTabIndices, updateTabIndices
-
Field Details
-
table
The underlying table layout can be used freely to create constraints on the fly
-
-
Constructor Details
-
TextModeLayout
public TextModeLayout(int rows, int columns) The constructor works like the standard table layout constructor and will behave as such with the on top mode
Parameters
-
rows: the number of rows -
columns: the number of columns;
-
-
-
Method Details
-
addLayoutComponent
Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.
Parameters
-
value: optional meta data information, like alignment orientation -
comp: the added component to the layout -
c: the parent container
- Overrides:
addLayoutComponentin classLayout
-
-
cloneConstraint
- Overrides:
cloneConstraintin classLayout
-
getComponentConstraint
Returns the optional component constraint
Parameters
comp: the component whose constraint should be returned
Returns
the optional component constraint
- Overrides:
getComponentConstraintin classLayout
-
isConstraintTracking
public boolean isConstraintTracking()If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container
Returns
false by default
- Overrides:
isConstraintTrackingin classLayout
-
isOverlapSupported
public boolean isOverlapSupported()This method returns true if the Layout allows Components to Overlap.
Returns
true if Components may intersect in this layout
- Overrides:
isOverlapSupportedin classLayout
-
obscuresPotential
Some layout managers can obscure their child components in some cases this returns true if the basic underpinnings are in place for that. This method doesn't take padding/margin etc. into account since that is checked by the caller
Parameters
parent: parent container
Returns
true if there is a chance that this layout manager can fully obscure the background, when in doubt return false...
- Overrides:
obscuresPotentialin classLayout
-
removeLayoutComponent
Removes the component from the layout this operation is only useful if the layout maintains references to components within it
Parameters
comp: the removed component from layout
- Overrides:
removeLayoutComponentin classLayout
-
layoutContainer
Layout the given parent container children
Parameters
parent: the given parent container
- Specified by:
layoutContainerin classLayout
-
getPreferredSize
Returns the container preferred size
Parameters
parent: the parent container
Returns
the container preferred size
- Specified by:
getPreferredSizein classLayout
-
createConstraint
Creates a new Constraint instance to add to the layout
Returns
the default constraint
-
cc
Creates a new Constraint instance to add to the layout
Returns
the default constraint
-
createConstraint
Creates a new Constraint instance to add to the layout
Parameters
-
row: the row for the table starting with 0 -
column: the column for the table starting with 0
Returns
the new constraint
-
-
cc
Creates a new Constraint instance to add to the layout
Parameters
-
row: the row for the table starting with 0 -
column: the column for the table starting with 0
Returns
the default constraint
-
-
isAutoGrouping
public boolean isAutoGrouping()Automatically invokes the
com.codename1.ui.InputComponent#group(com.codename1.ui.Component...)method on the text components in a BoxY layout scenarioReturns
the autoGrouping
-
setAutoGrouping
public void setAutoGrouping(boolean autoGrouping) Automatically invokes the
com.codename1.ui.InputComponent#group(com.codename1.ui.Component...)method on the text components in a BoxY layout scenarioParameters
autoGrouping: the autoGrouping to set
-