org.xith3d.ui.hud.widgets
Class ComboBox

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.BackgroundSettableWidget
          extended by org.xith3d.ui.hud.base.AbstractList
              extended by org.xith3d.ui.hud.widgets.ComboBox
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Positioned2fRO, org.openmali.types.twodee.Sized2f, org.openmali.types.twodee.Sized2fRO, PaddingSettable, TextWidget, PopUpable

public class ComboBox
extends AbstractList
implements TextWidget, org.jagatoo.datatypes.Enableable, PopUpable

A ComboBox is a bordered Label with a Button on the right, that pops up a List widget and displays the current selected Item's text.


Nested Class Summary
static class ComboBox.Description
           
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
BackgroundSettableWidget.BackgroundSettableDescriptionBase
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
ComboBox(boolean isHeavyWeight, float width, float height, ListModel listModel)
          Creates a new ComboBox.
ComboBox(boolean isHeavyWeight, float width, float height, ListModel listModel, ComboBox.Description desc)
          Creates a new ComboBox.
ComboBox(float width, float height, ListModel listModel)
          Creates a new ComboBox.
ComboBox(float width, float height, ListModel listModel, ComboBox.Description desc)
          Creates a new ComboBox.
 
Method Summary
 java.lang.Object addItem(int index, java.lang.Object item)
          Adds the given Item to the List (at the given position).
 void addItem(int index, java.lang.String text)
           
 void addItem(int index, java.lang.String text, org.openmali.vecmath2.Colorf color)
           
 void addItem(int index, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
           
 void addItem(java.lang.String text)
           
 void addItem(java.lang.String text, org.openmali.vecmath2.Colorf color)
           
 void addItem(java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
           
 void addItems(java.util.List<?> items)
          Adds all items from the given List to this List.
 void addItems(java.lang.Object[] items)
          Adds all items from the given array to this List.
 boolean addItemSetsSelectedItem()
          If set to true, the addItem() method sets the selected item to the added one.
 void addSelectionListener(ListSelectionListener l)
          Adds a new ListSelectionListener.
protected  boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
          Checks, if this Widget blocks the given DeviceComponent for focus-moves.
 void clear()
          Removes all items from the List.
protected  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
          
 TextAlignment getAlignment()
          This alignment is used to render the items, if possible.
 int getBottomIndex()
          The bottom-most item's index visible in the List (or -1, if the List is empty)
 HUDFont getFont()
          
 org.openmali.vecmath2.Colorf getFontColor()
          
 org.openmali.vecmath2.Colorf getHoverBackgroundColor()
          
 int getListHeightByItems()
          Gets the list's height by items count.
 int getMaxListHeightByItems()
          Gets the maximum list's height by items.
protected  float getMinHeight()
          
protected  float getMinWidth()
          
 ListModel getModel()
          Gets the underlying model.
 int getPaddingBottom()
          
 int getPaddingLeft()
          
 int getPaddingRight()
          
 int getPaddingTop()
          
protected  float getPickHeight()
           
 org.openmali.vecmath2.Colorf getSelectionBackgroundColor()
          
 java.lang.String getText()
          
 int getTopIndex()
          The top-most item's index visible in the List (or -1, if the List is empty)
protected  void init()
          This method is called when the WidgetContainer is set.
 boolean isEnabled()
          
 boolean isPoppedUp()
          
static ComboBox newTextCombo(boolean isHeavyWeight, float width, float height)
          Creates a new ComboBox with a TextListModel.
static ComboBox newTextCombo(boolean isHeavyWeight, float width, float height, ComboBox.Description desc)
          Creates a new ComboBox with a TextListModel.
static ComboBox newTextCombo(float width, float height)
          Creates a new ComboBox with a TextListModel.
static ComboBox newTextCombo(float width, float height, ComboBox.Description desc)
          Creates a new ComboBox with a TextListModel.
 void onAttachedToHUD(HUD hud)
          This event is fired, when this Widget is added to the HUD live Widget hierarchy.
 void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
 void onMouseExited(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse exited the Widget area.
protected  void onSizeChanged(float oldWidth, float oldHeight, float newWidth, float newHeight)
          
 void popUp(boolean p)
          Pops up the popupable Widget (or un-pops it)
 java.lang.String removeItem(int index)
          Removes the given Item from the List.
 void removeSelectionListener(ListSelectionListener l)
          Removes a ListSelectionListener.
 void scrollSelectedItemIntoView()
          Scrolls the list, so that the selected item is in the content area.
 void setAddItemSetsSelectedItem(boolean b)
          If set to true, the addItem() method sets the selected item to the added one.
 void setAlignment(TextAlignment alignment)
          This alignment is used to render the items, if possible.
 void setEnabled(boolean enabled)
          
 void setFont(HUDFont font)
          Sets the new Font to be used
 void setFontColor(org.openmali.vecmath2.Colorf color)
          Sets the new color to be used
 void setHoverBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background-color of the hovered Item.
 void setListHeightByItems(int numItems)
          Sets the list's height by items count.
 void setMaxListHeightByItems(int maxHeight)
          Sets the maximum list's height by items.
 void setModel(ListModel model)
          Sets the underlying model.
 boolean setPadding(int paddingBottom, int paddingRight, int paddingTop, int paddingLeft)
          Sets padding for this PaddingSettable Widget.
 void setSelectedIndex(int itemIndex)
          Sets the currently selected Item.
 void setSelectionBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background-color of the selected Item.
 void setText(java.lang.String text)
          Sets the new text to be displayed
 void setTopIndex(int topIndex)
          Scrolls the list, so that the given index is the top item's index (if possible).
 
Methods inherited from class org.xith3d.ui.hud.base.AbstractList
addItem, afterFirstItemAdded, afterItemAddedToEnd, afterModelSetWidthItems, findItem, getItem, getItemsCount, getSelectedIndex, getSelectedItem, getWidget, selectNextItem, selectPreviousItem, setPadding, updateSizesAndMarkDirty
 
Methods inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
drawBackground, getBackgroundColor, getBackgroundTexture, getBackgroundTileMode, setBackground, setBackground, setBackground, setBackgroundColor, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTileMode, setNoBackground
 
Methods inherited from class org.xith3d.ui.hud.base.Widget
addContainerListener, addControllerListener, addFocusListener, addInputListener, addKeyboardListener, addLocationListener, addMouseListener, addSizeListener, addVisibilityListener, bindToGlobalMouseMovement, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, detach, drawAndUpdateWidget, drawBorder, drawWidgetAfterWidgetAssembler, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentHeightPX, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContentWidthPX, getContextMenu, getCursor, getEqualHeight_, getEqualWidth_, getForcedRedrawFrequency, getHeight, getHeightPX, getHUD, getLeft, getLevel, getLocation, getLocation, getLocationHUD2Pixels_, getLocationHUD2SG_, getLocationPixels2HUD_, getLocationSG2HUD_, getMaxRedrawFrequency, getName, getParentWindow, getPickWidth, getRelLocationHUD2Pixels_, getRootHostWidget, getShape, getSize, getSizeHUD2Pixels_, getSizeHUD2SG_, getSizeOfPixels_, getSizePixels2HUD_, getSizeSG2HUD_, getToolTip, getTop, getTransparency, getUserObject, getWidgetAssembler, getWidth, getWidthPX, getZIndex, hasDropShadow, hasFocus, hasFocus, hasToolTip, initSize, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onDetachedFromHUD, onFocusGained, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onLocationChanged, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseMoved, onMouseStopped, onMouseWheelMoved, onVisibilityChanged, pick, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, setContentClipRect, setContextMenu, setCursor, setDraggable, setFocussable, setForcedRedrawFrequency, setHasDropShadow, setHeight, setHostedWidgetDirty, setHostTextureDirty, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, startDragging, toString, update, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComboBox

public ComboBox(boolean isHeavyWeight,
                float width,
                float height,
                ListModel listModel,
                ComboBox.Description desc)
Creates a new ComboBox.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
model - the ListModel (null for auto-generation)
desc -

ComboBox

public ComboBox(boolean isHeavyWeight,
                float width,
                float height,
                ListModel listModel)
Creates a new ComboBox.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
model - the ListModel (null for auto-generation)

ComboBox

public ComboBox(float width,
                float height,
                ListModel listModel,
                ComboBox.Description desc)
Creates a new ComboBox.

Parameters:
width - the new width
model - the ListModel (null for auto-generation)
height - the new height
desc -

ComboBox

public ComboBox(float width,
                float height,
                ListModel listModel)
Creates a new ComboBox.

Parameters:
width - the new width
height - the new height
model - the ListModel (null for auto-generation)
Method Detail

getMinWidth

protected float getMinWidth()

Overrides:
getMinWidth in class Widget

getMinHeight

protected float getMinHeight()

Overrides:
getMinHeight in class Widget

setModel

public void setModel(ListModel model)
Sets the underlying model.

Overrides:
setModel in class AbstractList

getModel

public ListModel getModel()
Gets the underlying model.

Overrides:
getModel in class AbstractList
Returns:
the underlying model.

setPadding

public boolean setPadding(int paddingBottom,
                          int paddingRight,
                          int paddingTop,
                          int paddingLeft)
Sets padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

Specified by:
setPadding in interface PaddingSettable
Returns:
true, if the padding actually has changed

getPaddingBottom

public final int getPaddingBottom()

Specified by:
getPaddingBottom in interface PaddingSettable
Returns:
bottom-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

getPaddingRight

public final int getPaddingRight()

Specified by:
getPaddingRight in interface PaddingSettable
Returns:
right-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

getPaddingTop

public final int getPaddingTop()

Specified by:
getPaddingTop in interface PaddingSettable
Returns:
top-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

getPaddingLeft

public final int getPaddingLeft()

Specified by:
getPaddingLeft in interface PaddingSettable
Returns:
left-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

setHoverBackgroundColor

public void setHoverBackgroundColor(org.openmali.vecmath2.Colorf color)
Sets the background-color of the hovered Item.

Specified by:
setHoverBackgroundColor in class AbstractList

getHoverBackgroundColor

public final org.openmali.vecmath2.Colorf getHoverBackgroundColor()

Specified by:
getHoverBackgroundColor in class AbstractList
Returns:
the background-color of the hovered Item.

setSelectionBackgroundColor

public void setSelectionBackgroundColor(org.openmali.vecmath2.Colorf color)
Sets the background-color of the selected Item.

Specified by:
setSelectionBackgroundColor in class AbstractList

getSelectionBackgroundColor

public final org.openmali.vecmath2.Colorf getSelectionBackgroundColor()

Specified by:
getSelectionBackgroundColor in class AbstractList
Returns:
the background-color of the selected Item.

setAlignment

public void setAlignment(TextAlignment alignment)
This alignment is used to render the items, if possible.

Specified by:
setAlignment in interface TextWidget
Specified by:
setAlignment in class AbstractList

getAlignment

public final TextAlignment getAlignment()
This alignment is used to render the items, if possible.

Specified by:
getAlignment in interface TextWidget
Specified by:
getAlignment in class AbstractList
Returns:
the TextAlignment.

addSelectionListener

public void addSelectionListener(ListSelectionListener l)
Adds a new ListSelectionListener.

Specified by:
addSelectionListener in class AbstractList
Parameters:
l - the new listener

removeSelectionListener

public void removeSelectionListener(ListSelectionListener l)
Removes a ListSelectionListener.

Specified by:
removeSelectionListener in class AbstractList
Parameters:
l - the listener to be removed

setSelectedIndex

public void setSelectedIndex(int itemIndex)
Sets the currently selected Item.

Overrides:
setSelectedIndex in class AbstractList

setAddItemSetsSelectedItem

public void setAddItemSetsSelectedItem(boolean b)
If set to true, the addItem() method sets the selected item to the added one.

Specified by:
setAddItemSetsSelectedItem in class AbstractList

addItemSetsSelectedItem

public final boolean addItemSetsSelectedItem()
If set to true, the addItem() method sets the selected item to the added one.

Specified by:
addItemSetsSelectedItem in class AbstractList

addItem

public java.lang.Object addItem(int index,
                                java.lang.Object item)
Adds the given Item to the List (at the given position).

Overrides:
addItem in class AbstractList
Parameters:
index - the position to add the Item at
item - the new Item to add to the List

addItem

public void addItem(int index,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)

addItem

public final void addItem(java.lang.String text,
                          HUDFont font,
                          org.openmali.vecmath2.Colorf color)

addItem

public final void addItem(int index,
                          java.lang.String text,
                          org.openmali.vecmath2.Colorf color)

addItem

public final void addItem(java.lang.String text,
                          org.openmali.vecmath2.Colorf color)

addItem

public final void addItem(int index,
                          java.lang.String text)

addItem

public final void addItem(java.lang.String text)

removeItem

public java.lang.String removeItem(int index)
Removes the given Item from the List.

Overrides:
removeItem in class AbstractList
Parameters:
index - the position of the Item to be removed
Returns:
the removed Item or null, if there was no item at the given index.

addItems

public void addItems(java.util.List<?> items)
Adds all items from the given List to this List.

Overrides:
addItems in class AbstractList

addItems

public void addItems(java.lang.Object[] items)
Adds all items from the given array to this List.

Overrides:
addItems in class AbstractList

clear

public void clear()
Removes all items from the List.

Overrides:
clear in class AbstractList

setTopIndex

public void setTopIndex(int topIndex)
Scrolls the list, so that the given index is the top item's index (if possible).

Specified by:
setTopIndex in class AbstractList

getTopIndex

public int getTopIndex()
The top-most item's index visible in the List (or -1, if the List is empty)

Specified by:
getTopIndex in class AbstractList
Returns:
the top index.

getBottomIndex

public final int getBottomIndex()
The bottom-most item's index visible in the List (or -1, if the List is empty)

Specified by:
getBottomIndex in class AbstractList
Returns:
the bottom index.

scrollSelectedItemIntoView

public void scrollSelectedItemIntoView()
Scrolls the list, so that the selected item is in the content area.

Specified by:
scrollSelectedItemIntoView in class AbstractList

setListHeightByItems

public void setListHeightByItems(int numItems)
Sets the list's height by items count.

Parameters:
numItems - the new height by items unit

getListHeightByItems

public int getListHeightByItems()
Gets the list's height by items count.

Returns:
the height by items count.

setMaxListHeightByItems

public void setMaxListHeightByItems(int maxHeight)
Sets the maximum list's height by items.
If the list contains less items, it is sized appropriately.

Parameters:
maxHeight -

getMaxListHeightByItems

public int getMaxListHeightByItems()
Gets the maximum list's height by items.

Returns:
the maximum list's height by items.

blocksFocusMoveDeviceComponent

protected boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
Checks, if this Widget blocks the given DeviceComponent for focus-moves.

Overrides:
blocksFocusMoveDeviceComponent in class Widget
Returns:
Widget blocks the queried DeviceComponent?

setText

public void setText(java.lang.String text)
Sets the new text to be displayed

Specified by:
setText in interface TextWidget
Parameters:
text - the new Text

getText

public java.lang.String getText()

Specified by:
getText in interface TextWidget
Returns:
the text that is displayed

getFont

public HUDFont getFont()

Specified by:
getFont in interface TextWidget
Returns:
the used Font

setFont

public void setFont(HUDFont font)
Sets the new Font to be used

Specified by:
setFont in interface TextWidget
Parameters:
font - the new Font

setFontColor

public void setFontColor(org.openmali.vecmath2.Colorf color)
Sets the new color to be used

Specified by:
setFontColor in interface TextWidget
Parameters:
color - the new color

getFontColor

public org.openmali.vecmath2.Colorf getFontColor()

Specified by:
getFontColor in interface TextWidget
Returns:
the used color

setEnabled

public final void setEnabled(boolean enabled)

Specified by:
setEnabled in interface org.jagatoo.datatypes.Enableable

isEnabled

public final boolean isEnabled()

Specified by:
isEnabled in interface org.jagatoo.datatypes.Enableable

onSizeChanged

protected void onSizeChanged(float oldWidth,
                             float oldHeight,
                             float newWidth,
                             float newHeight)

Overrides:
onSizeChanged in class Widget

getPickHeight

protected float getPickHeight()
Overrides:
getPickHeight in class Widget
Returns:
the height on which to pick. By default this is exactly getHeight().

popUp

public void popUp(boolean p)
Pops up the popupable Widget (or un-pops it)

Specified by:
popUp in interface PopUpable
Parameters:
p - if true, the pop-up will be visible

isPoppedUp

public boolean isPoppedUp()

Specified by:
isPoppedUp in interface PopUpable
Returns:
whether the pop-up is currently visible

onFocusLost

public void onFocusLost()
This event is fired, when the focus is lost by a Widget.

Overrides:
onFocusLost in class Widget

onMouseExited

public void onMouseExited(boolean isTopMost,
                          boolean hasFocus)
This method is called when the mouse exited the Widget area.

Overrides:
onMouseExited in class Widget
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onAttachedToHUD

public void onAttachedToHUD(HUD hud)
This event is fired, when this Widget is added to the HUD live Widget hierarchy.

Overrides:
onAttachedToHUD in class AbstractList
Parameters:
hud - the HUD, the Widget is added to

drawWidget

protected void drawWidget(Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height,
                          boolean drawsSelf)

Specified by:
drawWidget in class Widget

init

protected void init()
This method is called when the WidgetContainer is set.

Specified by:
init in class Widget

newTextCombo

public static final ComboBox newTextCombo(boolean isHeavyWeight,
                                          float width,
                                          float height,
                                          ComboBox.Description desc)
Creates a new ComboBox with a TextListModel.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
desc -

newTextCombo

public static final ComboBox newTextCombo(boolean isHeavyWeight,
                                          float width,
                                          float height)
Creates a new ComboBox with a TextListModel.

Parameters:
isHeavyWeight -
width - the new width
height - the new height

newTextCombo

public static final ComboBox newTextCombo(float width,
                                          float height,
                                          ComboBox.Description desc)
Creates a new ComboBox with a TextListModel.

Parameters:
width - the new width
model - the ListModel (null for auto-generation)
height - the new height
desc -

newTextCombo

public static final ComboBox newTextCombo(float width,
                                          float height)
Creates a new ComboBox with a TextListModel.

Parameters:
width - the new width
height - the new height
model - the ListModel (null for auto-generation)