public class Container extends Control
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
boolean |
alwaysEraseBackground
Set to true to always erase the background when repainting this container.
|
static int |
BACKGROUND_CYLINDRIC_SHADED
used in the backgroundStyle field.
|
static int |
BACKGROUND_SHADED
used in the backgroundStyle field
|
static int |
BACKGROUND_SHADED_INV
used in the backgroundStyle field
|
static int |
BACKGROUND_SOLID
used in the bckgroundStyle field
|
int |
backgroundStyle
Sets the type of background of this Container.
|
static byte |
BORDER_LOWERED
used in the setBorderStyle method
|
static byte |
BORDER_NONE
used in the setBorderStyle method
|
static byte |
BORDER_RAISED
used in the setBorderStyle method
|
static byte |
BORDER_ROUNDED
used in the setBorderStyle method.
|
static byte |
BORDER_SIMPLE
used in the setBorderStyle method
|
static byte |
BORDER_TOP
used in the setBorderStyle method
|
int |
borderColor
The color used in the border.
|
protected int |
borderRadius
Border Radius, used when border style is @see BORDER_ROUNDED
|
protected Control |
children
The children of the container.
|
protected static boolean |
controlFound
Returns true if the control was found in findChild, false otherwise.
|
protected boolean |
finishedStart |
protected boolean |
ignoreOnAddAgain
Set to true to avoid calling the methods onRemove or onAddAgain
|
protected boolean |
ignoreOnRemove
Set to true to avoid calling the methods onRemove or onAddAgain
|
protected Insets |
insets
The insets of this container.
|
protected int |
lastH |
protected int |
lastScreenWidth |
protected int |
lastW |
protected int |
lastX |
protected int |
lastY |
protected int |
numChildren |
protected boolean |
started |
Vector |
tabOrder
Holds the controls that will be used to transfer focus when the tab key is pressed.
|
protected Control |
tail
The tail of the children list.
|
static int |
TRANSITION_TIME
Defines the total transition time.
|
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
Constructor and Description |
---|
Container()
Creates a container with the default colors.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Control control)
Adds a child control to this container.
|
void |
add(Control control,
int x,
int y)
Add the control to this container and set its rect
to be the given x,y and PREFERRED as width/height
relative to the last control added
Same of
|
void |
add(Control control,
int x,
int y,
Control relative)
Add the control to this container and set its rect
to be the given x,y and PREFERRED as width/height
relative to the given control
Same of
|
void |
add(Control control,
int x,
int y,
int w,
int h)
Adds the control to this container, using the given bounds, relative to the last control added
Same of
|
void |
add(Control control,
int x,
int y,
int w,
int h,
Control relative)
Adds the control to this container, using the given bounds, relative to the given control.
|
void |
broadcastEvent(Event e)
Posts an event to the children of this container and to all containers inside this containers; recursively.
|
void |
clear()
Clears all children controls that are
focusTraversable , recursively. |
protected void |
fillBackground(Graphics g,
int b) |
Control |
findChild(int x,
int y)
Returns the child located at the given x and y coordinates.
|
Control |
findNearestChild(int x,
int y,
int minDistance) |
Control |
findNextFocusControl(Control c,
int direction)
Finds the next control that should receive focus based on the direction with respect to c.
|
int |
getBorderRadius()
get border radius for border style @see BORDER_ROUNDED.
|
byte |
getBorderStyle()
Returns the border style.
|
Control[] |
getChildren()
Return an array of Controls that are added to this Container.
|
int |
getChildrenCount() |
Rect |
getClientRect()
Returns the client rect for this Container, in relative coords.
|
protected void |
getClientRect(Rect r)
Returns the client rect for this Container, in relative coords, excluding the insets.
|
Control |
getFirstChild() |
void |
getFocusableControls(Vector v)
Get a list of child controls of this container which are focus candidates
|
void |
getInsets(Insets copyInto)
Copy the current insets values into the given insets.
|
void |
incLastX(int n)
Increments the lastX, used in relative positioning.
|
void |
incLastY(int n)
Increments the lastY, used in relative positioning.
|
void |
initUI()
Called to initialize the User Interface of this container.
|
boolean |
isPressed() |
Control |
moveFocusToNextControl(Control control,
boolean forward)
Moves the focus to the next control, which can be an Edit, a MultiEdit, or another control type.
|
Control |
moveFocusToNextEditable(Control control,
boolean forward)
Moves the focus to the next Edit or MultiEdit control.
|
protected void |
onAddAgain()
When the container is added for the first time, the method initUI is called,
so the user interface can be initialized.
|
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
void |
onPaint(Graphics g)
Draws the border (if any).
|
protected void |
onRemove()
Called when this container is removed from the parent.
|
void |
onSwapFinished()
Called when this container has been swapped into the Window and the swap is done.
|
void |
paintChildren()
Called by the system to draw the children of the container.
|
void |
remove(Control control)
Removes a child control from the container.
|
void |
removeAll()
Removes all controls inside this container.
|
void |
resize()
This method resizes the Container's width and height to the needed bounds, based on added childs.
|
void |
resizeHeight()
This method resizes the Container's width to the needed bounds, based on added childs.
|
void |
resizeWidth()
This method resizes the Container's width to the needed bounds, based on added childs.
|
void |
setBorderRadius(int borderRadius)
Set border radius for border style @see BORDER_ROUNDED.
|
void |
setBorderStyle(byte border)
Sets the border for this container.
|
void |
setEnabled(boolean enabled)
Sets if this container and all childrens can or not accept events
|
void |
setFocusTraversable(boolean b)
Changes the focusTraversable property for this container and all controls, recursively
|
void |
setHighlighting()
Called by the event dispatcher to set highlighting back to true.
|
void |
setInsets(int left,
int right,
int top,
int bottom)
Sets the insets value to match the given ones.
|
void |
setPressColor(int color) |
void |
setPressed(boolean p) |
void |
swapToTopmostWindow()
Call this method to swap this Container to the topmost window.
|
_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, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
protected Control children
protected Control tail
public int backgroundStyle
transparentBackground
of the Control class to true. This field is used when
transparentBackground is set to false (default).
If the transparent background doesn't work, try setting
alwaysEraseBackground = true
.BACKGROUND_SHADED
,
BACKGROUND_SOLID
,
UIColors.shadeFactor
public static final byte BORDER_NONE
public static final byte BORDER_LOWERED
public static final byte BORDER_RAISED
public static final byte BORDER_SIMPLE
public static final byte BORDER_TOP
public static final byte BORDER_ROUNDED
public static final int BACKGROUND_SOLID
public static final int BACKGROUND_SHADED
public static final int BACKGROUND_SHADED_INV
public static final int BACKGROUND_CYLINDRIC_SHADED
public int borderColor
protected int borderRadius
public static int TRANSITION_TIME
protected int lastX
protected int lastY
protected int lastW
protected int lastH
protected int numChildren
protected boolean started
protected boolean ignoreOnRemove
protected boolean ignoreOnAddAgain
protected boolean finishedStart
public Vector tabOrder
protected int lastScreenWidth
protected Insets insets
setInsets(int, int, int, int)
public boolean alwaysEraseBackground
protected static boolean controlFound
public Container()
public void setPressColor(int color)
public void setPressed(boolean p)
public boolean isPressed()
public void setInsets(int left, int right, int top, int bottom)
public void getInsets(Insets copyInto)
copyInto
- The created object where the insets values will be copied into.public void add(Control control, int x, int y, int w, int h)
add(control); control.setRect(x,y,w,h, null,false);
public void add(Control control, int x, int y, int w, int h, Control relative)
add(control); control.setRect(x,y,w,h, relative,false);
public void add(Control control, int x, int y)
add(control); control.setRect(x,y,PREFERRED,PREFERRED, null,false);
public void add(Control control, int x, int y, Control relative)
add(control); control.setRect(x,y,PREFERRED,PREFERRED, relative,false);
public void add(Control control)
public void remove(Control control)
public Control findChild(int x, int y)
controlFound
public Control findNearestChild(int x, int y, int minDistance)
public Control[] getChildren()
public Control getFirstChild()
public int getChildrenCount()
public void setEnabled(boolean enabled)
setEnabled
in class Control
public void broadcastEvent(Event e)
public void paintChildren()
public void setBorderStyle(byte border)
BORDER_NONE
,
BORDER_LOWERED
,
BORDER_RAISED
,
BORDER_SIMPLE
,
BORDER_TOP
,
BORDER_ROUNDED
public Rect getClientRect()
getClientRect(Rect)
protected void getClientRect(Rect r)
protected void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged
in class Control
protected void fillBackground(Graphics g, int b)
public void onPaint(Graphics g)
super.onPaint(g);
, or the border will not be drawn.protected void onAddAgain()
ignoreOnAddAgain = true;
inside
the method initUI or the class constructor. Doing so makes the user interface initialize faster.protected void onRemove()
ignoreOnRemove = true;
inside
the method initUI or the class constructor. Doing so makes the user interface initialize faster.public void initUI()
public void setHighlighting()
public void swapToTopmostWindow()
public class MainMenu extends Container // create a Singleton from MainMenu { private static instance; public static getInstance() { return instance != null ? instance : (instance=new MainMenu()); } private MainMenu() { } } // then at some other class, you can do: MainMenu.getInstance().swapToTopmostWindow();
public void clear()
focusTraversable
, recursively.public void getFocusableControls(Vector v)
v
- A vector into which to add the focus candidates.public Control findNextFocusControl(Control c, int direction)
c
- The reference control from which to find the next control.direction
- The direction in which to look from c. One of: SpecialKeys.LEFT, SpecialKeys.RIGHT, SpecialKeys.UP, SpecialKeys.DOWNSettings.geographicalFocus
public byte getBorderStyle()
public void removeAll()
public void incLastX(int n)
public void incLastY(int n)
public void resize()
// this sample will center two buttons of different sizes on screen Container c = new Container(); add(c, CENTER,BOTTOM,1000,1000); c.add(new Button("Ok"),LEFT,TOP); c.add(new Button("Cancel"),AFTER+5,SAME); c.resize();Note: differently of Window.resize, this method does not call setRect again, it only changes the width and height by direct assignment.
resizeWidth()
,
resizeHeight()
public void resizeWidth()
// this sample will center two buttons of different sizes on screen Container c = new Container(); add(c, CENTER,BOTTOM,1000,1000); c.add(new Button("Ok"),LEFT,TOP); c.add(new Button("Cancel"),AFTER+5,SAME); c.resize();Note: differently of Window.resize, this method does not call setRect again, it only changes the width by direct assignment.
resize()
,
resizeHeight()
public void resizeHeight()
// this sample will center two buttons of different sizes on screen Container c = new Container(); add(c, CENTER,BOTTOM,1000,1000); c.add(new Button("Ok"),LEFT,TOP); c.add(new Button("Cancel"),AFTER+5,SAME); c.resize();Note: differently of Window.resize, this method does not call setRect again, it only changes the height by direct assignment.
resizeWidth()
,
resize()
public Control moveFocusToNextEditable(Control control, boolean forward)
public Control moveFocusToNextControl(Control control, boolean forward)
public void setFocusTraversable(boolean b)
public void onSwapFinished()
public int getBorderRadius()
public void setBorderRadius(int borderRadius)
borderRadius
- border radius in pixels.