Class Menu

java.lang.Object
  extended by greenfoot.Actor
      extended by MenuElement
          extended by Menu

public class Menu
extends MenuElement

Menu view and view controller; extends MenuElement.

Since:
2012-04-19
Version:
v0.1
Author:
Felix Mo

Field Summary
 
Fields inherited from class MenuElement
active, FONT, frame, image, index, title
 
Constructor Summary
Menu(MenuBarItem menuBarItem, java.util.ArrayList<java.lang.String> items)
          Constructs a Menu.
 
Method Summary
 void act()
          The procedure containing the menu's behaviour.
protected  void addedToWorld(greenfoot.World world)
          Draws, and activates, the menu when it is added to the world.
 void didHoverOverMenuItem(MenuItem menuItem)
          Menu behaviour for hovering over a menu item.
 java.util.ArrayList<MenuItem> menuItems()
          Returns the MenuItems that belongs to the menu.
 void setActive(boolean state)
          Sets the state of the menu.
 void setItems(java.util.ArrayList<java.lang.String> items)
          Sets the items of the menu.
 
Methods inherited from class MenuElement
active, frame, index, setFrame
 
Methods inherited from class greenfoot.Actor
getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, move, setImage, setImage, setLocation, setRotation, turn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Menu

public Menu(MenuBarItem menuBarItem,
            java.util.ArrayList<java.lang.String> items)
Constructs a Menu.

Parameters:
menuBarItem - The menu bar item that the menu belongs to.
items - The items in the menu (as Strings)
Method Detail

act

public void act()
The procedure containing the menu's behaviour. The menu will highlight menu items as the cursor hovers over them.

Overrides:
act in class greenfoot.Actor

addedToWorld

protected void addedToWorld(greenfoot.World world)
Draws, and activates, the menu when it is added to the world.

Overrides:
addedToWorld in class greenfoot.Actor
Parameters:
World - The World the object was added to.

didHoverOverMenuItem

public void didHoverOverMenuItem(MenuItem menuItem)
Menu behaviour for hovering over a menu item.

Parameters:
menuItem - The menu item that the cursor is currently hovering over.

menuItems

public java.util.ArrayList<MenuItem> menuItems()
Returns the MenuItems that belongs to the menu.

Returns:
The MenuItems belonging to the menu.

setActive

public void setActive(boolean state)
Sets the state of the menu.

Overrides:
setActive in class MenuElement
Parameters:
The - new state of the menu.

setItems

public void setItems(java.util.ArrayList<java.lang.String> items)
Sets the items of the menu.

Parameters:
items - The titles (as Strings) of the menu's items.