|
|||||||||
| 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.ListBox
totalcross.ui.ColorList
public class ColorList
Implements a ListBox where colors can be choosen from. The only functional methods are setColors, getSelectedItem and getSelectedColor. Next an example of how to use this class as a combobox color chooser:
add(foreCombo = new ComboBox(new ColorList()), CENTER, BOTTOM);
| Nested Class Summary | |
|---|---|
static class |
ColorList.Item
Item added to the ListBox, containing the color as totalcross.lang.String and as int. |
| Field Summary |
|---|
| Fields inherited from class totalcross.ui.ListBox |
|---|
back0, back1, btnX, btnX0, dragScroll, EXTRA_HEIGHT_FACTOR, extraHorizScrollButtonHeight, ihtBackColors, ihtForeColors, itemCount, items, offset, sbar, selectedIndex, simpleBorder, useFullWidthOnSelection, visibleItems, visibleLines, xOffset |
| 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 | |
|---|---|
ColorList()
|
|
| Method Summary | |
|---|---|
protected void |
drawCursor(Graphics g,
int sel,
boolean on)
This method is used to draw the cursor around the desired item |
protected void |
drawItem(Graphics g,
int index,
int dx,
int dy)
You can extend ListBox and overide this method to draw the items |
protected void |
drawSelectedItem(Graphics g,
int index,
int dx,
int dy)
You can extend ListBox and overide this method to draw the items |
protected int |
getItemWidth(int index)
Returns the width of the given item index with the current fontmetrics. |
int |
getPreferredWidth()
Returns the preferred width, ie, the size of the largest item plus the size of the scrollbar. |
int |
getSelectedColor()
Returns the selected color or black if no one is selected. |
Object |
getSelectedItem()
Returns the selected Item object, or a black Item representing the black color if none was selected. |
void |
setColors(int[] newColors)
Sets the colors that will be displayed. |
| Methods inherited from class totalcross.ui.ListBox |
|---|
add, add, add, add, clear, drawSelectedItem, enableHorizontalScroll, endSelection, find, getCursorColor, getFocusableControls, getItemAt, getItems, getPreferredHeight, getSelectedIndex, getText, handleGeographicalFocusChangeKeys, handleSelection, hideScrollBarIfNotNeeded, indexOf, insert, leftReached, onBoundsChanged, onColorsChanged, onEvent, onPaint, qsort, qsort, remove, remove, remove, removeAll, selectLast, setCursorColor, setEnabled, setItemAt, setSelectedIndex, setSelectedItem, setSelectedItemStartingWith, setSimpleBorder, size |
| Methods inherited from class totalcross.ui.Container |
|---|
add, add, add, add, broadcastEvent, findChild, findNearestChild, findNextFocusControl, getBorderStyle, getChildren, getClientRect, getClientRect, getInsets, incLastX, incLastY, initUI, onAddAgain, onRemove, paintChildren, resize, resizeHeight, resizeWidth, setBorderStyle, setHighlighting, setInsets, swapToTopmostWindow |
| Methods inherited from class totalcross.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ColorList()
| Method Detail |
|---|
public void setColors(int[] newColors)
protected void drawItem(Graphics g,
int index,
int dx,
int dy)
ListBox
drawItem in class ListBox
protected void drawSelectedItem(Graphics g,
int index,
int dx,
int dy)
ListBox
drawSelectedItem in class ListBox
protected void drawCursor(Graphics g,
int sel,
boolean on)
ListBox
drawCursor in class ListBoxpublic int getPreferredWidth()
ListBox
getPreferredWidth in class ListBoxprotected int getItemWidth(int index)
ListBox
getItemWidth in class ListBoxpublic Object getSelectedItem()
getSelectedItem in class ListBoxpublic int getSelectedColor()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||