|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Displayable
javax.microedition.lcdui.Canvas
de.enough.polish.ui.Canvas
de.enough.polish.ui.Screen
public abstract class Screen
The common superclass of all high-level user interface classes. The contents displayed and their interaction with the user are defined by subclasses.
Using subclass-defined methods, the application may change the contents
of a Screen object while it is shown to the user. If
this occurs, and the
Screen object is visible, the display will be updated
automatically. That
is, the implementation will refresh the display in a timely fashion without
waiting for any further action by the application. For example, suppose a
List object is currently displayed, and every element
of the List is
visible. If the application inserts a new element at the beginning of the
List, it is displayed immediately, and the other
elements will be
rearranged appropriately. There is no need for the application to call
another method to refresh the display.
It is recommended that applications change the contents of a
Screen only
while it is not visible (that is, while another
Displayable is current).
Changing the contents of a Screen while it is visible
may result in
performance problems on some devices, and it may also be confusing if the
Screen's contents changes while the user is
interacting with it.
In MIDP 2.0 the four Screen methods that defined
read/write ticker and title properties were moved to Displayable,
Screen's superclass. The semantics of these methods have not changed.
| Field Summary | |
|---|---|
protected Background |
background
|
protected int |
backgroundHeight
|
protected int |
backgroundWidth
|
protected int |
backgroundX
|
protected int |
backgroundY
|
protected Border |
border
|
protected Container |
container
|
protected Background |
contentBackground
the content's (container) background |
protected int |
contentBackgroundAnchor
|
protected Dimension |
contentBackgroundHeight
|
protected Dimension |
contentBackgroundWidth
|
protected Border |
contentBgBorder
the content's (container) border that is drawn before the content-background is drawn |
protected Border |
contentBorder
the content's (container) border |
protected int |
contentHeight
|
protected int |
contentWidth
|
protected int |
contentX
|
protected int |
contentY
|
protected String |
cssSelector
|
protected boolean |
enableScreenChangeAnimation
|
protected int |
fullScreenHeight
the real, complete height of the screen - this includes title, subtitle, content and menubar |
protected boolean |
ignoreRepaintRequests
|
protected int |
infoHeight
determines whether the info text should be shown |
protected boolean |
isAnimated
|
protected boolean |
isInitRequested
requests a call to calcuateContentArea() the next time this screen is being painted |
protected boolean |
isRepaintRequested
|
protected boolean |
isScrollBackground
|
protected ItemStateListener |
itemStateListener
|
boolean |
keyPressedProcessed
flag for key pressed events - only for internal usage on Android platforms! |
boolean |
keyReleasedProcessed
flag for key released events - only for internal usage on Android platforms! |
protected Style |
landscapeStyle
|
protected long |
lastAnimateTime
|
protected long |
lastInteractionTime
The last time in ms when the user interacted with this screen. |
protected Command |
lastTriggeredCommand
|
protected int |
menuBarHeight
|
protected int |
originalScreenHeight
the screen height minus the height of the menu bar |
protected boolean |
paintScrollBarOnRightSide
|
protected Style |
portraitStyle
|
protected Background |
previousScreenOverlayBackground
|
protected boolean |
repaintPreviousScreen
|
protected int |
screenHeight
the screen height minus the ticker height and the height of the menu bar |
protected ScreenStateListener |
screenStateListener
|
protected int |
screenWidth
|
protected ScrollBar |
scrollBar
|
protected boolean |
scrollBarVisible
|
protected Style |
style
|
protected int |
subTitleHeight
|
protected Item |
title
|
protected int |
titleHeight
|
protected int |
triggerReleasedKeyCode
|
protected long |
triggerReleasedTime
|
protected ClippingRegion |
userEventRepaintRegion
|
| Fields inherited from class de.enough.polish.ui.Canvas |
|---|
_commands, DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP |
| Constructor Summary | |
|---|---|
Screen(String title,
boolean createDefaultContainer)
Creates a new screen, this constructor can be used together with the //#style directive. |
|
Screen(String title,
boolean createDefaultContainer,
Style style)
Creates a new screen, this constructor can be used together with the //#style directive. |
|
Screen(String title,
Style style,
boolean createDefaultContainer)
Creates a new screen |
|
| Method Summary | |
|---|---|
boolean |
_keyPressed(int keyCode)
Handles key events. |
boolean |
_keyReleased(int keyCode)
Is called when a key is released. |
boolean |
_keyRepeated(int keyCode)
Just maps the event to the the keyPressed method. |
boolean |
_pointerDragged(int x,
int y)
Called when the pointer is dragged. |
boolean |
_pointerPressed(int x,
int y)
Called when the pointer is pressed. |
boolean |
_pointerReleased(int x,
int y)
Called when the pointer is released. |
void |
addCommand(Command cmd)
Adds a command to this screen |
void |
addCommand(Command cmd)
Adds a command to the Displayable. |
void |
addCommand(Command cmd,
Style commandStyle)
Adds a command to this screen with the specified style. |
void |
addCommandSeparator(int priority)
Adds a command separator to the menu of this screen. |
void |
addCommandSeparator(int priority,
Style separatorStyle)
Adds a command separator to the menu of this screen. |
void |
addCommandsLayer(Command[] commands)
|
void |
addPermanentNativeItem(Item item)
Notifies this screen about the new item with a native componen that is added on BlackBerry platforms. |
void |
addRelativeToContentRegion(ClippingRegion repaintRegion,
int x,
int y,
int width,
int height)
Adds a region relative to this screen's content x/y start position. |
void |
addRepaintArea(ClippingRegion repaintArea)
UI ELEMENT INTERFACE |
void |
addSubCommand(Command child,
Command parent)
Adds the given command as a subcommand to the specified parent command. |
void |
addSubCommand(Command child,
Command parent,
Style commandStyle)
Adds the given command as a subcommand to the specified parent command. |
protected void |
adjustContentArea(int x,
int y,
int width,
int height,
Container cont)
Subclasses may override this to adjust the content area of a screen. |
boolean |
animate()
Animates this Screen. |
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this screen. |
protected void |
calculateContentArea(int x,
int y,
int width,
int height)
Calculates and initializes the content area for this screen. |
protected void |
callCommandListener(Command cmd)
Calls the command listener with the specified command. |
protected boolean |
canScrollDown()
Checks if this screen can currently scroll downwards. |
protected boolean |
canScrollUp()
Checks if this screen can currently scroll upwards. |
protected boolean |
checkForRequestInit(Item source)
Checks if this screen's content area should be refreshed when the specified item has changed it's size. |
protected void |
clearItemCommands()
Removes commands from the complete focused item hierarchy |
void |
closeMenu()
Closes the commands menu of this screen. |
void |
commandAction(Command command,
Displayable screen)
|
protected abstract String |
createCssSelector()
Retrieves the CSS selector for this screen. |
void |
destroy()
Destroys the screen |
void |
fireEvent(String eventName,
Object eventData)
Fires an event for this screen and all its components. |
void |
fireEventForTitleAndMenubar(String eventName,
Object eventData)
Fires an event for the title and menubar of the specified screen. |
void |
focus(int index)
Focuses the specified item. |
void |
focus(int index,
boolean force)
Focuses the specified item. |
void |
focus(int index,
Item item,
boolean force)
Focuses the specified item. |
void |
focus(Item item)
Focuses the specified item. |
void |
focus(Item item,
boolean force)
Focuses the specified item. |
int |
getAvailableHeight()
Retrieves the available height for this screen. |
CommandItem |
getCommandItem(Command command)
Retrieves the CommandItem used for rendering the specified command. |
CommandListener |
getCommandListener()
Retrieves the asscociated command listener of this screen (if any). |
Object[] |
getCommands()
Retrieves all commands as an object array which may contain null values |
int |
getCurrentIndex()
Retrieves the index of the currently focused item. |
Item |
getCurrentItem()
Retrieves the currently focused item. |
protected Command |
getDefaultCommand(Item item)
Retrieves the default command of the specfied item. |
Item |
getItemAt(int x,
int y)
Locates and returns the item at the given coordinate. |
int |
getKeyStates()
Gets the states of the physical game keys. |
MenuBar |
getMenuBar()
Allows to access the menu bar. |
NativeScreen |
getNativeScreen()
Species a native implementation for this screen. |
Object |
getPaintLock()
Retrieves the lock object for the paint thread. |
Ticker |
getPolishTicker()
Gets the ticker used by this Screen. |
Container |
getRootContainer()
Retrieves the root container of this screen |
protected Item[] |
getRootItems()
Retrieves all root-items of this screen. |
int |
getScreenContentHeight()
Retrieves the height of the content area. |
int |
getScreenContentWidth()
Retrieves the width of the content area. |
int |
getScreenContentX()
Retrieves the horizontal start position of the screen's content area |
int |
getScreenContentY()
Retrieves the vertical start position of the screen's content area |
Object |
getScreenData()
Retrieves screen specific data. |
int |
getScreenFullHeight()
Retrieves the height that the complete screen uses, including title, menubar, ticker, etc. |
int |
getScreenFullWidth()
Retrieves the width that the complete screen uses, including scrollbar, etc. |
int |
getScreenHeight()
|
ScreenInitializerListener |
getScreenInitializerListener()
Sets a new screen initializer listener. |
Style |
getScreenStyle()
Retrieves the style currently used by this screen. |
protected int |
getScrollBarWidth()
Retrieves the width of the scrollbar Note that you need to activate the usage of the scrollbar by setting polish.useScrollbar=true |
protected int |
getScrollDownBackgroundOffset()
Retrieves the scroll down offset |
int |
getScrollHeight()
Retrieves this screen's actual content's height |
protected int |
getScrollUpBackgroundOffset()
Retrieves the scroll up offset |
int |
getScrollYOffset()
Retrieves the vertical scroll offset. |
Style |
getStyle()
Retrieves the currently used style |
Item |
getSubTitleItem()
Retrieves the subtitle of this screen. |
String |
getTitle()
Gets the title of the Screen. |
int |
getTitleHeight()
Retrieves the height of the title. |
Item |
getTitleItem()
Retrieves this screen's title item (when the fullscreen mode of J2ME Polish is activated) |
UiEventListener |
getUiEventListener()
Retrieves the UiEventListener for this screen |
protected boolean |
handleCommand(Command cmd)
Tries to handle the specified command. |
protected boolean |
handleCommand(Command cmd)
Tries to handle the specified command. |
protected boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the key-pressed event. |
protected boolean |
handleKeyReleased(int keyCode,
int gameAction)
Handles the key-released event. |
protected boolean |
handleKeyRepeated(int keyCode,
int gameAction)
Handles the key-repeated event. |
protected boolean |
handlePointerDragged(int x,
int y)
Handles the dragging/movement of a pointer. |
protected boolean |
handlePointerDragged(int x,
int y,
ClippingRegion repaintRegion)
Handles the dragging/movement of a pointer. |
protected boolean |
handlePointerPressed(int x,
int y)
Handles the pressing of a pointer. |
protected boolean |
handlePointerReleased(int x,
int y)
Handles the release of a pointer. |
protected boolean |
handlePointerReleasedOutsideScreenArea(int x,
int y)
Handles the release of a pointer outside of this screens area. |
boolean |
handlePointerTouchDown(int x,
int y)
Deprecated. as BlackBerry used to differentiate between click and touch only on its first Storm model |
boolean |
handlePointerTouchUp(int x,
int y)
Deprecated. as BlackBerry used to differentiate between click and touch only on its first Storm model |
void |
hideNotify()
Unregisters this screen and notifies all items that they will not be shown anymore. |
protected void |
init(int width,
int height)
Initializes this screen before it is painted for the first time. |
protected void |
initContent(Container cont)
Initializes the container and background position |
boolean |
isActive()
Indicates if this screen is active (scrolling, key pressed etc.) |
boolean |
isGameActionFire(int keyCode,
int gameAction)
Determines whether the given key is really a Canvas.FIRE game action |
boolean |
isInteracted(long timespan)
Indicates if this screen was interacted with in the given timespan |
protected boolean |
isKeyboardAccessible()
Checks if the keyboard (if any) is currently accessible by the application. |
boolean |
isMenuOpened()
Checks whether the commands menu of the screen is currently opened. |
protected boolean |
isNativeUiShownFor(Item item)
Determines whether a native UI component is shown for the specified item. |
boolean |
isSoftKey(int keyCode)
Determines if the given keycode belongs to a softkey |
boolean |
isSoftKey(int keyCode,
int gameAction)
Determines if the given keycode belongs to a soft key |
boolean |
isSoftKeyLeft(int keyCode,
int gameAction)
Checks if the given keycode is the left softkey |
boolean |
isSoftKeyMiddle(int keyCode,
int gameAction)
Checks if the given keycode is the middle softkey |
boolean |
isSoftKeyRight(int keyCode,
int gameAction)
Checks if the given keycode is the right softkey |
void |
notifyDefaultCommand(Command cmd)
Informs this screen about a new default command for a focused item |
protected void |
notifyFocusSet(Item item)
Notifies this screen about the new item that is focused on BlackBerry platforms. |
void |
notifyScreenStateChanged()
Notifies the screen state change listener about a change in this screen. |
protected void |
notifyStateListener(Item item)
Adds the given item to the queue for state notifications. |
void |
paint(Graphics g)
Paints the screen. |
protected void |
paintBackgroundAndBorder(Graphics g)
Paints the background and border for this screen. |
protected void |
paintMenuBar(Graphics g)
Paints the menubar, if in fullscreen mode. |
protected void |
paintScreen(Graphics g)
Paints the screen. |
protected void |
paintScrollBar(Graphics g)
Paints the scrollbar of this screen. |
protected void |
paintTitleAndSubtitle(Graphics g)
Paints the title (if in fullscreen mode) and the subtitle of this screen |
void |
releaseResources()
Releases all (memory intensive) resources such as images or RGB arrays of this item. |
void |
removeAllCommands()
Removes all commands from this screen. |
void |
removeCommand(Command cmd)
Removes a command from the Displayable. |
void |
removeCommandsLayer()
|
protected void |
removeItemCommands(Item item)
Removes the commands of the given item. |
void |
removePermanentNativeItem(Item item)
Notifies this screen about an item with a native componen that is removed on BlackBerry platforms. |
void |
removeSubCommand(Command childCommand,
Command parentCommand)
Removes the given command as a subcommand. |
protected void |
requestInit()
Reinitializes this screen's content area. |
void |
requestRepaint()
Forwards a repaint request only when those requests should not be ignored. |
void |
requestRepaint(int x,
int y,
int width,
int height)
Forwards a repaint request only when those requests should not be ignored. |
void |
resetStyle(boolean recursive)
Resets the style of this screen and all its elements. |
void |
scrollRelative(int amount)
Scrolls this screen by the given amount. |
void |
scrollToBottom()
Scrolls this screen so that the last item is in the visible space |
void |
setCommandListener(CommandListener listener)
Sets the commandlistener for this canvas |
void |
setCommandListener(CommandListener listener)
Sets the command listener for this screen |
void |
setFullScreenMode(boolean enable)
Controls whether the Canvas is in full-screen mode
or in normal mode. |
void |
setInfo(Item info)
Sets the information which should be shown to the user. |
void |
setInfo(String infoText)
Sets the information which should be shown to the user. |
protected void |
setItemCommands(ArrayList commandsList,
Item item)
Sets the commands of the given item |
void |
setItemStateListener(ItemStateListener iListener)
Sets the ItemStateListener for the Screen,
replacing any previous ItemStateListener. |
void |
setItemStateListener(ItemStateListener iListener)
Sets the ItemStateListener for the Screen,
replacing any previous ItemStateListener. |
void |
setLastInteractionTime(long currentTimeMillis)
Sets the last interaction time for this screen. |
void |
setMenuBarStyle(Style menuBarStyle)
Sets the style for the menubar. |
void |
setMenuItemStyle(Style menuItemStyle)
Sets the style for menuItems. |
void |
setNativeScreen(NativeScreen nativeScreen)
Species a native implementation for this screen. |
void |
setPolishTicker(Ticker ticker)
Set a ticker for use with this Screen, replacing any previous ticker. |
void |
setPolishTicker(Ticker ticker,
Style tickerStyle)
Set a ticker for use with this Screen, replacing any previous ticker. |
void |
setRootContainer(Container cont)
Sets the root container of this screen |
void |
setScreenData(Object data)
Attaches data to this screen. |
void |
setScreenInitializerListener(ScreenInitializerListener listener)
Sets a new screen initializer listener. |
void |
setScreenOrientation(int degrees)
Deprecated. use Display.getInstance().setScreenOrientation(int) instead |
void |
setScreenStateListener(ScreenStateListener listener)
Sets the screen listener for this screen. |
void |
setScrollYOffset(int offset,
boolean smooth)
Sets the vertical scrolling offset of this screen. |
void |
setStyle(Style style)
Sets the style of this screen. |
void |
setStyle(Style style,
boolean resetStyle)
Sets the style with animatable CSS attributes of this user interface element. |
protected void |
setSubTitle(Item subTitle)
Sets the subtitle element. |
void |
setTitle(Item item)
Sets an Item as the title for this screen. |
void |
setTitle(Item item,
Style tStyle)
Sets an Item as the title for this screen. |
void |
setTitle(String s)
Sets the title of the Screen. |
void |
setTitle(String text,
Style tStyle)
Sets the title of the Screen. |
void |
setUiEventListener(UiEventListener listener)
Sets an UiEventListener for this screen and its items. |
void |
showNotify()
Initialises this screen and informs all items about being painted soon. |
void |
sizeChanged(int width,
int height)
Adjusts the size of this screen. |
String |
toString()
|
| Methods inherited from class de.enough.polish.ui.Canvas |
|---|
_hideNotify, _hideNotifyExternal, _showNotify, getGameAction, getHeight, getKeyCode, getKeyName, getWidth, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotifyExternal, isDoubleBuffered, isShown, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, setTicker |
| Methods inherited from class javax.microedition.lcdui.Canvas |
|---|
repaint, repaint, serviceRepaints |
| Methods inherited from class javax.microedition.lcdui.Displayable |
|---|
getTicker, removeCommand, setTicker |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Item title
protected int subTitleHeight
protected int titleHeight
protected Background background
protected int backgroundX
protected int backgroundY
protected int backgroundWidth
protected int backgroundHeight
protected Border border
protected Style style
protected Dimension contentBackgroundWidth
protected Dimension contentBackgroundHeight
protected int contentBackgroundAnchor
protected Background contentBackground
protected Border contentBorder
protected Border contentBgBorder
protected int screenHeight
protected int originalScreenHeight
protected int screenWidth
protected String cssSelector
protected Container container
protected Command lastTriggeredCommand
protected int fullScreenHeight
protected int menuBarHeight
protected final ScrollBar scrollBar
protected boolean paintScrollBarOnRightSide
protected boolean scrollBarVisible
protected int infoHeight
public boolean keyPressedProcessed
public boolean keyReleasedProcessed
protected int contentX
protected int contentY
protected int contentWidth
protected int contentHeight
protected boolean repaintPreviousScreen
protected Background previousScreenOverlayBackground
protected ScreenStateListener screenStateListener
protected ItemStateListener itemStateListener
protected long lastInteractionTime
protected boolean ignoreRepaintRequests
protected boolean isRepaintRequested
protected boolean isInitRequested
protected int triggerReleasedKeyCode
protected long triggerReleasedTime
protected boolean isScrollBackground
protected long lastAnimateTime
protected boolean isAnimated
protected boolean enableScreenChangeAnimation
protected Style landscapeStyle
protected Style portraitStyle
protected final ClippingRegion userEventRepaintRegion
| Constructor Detail |
|---|
public Screen(String title,
boolean createDefaultContainer)
title - the title, or null for no titlecreateDefaultContainer - true when the default container should be created.
public Screen(String title,
boolean createDefaultContainer,
Style style)
title - the title, or null for no titlestyle - the style of this screencreateDefaultContainer - true when the default container should be created.
public Screen(String title,
Style style,
boolean createDefaultContainer)
title - the title, or null for no titlestyle - the style of this screencreateDefaultContainer - true when the default container should be created.| Method Detail |
|---|
protected void init(int width,
int height)
protected void requestInit()
public void requestRepaint()
ignoreRepaintRequests
public void requestRepaint(int x,
int y,
int width,
int height)
x - the x coordinate of the area that needs to be refreshedy - the y coordinate of the area that needs to be refreshedwidth - the width of the area that needs to be refreshedheight - the height of the area that needs to be refreshedignoreRepaintRequestsprotected boolean checkForRequestInit(Item source)
source - the source of the event
protected void calculateContentArea(int x,
int y,
int width,
int height)
x - left start of the content area, might later be adjusted by an external scrollindicatory - top start of the content area, is adjusted by the top margin, title height, subtitle height,
info height and maybe ticker height (when the ticker should be painted at the top).width - width of the content area, might later be adjusted by an external scrollindicatorheight - height of the content area, is adjusted by the title height, subtitle height,
info height and ticker height.
protected void adjustContentArea(int x,
int y,
int width,
int height,
Container cont)
x - the contentX fieldy - the contentY fieldwidth - the contentWidth fieldheight - the contentHeight fieldcont - the container, may be nullsetScreenInitializerListener(ScreenInitializerListener)protected void initContent(Container cont)
cont - the container, may be null if no container is used at all.public void showNotify()
showNotify in class Canvaspublic void hideNotify()
hideNotify in class Canvaspublic void resetStyle(boolean recursive)
recursive - true when all subelements of this screen should reset their style as well.public void setStyle(Style style)
setStyle in interface UiElementstyle - the stylesetStyle(Style, boolean)
public void setStyle(Style style,
boolean resetStyle)
UiElement
setStyle in interface UiElementstyle - the new style for this element.resetStyle - true when style settings should be resetted. This is not the case
when styles are animated, for example.
public void animate(long currentTime,
ClippingRegion repaintRegion)
animate in interface AnimatablecurrentTime - the current time in millisecondsrepaintRegion - the repaint area that needs to be updated when this item is animatedItem.addRelativeToContentRegion(ClippingRegion, int, int, int, int)public boolean animate()
animate(long, ClippingRegion)public void paint(Graphics g)
paint in class Canvasg - the graphics context.paintScreen(Graphics)protected void paintScrollBar(Graphics g)
g - the Graphics contextprotected void paintMenuBar(Graphics g)
g - the graphics contextprotected void paintTitleAndSubtitle(Graphics g)
g - the graphics contextprotected void paintBackgroundAndBorder(Graphics g)
g - the graphics contextprotected boolean canScrollDown()
protected boolean canScrollUp()
protected int getScrollDownBackgroundOffset()
protected int getScrollUpBackgroundOffset()
protected void paintScreen(Graphics g)
g - the graphics on which the screen should be paintedcontentX,
contentY,
contentWidth,
contentHeight,
paintScrollIndicator,
paintScrollIndicatorUp,
paintScrollIndicatorDownpublic String getTitle()
getTitle in interface DisplayablegetTitle in class CanvasDisplayable.setTitle(java.lang.String)public void setTitle(String s)
startApp
returns back to the implementation.
setTitle in interface DisplayablesetTitle in class Canvass - - the new title, or null for no titleDisplayable.getTitle()
public void setTitle(String text,
Style tStyle)
startApp
returns back to the implementation.
text - the new title, or null for no titletStyle - the new style for the title, is ignored when nullpublic void setTitle(Item item)
item - the title Item
public void setTitle(Item item,
Style tStyle)
item - the title ItemtStyle - the new style for the title, is ignored when nullpublic Item getTitleItem()
public void setInfo(String infoText)
infoText - the text which will be shown to the userpublic void setInfo(Item info)
info - the info item which will be shown to the userpublic void setPolishTicker(Ticker ticker)
startApp
returns back to the implementation.
ticker - - the ticker object used on this screen
public void setPolishTicker(Ticker ticker,
Style tickerStyle)
startApp
returns back to the implementation.
ticker - the ticker object used on this screentickerStyle - the style of the tickerpublic Ticker getPolishTicker()
getPolishTicker in interface DisplayablegetPolishTicker in class CanvasDisplayable.setTicker(Ticker)public int getKeyStates()
For example:
// Get the key state and store it
int keyState = getKeyStates();
if ((keyState & UiAccess.LEFT_KEY) != 0) {
positionX--;
}
else if ((keyState & UiAccess.RIGHT_KEY) != 0) {
positionX++;
}
Calling this method has the side effect of clearing any latched state. Another call to getKeyStates immediately after a prior call will therefore report the system's best idea of the current state of the keys, the latched bits having been cleared by the first call.
On J2ME Polish this method is implemented by monitoring key press and release events. Thus the state reported by getKeyStates might lag the actual state of the physical keys since the timeliness of the key information is be subject to the capabilities of each device. Also, some devices may be incapable of detecting simultaneous presses of multiple keys.
This method returns 0 unless the GameCanvas is currently visible as
reported by Displayable.isShown().
Upon becoming visible, a GameCanvas will initially indicate that
all keys are unpressed (0); if a key is held down while the GameCanvas
is being shown, the key must be first released and then pressed in
order for the key press to be reported by the GameCanvas.
UiAccess.UP_PRESSED,
UiAccess.DOWN_PRESSED,
UiAccess.LEFT_PRESSED,
UiAccess.RIGHT_PRESSED,
UiAccess.FIRE_PRESSED,
UiAccess.GAME_A_PRESSED,
UiAccess.GAME_B_PRESSED,
UiAccess.GAME_C_PRESSED,
UiAccess.GAME_D_PRESSEDpublic boolean _keyPressed(int keyCode)
_keyPressed in class CanvaskeyCode - The code of the pressed key
public boolean _keyRepeated(int keyCode)
_keyRepeated in class CanvaskeyCode - the code of the key, which is pressed repeatedly
Canvas.hasRepeatEvents()public boolean _keyReleased(int keyCode)
_keyReleased in class CanvaskeyCode - the code of the key, which has been released
protected abstract String createCssSelector()
protected Item[] getRootItems()
protected boolean handleKeyPressed(int keyCode,
int gameAction)
keyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
protected boolean handleKeyRepeated(int keyCode,
int gameAction)
keyCode - the code of the repeated key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
protected boolean handleKeyReleased(int keyCode,
int gameAction)
keyCode - the code of the released key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
public void setScreenStateListener(ScreenStateListener listener)
listener - the listener that is notified whenever the user changes the internal state of this screen.public void notifyScreenStateChanged()
public void setCommandListener(CommandListener listener)
Canvas
setCommandListener in interface DisplayablesetCommandListener in class Canvaslistener - the listener, use null to remove command listenerpublic void setCommandListener(CommandListener listener)
setCommandListener in class Displayablelistener - the listenerpublic CommandListener getCommandListener()
getCommandListener in class Canvaspublic void addCommand(Command cmd)
addCommand in class Displayablecmd - the commandpublic void addCommand(Command cmd)
DisplayableDisplayable. The
implementation may choose,
for example,
to add the command to any of the available soft buttons or place it
in a menu.
If the added command is already in the screen (tested by comparing the
object references), the method has no effect.
If the Displayable is actually visible on the
display, and this call
affects the set of visible commands, the implementation should update
the display as soon as it is feasible to do so.
addCommand in interface DisplayableaddCommand in class Canvascmd - the command to be added
public void addCommand(Command cmd,
Style commandStyle)
cmd - the commandcommandStyle - the style for the commandpublic CommandItem getCommandItem(Command command)
command - the command
public void removeAllCommands()
public Object[] getCommands()
Canvas
getCommands in class Canvas
public void addSubCommand(Command child,
Command parent)
child - the child commandparent - the parent command
public void addSubCommand(Command child,
Command parent,
Style commandStyle)
child - the child commandparent - the parent commandcommandStyle - the style for the command
IllegalStateException - when the parent command has not been added beforepublic void removeCommand(Command cmd)
DisplayableDisplayable.
If the command is not in the Displayable
(tested by comparing the
object references), the method has no effect.
If the Displayable is actually visible on the
display, and this call
affects the set of visible commands, the implementation should update
the display as soon as it is feasible to do so.
If cmd is null, this method
does nothing.
removeCommand in interface DisplayableremoveCommand in class Canvascmd - the command to be removed
public void removeSubCommand(Command childCommand,
Command parentCommand)
childCommand - the command to removeparentCommand - the parent command of the command to remove.
IllegalStateException - when the command has not been added beforepublic void addCommandsLayer(Command[] commands)
commands - public void removeCommandsLayer()
protected void setItemCommands(ArrayList commandsList,
Item item)
commandsList - the commands that are addeditem - the item which contains the specified commandsremoveItemCommands(Item)public void notifyDefaultCommand(Command cmd)
cmd - the new default commandprotected Command getDefaultCommand(Item item)
item - the item
protected void clearItemCommands()
protected void removeItemCommands(Item item)
item - the item which has at least one commandsetItemCommands(ArrayList,Item)protected void callCommandListener(Command cmd)
cmd - the command wich should be issued to the listenerpublic int getAvailableHeight()
public void commandAction(Command command,
Displayable screen)
public boolean _pointerPressed(int x,
int y)
Canvas
_pointerPressed in class Canvasx - - the horizontal location where the pointer was pressed (relative to the Canvas)y - - the vertical location where the pointer was pressed (relative to the Canvas)
public boolean _pointerDragged(int x,
int y)
Canvas
_pointerDragged in class Canvasx - the horizontal location where the pointer was dragged (relative to the Canvas)y - the vertical location where the pointer was dragged (relative to the Canvas)
public boolean _pointerReleased(int x,
int y)
Canvas
_pointerReleased in class Canvasx - the horizontal location where the pointer was released (relative to the Canvas)y - the vertical location where the pointer was released (relative to the Canvas)
protected boolean handlePointerPressed(int x,
int y)
x - the absolute x position of the pointer pressingy - the absolute y position of the pointer pressing
protected boolean handlePointerReleased(int x,
int y)
x - the absolute x position of the pointer releasey - the absolute y position of the pointer release
protected boolean handlePointerReleasedOutsideScreenArea(int x,
int y)
x - the absolute x position of the pointer release (outside of this screen's area)y - the absolute y position of the pointer release (outside of this screen's area)
protected boolean handlePointerDragged(int x,
int y,
ClippingRegion repaintRegion)
x - the absolute x position of the pointer movementy - the absolute y position of the pointer movement
protected boolean handlePointerDragged(int x,
int y)
x - the absolute x position of the pointer movementy - the absolute y position of the pointer movement
handlePointerDragged(int, int, ClippingRegion)
public boolean handlePointerTouchDown(int x,
int y)
handlePointerTouchDown in class Canvasx - the absolute horizontal pixel position of the touch eventy - the absolute vertical pixel position of the touch event
public boolean handlePointerTouchUp(int x,
int y)
handlePointerTouchUp in class Canvasx - the absolute horizontal pixel position of the touch eventy - the absolute vertical pixel position of the touch event
protected boolean handleCommand(Command cmd)
cmd - the command
protected boolean handleCommand(Command cmd)
cmd - the command
public void setFullScreenMode(boolean enable)
CanvasCanvas is in full-screen mode
or in normal mode.
setFullScreenMode in class Canvasenable - true if the Canvas is to be in full screen mode, false otherwise
public void sizeChanged(int width,
int height)
sizeChanged in interface DisplayablesizeChanged in class Canvaswidth - the new width of the screenheight - the new height of the screenin class Displayablepublic int getScreenHeight()
public void focus(Item item)
item - the item which is already shown on this screen.
public void focus(Item item,
boolean force)
item - the item which is already shown on this screen.force - true when the item should be focused even when it is inactive (like a label for example)public void focus(int index)
index - the index of the item which is already shown on this screen.
public void focus(int index,
boolean force)
index - the index of the item which is already shown on this screen.force - true when the item should be focused even when it is inactive (like a label for example)
public void focus(int index,
Item item,
boolean force)
index - the index of the item which is already shown on this screen.item - the item which is already shown on this screen.force - true when the item should be focused even when it is inactive (like a label for example)protected void setSubTitle(Item subTitle)
subTitle - the new subtitle element.getSubTitleItem()public Item getCurrentItem()
public int getCurrentIndex()
public boolean isMenuOpened()
public void closeMenu()
public void releaseResources()
public void destroy()
public void scrollRelative(int amount)
amount - the number of pixels, positive values scroll upwards, negative scroll downwardssetScrollYOffset(int, boolean)public void scrollToBottom()
public void setScreenData(Object data)
data - the screen specific dataUiAccess.setData(Screen, Object),
UiAccess.getData(Screen)public Object getScreenData()
UiAccess.setData(Screen, Object),
UiAccess.getData(Screen)
public Item getItemAt(int x,
int y)
x - horizontal position in pixelsy - vertical position in pixels
public Style getScreenStyle()
public void setItemStateListener(ItemStateListener iListener)
ItemStateListener for the Screen,
replacing any previous ItemStateListener.
If
iListener is null, simply
removes the previous ItemStateListener.
iListener - the new listener, or null to remove itpublic void setItemStateListener(ItemStateListener iListener)
ItemStateListener for the Screen,
replacing any previous ItemStateListener.
If
iListener is null, simply
removes the previous ItemStateListener.
iListener - the new listener, or null to remove itprotected void notifyStateListener(Item item)
item - the item which contents have been edited.protected boolean isKeyboardAccessible()
protected int getScrollBarWidth()
public int getScreenContentHeight()
for retrieving the screen's actual content heightpublic int getScreenContentWidth()
public int getScreenContentX()
public int getScreenContentY()
public int getScreenFullHeight()
public int getScreenFullWidth()
public void setMenuItemStyle(Style menuItemStyle)
menuItemStyle - the style for menu itemspublic MenuBar getMenuBar()
public void setMenuBarStyle(Style menuBarStyle)
menuBarStyle - public int getScrollYOffset()
setScrollYOffset(int, boolean),
getScrollHeight()public int getScrollHeight()
getScrollYOffset()
public void setScrollYOffset(int offset,
boolean smooth)
offset - either the new offsetsmooth - scroll to this new offset smooth if allowedgetScrollYOffset()public boolean isActive()
public boolean isInteracted(long timespan)
timespan - the timespan
public void setScreenOrientation(int degrees)
degrees - the screen orientation in degrees: 90, 180, 270 or 0Display.setScreenOrientation(int)
public boolean isGameActionFire(int keyCode,
int gameAction)
keyCode - the key codegameAction - the game action
public final boolean isSoftKeyLeft(int keyCode,
int gameAction)
keyCode - the key codegameAction - the associated game action
public final boolean isSoftKeyRight(int keyCode,
int gameAction)
keyCode - the key codegameAction - the associated game action
public final boolean isSoftKeyMiddle(int keyCode,
int gameAction)
keyCode - the key codegameAction - the associated game action
public boolean isSoftKey(int keyCode)
keyCode - the keycode
public boolean isSoftKey(int keyCode,
int gameAction)
keyCode - the key codegameAction - the associated game action
protected void notifyFocusSet(Item item)
item - the item that has been focusedprotected boolean isNativeUiShownFor(Item item)
item - the item that has been focusedpublic void addPermanentNativeItem(Item item)
item - the item with a native component which needs to be displayed all the time.public void removePermanentNativeItem(Item item)
item - the item with a native component which was displayed all the time.public void addRepaintArea(ClippingRegion repaintArea)
addRepaintArea in interface UiElementrepaintArea - the clipping rectangle to which the repaint area should be added
public void addRelativeToContentRegion(ClippingRegion repaintRegion,
int x,
int y,
int width,
int height)
addRelativeToContentRegion in interface UiElementrepaintRegion - the clipping regionx - horizontal start relative to this item's content positiony - vertical start relative to this item's content positionwidth - widthheight - heightgetScreenContentWidth(),
getScreenContentWidth()public Style getStyle()
UiElement
getStyle in interface UiElement
public void fireEvent(String eventName,
Object eventData)
eventName - the name of the eventeventData - the associated data of the eventfireEventForTitleAndMenubar(String, Object)
public void fireEventForTitleAndMenubar(String eventName,
Object eventData)
eventName - the name of the eventeventData - the associated data of the eventfireEvent(String, Object)public Object getPaintLock()
public Container getRootContainer()
public void setRootContainer(Container cont)
cont - the root containerpublic int getTitleHeight()
public void setLastInteractionTime(long currentTimeMillis)
currentTimeMillis - the time for the last interaction, typically System.currentTimeMillis()public void setUiEventListener(UiEventListener listener)
listener - the listener, use null to remove a listenerpublic UiEventListener getUiEventListener()
public Item getSubTitleItem()
setSubTitle(Item)public void setScreenInitializerListener(ScreenInitializerListener listener)
listener - the screen initialization listenergetScreenInitializerListener()public ScreenInitializerListener getScreenInitializerListener()
setScreenInitializerListener(ScreenInitializerListener)public void setNativeScreen(NativeScreen nativeScreen)
nativeScreen - the native implementationpublic NativeScreen getNativeScreen()
public void addCommandSeparator(int priority)
priority - the priority of the sepator, same as for Command
public void addCommandSeparator(int priority,
Style separatorStyle)
priority - the priority of the sepator, same as for CommandseparatorStyle - the style of the separatorpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||