Package totalcross.ui
Class ColorList
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.ListBox
-
- totalcross.ui.ColorList
-
- All Implemented Interfaces:
Scrollable
public class ColorList extends ListBox
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);
Consider using ColorChooserBox instead.- See Also:
totalcross.ui#ColorChooserBox
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classColorList.ItemItem added to the ListBox, containing the color as String and as int.-
Nested classes/interfaces inherited from class totalcross.ui.ListBox
ListBox.CustomDrawingItem, ListBox.IconItem
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
-
Fields inherited from class totalcross.ui.ListBox
back0, back1, btnX, btnX0, customCursorColor, dataCol, DEFAULT_ITEM_HEIGHT_FACTOR, drawBorder, EXTRA_HEIGHT_FACTOR, extraHorizScrollButtonHeight, flick, iconGap, ihFactor, ihtBackColors, ihtForeColors, itemCount, itemHeightFactor, items, offset, sbar, selectedIndex, simpleBorder, tempSelectedIndex, useFullWidthOnSelection, visibleItems, visibleLines, xOffset
-
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, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_FADE, TRANSITION_NONE, TRANSITION_OPEN, TRANSITION_TIME, transitionEffect
-
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, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, nextTabControl, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Constructor Summary
Constructors Constructor Description ColorList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddrawCursor(Graphics g, int sel, boolean on)This method is used to draw the cursor around the desired itemprotected voiddrawItem(Graphics g, int index, int dx, int dy)You can extend ListBox and overide this method to draw the itemsprotected voiddrawSelectedItem(Graphics g, int index, int dx, int dy)You can extend ListBox and overide this method to draw the itemsprotected intgetItemWidth(int index)Returns the width of the given item index with the current fontmetrics.intgetPreferredWidth()Returns the preferred width, ie, the size of the largest item plus the size of the scrollbar.intgetSelectedColor()Returns the selected color or black if no one is selected.java.lang.ObjectgetSelectedItem()Returns the selected Item object, or a black Item representing the black color if none was selected.voidsetColors(int[] newColors)Sets the colors that will be displayed.-
Methods inherited from class totalcross.ui.ListBox
add, add, add, add, addWrapping, canScrollContent, clear, drawItems, drawSelectedItem, enableHorizontalScroll, endSelection, find, flickEnded, flickStarted, getCursorColor, getEffectH, getEffectW, getEffectX, getEffectY, getFlick, getFocusableControls, getItemAt, getItemHeight, getItems, getItemsArray, getPreferredHeight, getScrollPosition, getSelectedIndex, getText, handleGeographicalFocusChangeKeys, handleSelection, hideScrollBarIfNotNeeded, indexOf, insert, leftReached, onBoundsChanged, onColorsChanged, onEvent, onPaint, qsort, qsort, remove, remove, remove, removeAll, scrollContent, selectLast, selectLast, setCursorColor, setEnabled, setItemAt, setSelectedIndex, setSelectedIndex, setSelectedItem, setSelectedItemStartingWith, setSimpleBorder, setTextAreaClip, size, wasScrolled
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, applyTransitionEffect, broadcastEvent, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, resize, resizeHeight, resizeWidth, setBorderStyle, setFocusTraversable, setHighlighting, setInsets, setNextTransitionEffect, setPressColor, setPressed, swapToTopmostWindow
-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addGridListener, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addTimer, addTimer, addTimerListener, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onFontChanged, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Method Detail
-
setColors
public void setColors(int[] newColors)
Sets the colors that will be displayed.
-
drawItem
protected void drawItem(Graphics g, int index, int dx, int dy)
Description copied from class:ListBoxYou can extend ListBox and overide this method to draw the items
-
drawSelectedItem
protected void drawSelectedItem(Graphics g, int index, int dx, int dy)
Description copied from class:ListBoxYou can extend ListBox and overide this method to draw the items- Overrides:
drawSelectedItemin classListBox
-
drawCursor
protected void drawCursor(Graphics g, int sel, boolean on)
Description copied from class:ListBoxThis method is used to draw the cursor around the desired item- Overrides:
drawCursorin classListBox
-
getPreferredWidth
public int getPreferredWidth()
Description copied from class:ListBoxReturns the preferred width, ie, the size of the largest item plus the size of the scrollbar.- Overrides:
getPreferredWidthin classListBox
-
getItemWidth
protected int getItemWidth(int index)
Description copied from class:ListBoxReturns the width of the given item index with the current fontmetrics. Note: if you overide this class you must implement this method.- Overrides:
getItemWidthin classListBox
-
getSelectedItem
public java.lang.Object getSelectedItem()
Returns the selected Item object, or a black Item representing the black color if none was selected. From the Item you can retrieve the color as int. Use the getSelectedColor method to retrieve the color directly.- Overrides:
getSelectedItemin classListBox
-
getSelectedColor
public int getSelectedColor()
Returns the selected color or black if no one is selected.
-
-