de.enough.polish.ui.keyboard
Class KeyItem
java.lang.Object
de.enough.polish.ui.Item
de.enough.polish.ui.keyboard.KeyItem
- All Implemented Interfaces:
- Animatable, UiElement
- Direct Known Subclasses:
- BlankItem, ClearKeyItem, DeleteKeyItem, ModeKeyItem, ShiftKeyItem
public class KeyItem
- extends Item
A key item to display keys in a keyboard
- Author:
- Andre
|
Field Summary |
static char |
KEY_UNDEFINED
a blank for undefined key values |
static int |
POSITION_INDEX
the index of the index of a key position in a keyboard |
static int |
POSITION_ROW
the index of the row of a key position in a keyboard |
| Fields inherited from class de.enough.polish.ui.Item |
_androidView, _bbField, appearanceMode, availableHeight, availableWidth, availContentHeight, availContentWidth, background, backgroundHeight, backgroundWidth, backgroundYOffset, bgBorder, border, BUTTON, cacheItemImage, colSpan, commands, completeBackground, completeBackgroundPadding, completeBorder, contentHeight, contentWidth, contentX, contentXAdjustment, contentY, contentYAdjustment, cssHeight, cssSelector, cssWidth, defaultCommand, focusedStyle, HORIZONTAL, HYPERLINK, ignoreRepaintRequests, includeLabel, INTERACTIVE, internalHeight, internalWidth, internalX, internalY, isContentVisible, isFocused, isInlineLabel, isInvisible, isJustFocused, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialized, itemCommandListener, itemHeight, itemWidth, label, labelStyle, landscapeStyle, layout, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, marginBottom, marginLeft, marginRight, marginTop, maximumHeight, maximumItemHeight, maximumItemWidth, maximumWidth, minimumHeight, minimumItemHeight, minimumItemWidth, minimumWidth, nativeItem, NO_POSITION_SET, opacity, opacityPaintNormally, opacityRgbData, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, portraitStyle, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, setView, style, TRANSPARENT, useSingleRow, VERTICAL, view, xAdjustment, yAdjustment |
|
Method Summary |
protected void |
apply(boolean doubleclick)
Applies the current key to the keyboard |
protected String |
createCssSelector()
Retrieves the CSS selector for this item. |
char |
getCurrentKey(boolean shift)
Returns the (shifted) current key |
Font |
getFont()
Returns the font of the style. |
int |
getIndex()
Returns the index |
protected Keyboard |
getKeyboard()
Returns the keyboard |
int |
getRow()
Returns the row |
protected boolean |
handlePointerReleased(int relX,
int relY)
Handles the event when a pointer has been released at the specified position. |
protected void |
initContent(int firstLineWidth,
int availWidth,
int availHeight)
Initialises this item. |
protected void |
paintContent(int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
Paints the content of this item. |
String |
toString()
Generates a String representation of this item. |
| Methods inherited from class de.enough.polish.ui.Item |
addCommand, addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToBackgroundRegion, addRelativeToContentRegion, addRepaintArea, animate, animate, containsCommand, defocus, destroy, fireContinueCycle, fireEvent, focus, getAbsoluteX, getAbsoluteY, getAfterWidthWithPadding, getAppearanceMode, getAttribute, getAttributes, getAvailableContentHeight, getAvailableContentWidth, getAvailableHeight, getAvailableWidth, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getBeforeWidthWithPadding, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getContentHeight, getContentWidth, getContentX, getContentY, getCycleListener, getDefaultCommand, getFocusedStyle, getInternalHeight, getInternalWidth, getInternalX, getInternalY, getItemAreaHeight, getItemAt, getItemCommandListener, getItemCommands, getItemHeight, getItemHeight, getItemStateListener, getItemWidth, getItemWidth, getLabel, getLabelItem, getLayout, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaximumHeight, getMaximumHeight, getMaximumWidth, getMaximumWidth, getMinimumHeight, getMinimumHeight, getMinimumWidth, getMinimumWidth, getNativeItem, getPaddingBottom, getPaddingHorizontal, getPaddingLeft, getPaddingRight, getPaddingTop, getPaddingVertical, getParent, getParentRoot, getpreferredHeight, getpreferredWidth, getRgbData, getRgbData, getScreen, getStyle, getUiEventListener, getView, getView, handleCommand, handleCommand, handleGesture, handleGestureHold, handleGestureSwipeLeft, handleGestureSwipeRight, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handleOnFocusSoftKeyboardDisplayBehavior, handlePointerDragged, handlePointerDragged, handlePointerPressed, handlePointerTouchDown, handlePointerTouchUp, hideNotify, init, initLayout, initMargin, initPadding, initStyle, isFocused, isInContentArea, isInContentWithPaddingArea, isInItemArea, isInItemArea, isInitialized, isInteractive, isLayoutBottom, isLayoutCenter, isLayoutExpand, isLayoutLeft, isLayoutNewlineAfter, isLayoutNewlineBefore, isLayoutRight, isLayoutShrink, isLayoutTop, isLayoutVerticalCenter, isLayoutVerticalExpand, isLayoutVerticalShrink, isPressed, isSameRowForContentAndLabel, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, notifyUnvisited, notifyValueChanged, notifyVisited, onScreenSizeChanged, paint, paintBackground, paintBackgroundAndBorder, paintBorder, paintCommands, paintFilter, releaseResources, removeAttribute, removeCommand, repaint, repaint, repaintFully, requestInit, resetStyle, setAbsoluteY, setAppearanceMode, setAttribute, setBackground, setBorder, setContentHeight, setContentWidth, setCycleListener, setDefaultCommand, setDefaultCommand, setInitialized, setItemCommandListener, setItemCommandListener, setItemHeight, setItemStateListener, setItemTransition, setItemWidth, setLabel, setLayout, setNativeItem, setParent, setParent, setpreferredSize, setSameRowForContentAndLabel, setStyle, setStyle, setStyle, setUiEventListener, setView, setVisible, show, show, showCommands, showNotify, toImage, toRgbImage, updateInternalArea |
POSITION_ROW
public static final int POSITION_ROW
- the index of the row of a key position in a keyboard
- See Also:
- Constant Field Values
POSITION_INDEX
public static final int POSITION_INDEX
- the index of the index of a key position in a keyboard
- See Also:
- Constant Field Values
KEY_UNDEFINED
public static final char KEY_UNDEFINED
- a blank for undefined key values
- See Also:
- Constant Field Values
KeyItem
public KeyItem(Keyboard keyboard,
String position,
String keys)
- Creates a new KeyItem instance
- Parameters:
keyboard - the keyboardposition - the positionkeys - the keys
KeyItem
public KeyItem(Keyboard keyboard,
String position,
String keys,
Style style)
- Creates a new KeyItem instance
- Parameters:
keyboard - the keyboardposition - the positionkeys - the keysstyle - the style
createCssSelector
protected String createCssSelector()
- Description copied from class:
Item
- Retrieves the CSS selector for this item.
The CSS selector is used for the dynamic assignment of styles -
that is the styles are assigned by the usage of the item and
not by a predefined style-name.
With the #style preprocessing command styles are set fix, this method
yields in a faster GUI and is recommended. When in a style-sheet
dynamic styles are used, e.g. "Form>p", than the selector of the
item is needed.
This abstract method needs only be implemented, when dynamic styles
are used: #ifdef polish.useDynamicStyles
The returned selector needs to be in lower case.
- Specified by:
createCssSelector in class Item
- Returns:
- the appropriate CSS selector for this item.
The selector needs to be in lower case.
getFont
public Font getFont()
- Returns the font of the style. If the font of the style
is null return the default font.
- Returns:
- the font
initContent
protected void initContent(int firstLineWidth,
int availWidth,
int availHeight)
- Description copied from class:
Item
- Initialises this item.
The implementation needs to calculate and set the contentWidth and
contentHeight fields.
The implementation should take the fields preferredWidth and preferredHeight
into account.
- Specified by:
initContent in class Item
- Parameters:
firstLineWidth - the maximum width of the first lineavailWidth - the available maximum width of this item in pixelsavailHeight - the available maximum height of this item in pixels- See Also:
Item.contentWidth,
Item.contentHeight,
Item.preferredWidth,
Item.preferredHeight
paintContent
protected void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
Graphics g)
- Description copied from class:
Item
- Paints the content of this item.
The background has already been painted and the border will be added after
this method returns.
- Specified by:
paintContent in class Item
- Parameters:
x - 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.
getCurrentKey
public char getCurrentKey(boolean shift)
- Returns the (shifted) current key
- Parameters:
shift - true if the shifted current key should be returned
- Returns:
- the (shifted) current key
getKeyboard
protected Keyboard getKeyboard()
- Returns the keyboard
- Returns:
- the keyboard
getRow
public int getRow()
- Returns the row
- Returns:
- the row
getIndex
public int getIndex()
- Returns the index
- Returns:
- the index
apply
protected void apply(boolean doubleclick)
- Applies the current key to the keyboard
- Parameters:
doubleclick -
toString
public String toString()
- Description copied from class:
Item
- Generates a String representation of this item.
This method is only implemented when the logging framework is active or the preprocessing variable
"polish.keepToString" is set to true.
- Overrides:
toString in class Item
- Returns:
- a String representation of this item.
handlePointerReleased
protected boolean handlePointerReleased(int relX,
int relY)
- Description copied from class:
Item
- Handles the event when a pointer has been released at the specified position.
The default method discards this event when relX/relY is outside of the item's area.
When the event took place inside of the content area, the pointer-event is translated into an artificial
FIRE game-action keyReleased event, which is subsequently handled
bu the handleKeyPressed(-1, Canvas.FIRE) method.
This method needs should be overwritten only when the "polish.hasPointerEvents"
preprocessing symbol is defined: "//#ifdef polish.hasPointerEvents".
- Overrides:
handlePointerReleased in class Item
- Parameters:
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
- Returns:
- true when the pressing of the pointer was actually handled by this item.
- See Also:
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,
Item.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)