|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.ui.ItemView
public abstract class ItemView
An item view can take over the rendering of an item.
Copyright Enough Software 2006 - 2009
history
Nov 27, 2006 - rob creation
| Field Summary | |
|---|---|
protected int |
availableHeight
|
protected int |
availableWidth
|
protected int |
contentHeight
|
protected int |
contentWidth
|
protected boolean |
isFocused
|
protected boolean |
isLayoutCenter
|
protected boolean |
isLayoutRight
|
protected int |
layout
|
protected int |
paddingHorizontal
|
protected int |
paddingVertical
|
protected Item |
parentItem
|
| Constructor Summary | |
|---|---|
ItemView()
|
|
| Method Summary | |
|---|---|
protected void |
addFullRepaintRegion(Item item,
ClippingRegion repaintRegion)
Adds the complete item's dimensions to the repaint region. |
protected void |
addItemBackground(Item item,
Background background)
Adds a background to an item again |
protected void |
addItemBackgroundBorder(Item item,
Background background,
Border border)
Adds a background and a border to an item again |
protected void |
addItemBorder(Item item,
Border border)
Adds a border to an item again |
protected Point |
adjustToContentArea(int x,
int y)
Adjusts the given position to the content area of this view |
boolean |
animate()
Animates this view - please use animate(long, ClippingRegion) instead, if possible |
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this item. |
protected void |
defocus(Style originalStyle)
Notifies this view that the parent container is not focused anymore. |
void |
destroy()
Destroys the containerview by removing references to the parent item |
void |
focus(Style focusstyle,
int direction)
Sets the focus to this container view. |
protected Screen |
getScreen()
Retrieves the screen to which this view belongs to. |
boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the given keyPressed event. |
boolean |
handleKeyReleased(int keyCode,
int gameAction)
Handles the given keyReleased event when the currently focused item was not able to handle it. |
boolean |
handlePointerDragged(int x,
int y)
Handles the event when a pointer has been dragged to the specified position. |
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. |
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. |
protected void |
init(Item parent,
int firstLineWidth,
int availWidth,
int availHeight)
Initializes this item view. |
protected abstract void |
initContent(Item parent,
int firstLineWidth,
int availWidth,
int availHeight)
Initialises this item view. |
protected void |
initContentByParent(Item parent,
int firstLineWidth,
int availWidth,
int availHeight)
Calls the original initContent method on the parent. |
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 |
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. |
protected void |
notifyItemPressedEnd()
Is called when pressing an item is finished, usually when the FIRE key is released The default implementation fowards this to the parent item. |
protected void |
notifyItemPressedEnd(Item item)
Call this to notify an item that it is not being pressed anymore after a FIRE game action or similar |
protected boolean |
notifyItemPressedStart()
Is called when an item is pressed using the FIRE game action. |
protected boolean |
notifyItemPressedStart(Item item)
Call this to notify an item that it is being pressed using a FIRE game action or similar |
protected void |
onScreenSizeChanged(int screenWidth,
int screenHeight)
Notifies this item about a new screen size. |
void |
paintBackground(Background background,
int x,
int y,
int width,
int height,
Graphics g)
|
void |
paintBorder(Border border,
int x,
int y,
int width,
int height,
Graphics g)
|
protected abstract void |
paintContent(Item parent,
int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
Paints this item view. |
protected void |
paintContentByParent(Item parent,
int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
Paints this item view by the parent. |
void |
releaseResources()
Releases all resources that are not required to keep the state of this view. |
protected Background |
removeItemBackground(Item item)
Removes the set background from an item. |
protected Border |
removeItemBorder(Item item)
Removes the set border from an item. |
Background |
removeParentBackground()
Removes the background from the parent container so that the view implementation can paint it itself. |
Border |
removeParentBorder()
Removes the border from the parent container so that the view implementation can paint it itself. |
protected void |
removeViewFromParent()
Removes this view from the parent item. |
void |
requestInit()
Requests the re-initialization of this item view. |
protected void |
setContentHeight(int height)
Sets the content height of this item. |
protected void |
setContentWidth(int width)
Sets the content width of this view. |
protected void |
setStyle(Style style)
Sets the style for this view. |
protected void |
setStyle(Style style,
boolean resetStyle)
Sets the style for this view and is used to specify animatable CSS attribute. |
void |
showNotify()
Notifies this view that it is about to be shown (again). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int contentWidth
protected int contentHeight
protected int availableWidth
protected int availableHeight
protected int paddingVertical
protected int paddingHorizontal
protected int layout
protected boolean isLayoutCenter
protected boolean isLayoutRight
protected transient Item parentItem
protected boolean isFocused
| Constructor Detail |
|---|
public ItemView()
| Method Detail |
|---|
protected void initMargin(Style style,
int availWidth)
style - the styleavailWidth - the available width
protected void initPadding(Style style,
int availWidth)
style - the styleavailWidth - the available width
protected void init(Item parent,
int firstLineWidth,
int availWidth,
int availHeight)
parent - the parent itemfirstLineWidth - the maximum width of the first lineavailWidth - the maximum width of the viewavailHeight - the maximum height of the viewinitContent(Item, int, int, int),
availableWidth,
availableHeight
protected abstract void initContent(Item parent,
int firstLineWidth,
int availWidth,
int availHeight)
parent - the parent itemfirstLineWidth - the maximum width of the first lineavailWidth - the maximum width of the viewavailHeight - the maximum height of the viewcontentWidth,
contentHeight
protected abstract void paintContent(Item parent,
int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
parent - 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.
protected void initContentByParent(Item parent,
int firstLineWidth,
int availWidth,
int availHeight)
parent - the parent itemfirstLineWidth - the maximum width of the first lineavailWidth - the maximum width of any following linesavailHeight - TODO
protected void paintContentByParent(Item parent,
int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
parent - 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.
public void focus(Style focusstyle,
int direction)
focusstyle - the appropriate style.direction - the direction from the which the focus is gained,
either Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.RIGHT or 0.
When 0 is given, the direction is unknown.1protected void defocus(Style originalStyle)
originalStyle - the previous used style, may be null.protected void setStyle(Style style)
style - the style
protected void setStyle(Style style,
boolean resetStyle)
style - the styleresetStyle - true when default style settings should be applied when nothing is setpublic void requestInit()
public Background removeParentBackground()
public Border removeParentBorder()
protected Border removeItemBorder(Item item)
item - the item to remove the border from
removeItemBackground(Item),
addItemBorder(Item, Border)protected Background removeItemBackground(Item item)
item - the item to remove the background from
removeItemBorder(Item),
addItemBackground(Item, Background)
protected void addItemBackground(Item item,
Background background)
item - to which the background should be addedbackground - the backgroundremoveItemBackground(Item),
addItemBackgroundBorder(Item, Background, Border)
protected void addItemBorder(Item item,
Border border)
item - to which the border should be addedborder - the borderremoveItemBorder(Item),
addItemBackgroundBorder(Item, Background, Border)
protected void addItemBackgroundBorder(Item item,
Background background,
Border border)
item - to which the border should be addedbackground - the backgroundborder - the borderremoveItemBackground(Item),
removeItemBorder(Item)
public void animate(long currentTime,
ClippingRegion repaintRegion)
currentTime - the current time in millisecondsrepaintRegion - the repaint area that needs to be updated when this item is animatedItem.getAbsoluteX(),
Item.getAbsoluteY()
protected void addFullRepaintRegion(Item item,
ClippingRegion repaintRegion)
item - the itemrepaintRegion - the region to which the item's positions are addedpublic boolean animate()
animate(long, ClippingRegion)public void showNotify()
public void hideNotify()
paint() calls will be made on this item
until after a showNotify() has been called again.
protected Screen getScreen()
public boolean handleKeyPressed(int keyCode,
int gameAction)
keyCode - the key codegameAction - the game action like Canvas.UP etc
public boolean handleKeyReleased(int keyCode,
int gameAction)
keyCode - the key codegameAction - the game action like Canvas.UP etc
protected Point adjustToContentArea(int x,
int y)
x - the horizontal position relative to the parent item's outer left bordery - the vertical position relative to the parent item's outer top border
public boolean handlePointerPressed(int x,
int y)
//#if polish.hasPointerEvents
x - 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 handlePointerReleased(int x,
int y)
//#if polish.hasPointerEvents
x - 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 handlePointerDragged(int x,
int y,
ClippingRegion repaintRegion)
//#if polish.hasPointerEvents
x - 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
handlePointerDragged(int, int),
Item.addRepaintArea(ClippingRegion)
public boolean handlePointerDragged(int x,
int y)
//#if polish.hasPointerEvents
x - 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)
x - 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 handlePointerTouchUp(int x,
int y)
x - 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 boolean isValid(Item parent,
Style style)
parent - the parent itemstyle - the style
protected void removeViewFromParent()
protected boolean notifyItemPressedStart()
protected void notifyItemPressedEnd()
public void paintBackground(Background background,
int x,
int y,
int width,
int height,
Graphics g)
background - x - y - width - height - g -
public void paintBorder(Border border,
int x,
int y,
int width,
int height,
Graphics g)
border - x - y - width - height - g - public void releaseResources()
public void destroy()
protected boolean notifyItemPressedStart(Item item)
item - the item that should be notified
protected void notifyItemPressedEnd(Item item)
item - the item that should be notifiedprotected void setContentWidth(int width)
width - the new content width in pixelprotected void setContentHeight(int height)
height - the new content height in pixel
protected void onScreenSizeChanged(int screenWidth,
int screenHeight)
screenWidth - the screen widthscreenHeight - the screen height
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||