de.enough.polish.ui.containerviews
Class TabbedContainerView

java.lang.Object
  extended by de.enough.polish.ui.ItemView
      extended by de.enough.polish.ui.ContainerView
          extended by de.enough.polish.ui.containerviews.TabbedContainerView
All Implemented Interfaces:
Serializable, FocusListener

public class TabbedContainerView
extends ContainerView
implements FocusListener

Displays embedded all items in different tabs.

usage:

 .myList {
    view-type: tabbed;
    tabbedview-icon: url( tab.png );
    tabbedview-icon-hover: url( tabHover.png );
    tabbedview-tabbar-position: bottom;
    tabbedview-tabbar-style: .myListTabs; 
    tabbedview-tab-style: .myListTab; 
 }
 
 .myListTabs {
          view-type: horizontal;
          layout: center;
 }
 
 .myListTab {
 }
 .myListTab:hover {
         background-color: red;
 }
 

Copyright Enough Software 2010

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
static int POSITION_BOTTOM
          Positions the tabs below the items.
static int POSITION_TOP
          Positions the tabs above the items.
 
Fields inherited from class de.enough.polish.ui.ContainerView
allowCycling, allowsAutoTraversal, allowsDirectSelectionByPointerEvent, appearanceMode, columnsSetting, columnsWidths, EQUAL_WIDTH_COLUMNS, focusedIndex, focusedItem, focusFirstElement, isAlignHeights, isExpandItems, isHorizontal, isPointerPressedHandled, isSequentialTraversal, isVertical, leftXOffset, NO_COLUMNS, NORMAL_WIDTH_COLUMNS, numberOfColumns, numberOfRows, parentContainer, restartAnimation, rightXOffset, rowsHeights, scrollContinuous, STATIC_WIDTH_COLUMNS, targetXOffset, topYOffset, xOffset, yOffset
 
Fields inherited from class de.enough.polish.ui.ItemView
availableHeight, availableWidth, contentHeight, contentWidth, isFocused, isLayoutCenter, isLayoutRight, layout, paddingHorizontal, paddingVertical, parentItem
 
Constructor Summary
TabbedContainerView()
          Creates a new tabbed view-type
 
Method Summary
 void animate(long currentTime, ClippingRegion repaintRegion)
          Animates this item.
protected  Item getNextItem(int keyCode, int gameAction)
          Interprets the given user-input and retrieves the next item which should be focused.
 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.
 void onFocusChanged(Container parent, Item focItem, int focIndex)
          Notifies about that the focus has been changed.
protected  void onScreenSizeChanged(int screenWidth, int screenHeight)
          Notifies this item about a new screen size.
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 setStyle(Style style)
          Sets the style for this view.
 
Methods inherited from class de.enough.polish.ui.ContainerView
addFullRepaintRegion, destroy, focusItem, focusItem, focusItem, getAppearanceMode, getChildAt, getChildHeight, getChildWidth, getContentHeight, getContentWidth, getItemRelativeY, getNextFocusableItem, getParentRelativeY, getScreen, getScrollTargetXOffset, getScrollXOffset, handleKeyPressed, initMargin, initPadding, isInBottomRow, isLayoutExpand, isValid, isVerticalLayout, isVirtualContainer, paintContent, paintItem, releaseResources, scroll, setAppearanceMode, setScrollXOffset, setScrollXOffset, shiftFocus, shiftFocus, shiftFocus, showNotify, startScroll
 
Methods inherited from class de.enough.polish.ui.ItemView
addItemBackground, addItemBackgroundBorder, addItemBorder, adjustToContentArea, animate, defocus, focus, handleKeyReleased, handlePointerDragged, hideNotify, init, initContentByParent, notifyItemPressedEnd, notifyItemPressedEnd, notifyItemPressedStart, notifyItemPressedStart, paintBackground, paintBorder, paintContentByParent, removeItemBackground, removeItemBorder, removeParentBackground, removeParentBorder, removeViewFromParent, requestInit, setContentHeight, setContentWidth, setStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSITION_TOP

public static final int POSITION_TOP
Positions the tabs above the items.

See Also:
Constant Field Values

POSITION_BOTTOM

public static final int POSITION_BOTTOM
Positions the tabs below the items.

See Also:
Constant Field Values
Constructor Detail

TabbedContainerView

public TabbedContainerView()
Creates a new tabbed view-type

Method Detail

initContent

protected void initContent(Item parentContainerItem,
                           int firstLineWidth,
                           int availWidth,
                           int availHeight)
Description copied from class: ContainerView
Initializes this container view. The implementation needs to calculate and set the contentWidth and contentHeight fields. The style of the focused item has already been set. When the contentWidth will be larger than the specified availWidth, the container view allows to scroll horizontally automatically using pointer events.

Overrides:
initContent in class ContainerView
Parameters:
parentContainerItem - the Container which uses this view, use parent.getItems() for retrieving all items.
firstLineWidth - the maximum width of the first line
availWidth - the maximum width of any following lines
availHeight - the maximum height of the view
See Also:
ItemView.contentWidth, ItemView.contentHeight

paintContent

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)
Description copied from class: ContainerView
Paints the content of this container view. This method calls

