de.enough.polish.ui
Class FramedForm

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by de.enough.polish.ui.Screen
              extended by de.enough.polish.ui.Form
                  extended by de.enough.polish.ui.FramedForm
All Implemented Interfaces:
AccessibleCanvas

public class FramedForm
extends Form

Allows to split up a form into several frames.

The main frame is used for the normal content. Additional frames can be used for keeping GUI elements always in the same position, regardless whether the form is scrolled.

Copyright (c) Enough Software 2005 - 2008

 history
        14-Apr-2005 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
protected  Container bottomFrame
           
protected  Container currentlyActiveContainer
           
protected  Container leftFrame
           
protected  Container rightFrame
           
protected  Container topFrame
           
 
Fields inherited from class de.enough.polish.ui.Screen
background, border, container, contentHeight, contentWidth, contentX, contentY, cssSelector, fullScreenHeight, ignoreRepaintRequests, infoHeight, isInitRequested, isRepaintRequested, isScrollBackground, isSetFullScreenCalled, itemStateListener, keyPressedProcessed, keyReleasedProcessed, lastInteractionTime, lastTriggeredCommand, menuBarHeight, originalScreenHeight, paintScrollBarOnRightSide, screenHeight, screenOrientationDegrees, screenStateListener, screenWidth, scrollBar, scrollBarVisible, style, subTitleHeight, title, titleHeight, triggerReleasedKeyCode, triggerReleasedTime
 
Fields inherited from class javax.microedition.lcdui.Canvas
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
FramedForm(java.lang.String title)
          Creates a new FramedForm
FramedForm(java.lang.String title, Style style)
          Creates a new FramedForm
 
Method Summary
 void animate(long currentTime, ClippingRegion repaintRegion)
          Animates this screen.
 void append(int frameOrientation, javax.microedition.lcdui.Item item)
           
 void append(int frameOrientation, Item item)
          Adds the given item to the specifid frame.
 void append(int frameOrientation, Item item, Style itemStyle)
          Adds the given item to the specifid frame.
 int append(javax.microedition.lcdui.Item item)
          Adds an Item into the Form.
protected  void calculateContentArea(int x, int y, int width, int height)
          Calculates and sets the content area for this screen.
protected  boolean checkForRequestInit(Item source)
          Checks if this screen's content area should be refreshed when the specified item has changed it's size.
 void delete(int frameOrientation, int itemNum)
          Removes the given item from the specifid frame.
 void deleteAll()
          Deletes all the items from all frames of this FramedForm, leaving it with zero items.
 void deleteAll(int frameOrientation)
          Removes all items from the specifid frame.
 boolean deleteFrame(int frameOrientation)
          Deletes a complete frame.
 Item getCurrentItem()
          Retrieves the currently focused item.
protected  Item[] getRootItems()
          Retrieves all root-items of this screen.
