|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Item
javax.microedition.lcdui.CustomItem
de.enough.polish.ui.FakeCustomItem
de.enough.polish.ui.FakeContainerCustomItem
public class FakeContainerCustomItem
Contains a number of items.
Main purpose is to manage all items of a Form or similiar canvases.
Containers support following additional CSS attributes:
columns: 2;
columns-width: 15,5;
Copyright Enough Software 2004 - 2007 - 2008
history
01-Mar-2004 - rob creation
| Field Summary | |
|---|---|
boolean |
allowCycling
specifies whether this container is allowed to cycle to the beginning when the last item has been reached |
protected boolean |
autoFocusEnabled
|
protected int |
autoFocusIndex
|
protected int |
availableHeight
The height available for scrolling, ignore when set to -1 |
protected ContainerView |
containerView
|
protected boolean |
enableScrolling
|
int |
focusedIndex
the index of the currently focused item - please use only for reading, not for setting, unless you know what you are doing |
protected Item |
focusedItem
|
protected Style |
focusedStyleFirst
|
protected Style |
focusedStyleLast
|
protected boolean |
isExpandItems
|
protected ArrayList |
itemsList
|
protected Style |
itemStyle
|
protected int |
lastPointerPressY
vertical pointer position when it was pressed the last time |
protected Style |
plainStyle
|
static int |
SCROLL_DEFAULT
constant for normal scrolling (0) |
static int |
SCROLL_SMOOTH
constant for smooth scrolling (1) |
protected boolean |
scrollSmooth
|
protected int |
targetYOffset
|
protected int |
yOffset
|
| Fields inherited from class javax.microedition.lcdui.CustomItem |
|---|
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL |
| Constructor Summary | |
|---|---|
FakeContainerCustomItem(boolean focusFirstElement)
Creates a new empty container. |
|
FakeContainerCustomItem(boolean focusFirstElement,
Style style)
Creates a new empty container. |
|
FakeContainerCustomItem(java.lang.String label,
boolean focusFirstElement,
Style style,
int height)
Creates a new empty container. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Item item)
Inserts the given item at the defined position. |
void |
add(int index,
javax.microedition.lcdui.Item item)
|
void |
add(Item item)
Adds an item to this container. |
void |
add(javax.microedition.lcdui.Item item)
|
void |
add(Item item,
Style itemAddStyle)
Adds an item to this container. |
void |
add(java.lang.String text)
Adds an StringItem with the given text to this container. |
void |
add(java.lang.String text,
Style textAddStyle)
Adds an StringItem with the given text to this container. |
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this item. |
void |
changeChildStyles(java.lang.String oldChildStyleName,
java.lang.String newChildStyleName)
Changes the style of all children that are currently using the specified oldChildStyle with the given newChildStyle. |
void |
changeChildStyles(Style oldChildStyle,
Style newChildStyle)
Changes the style of all children that are currently using the specified oldChildStyle with the given newChildStyle. |
void |
clear()
Removes all items from this container. |
protected java.lang.String |
createCssSelector()
Retrieves the CSS selector for this item. |
void |
defocus(Style originalStyle)
Removes the focus from this item. |
boolean |
focus(int index)
Focuses the specified item. |
void |
focus(int index,
Item item,
int direction)
Sets the focus to the given item. |
protected Style |
focus(Style focusStyle,
int direction)
Focuses this item. |
boolean |
focusClosestItem(int index)
Focuses the next focussable item starting at the specified index +/- 1. |
protected boolean |
focusClosestItem(int index,
Item[] myItems)
Focuses the next focussable item starting at the specified index +/- 1. |
boolean |
focusClosestItemAbove(int index)
Focuses the next focussable item starting at the specified index + 1. |
Item |
get(int index)
Returns the item at the specified position of this container. |
int |
getFocusedIndex()
Retrieves the index of the item which is currently focused. |
Item |
getFocusedItem()
Retrieves the currently focused item. |
protected Style |
getFocusedStyle(int index,
Item item)
Retrieves the best matching focus style for the given item |
Item |
getItemAt(int relX,
int relY)
Determines if this item or one of it's children is within the specified point. |
Item[] |
getItems()
Retrieves all items which this container holds. |
int |
getNumberOfInteractiveItems()
Calculates the number of interactive items included in this container. |
int |
getPosition(Item item)
Retrieves the position of the specified item. |
int |
getRelativeScrollHeight()
Returns the available height for scrolling eiter from this container or from it's parent container. |
int |
getRelativeScrollYOffset()
Retrieves the vertical scrolling offset of this item relative to the top most container. |
int |
getScrollHeight()
Returns the available height for scrolling eiter from this container or from it's parent container. |
int |
getScrollYOffset()
Retrieves the vertical scrolling offset of this item. |
protected boolean |
handleCommand(javax.microedition.lcdui.Command cmd)
Tries to handle the specified command. |
protected boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the key-pressed event. |
protected boolean |
handleKeyReleased(int keyCode,
int gameAction)
Handles the key-released event. |
protected boolean |
handleKeyRepeated(int keyCode,
int gameAction)
Handles the key-repeated event. |
protected boolean |
handleNavigate(int keyCode,
int gameAction)
Handles a keyPressed or keyRepeated event for navigating in the container. |
protected boolean |
handlePointerPressed(int relX,
int relY)
Handles the event when a pointer has been pressed at the specified position. |
protected boolean |
handlePointerReleased(int relX,
int relY)
Handles the event when a pointer has been released at the specified position. |
protected boolean |
handlePointerScrollReleased(int relX,
int relY)
Allows subclasses to check if a pointer release event is used for scrolling the container. |
protected void |
hideNotify()
Called by the system to notify the item that it is now completely invisible, when it previously had been at least partially visible. |
int |
indexOf(Item item)
Retrieves the index of the specified item. |
protected void |
initContent(int firstLineWidth,
int lineWidth)
Initialises this item. |
protected void |
paintBackgroundAndBorder(int x,
int y,
int width,
int height,
javax.microedition.lcdui.Graphics g)
Paints the background and border of this item. |
protected void |
paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
Paints the content of this item. |
java.lang.String |
parseIndexUrl(java.lang.String url,
Item item)
Parses the given URL and includes the index of the item, when there is an "%INDEX%" within the given url. |
void |
releaseResources()
Releases all (memory intensive) resources such as images or RGB arrays of this background. |
Item |
remove(int index)
Removes the item at the specified position of this container. |
boolean |
remove(Item item)
Removes the given item. |
void |
requestDefocus(Item item)
Moves the focus away from the specified item. |
void |
requestFullInit()
Requests the initialization of this container and all of its children items. |
protected boolean |
scroll(int direction,
int x,
int y,
int width,
int height)
Adjusts the yOffset or the targetYOffset so that the given relative values are inside of the visible area. |
boolean |
scroll(int direction,
Item item)
Scrolls this container so that the (internal) area of the given item is best seen. |
Item |
set(int index,
Item item)
Replaces the item at the specified position in this list with the given item. |
Item |
set(int index,
Item item,
Style itemStyle)
Replaces the item at the specified position in this list with the given item. |
void |
setItemsList(ArrayList itemsList)
Sets a list of items for this container. |
void |
setScrollHeight(int height)
Sets the height available for scrolling of this item. |
void |
setScrollYOffset(int offset)
Sets the vertical scrolling offset of this item. |
void |
setScrollYOffset(int offset,
boolean smooth)
Sets the vertical scrolling offset of this item. |
void |
setStyle(Style style)
Sets the style of this item. |
void |
setStyle(Style style,
boolean ignoreBackground)
Sets the style of this container. |
void |
showCommands()
Shows the commands on the screen. |
protected void |
showNotify()
Called by the system to notify the item that it is now at least partially visible, when it previously had been completely invisible. |
int |
size()
Retrieves the number of items stored in this container. |
java.lang.String |
toString()
Generates a String representation of this item. |
| Methods inherited from class javax.microedition.lcdui.CustomItem |
|---|
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SCROLL_DEFAULT
public static final int SCROLL_SMOOTH
protected ArrayList itemsList
protected boolean autoFocusEnabled
protected int autoFocusIndex
protected Style itemStyle
protected Item focusedItem
public int focusedIndex
protected boolean enableScrolling
public boolean allowCycling
protected int yOffset
protected int targetYOffset
protected ContainerView containerView
protected boolean scrollSmooth
protected boolean isExpandItems
protected int lastPointerPressY
protected Style focusedStyleFirst
protected Style focusedStyleLast
protected int availableHeight
protected Style plainStyle
| Constructor Detail |
|---|
public FakeContainerCustomItem(boolean focusFirstElement)
focusFirstElement - true when the first focussable element should be focused automatically.
public FakeContainerCustomItem(boolean focusFirstElement,
Style style)
focusFirstElement - true when the first focussable element should be focused automatically.style - the style for this container
public FakeContainerCustomItem(java.lang.String label,
boolean focusFirstElement,
Style style,
int height)
label - the label of this containerfocusFirstElement - true when the first focussable element should be focused automatically.style - the style for this containerheight - the vertical space available for this container, set to -1 when scrolling should not be activatedsetScrollHeight( int )| Method Detail |
|---|
public void setScrollHeight(int height)
height - available height for this item including label, padding, margin and border, -1 when scrolling should not be done.public int getScrollHeight()
getContentScrollHeight()public int getRelativeScrollHeight()
getContentScrollHeight()public void add(java.lang.String text)
text - the text
java.lang.IllegalArgumentException - when the given item is null
public void add(java.lang.String text,
Style textAddStyle)
text - the texttextAddStyle - the style for the text
java.lang.IllegalArgumentException - when the given item is nullpublic void add(Item item)
item - the item which should be added.
java.lang.IllegalArgumentException - when the given item is null
public void add(Item item,
Style itemAddStyle)
item - the item which should be added.itemAddStyle - the style for the item
java.lang.IllegalArgumentException - when the given item is null
public void add(int index,
Item item)
index - the position at which the element should be inserted,
use 0 when the element should be inserted in the front of this list.item - the item which should be inserted
java.lang.IllegalArgumentException - when the given item is null
java.lang.IndexOutOfBoundsException - when the index < 0 || index >= size()public void add(javax.microedition.lcdui.Item item)
public void add(int index,
javax.microedition.lcdui.Item item)
public Item set(int index,
Item item)
index - the position of the element, the first element has the index 0.item - the item which should be set
java.lang.IndexOutOfBoundsException - when the index < 0 || index >= size()
public Item set(int index,
Item item,
Style itemStyle)
index - the position of the element, the first element has the index 0.item - the item which should be setitemStyle - the new style for the item
java.lang.IndexOutOfBoundsException - when the index < 0 || index >= size()public Item get(int index)
index - the position of the desired item.
java.lang.IndexOutOfBoundsException - when the index < 0 || index >= size()public Item remove(int index)
index - the position of the desired item.
java.lang.IndexOutOfBoundsException - when the index < 0 || index >= size()public boolean focusClosestItemAbove(int index)
index - the index of the item that should be used as a starting point for the search of a new possible focussable item
public boolean focusClosestItem(int index)
index - the index of the item that should be used as a starting point for the search of a new possible focussable item
protected boolean focusClosestItem(int index,
Item[] myItems)
index - the index of the item that should be used as a starting point for the search of a new possible focussable itemmyItems - the items that should be used for the search
public boolean remove(Item item)
item - the item which should be removed.
java.lang.IllegalArgumentException - when the given item is nullpublic void clear()
public int size()
public Item[] getItems()
public boolean focus(int index)
index - the index of the item. The first item has the index 0,
when -1 is given, the focus will be removed altogether
public void focus(int index,
Item item,
int direction)
index - the positionitem - the item which should be focuseddirection - the direction, either Canvas.DOWN, Canvas.RIGHT, Canvas.UP, Canvas.LEFT or 0.
protected Style getFocusedStyle(int index,
Item item)
index - the index of the itemitem - the item
public boolean scroll(int direction,
Item item)
direction - the direction, is used for adjusting the scrolling when the internal area is to large. Either 0 or Canvas.UP, Canvas.DOWN, Canvas.LEFT or Canvas.RIGHTitem - the item for which the scrolling should be adjusted
protected boolean scroll(int direction,
int x,
int y,
int width,
int height)
direction - the direction, is used for adjusting the scrolling when the internal area is to large. Either 0 or Canvas.UP, Canvas.DOWN, Canvas.LEFT or Canvas.RIGHTx - the horizontal position of the area relative to this content's left edge, is ignored in the current versiony - the vertical position of the area relative to this content's top edgewidth - the width of the areaheight - the height of the area
protected void initContent(int firstLineWidth,
int lineWidth)
FakeCustomItem
initContent in class FakeCustomItemfirstLineWidth - the maximum width of the first linelineWidth - the maximum width of any following linesFakeCustomItem.contentWidth,
FakeCustomItem.contentHeight,
FakeCustomItem.preferredWidth,
FakeCustomItem.preferredHeight
protected void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
FakeCustomItem
paintContent in class FakeCustomItemx - the left start positiony - the upper start positionleftBorder - the left border, nothing must be painted left of this positionrightBorder - the right border, nothing must be painted right of this positiong - the Graphics on which this item should be painted.
protected void paintBackgroundAndBorder(int x,
int y,
int width,
int height,
javax.microedition.lcdui.Graphics g)
FakeCustomItem
paintBackgroundAndBorder in class FakeCustomItemx - the horizontal start positiony - the vertical start positionwidth - the widthheight - the heightg - graphics contextFakeCustomItem.paintBackground(int, int, int, int, Graphics),
FakeCustomItem.paintBorder(int, int, int, int, Graphics)protected java.lang.String createCssSelector()
FakeCustomItem
createCssSelector in class FakeCustomItem
protected boolean handleKeyPressed(int keyCode,
int gameAction)
FakeCustomItem
handleKeyPressed in class FakeCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
protected boolean handleNavigate(int keyCode,
int gameAction)
keyCode - the code of the keypress/keyrepeat eventgameAction - the associated game action
protected boolean handleKeyReleased(int keyCode,
int gameAction)
FakeCustomItem
handleKeyReleased in class FakeCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
FakeCustomItem.handleKeyPressed(int, int)
protected boolean handleKeyRepeated(int keyCode,
int gameAction)
FakeCustomItem
handleKeyRepeated in class FakeCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
FakeCustomItem.handleKeyPressed(int, int)public int getFocusedIndex()
public Item getFocusedItem()
public void setStyle(Style style)
FakeCustomItem
setStyle in class FakeCustomItemstyle - the new style for this item.
public void setStyle(Style style,
boolean ignoreBackground)
style - the styleignoreBackground - when true is given, the background and border-settings
will be ignored.
public void changeChildStyles(java.lang.String oldChildStyleName,
java.lang.String newChildStyleName)
oldChildStyleName - the name of the style of child items that should be exchangednewChildStyleName - the name of the new style for child items that were using the specified oldChildStyle before
java.lang.IllegalArgumentException - if no corresponding newChildStyle could be foundStyleSheet.getStyle(String)
public void changeChildStyles(Style oldChildStyle,
Style newChildStyle)
oldChildStyle - the style of child items that should be exchangednewChildStyle - the new style for child items that were using the specified oldChildStyle before
java.lang.IllegalArgumentException - if newChildStyle is null
public java.lang.String parseIndexUrl(java.lang.String url,
Item item)
url - the resource URL which might include the substring "%INDEX%"item - the item to which the URL belongs to. The item must be
included in this container.
java.lang.NullPointerException - when the given url or item is nullpublic int getPosition(Item item)
item - the item
protected Style focus(Style focusStyle,
int direction)
FakeCustomItem
focus in class FakeCustomItemfocusStyle - the style which is used to indicate the focused statedirection - the direction from which this item is focused,
either Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.RIGHT or 0.
When 0 is given, the direction is unknown.
public void defocus(Style originalStyle)
FakeCustomItem
defocus in class FakeCustomItemoriginalStyle - the original style which will be restored.public void showCommands()
FakeCustomItem
showCommands in class FakeCustomItemprotected boolean handleCommand(javax.microedition.lcdui.Command cmd)
FakeCustomItem
handleCommand in class FakeCustomItemcmd - the command
public void animate(long currentTime,
ClippingRegion repaintRegion)
FakeCustomItem
animate in class FakeCustomItemcurrentTime - the current time in millisecondsrepaintRegion - the repaint area that needs to be updated when this item is animated#addRelativeRegion(ClippingRegion, int, int, int, int)protected void showNotify()
paint() calls after
showNotify() has been called.
The container implementation calls showNotify() on the embedded items.
showNotify in class FakeCustomItemprotected void hideNotify()
paint() calls will be made on this item
until after a showNotify() has been called again.
The container implementation calls hideNotify() on the embedded items.
hideNotify in class FakeCustomItem
protected boolean handlePointerPressed(int relX,
int relY)
FakeCustomItem
handlePointerPressed in class FakeCustomItemrelX - the x position of the pointer pressing relative to this item's left positionrelY - the y position of the pointer pressing relative to this item's top position
this method is used for determining whether the event belongs to this item,
for a helper method for determining whether the event took place into the actual content area,
FakeCustomItem.handleKeyPressed(int, int),
for calculating the horizontal position relative to the content (relX - contentX),
for calculating the vertical position relative to the content (relY - contentY)
protected boolean handlePointerScrollReleased(int relX,
int relY)
relX - the x position of the pointer pressing relative to this item's left positionrelY - the y position of the pointer pressing relative to this item's top position
protected boolean handlePointerReleased(int relX,
int relY)
FakeCustomItem
handlePointerReleased in class FakeCustomItemrelX - the x position of the pointer pressing relative to this item's left positionrelY - the y position of the pointer pressing relative to this item's top position
this method is used for determining whether the event belongs to this item,
for a helper method for determining whether the event took place into the actual content area,
FakeCustomItem.handleKeyPressed(int, int),
for calculating the horizontal position relative to the content (relX - contentX),
for calculating the vertical position relative to the content (relY - contentY)
public Item getItemAt(int relX,
int relY)
FakeCustomItem
getItemAt in class FakeCustomItemrelX - the x position of the point relative to this item's left positionrelY - the y position of the point relative to this item's top position
public void requestDefocus(Item item)
item - the item that currently has the focuspublic void requestFullInit()
public int getScrollYOffset()
public int getRelativeScrollYOffset()
public void setScrollYOffset(int offset)
offset - either the new offset
public void setScrollYOffset(int offset,
boolean smooth)
offset - either the new offsetsmooth - scroll to this new offset smooth if allowedpublic int indexOf(Item item)
item - the item
public java.lang.String toString()
toString in class FakeCustomItempublic void setItemsList(ArrayList itemsList)
itemsList - the list of items to setpublic int getNumberOfInteractiveItems()
public void releaseResources()
releaseResources in class FakeCustomItem
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||