|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
totalcross.lang.Objecttotalcross.ui.gfx.GfxSurface
totalcross.ui.Control
totalcross.ui.Container
public class Container
Container is a control that contains child controls.
| Field Summary | |
|---|---|
boolean |
alwaysEraseBackground
Set to true to always erase the background when repainting 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_SIMPLE
used in the setBorderStyle method |
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
|
static int |
nextTransitionEffect
The transition effect to apply in the next screen update. |
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_CLOSE
Used when animating the exhibition of a container. |
static int |
TRANSITION_NONE
Used when animating the exhibition of a container. |
static int |
TRANSITION_OPEN
Used when animating the exhibition of a container. |
int |
transitionEffect
Set the transition effect when this container appears on screen. |
| Fields inherited from class totalcross.ui.Control |
|---|
AFTER, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, CENTER, CENTER_OF, clearValueInt, clearValueStr, enabled, enableUpdateScreen, FILL, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, foreColor, height, isHighlighting, KEEP, LEFT, onEventFirst, parent, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, setFont, setH, setRel, setW, setX, setY, TOP, transparentBackground, uiCE, uiFlat, uiPalm, uiVista, visible, width, WILL_RESIZE, x, y |
| Constructor Summary | |
|---|---|
Container()
Creates a container with the default colors. |
|
| Method Summary | |
|---|---|
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 add(control); control.setRect(x,y,PREFERRED,PREFERRED, null,false); |
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 add(control); control.setRect(x,y,PREFERRED,PREFERRED, relative,false); |
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 add(control); control.setRect(x,y,w,h, null,false); |
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. |
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. |
byte |
getBorderStyle()
Returns the border style. |
Control[] |
getChildren()
Return an array of Controls that are added to this Container. |
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. |
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. |
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 |
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 |
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 |
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 |
swapToTopmostWindow()
Call this method to swap this Container to the topmost window. |
| Methods inherited from class totalcross.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Control children
protected Control tail
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 int TRANSITION_NONE
public static final int TRANSITION_OPEN
public static final int TRANSITION_CLOSE
public int transitionEffect
TRANSITION_NONE,
TRANSITION_OPEN,
TRANSITION_CLOSE,
Window.swap(Container),
Window.popup(),
Window.unpop(),
nextTransitionEffectpublic static int nextTransitionEffect
transitionEffect,
TRANSITION_NONE,
TRANSITION_OPEN,
TRANSITION_CLOSEprotected int lastX
protected int lastY
protected int lastW
protected int lastH
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
| Constructor Detail |
|---|
public Container()
| Method Detail |
|---|
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);
Control.setRect(int, int, int, int, Control, boolean)
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);
Control.setRect(int, int, int, int, Control, boolean)
public void add(Control control,
int x,
int y)
add(control); control.setRect(x,y,PREFERRED,PREFERRED, null,false);
Control.setRect(int, int, int, int, Control, boolean)
public void add(Control control,
int x,
int y,
Control relative)
add(control); control.setRect(x,y,PREFERRED,PREFERRED, relative,false);
Control.setRect(int, int, int, int, Control, boolean)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 void setEnabled(boolean enabled)
setEnabled in class Controlpublic void broadcastEvent(Event e)
public void paintChildren()
public void setBorderStyle(byte border)
BORDER_NONE,
BORDER_LOWERED,
BORDER_RAISED,
BORDER_SIMPLEpublic Rect getClientRect()
getClientRect(Rect)protected void getClientRect(Rect r)
protected void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged in class Controlpublic void onPaint(Graphics g)
super.onPaint(g);, or the border will not be drawn.
onPaint in class Controlg - the graphics object for drawingGraphicsprotected 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.
clear in class Controlpublic 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.DOWN
Settings.geographicalFocuspublic 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()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||