de.enough.polish.ui.containerviews
Class Midp2ContainerView

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

public class Midp2ContainerView
extends ContainerView

Aligns elements according to the MIDP 2.0 layout directives of the items.

Usage:

 .myForm {
                view-type: midp2;
 }
 

Copyright Enough Software 2008

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
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
Midp2ContainerView()
          Creates a new view type
 
Method Summary
protected  void addLineBreak(Item[] items, int currentRowStartIndex, int currentRowEndIndex, int currentRowWidth, int currentRowHeight, int availWidth)
          Adds a linebreak to the current list of items.
 int getContentHeight()
          Retrieves the content height
 int getContentWidth()
          Retrieves the content width
 void initContent(Item[] items, int firstLineWidth, int availWidth, int availHeight)
          Initiates this view for the specified items
protected  void initContent(Item parentContainerItem, int firstLineWidth, int availWidth, int availHeight)
          Initializes this container view.
 boolean isVerticalLayout()
          Checks if this ContainerView arranges its child items vertically.
 void paintContent(Item[] items, int x, int y, int leftBorder, int rightBorder, Graphics g)
          Paints the content of this MIDP2 view.
 
Methods inherited from class de.enough.polish.ui.ContainerView
addFullRepaintRegion, animate, destroy, focusItem, focusItem, focusItem, getAppearanceMode, getChildAt, getChildHeight, getChildWidth, getItemRelativeY, getNextFocusableItem, getNextItem, getParentRelativeY, getScreen, getScrollTargetXOffset, getScrollXOffset, handleKeyPressed, handlePointerDragged, handlePointerPressed, handlePointerReleased, handlePointerTouchDown, handlePointerTouchUp, initMargin, initPadding, isInBottomRow, isLayoutExpand, isValid, isVirtualContainer, paintContent, paintContent, paintItem, releaseResources, scroll, setAppearanceMode, setScrollXOffset, setScrollXOffset, setStyle, 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, onScreenSizeChanged, 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
 

Constructor Detail

Midp2ContainerView

public Midp2ContainerView()
Creates a new 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

initContent

public void initContent(Item[] items,
                        int firstLineWidth,
                        int availWidth,
                        int availHeight)
Initiates this view for the specified items

Parameters:
items - the items
firstLineWidth - available width for the first line
availWidth - available width for the view
availHeight - available height for the view

addLineBreak

protected void addLineBreak(Item[] items,
                            int currentRowStartIndex,
                            int currentRowEndIndex,
                            int currentRowWidth,
                            int currentRowHeight,
                            int availWidth)
Adds a linebreak to the current list of items.


paintContent

public void paintContent(Item[] items,
                         int x,
                         int y,
                         int leftBorder,
                         int rightBorder,
                         Graphics g)
Paints the content of this MIDP2 view.

Parameters:
items - the nested items
x -
y -
leftBorder -
rightBorder -
g -

getContentHeight

public int getContentHeight()
Retrieves the content height

Overrides:
getContentHeight in class ContainerView
Returns:
the height of this view

getContentWidth

public int getContentWidth()
Retrieves the content width

Overrides:
getContentWidth in class ContainerView
Returns:
the width of this view

isVerticalLayout

public boolean isVerticalLayout()
Description copied from class: ContainerView
Checks if this ContainerView arranges its child items vertically.

Overrides:
isVerticalLayout in class ContainerView
Returns:
true when the layout is vertical, false when it is horizontal or complex