protected  boolean handleCommand(javax.microedition.lcdui.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 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  void paintScreen(javax.microedition.lcdui.Graphics g)
          Paints the screen.
protected  void requestInit()
          Reinitializes this screen's content area.
 void set(int frameIndex, int itemNumber, javax.microedition.lcdui.Item item)
           
 void set(int frameOrientation, int itemNum, Item item)
          Updates an existing item in the specified frame
 void set(int itemNumber, javax.microedition.lcdui.Item item)
           
 void setActiveFrame(int frameOrientation)
          Focuses the specified frame.
 void setItemStateListener(javax.microedition.lcdui.ItemStateListener listener)
          Sets the ItemStateListener for the Screen, replacing any previous ItemStateListener.
 void setStyle(Style style)
          Sets the style of this screen.
 int size(int frameOrientation)
          Retrieves the size of the specified frame.
 
Methods inherited from class de.enough.polish.ui.Form
append, append, append, append, append, append, createCssSelector, delete, get, insert, insert, set, set, size
 
Methods inherited from class de.enough.polish.ui.Screen
addCommand, addCommand, addSubCommand, addSubCommand, animate, callCommandListener, closeMenu, commandAction, focus, focus, focus, focus, focus, getAvailableHeight, getCommandItem, getCommandListener, getCurrentIndex, getGameAction, getItemAt, getMenuBar, getPolishTicker, getScreenContentHeight, getScreenContentWidth, getScreenData, getScreenFullHeight, getScreenFullWidth, getScreenHeight, getScreenStyle, getScrollBarWidth, getScrollYOffset, getTitle, hideNotify, isGameActionFire, isKeyboardAccessible, isMenuOpened, isShown, isSoftKey, isSoftKey, isSoftKeyLeft, isSoftKeyMiddle, isSoftKeyRight, keyPressed, keyReleased, keyRepeated, notifyScreenStateChanged, notifyStateListener, paint, pointerDragged, pointerPressed, pointerReleased, releaseResources, removeAllCommands, removeCommand, removeItemCommands, requestRepaint, requestRepaint, scrollRelative, setCommandListener, setFullScreenMode, setInfo, setItemCommands, setItemStateListener, setMenuBarStyle, setMenuItemStyle, setPolishTicker, setPolishTicker, setScreenData, setScreenOrientation, setScreenStateListener, setScrollYOffset, setSubTitle, setTitle, setTitle, setTitle, showNotify, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Canvas
getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, repaint, repaint, serviceRepaints
 
Methods inherited from class javax.microedition.lcdui.Displayable
getHeight, getTicker, getWidth, setTicker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftFrame

protected Container leftFrame

rightFrame

protected Container rightFrame

topFrame

protected Container topFrame

bottomFrame

protected Container bottomFrame

currentlyActiveContainer

protected Container currentlyActiveContainer
Constructor Detail

FramedForm

public FramedForm(java.lang.String title)
Creates a new FramedForm

Parameters:
title - the title of this form

FramedForm

public FramedForm(java.lang.String title,
                  Style style)
Creates a new FramedForm

Parameters:
title - the title of this form
style - the style of this form, usually set with a #style directive
Method Detail

deleteAll

public void deleteAll()
Deletes all the items from all frames of this FramedForm, leaving it with zero items. This method does nothing if the FramedForm is already empty.

Overrides:
deleteAll in class Form
Since:
MIDP 2.0

deleteAll

public void deleteAll(int frameOrientation)
Removes all items from the specifid frame.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT. Use -1 for the content frame.

append

public int append(javax.microedition.lcdui.Item item)
Description copied from class: Form
Adds an Item into the Form. The newly added Item becomes the last Item in the Form, and the size of the Form grows by one. This method is only provided for being able to add native items as well as custom items to a J2ME Polish form within an IDE.

Overrides:
append in class Form
Parameters:
item - the Item to be added.
Returns:
the assigned index of the Item

set

public void set(int frameIndex,
                int itemNumber,
                javax.microedition.lcdui.Item item)

set

public void set(int itemNumber,
                javax.microedition.lcdui.Item item)

append

public void append(int frameOrientation,
                   javax.microedition.lcdui.Item item)

setItemStateListener

public void setItemStateListener(javax.microedition.lcdui.ItemStateListener listener)
Description copied from class: Screen
Sets the ItemStateListener for the Screen, replacing any previous ItemStateListener. If iListener is null, simply removes the previous ItemStateListener.

Overrides:
setItemStateListener in class Screen
Parameters:
listener - the new listener, or null to remove it

append

public void append(int frameOrientation,
                   Item item)
Adds the given item to the specifid frame.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT
item - the item

set

public void set(int frameOrientation,
                int itemNum,
                Item item)
Updates an existing item in the specified frame

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT
itemNum - the index of the previous item
item - the new item

delete

public void delete(int frameOrientation,
                   int itemNum)
Removes the given item from the specifid frame. The itemNum parameter must be within the range [0..size()-1], inclusive.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT
itemNum - the index of the item

size

public int size(int frameOrientation)
Retrieves the size of the specified frame.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT
Returns:
the size of the frame, -1 when the frame does not exist

deleteFrame

public boolean deleteFrame(int frameOrientation)
Deletes a complete frame.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT
Returns:
true when the frame could be deleted

append

public void append(int frameOrientation,
                   Item item,
                   Style itemStyle)
Adds the given item to the specifid frame.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT or Graphics.RIGHT
item - the item
itemStyle - the style for that item, is ignored when null

calculateContentArea

protected void calculateContentArea(int x,
                                    int y,
                                    int width,
                                    int height)
Description copied from class: Screen
Calculates and sets the content area for this screen. Usually no items are painted outside of the specified area. This method knows about the title, subtitle, infoarea and ticker and adjusts the content area accordingly

Overrides:
calculateContentArea in class Screen
Parameters:
x - left start of the content area, might later be adjusted by an external scrollindicator
y - 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 scrollindicator
height - height of the content area, is adjusted by the title height, subtitle height, info height and ticker height.

checkForRequestInit

protected boolean checkForRequestInit(Item source)
Description copied from class: Screen
Checks if this screen's content area should be refreshed when the specified item has changed it's size.

Overrides:
checkForRequestInit in class Screen
Parameters:
source - the source of the event
Returns:
true when the source is a directly visible element (default container or title, for example)

requestInit

protected void requestInit()
Description copied from class: Screen
Reinitializes this screen's content area. This call returns immediately and results in a run of the initialization at some later point in some screen subclasses or when this screen has a shrink layout.

Overrides:
requestInit in class Screen

paintScreen

protected void paintScreen(javax.microedition.lcdui.Graphics g)
Description copied from class: Screen
Paints the screen. This method also needs to set the protected variables paintScrollIndicator, paintScrollIndicatorUp and paintScrollIndicatorDown.

Overrides:
paintScreen in class Screen
Parameters:
g - the graphics on which the screen should be painted
See Also:
Screen.contentX, Screen.contentY, Screen.contentWidth, Screen.contentHeight, Screen.paintScrollIndicator, Screen.paintScrollIndicatorUp, Screen.paintScrollIndicatorDown

handleKeyPressed

protected boolean handleKeyPressed(int keyCode,
                                   int gameAction)
Description copied from class: Screen
Handles the key-pressed event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed.

Overrides:
handleKeyPressed in class Screen
Parameters:
keyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key-event was processed

handleKeyReleased

protected boolean handleKeyReleased(int keyCode,
                                    int gameAction)
Description copied from class: Screen
Handles the key-released event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed.

Overrides:
handleKeyReleased in class Screen
Parameters:
keyCode - the code of the released key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key-event was processed

handleKeyRepeated

protected boolean handleKeyRepeated(int keyCode,
                                    int gameAction)
Description copied from class: Screen
Handles the key-repeated event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed.

Overrides:
handleKeyRepeated in class Screen
Parameters:
keyCode - the code of the repeated key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key-event was processed

handleCommand

protected boolean handleCommand(javax.microedition.lcdui.Command cmd)
Description copied from class: Screen
Tries to handle the specified command. The default implementation forwards the call to the container. When the container is unable to process the command, it will be forwarded to an external command listener that has been set using setCommandListener(..)

Overrides:
handleCommand in class Screen
Parameters:
cmd - the command
Returns:
true when the command has been handled by this screen

getCurrentItem

public Item getCurrentItem()
Retrieves the currently focused item.

Overrides:
getCurrentItem in class Screen
Returns:
the currently focused item, null when none is focused.

setActiveFrame

public void setActiveFrame(int frameOrientation)
Focuses the specified frame.

Parameters:
frameOrientation - either Graphics.TOP, Graphics.BOTTOM, Graphics.LEFT, Graphics.RIGHT or -1 for the main/scrollable frame

handlePointerPressed

protected boolean handlePointerPressed(int x,
                                       int y)
Description copied from class: Screen
Handles the pressing of a pointer. This method should be overwritten only when the polish.hasPointerEvents preprocessing symbol is defined. When the screen could handle the pointer pressing, it needs to return true. The default implementation returns the result of calling the container's handlePointerPressed-method

Overrides:
handlePointerPressed in class Screen
Parameters:
x - the absolute x position of the pointer pressing
y - the absolute y position of the pointer pressing
Returns:
true when the pressing of the pointer was actually handled by this item.

handlePointerReleased

protected boolean handlePointerReleased(int x,
                                        int y)
Description copied from class: Screen
Handles the release of a pointer. This method should be overwritten only when the polish.hasPointerEvents preprocessing symbol is defined. When the screen could handle the pointer release, it needs to return true. The default implementation returns the result of calling the container's handlePointerReleased-method

Overrides:
handlePointerReleased in class Screen
Parameters:
x - the absolute x position of the pointer pressing
y - the absolute y position of the pointer pressing
Returns:
true when the pressing of the pointer was actually handled by this item.

animate

public void animate(long currentTime,
                    ClippingRegion repaintRegion)
Description copied from class: Screen
Animates this screen. Subclasses can override this method to create animations. All embedded items are also animated.

Overrides:
animate in class Screen
Parameters:
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated

getRootItems

protected Item[] getRootItems()
Description copied from class: Screen
Retrieves all root-items of this screen. The root items are those in first hierarchy, in a Form this is a Container for example. The default implementation does return an empty array, since apart from the container no additional items are used. Subclasses which use more root items than the container needs to override this method.

Overrides:
getRootItems in class Screen
Returns:
the root items an array, the array can be empty but not null.

setStyle

public void setStyle(Style style)
Description copied from class: Screen
Sets the style of this screen.

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