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, itemCount, items, offset, sbar, selectedIndex, simpleBorder, visibleItems
 
Fields inherited from class waba.ui.Container
BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, lastH, lastW, lastX, lastY, parentWindow, tail
 
Fields inherited from class waba.ui.Control
AFTER, appId, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, enabled, FILL, FIT, fm, fmH, focusLess, font, foreColor, foreDis, height, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, visible, width, x, x2, y, y2
 
Constructor Summary
ColorList()
           
 
Method Summary
protected  void drawCursor(Graphics g, int sel, boolean on)
           
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 20.
 Object getSelectedItem()
          Will return a String with the rrggbb in hex
 
Methods inherited from class waba.ui.ListBox
add, add, add, find, getItemAt, getItems, getPreferredHeight, getSelectedIndex, indexOf, insert, onBoundsChanged, onColorsChanged, onEvent, onPaint, qsort, remove, remove, remove, removeAll, select, setCursorColor, setEnabled, setItemAt, setSimpleBorder, size
 
Methods inherited from class waba.ui.Container
add, add, broadcastEvent, findChild, getChildren, getClientRect, onStart, paintChildren, setBorderStyle
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Constructor Detail

ColorList

public ColorList()
Method Detail

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)
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 20.
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 Object getSelectedItem()
Will return a String with the rrggbb in hex
Overrides:
getSelectedItem in class ListBox