superwaba.ext.xplat.ui
Class ColorList

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.Container
              |
              +--waba.ui.ListBox
                    |
                    +--superwaba.ext.xplat.ui.ColorList

public class ColorList
extends ListBox

Implements a ListBox where colors can be choosed from. The only functional methods are getSelectedItem and getSelectedIndex. This class works well in 2 and 4 bpp (gray scale). Next an example of how to use this class as a combobox color chooser:

 add(foreCombo = new ComboBox(new ColorList()), CENTER, BOTTOM);
 


Fields inherited from class waba.ui.ListBox
btnX, extraHorizScrollButtonHeight, itemCount, items, offset, sbar, selectedIndex, simpleBorder, useFullWidthOnSelection, visibleItems, xOffset
 
Fields inherited from class waba.ui.Container
BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, lastH, lastW, lastX, lastY, parentWindow, started, tabOrder, tail
 
Fields inherited from class waba.ui.Control
AFTER, appId, appObj, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, clearValueInt, clearValueStr, enabled, FILL, FIT, fm, fmH, focusLess, focusTraversable, font, foreColor, foreDis, height, highlightRectsCount, isHighlighting, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, uiCE, uiFlat, uiPalm, uiVista, visible, width, x, x2, y, y2
 
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  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.
 java.lang.Object getSelectedItem()
          Will return a waba.fx.Color object
 void setColors(Color[] colors)
          Sets the colors that will be displayed.
 
Methods inherited from class waba.ui.ListBox
add, add, add, clear, enableHorizScroll, find, getItemAt, getItems, getPreferredHeight, getSelectedIndex, indexOf, insert, onBoundsChanged, onColorsChanged, onEvent, onPaint, qsort, remove, remove, remove, removeAll, select, select, selectLast, setCursorColor, setEnabled, setItemAt, setSimpleBorder, size
 
Methods inherited from class waba.ui.Container
add, add, broadcastEvent, findChild, getChildren, getClientRect, getClientRect, onAdd, onRemove, onStart, paintChildren, setBorderStyle, setHighlighting, swapToTopmostWindow
 
Methods inherited from class waba.ui.Control
addTimer, changeHighlighted, contains, createGraphics, drawHighlight, getAbsoluteRect, getBackColor, getFont, getFontMetrics, getForeColor, getNext, getParent, getParentWindow, getPos, getRect, getSize, isDisplayed, isEnabled, isVisible, onFontChanged, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, requestFocus, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setVisible, translateFromOrigin, uiStyleChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorList

public ColorList()
Method Detail

setColors

public void setColors(Color[] colors)
Sets the colors that will be displayed.

drawItem

protected void drawItem(Graphics g,
                        int index,
                        int dx,
                        int dy)
Description copied from class: ListBox
You can extend ListBox and overide this method to draw the items
Overrides:
drawItem in class ListBox

drawCursor

protected void drawCursor(Graphics g,
                          int sel,
                          boolean on)
Description copied from class: ListBox
This method is used to draw the cursor around the desired item
Overrides:
drawCursor in class ListBox

getPreferredWidth

public int getPreferredWidth()
Description copied from class: ListBox
returns the preferred width, ie, the size of the largest item plus the size of the scrollbar.
Overrides:
getPreferredWidth in class ListBox

getItemWidth

protected int getItemWidth(int index)
Description copied from class: ListBox
Returns the width of the given item index with the current fontmetrics. Note: if you overide this class you must implement this method.
Overrides:
getItemWidth in class ListBox

getSelectedItem

public java.lang.Object getSelectedItem()
Will return a waba.fx.Color object
Overrides:
getSelectedItem in class ListBox