|
|||||||||
| 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
totalcross.ui.AlignedLabelsContainer
public class AlignedLabelsContainer
LabelContainer is a Container used to align all controls to the maximum width of a set of labels. You can define the label alignment. The controls that you add to this container are placed at the right of the labels. Here's a sample of how to use it:
totalcross.lang.String[] labels =
{
"Name",
"Born date",
"Telephone",
"Address",
"City",
"Country",
"",
};
AlignedLabelsContainer c = new AlignedLabelsContainer(labels);
c.setBorderStyle(BORDER_LOWERED);
c.labelAlign = RIGHT;
c.foreColors = new int[]{Color.RED,Color.BLACK,Color.BLACK,Color.BLACK,Color.BLACK,Color.BLACK,Color.BLACK,};
c.setInsets(2,2,2,2);
add(c,LEFT+2,TOP+2,FILL-2,PREFERRED+4);
for (int i =0; i < labels.length-2; i++)
c.add(new Edit(),LEFT+2,AFTER+(i==0?2:0));
c.add(new ComboBox(new totalcross.lang.String[]{"Brazil","France"}),LEFT+2,AFTER);
c.add(new Button("Insert data"),RIGHT,SAME);
c.add(new Button("Clear data"),RIGHT,AFTER,SAME,PREFERRED);
| Field Summary | |
|---|---|
int[] |
foreColors
Set an array with the same number of labels and the colors you want to show for each label. |
int |
labelAlign
The alignment of the labels. |
protected String[] |
labels
The label captions |
protected int[] |
widths
The computed widths for the labels. |
| Fields inherited from class totalcross.ui.Container |
|---|
alwaysEraseBackground, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, nextTransitionEffect, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_NONE, TRANSITION_OPEN, transitionEffect |
| 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 | |
|---|---|
AlignedLabelsContainer()
Creates a new AlignedLabelsContainer without labels. |
|
AlignedLabelsContainer(String[] labels)
Creates a new AlignedLabelsContainer with the given labels. |
|
AlignedLabelsContainer(String[] labels,
int vgap)
Creates a new AlignedLabelsContainer with the given labels. |
|
| Method Summary | |
|---|---|
int |
getLeftInset()
Returns the left inset. |
int |
getLineHeight()
Returns the height of a line. |
int |
getLineY(int line)
Given a line (staring from 0), returns the y position. |
int |
getPreferredHeight()
Returns the preferred height of this control. |
int |
getPreferredWidth()
Returns the preferred width of this control. |
void |
onFontChanged()
Called after a setFont |
void |
onPaint(Graphics g)
Draws the border (if any). |
void |
setInsets(int left,
int right,
int top,
int bottom)
Sets the insets value to match the given ones. |
void |
setLabels(String[] labels,
int vgap)
Sets the labels and the vgap (which may be 0). |
| Methods inherited from class totalcross.ui.Container |
|---|
add, add, add, add, add, broadcastEvent, clear, findChild, findNearestChild, findNextFocusControl, getBorderStyle, getChildren, getClientRect, getClientRect, getFocusableControls, getInsets, incLastX, incLastY, initUI, onAddAgain, onColorsChanged, onRemove, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderStyle, setEnabled, setHighlighting, swapToTopmostWindow |
| Methods inherited from class totalcross.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected String[] labels
protected int[] widths
public int[] foreColors
public int labelAlign
Control.LEFT,
Control.CENTER,
Control.RIGHT| Constructor Detail |
|---|
public AlignedLabelsContainer()
AlignedLabelsContainer(totalcross.lang.String[]),
AlignedLabelsContainer(totalcross.lang.String[], int),
setLabels(totalcross.lang.String[], int)public AlignedLabelsContainer(String[] labels)
labels - The strings that represents the labels. You may pass null, but be sure to call setLabels to set the labels.AlignedLabelsContainer(totalcross.lang.String[], int),
setLabels(totalcross.lang.String[], int)
public AlignedLabelsContainer(String[] labels,
int vgap)
labels - The strings that represents the labels. You may pass null, but be sure to call setLabels to set the labels.vgap - The extra gap between rows. May be negative.AlignedLabelsContainer(totalcross.lang.String[]),
setLabels(totalcross.lang.String[], int)| Method Detail |
|---|
public void setLabels(String[] labels,
int vgap)
labels - The strings that represents the labels. You may pass null, but be sure to call setLabels to set the labels.vgap - The extra gap between rows. May be negative.AlignedLabelsContainer(totalcross.lang.String[]),
AlignedLabelsContainer(totalcross.lang.String[], int)public void onFontChanged()
Control
onFontChanged in class Control
public void setInsets(int left,
int right,
int top,
int bottom)
Container
setInsets in class Containerpublic int getPreferredWidth()
Control
getPreferredWidth in class Controlpublic int getPreferredHeight()
Control
getPreferredHeight in class Controlpublic void onPaint(Graphics g)
Containersuper.onPaint(g);, or the border will not be drawn.
onPaint in class Containerg - the graphics object for drawingGraphicspublic int getLineY(int line)
add(chCasado = new Check("Married"),LEFT,getLineY(4)+2);
public int getLineHeight()
public int getLeftInset()
control.setRect(CENTER-getLeftInset()/2,...);
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||