|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.ui.ItemView
de.enough.polish.ui.ContainerView
public class ContainerView
Is responsible for visual representation and interpretation of user-input.
Copyright Enough Software 2004 - 2010
| Field Summary | |
|---|---|
protected boolean |
allowCycling
|
protected boolean |
allowsAutoTraversal
indicates whether the parent Container is allowed to change the currently focused item when the user traverses around a form and enters the container from different sides |
protected boolean |
allowsDirectSelectionByPointerEvent
indicates whether elements in this container view can be selected directly by pointer events |
protected int |
appearanceMode
|
protected int |
columnsSetting
|
protected Dimension[] |
columnsWidths
|
protected static int |
EQUAL_WIDTH_COLUMNS
|
protected int |
focusedIndex
|
protected Item |
focusedItem
|
protected boolean |
focusFirstElement
|
protected boolean |
isAlignHeights
|
protected boolean |
isExpandItems
|
protected boolean |
isHorizontal
|
protected boolean |
isPointerPressedHandled
|
protected boolean |
isSequentialTraversal
|
protected boolean |
isVertical
|
protected int |
leftXOffset
|
protected static int |
NO_COLUMNS
|
protected static int |
NORMAL_WIDTH_COLUMNS
|
protected int |
numberOfColumns
|
protected int |
numberOfRows
|
protected Container |
parentContainer
this field is set automatically, so that subclasses can use it for referencing the parent-container |
protected boolean |
restartAnimation
determines whether any animation of this view should be (re) started at the next possibility. |
protected int |
rightXOffset
|
protected int[] |
rowsHeights
|
protected boolean |
scrollContinuous
|
protected static int |
STATIC_WIDTH_COLUMNS
|
protected int |
targetXOffset
|
protected int |
topYOffset
|
protected int |
xOffset
|
protected int |
yOffset
|
| Fields inherited from class de.enough.polish.ui.ItemView |
|---|
availableHeight, availableWidth, contentHeight, contentWidth, isFocused, isLayoutCenter, isLayoutRight, layout, paddingHorizontal, paddingVertical, parentItem |
| Constructor Summary | |
|---|---|
protected |
ContainerView()
Creates a new view |
| Method Summary | |
|---|---|
protected void |
addFullRepaintRegion(Item item,
ClippingRegion repaintRegion)
Adds the complete item's dimensions to the repaint region. |
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this item. |
void |
destroy()
Destroys the containerview by removing references to the parent item |
protected void |
focusItem(int index,
Item item)
Focuses the item with the given index. |
protected void |
focusItem(int index,
Item item,
int direction)
Focuses the item with the given index. |
Style |
focusItem(int index,
Item item,
int direction,
Style focusedStyle)
Focuses the given item and retrieves the previous style of that item. |
int |
getAppearanceMode()
Returns the appearance mode for this view |
Item |
getChildAt(int relX,
int relY)
Retrieves the child of this container view at the corresponding position. |
protected int |
getChildHeight(Item item)
Queries the height of an child item of this container. |
protected int |
getChildWidth(Item item)
Queries the width of an child item of this container. |
int |
getContentHeight()
Returns the content height |
int |
getContentWidth()
Returns the content width |
protected int |
getItemRelativeY(Item item)
|
protected Item |
getNextFocusableItem(Item[] items,
boolean forward,
int steps,
boolean allowCircle)
Retrieves the next focusable item. |
protected Item |
getNextItem(int keyCode,
int gameAction)
Interprets the given user-input and retrieves the next item which should be focused. |
protected int |
getParentRelativeY()
|
protected Screen |
getScreen()
Retrieves the screen to which this view belongs to. |
int |
getScrollTargetXOffset()
Retrieves the target horizontal scroll offset |
int |
getScrollXOffset()
Retrieves the current horizontal scroll offset |
boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the given keyPressed event when the currently focused item was not able to handle it. |
boolean |
handlePointerDragged(int x,
int y,
ClippingRegion repaintRegion)
Handles the event when a pointer has been dragged to the specified position. |
boolean |
handlePointerPressed(int x,
int y)
Handles pointer pressed events. |
boolean |
handlePointerReleased(int x,
int y)
Handles the event when a pointer has been released at the specified position. |
boolean |
handlePointerTouchDown(int x,
int y)
Handles a touch down/press event. |
boolean |
handlePointerTouchUp(int x,
int y)
Handles a touch up/release event. |
protected void |
initContent(Item parentContainerItem,
int firstLineWidth,
int availWidth,
int availHeight)
Initializes this container view. |
protected void |
initMargin(Style style,
int availWidth)
Initializes the margin of the parent item Subclasses can override this (e.g. |
protected void |
initPadding(Style style,
int availWidth)
Initializes the padding of the parent item Subclasses can override this (e.g. |
protected boolean |
isInBottomRow(int index)
Detects if the specified item index is within the last row of this view. |
protected boolean |
isLayoutExpand()
Determines whether this view should be expanded horizontally |
protected boolean |
isValid(Item parent,
Style style)
Implementation that are valid only for specific item classes can override this method so that they cannot be accidently attached to unsupported classes. |
boolean |
isVerticalLayout()
Checks if this ContainerView arranges its child items vertically. |
protected boolean |
isVirtualContainer()
Checks if this view is a virtual container. |
protected void |
paintContent(Container container,
Item[] myItems,
int x,
int y,
int leftBorder,
int rightBorder,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
Graphics g)
Paints the content of this container view. |
protected void |
paintContent(Item parent,
int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
Paints the content of this container view. |
protected void |
paintItem(Item item,
int index,
int x,
int y,
int leftBorder,
int rightBorder,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
Graphics g)
Paints this item at the specified position. |
void |
releaseResources()
Releases all resources that are not required to keep the state of this view. |
protected void |
scroll(int direction,
int x,
int y,
int width,
int height,
boolean force)
Adjusts the yOffset or the targetYOffset so that the given relative values are inside of the visible area. |
void |
setAppearanceMode(int appearanceMode)
Sets the appearance mode for this view |
void |
setScrollXOffset(int offset)
Sets the horizontal scrolling offset of this item. |
void |
setScrollXOffset(int offset,
boolean smooth)
Sets the horizontal scrolling offset of this item. |
protected void |
setStyle(Style style)
Sets the style for this view. |
protected Item |
shiftFocus(boolean forwardFocus,
int steps,
Item[] items)
Shifts the focus to the next or the previous item. |
protected Item |
shiftFocus(boolean forwardFocus,
int steps,
Item[] items,
boolean allowCycle)
Shifts the focus to the next or the previous item. |
protected Item |
shiftFocus(boolean forwardFocus,
int steps,
Item[] items,
boolean allowCycle,
int direction)
Shifts the focus to the next or the previous item. |
void |
showNotify()
Notifies this view that it is about to be shown (again). |
void |
startScroll(int direction,
int speed,
int damping)
Starts to scroll in the specified direction |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int NO_COLUMNS
protected static final int EQUAL_WIDTH_COLUMNS
protected static final int NORMAL_WIDTH_COLUMNS
protected static final int STATIC_WIDTH_COLUMNS
protected int xOffset
protected int targetXOffset
protected int yOffset
protected int focusedIndex
protected transient Container parentContainer
protected boolean restartAnimation
protected boolean focusFirstElement
protected int appearanceMode
protected transient Item focusedItem
protected int columnsSetting
protected int numberOfColumns
protected Dimension[] columnsWidths
protected int[] rowsHeights
protected int numberOfRows
protected boolean allowCycling
protected int leftXOffset
protected int rightXOffset
protected int topYOffset
protected boolean isSequentialTraversal
protected boolean isExpandItems
protected boolean isAlignHeights
protected boolean allowsAutoTraversal
protected boolean isHorizontal
protected boolean isVertical
protected boolean allowsDirectSelectionByPointerEvent
protected boolean isPointerPressedHandled
protected boolean scrollContinuous
| Constructor Detail |
|---|
protected ContainerView()
| Method Detail |
|---|
public void animate(long currentTime,
ClippingRegion repaintRegion)
ItemView
animate in class ItemViewcurrentTime - the current time in millisecondsrepaintRegion - the repaint area that needs to be updated when this item is animatedItem.getAbsoluteX(),
Item.getAbsoluteY()public void setScrollXOffset(int offset)
offset - either the new offset
public void setScrollXOffset(int offset,
boolean smooth)
offset - either the new offsetsmooth - scroll to this new offset smooth if allowedgetScrollXOffset()public int getScrollXOffset()
public int getScrollTargetXOffset()
protected void addFullRepaintRegion(Item item,
ClippingRegion repaintRegion)
ItemView
addFullRepaintRegion in class ItemViewitem - the itemrepaintRegion - the region to which the item's positions are added
protected void initMargin(Style style,
int availWidth)
ItemView
initMargin in class ItemViewstyle - the styleavailWidth - the available width
protected void initPadding(Style style,
int availWidth)
ItemView
initPadding in class ItemViewstyle - the styleavailWidth - the available width
protected void initContent(Item parentContainerItem,
int firstLineWidth,
int availWidth,
int availHeight)
initContent in class ItemViewfirstLineWidth - the maximum width of the first lineavailWidth - the maximum width of any following linesparentContainerItem - the Container which uses this view, use parent.getItems() for retrieving all items.availHeight - the maximum height of the viewItemView.contentWidth,
ItemView.contentHeightpublic int getContentWidth()
public int getContentHeight()
protected boolean isLayoutExpand()
ItemView.layout,
Item.LAYOUT_EXPAND
protected void paintContent(Item parent,
int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
paintContent in class ItemViewparent - the parent itemx - 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.paintContent(Container, Item[], int, int, int, int, int, int, int, int, Graphics)
protected void paintContent(Container container,
Item[] myItems,
int x,
int y,
int leftBorder,
int rightBorder,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
Graphics g)
container - the parent containermyItems - the items that should be paintedx - 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 positionclipX - absolute horizontal clipping startclipY - absolute verical clipping startclipWidth - clipping widthclipHeight - clipping heightg - the Graphics on which this item should be painted.
protected void paintItem(Item item,
int index,
int x,
int y,
int leftBorder,
int rightBorder,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
Graphics g)
item - the item that needs to be paintedindex - the index of the itemx - the horizontal position of the itemy - the vertical position of the itemleftBorder - the left borderrightBorder - the right borderclipX - absolute horizontal clipping startclipY - absolute verical clipping startclipWidth - clipping widthclipHeight - clipping heightg - the graphics context
protected Item getNextItem(int keyCode,
int gameAction)
keyCode - the code of the keyPressed-eventsgameAction - the associated game-action to the given keyCode
protected Item shiftFocus(boolean forwardFocus,
int steps,
Item[] items)
forwardFocus - true when the next item should be focused, false when
the previous item should be focused.steps - how many steps forward or backward the search for the next focusable item should be started,
0 for the current item, negative values go backwards.items - the items of this view
protected Item shiftFocus(boolean forwardFocus,
int steps,
Item[] items,
boolean allowCycle)
forwardFocus - true when the next item should be focused, false when
the previous item should be focused.steps - how many steps forward or backward the search for the next focusable item should be started,
0 for the current item, negative values go backwards.items - the items of this viewallowCycle - true when cycling should be allowed (starting at the first item when the last has been reached and the other way round)
protected Item shiftFocus(boolean forwardFocus,
int steps,
Item[] items,
boolean allowCycle,
int direction)
forwardFocus - true when the next item should be focused, false when
the previous item should be focused.steps - how many steps forward or backward the search for the next focusable item should be started,
0 for the current item, negative values go backwards.items - the items of this viewallowCycle - true when cycling should be allowed (starting at the first item when the last has been reached and the other way round)direction - the original direction that should be gone, e.g. Canvas.UP or Canvas.LEFT
protected boolean isInBottomRow(int index)
index - the item's index
protected void focusItem(int index,
Item item)
index - the index of the itemitem - the item which should be focusedfocusItem(int, Item, int)
protected void focusItem(int index,
Item item,
int direction)
index - the index of the itemitem - the item which should be focuseddirection - the direction, either Canvas.DOWN, Canvas.RIGHT, Canvas.UP, Canvas.LEFT or 0.protected void setStyle(Style style)
setStyle in class ItemViewstyle - the style
protected Item getNextFocusableItem(Item[] items,
boolean forward,
int steps,
boolean allowCircle)
items - the available itemsforward - true when a following item should be looked for,
false if a previous item should be looked for.steps - the number of steps which should be used (e.g. 2 in a table with two columns)allowCircle - true when either the first focusable or the last focusable element
should be returned when there is no focusable item in the given direction.
focusItem(int, Item)public void showNotify()
showNotify in class ItemViewprotected Screen getScreen()
getScreen in class ItemView
public boolean handleKeyPressed(int keyCode,
int gameAction)
handleKeyPressed in class ItemViewkeyCode - the key codegameAction - the game action like Canvas.UP etc
public boolean handlePointerPressed(int x,
int y)
ItemView//#if polish.hasPointerEvents
handlePointerPressed in class ItemViewx - the x position of the event relative to the item's horizontal left edgey - the y position of the event relative to the item's vertical top edge
public boolean handlePointerTouchDown(int x,
int y)
ItemView
handlePointerTouchDown in class ItemViewx - the horizontal pixel position of the touch event relative to the parent item's left positiony - the vertical pixel position of the touch event relative to the parent item's top position
public boolean handlePointerDragged(int x,
int y,
ClippingRegion repaintRegion)
ItemView//#if polish.hasPointerEvents
handlePointerDragged in class ItemViewx - the x position of the event relative to the item's horizontal left edgey - the y position of the event relative to the item's vertical top edgerepaintRegion - the repaint region into which the repaint area is marked when the event is handled
ItemView.handlePointerDragged(int, int),
Item.addRepaintArea(ClippingRegion)
public boolean handlePointerReleased(int x,
int y)
ItemView//#if polish.hasPointerEvents
handlePointerReleased in class ItemViewx - the x position of the event relative to the item's horizontal left edgey - the y position of the event relative to the item's vertical top edge
public boolean handlePointerTouchUp(int x,
int y)
ItemView
handlePointerTouchUp in class ItemViewx - the horizontal pixel position of the touch event relative to the parent item's left positiony - the vertical pixel position of the touch event relative to the parent item's top position
protected void scroll(int direction,
int x,
int y,
int width,
int height,
boolean force)
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 areaprotected int getParentRelativeY()
protected int getItemRelativeY(Item item)
protected boolean isValid(Item parent,
Style style)
ItemView
isValid in class ItemViewparent - the parent itemstyle - the style
public Style focusItem(int index,
Item item,
int direction,
Style focusedStyle)
index - the index of the itemitem - the item which should be focuseddirection - the direction, either Canvas.DOWN, Canvas.RIGHT, Canvas.UP, Canvas.LEFT or 0.focusedStyle - the new style for the focused item
public void releaseResources()
ItemView
releaseResources in class ItemViewpublic void destroy()
ItemView
destroy in class ItemViewprotected boolean isVirtualContainer()
public void startScroll(int direction,
int speed,
int damping)
direction - either Canvas.UP or Canvas.DOWNspeed - the speed in pixels per seconddamping - the damping in percent; 0 means no damping at all; 100 means the scrolling will be stopped immediatelypublic void setAppearanceMode(int appearanceMode)
appearanceMode - the appearance modepublic int getAppearanceMode()
public Item getChildAt(int relX,
int relY)
relX - the relative horizontal positionrelY - the relatiev vertical position
protected int getChildWidth(Item item)
item - the child item
getChildHeight(Item)protected int getChildHeight(Item item)
item - the child item
getChildHeight(Item)public boolean isVerticalLayout()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||