Overrides:
paintContent in class ContainerView
Parameters:
container - the parent container
myItems - the items that should be painted
x - the left start position
y - the upper start position
leftBorder - the left border, nothing must be painted left of this position
rightBorder - the right border, nothing must be painted right of this position
clipX - absolute horizontal clipping start
clipY - absolute verical clipping start
clipWidth - clipping width
clipHeight - clipping height
g - the Graphics on which this item should be painted.

setStyle

protected void setStyle(Style style)
Description copied from class: ContainerView
Sets the style for this view. The style can include additional parameters for the view. Subclasses should call super.setStyle(style) first.

Overrides:
setStyle in class ContainerView
Parameters:
style - the style

handlePointerPressed

public boolean handlePointerPressed(int x,
                                    int y)
Description copied from class: ItemView
Handles pointer pressed events. This is an optional feature that doesn't need to be implemented by subclasses, since the parent container already forwards the event to the appropriate item (when this method returns false). The default implementation just returns false. You only need to implement this method when there are pointer events:
 //#if polish.hasPointerEvents
 

Overrides:
handlePointerPressed in class ContainerView
Parameters:
x - the x position of the event relative to the item's horizontal left edge
y - the y position of the event relative to the item's vertical top edge
Returns:
true when the event has been handled. When false is returned the parent container will forward the event to the affected item.

handlePointerReleased

public boolean handlePointerReleased(int x,
                                     int y)
Description copied from class: ItemView
Handles the event when a pointer has been released at the specified position. The default implementation just returns false. You only need to implement this method when there are pointer events:
 //#if polish.hasPointerEvents
 

Overrides:
handlePointerReleased in class ContainerView
Parameters:
x - the x position of the event relative to the item's horizontal left edge
y - the y position of the event relative to the item's vertical top edge
Returns:
true when the pressing of the pointer was actually handled by this item.

handlePointerDragged

public boolean handlePointerDragged(int x,
                                    int y,
                                    ClippingRegion repaintRegion)
Description copied from class: ItemView
Handles the event when a pointer has been dragged to the specified position. The default implementation adds a repaint region when handlePointerDragged(x,y) returned true. You only need to implement this method when there are pointer events:
 //#if polish.hasPointerEvents
 

Overrides:
handlePointerDragged in class ContainerView
Parameters:
x - the x position of the event relative to the item's horizontal left edge
y - the y position of the event relative to the item's vertical top edge
repaintRegion - the repaint region into which the repaint area is marked when the event is handled
Returns:
true when the pressing of the pointer was actually handled by this item.
See Also:
ItemView.handlePointerDragged(int, int), Item.addRepaintArea(ClippingRegion)

handlePointerTouchDown

public boolean handlePointerTouchDown(int x,
                                      int y)
Description copied from class: ItemView
Handles a touch down/press event. This is similar to a pointerPressed event, however it is only available on devices with screens that differentiate between press and touch events (read: BlackBerry Storm).

Overrides:
handlePointerTouchDown in class ContainerView
Parameters:
x - the horizontal pixel position of the touch event relative to the parent item's left position
y - the vertical pixel position of the touch event relative to the parent item's top position
Returns:
true when the event was handled

handlePointerTouchUp

public boolean handlePointerTouchUp(int x,
                                    int y)
Description copied from class: ItemView
Handles a touch up/release event. This is similar to a pointerReleased event, however it is only available on devices with screens that differentiate between press and touch events (read: BlackBerry Storm).

Overrides:
handlePointerTouchUp in class ContainerView
Parameters:
x - the horizontal pixel position of the touch event relative to the parent item's left position
y - the vertical pixel position of the touch event relative to the parent item's top position
Returns:
true when the event was handled

getNextItem

protected Item getNextItem(int keyCode,
                           int gameAction)
Description copied from class: ContainerView
Interprets the given user-input and retrieves the next item which should be focused. Please not that the focusItem()-method is not called as well. The view is responsible for updating its internal configuration here as well.

Overrides:
getNextItem in class ContainerView
Parameters:
keyCode - the code of the keyPressed-events
gameAction - the associated game-action to the given keyCode
Returns:
the next item which will be focused, null when there is no such element.

animate

public void animate(long currentTime,
                    ClippingRegion repaintRegion)
Description copied from class: ItemView
Animates this item. Subclasses can override this method to create animations. The default implementation animates the background and the item view if present.

Overrides:
animate in class ContainerView
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
Item.getAbsoluteX(), Item.getAbsoluteY()

onFocusChanged

public void onFocusChanged(Container parent,
                           Item focItem,
                           int focIndex)
Description copied from interface: FocusListener
Notifies about that the focus has been changed.

Specified by:
onFocusChanged in interface FocusListener
Parameters:
parent - the parent container
focItem - the item that has received the focus, may be null
focIndex - the new focused index, may be -1.

onScreenSizeChanged

protected void onScreenSizeChanged(int screenWidth,
                                   int screenHeight)
Description copied from class: ItemView
Notifies this item about a new screen size. The default implementation is empty.

Overrides:
onScreenSizeChanged in class ItemView
Parameters:
screenWidth - the screen width
screenHeight - the screen height