|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.ui.Item
de.enough.polish.ui.MenuBar
public class MenuBar
Provides a more powerful alternative to the build-in menu bar of the Screen-class.
Copyright (c) Enough Software 2005 - 2008
history
24-Jan-2005 - rob creation
| Field Summary | |
|---|---|
protected java.util.Hashtable |
allCommands
|
protected javax.microedition.lcdui.Image |
cancelImage
|
protected boolean |
canScrollDownwards
|
protected boolean |
canScrollUpwards
|
protected ArrayList |
commandsList
|
protected boolean |
isOpened
|
protected boolean |
isOrientationVertical
|
protected boolean |
isSoftKeyPressed
|
protected Style |
menuItemStyle
|
protected javax.microedition.lcdui.Image |
optionsImage
|
protected Background |
overlayBackground
|
protected boolean |
paintScrollIndicator
|
protected javax.microedition.lcdui.Image |
selectImage
|
protected boolean |
showImageAndText
|
protected static javax.microedition.lcdui.Image |
windowsSipImage
|
protected int |
windowsSipX
|
protected int |
windowsSipY
|
| Constructor Summary | |
|---|---|
MenuBar(Screen screen)
Creates a new menu bar |
|
MenuBar(Screen screen,
Style style)
Creates a new menu bar |
|
| Method Summary | |
|---|---|
void |
addCommand(javax.microedition.lcdui.Command cmd)
Adds a context sensitive Command to the item. |
void |
addCommand(javax.microedition.lcdui.Command cmd,
Style commandStyle)
Adds a context sensitive Command to the item. |
void |
addSubCommand(javax.microedition.lcdui.Command childCommand,
javax.microedition.lcdui.Command parentCommand)
Adds the given command as a subcommand to the specified parent command. |
void |
addSubCommand(javax.microedition.lcdui.Command childCommand,
javax.microedition.lcdui.Command parentCommand,
Style commandStyle)
Adds the given command as a subcommand to the specified parent command. |
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this item. |
protected java.lang.String |
createCssSelector()
Retrieves the CSS selector for this item. |
CommandItem |
getCommandItem(javax.microedition.lcdui.Command command)
Retrieves the CommandItem used for rendering the specified command. |
Container |
getCommandsContainer()
|
Item |
getItemAt(int relX,
int relY)
Determines if this item or one of it's children is within the specified point. |
Style |
getMenuItemStyle()
|
int |
getSpaceBottom(int width,
int height)
|
int |
getSpaceLeft(int width,
int height)
|
int |
getSpaceRight(int width,
int height)
|
int |
getSpaceTop(int width,
int height)
|
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 |
handlePointerPressed(int relX,
int relY)
Handles the event when a pointer has been pressed at the specified position. |
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 lineWidth)
Initialises this item. |
boolean |
isOrientationVertical()
|
static void |
notifyKeyPressed()
Commits different actions depending on the device using a menubar |
protected void |
paintBackgroundAndBorder(int x,
int y,
int width,
int height,
javax.microedition.lcdui.Graphics g)
Paints the background and border of this item. |
protected void |
paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
Paints the content of this item. |
void |
removeAllCommands()
Removes all commands from this MenuBar. |
void |
removeCommand(javax.microedition.lcdui.Command cmd)
Removes the context sensitive command from item. |
void |
setMenuItemStyle(Style menuItemStyle)
|
protected void |
setOpen(boolean open)
Used to toggle the opened state of the menu bar |
void |
setOrientationVertical(boolean isVertical)
|
void |
setStyle(Style style)
Sets the style of this item. |
int |
size()
Retrieves the number of commands in this menubar. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final ArrayList commandsList
protected boolean isOpened
protected boolean isSoftKeyPressed
protected boolean canScrollDownwards
protected boolean canScrollUpwards
protected boolean paintScrollIndicator
protected javax.microedition.lcdui.Image optionsImage
protected boolean showImageAndText
protected javax.microedition.lcdui.Image selectImage
protected javax.microedition.lcdui.Image cancelImage
protected Background overlayBackground
protected final java.util.Hashtable allCommands
protected boolean isOrientationVertical
protected static javax.microedition.lcdui.Image windowsSipImage
protected int windowsSipX
protected int windowsSipY
protected Style menuItemStyle
| Constructor Detail |
|---|
public MenuBar(Screen screen)
screen - the parent screen
public MenuBar(Screen screen,
Style style)
screen - the parent screenstyle - the style of this menu-bar| Method Detail |
|---|
public void addCommand(javax.microedition.lcdui.Command cmd)
ItemCommand to the item.
The semantic type of
Command should be ITEM. The implementation
will present the command
only when the item is active, for example, highlighted.
If the added command is already in the item (tested by comparing the object references), the method has no effect. If the item 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.
It is illegal to call this method if this Item
is contained within an Alert.
addCommand in class Itemcmd - the command to be added
public void addCommand(javax.microedition.lcdui.Command cmd,
Style commandStyle)
ItemCommand to the item.
The semantic type of
Command should be ITEM. The implementation
will present the command
only when the item is active, for example, highlighted.
If the added command is already in the item (tested by comparing the object references), the method has no effect. If the item 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.
It is illegal to call this method if this Item
is contained within an Alert.
addCommand in class Itemcmd - the command to be addedcommandStyle - the style of the command, for the moment this is ignoredpublic void removeCommand(javax.microedition.lcdui.Command cmd)
ItemItem (tested by comparing the object references),
the method has
no effect. If the Item 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 the command to be removed happens to be the default command,
the command is removed and the default command on this Item is
set to null.
The following code:
// Command c is the default command on Item item
item.removeCommand(c);
is equivalent to the following code:
// Command c is the default command on Item item
item.setDefaultCommand(null);
item.removeCommand(c);
removeCommand in class Itemcmd - - the command to be removed
protected void initContent(int firstLineWidth,
int lineWidth)
Item
initContent in class ItemfirstLineWidth - the maximum width of the first linelineWidth - the maximum width of any following linesItem.contentWidth,
Item.contentHeight,
Item.preferredWidth,
Item.preferredHeight
protected void paintBackgroundAndBorder(int x,
int y,
int width,
int height,
javax.microedition.lcdui.Graphics g)
Item
paintBackgroundAndBorder in class Itemx - the horizontal start positiony - the vertical start positionwidth - the widthheight - the heightg - graphics contextItem.paintBackground(int, int, int, int, Graphics),
Item.paintBorder(int, int, int, int, Graphics)
protected void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
Item
paintContent in class Itemx - 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.protected java.lang.String createCssSelector()
Item
createCssSelector in class Itemprotected void setOpen(boolean open)
open - true when the menu should be opened
protected boolean handleKeyPressed(int keyCode,
int gameAction)
Item
handleKeyPressed in class ItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
public static void notifyKeyPressed()
protected boolean handleKeyReleased(int keyCode,
int gameAction)
Item
handleKeyReleased in class ItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
Item.handleKeyPressed(int, int)
protected boolean handlePointerPressed(int relX,
int relY)
Item
handlePointerPressed in class ItemrelX - 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
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)
protected boolean handlePointerReleased(int relX,
int relY)
Item
handlePointerReleased in class ItemrelX - 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
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)public void setStyle(Style style)
Item
setStyle in class Itemstyle - the new style for this item.
public void animate(long currentTime,
ClippingRegion repaintRegion)
Item
animate in class ItemcurrentTime - 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 void addSubCommand(javax.microedition.lcdui.Command childCommand,
javax.microedition.lcdui.Command parentCommand)
parentCommand - the parent commandchildCommand - the child command
java.lang.IllegalStateException - when the parent command has not be added beforeaddSubCommand(Command, Command, Style)
public void addSubCommand(javax.microedition.lcdui.Command childCommand,
javax.microedition.lcdui.Command parentCommand,
Style commandStyle)
parentCommand - the parent commandchildCommand - the child commandcommandStyle - the style for the command
java.lang.IllegalStateException - when the parent command has not be added beforeaddSubCommand(Command, Command)public void removeAllCommands()
public CommandItem getCommandItem(javax.microedition.lcdui.Command command)
command - the command
public Item getItemAt(int relX,
int relY)
Item
getItemAt in class ItemrelX - the x position of the point relative to this item's left positionrelY - the y position of the point relative to this item's top position
public boolean isOrientationVertical()
public void setOrientationVertical(boolean isVertical)
public int getSpaceTop(int width,
int height)
public int getSpaceLeft(int width,
int height)
public int getSpaceRight(int width,
int height)
public int getSpaceBottom(int width,
int height)
public int size()
public Style getMenuItemStyle()
public void setMenuItemStyle(Style menuItemStyle)
public Container getCommandsContainer()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||