Package totalcross.ui.layout
Class LinearBox
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.layout.LinearBox
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description protected intalignmentThe elements alignment with regard to this component.static intALIGNMENT_CENTERCenters each child objectstatic intALIGNMENT_LEFTAligns each child along the left/top borderstatic intALIGNMENT_RIGHTAligns each child along the right/bottom borderstatic intALIGNMENT_STRETCHStretches each child objectstatic intLAYOUT_DISTRIBUTEDistributes the elements along the width of the containerstatic intLAYOUT_FILLDistribute and scale each element to fill the entire width of this componentstatic intLAYOUT_STACK_CENTEROrganizes each element around the centerprotected intmodeThe mode that the components will be displayed.protected intspacingThe spacing between each component.protected booleansuspendLayoutSwitches if the 'add' method will also layout each component or if this is deferred until a 'resumeLayout' call-
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, npback, numChildren, started, tabOrder, tail, TRANSITION_TIME
-
Fields inherited from class totalcross.ui.Control
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(Control control)Adds the given control to this component and performs all layout operations to fit it within the layout.voidadd(Control[] controls)Adds several controls to this layout at oncevoidadd(Control control, int w, int h)Adds the given control to this component using the given width and height and performs all layout operations to fit it within the layout.voidadd(Control control, int x, int y, int w, int h)This layout does not supports this action.voidadd(Control control, int x, int y, int w, int h, Control relative)This layout does not supports this action.protected voiddoLayout()Recalculates every element's width and height, and also the paddings and spacings every time one of these values are changed.intgetSpacing()Gets the spacing between components.protected voidinternalAdd(Control control, int x, int y, int w, int h, Control relative)Used internally to add controls to this layoutprotected abstract voidresizeElements(int mode, int alignment)Recalculates every element's width and height, and also the paddings and spacings every time one of these values are changed.voidresumeLayout()Performs all queued layout operations and resumes the default layout behaviour of the 'add' method.voidsetInsets(int left, int right, int top, int bottom)Sets the internal paddings of this component.voidsetLayout(int mode, int alignment)Sets the layout mode of this componentvoidsetRect(int x, int y, int width, int height, Control relative, boolean screenChanged)The relative positioning will be made with the given control (relative).voidsetSpacing(int spacing)Sets the spacing between components.voidsuspendLayout()Suspends all layout operations from 'add' calls until a 'resumeLayout' call.-
Methods inherited from class totalcross.ui.Container
add, broadcastEvent, clear, fillBackground, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onPaint, onRemove, onSwapFinished, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, setEnabled, setFocusTraversable, setHighlighting, setPressColor, setPressed, swapToTopmostWindow
-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPreferredHeight, getPreferredWidth, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onBoundsChanged, onEvent, onFontChanged, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
LAYOUT_STACK_CENTER
public static final int LAYOUT_STACK_CENTER
Organizes each element around the center- See Also:
- Constant Field Values
-
LAYOUT_DISTRIBUTE
public static final int LAYOUT_DISTRIBUTE
Distributes the elements along the width of the container- See Also:
- Constant Field Values
-
LAYOUT_FILL
public static final int LAYOUT_FILL
Distribute and scale each element to fill the entire width of this component- See Also:
- Constant Field Values
-
ALIGNMENT_LEFT
public static final int ALIGNMENT_LEFT
Aligns each child along the left/top border- See Also:
- Constant Field Values
-
ALIGNMENT_RIGHT
public static final int ALIGNMENT_RIGHT
Aligns each child along the right/bottom border- See Also:
- Constant Field Values
-
ALIGNMENT_CENTER
public static final int ALIGNMENT_CENTER
Centers each child object- See Also:
- Constant Field Values
-
ALIGNMENT_STRETCH
public static final int ALIGNMENT_STRETCH
Stretches each child object- See Also:
- Constant Field Values
-
mode
protected int mode
The mode that the components will be displayed.
-
alignment
protected int alignment
The elements alignment with regard to this component.
-
spacing
protected int spacing
The spacing between each component.
-
suspendLayout
protected boolean suspendLayout
Switches if the 'add' method will also layout each component or if this is deferred until a 'resumeLayout' call
-
-
Method Detail
-
setRect
public void setRect(int x, int y, int width, int height, Control relative, boolean screenChanged)Description copied from class:ControlThe relative positioning will be made with the given control (relative). Note that in this case, only the SAME,BEFORE,AFTER are affected by the given control. Here is an example of relative positioning:Important note: you can't use FILL/FIT with BEFORE/RIGHT/BOTTOM (for x,y).
add(new Label("1"),CENTER,CENTER); add(new Label("2"),AFTER,SAME); add(new Label("3"),SAME,AFTER); add(new Label("4"),BEFORE,SAME); add(new Label("5"),BEFORE,BEFORE);You will see this on screen:512 43
Note: add(control, x,y) does:add(control); control.setRect(x,y,PREFERRED,PREFERRED);Important! Always add the control to the container before doing a setRect.
The relative positioning does not work well if the control is placed outside screen bounds.
- Overrides:
setRectin classControl- Parameters:
x- One of the relative positioning constants: LEFT, RIGHT, SAME, BEFORE, AFTER, CENTER, with a small adjustment. You can also use an absolute value, but this is strongly discouraged.y- One of the relative positioning constants: TOP, BOTTOM, SAME, BEFORE, AFTER, CENTER, with a small adjustment. You can also use an absolute value, but this is strongly discouraged.width- One of the relative positioning constants: PREFERRED, FILL, FIT, SAME. You can also use an absolute value, but this is strongly discouraged.height- One of the relative positioning constants: PREFERRED, FILL, FIT, SAME. You can also use an absolute value, but this is strongly discouraged.relative- To whom the position should be relative to; or null to be relative to the last control.screenChanged- Indicates that a screen change (resize, collapse) occured and therepositionmethod is calling this method. Set by the system. If you call this method directly, always pass false to it.- See Also:
Control.LEFT,Control.TOP,Control.RIGHT,Control.BOTTOM,Control.BEFORE,Control.AFTER,Control.CENTER,Control.SAME,Control.FILL,Control.PREFERRED,Control.FIT,Control.CENTER_OF,Control.RIGHT_OF,Control.BOTTOM_OF,Control.SCREENSIZE,Control.SCREENSIZEMIN,Control.SCREENSIZEMAX,Control.PARENTSIZE,Control.PARENTSIZEMIN,Control.PARENTSIZEMAX,Control.FONTSIZE,Container.add(Control, int, int),Container.add(Control, int, int, Control)
-
add
public void add(Control control)
Adds the given control to this component and performs all layout operations to fit it within the layout. Consider using the 'suspendLayout' and 'resumeLayout' methods if you plan on adding many controls at once.
-
add
public void add(Control control, int w, int h)
Adds the given control to this component using the given width and height and performs all layout operations to fit it within the layout. Consider using the 'suspendLayout' and 'resumeLayout' methods if you plan on adding many controls at once.- Overrides:
addin classContainer- See Also:
Control.setRect(int, int, int, int, Control, boolean)
-
add
public void add(Control[] controls)
Adds several controls to this layout at once
-
add
public void add(Control control, int x, int y, int w, int h)
This layout does not supports this action. Use the add(control) or add(control, w, h) instead.- Overrides:
addin classContainer- See Also:
Control.setRect(int, int, int, int, Control, boolean)
-
add
public void add(Control control, int x, int y, int w, int h, Control relative)
This layout does not supports this action. Use the add(control) or add(control, w, h) instead.- Overrides:
addin classContainer- See Also:
Control.setRect(int, int, int, int, Control, boolean)
-
internalAdd
protected void internalAdd(Control control, int x, int y, int w, int h, Control relative)
Used internally to add controls to this layout
-
suspendLayout
public void suspendLayout()
Suspends all layout operations from 'add' calls until a 'resumeLayout' call.
-
resumeLayout
public void resumeLayout()
Performs all queued layout operations and resumes the default layout behaviour of the 'add' method.
-
doLayout
protected void doLayout()
Recalculates every element's width and height, and also the paddings and spacings every time one of these values are changed.
-
resizeElements
protected abstract void resizeElements(int mode, int alignment)Recalculates every element's width and height, and also the paddings and spacings every time one of these values are changed.
-
setLayout
public void setLayout(int mode, int alignment)Sets the layout mode of this component
-
getSpacing
public int getSpacing()
Gets the spacing between components.
-
setSpacing
public void setSpacing(int spacing)
Sets the spacing between components.
-
-