ewe.ui
Class MenuItem

java.lang.Object
  extended byewe.ui.MenuItem

public class MenuItem
extends Object


Field Summary
 String action
          The action String for the MenuItem.
static int Checked
          A MenuItem modifier.
 Object data
          Optional data to associate with the MenuItem.
static int Disabled
          A MenuItem modifier.
 int hotkey
          An optional hotkey for the MenuItem.
 int id
          An optional ID for the item.
 IImage image
          If this is not null then this will be displayed instead of the label.
 int indentLevel
          This is -1 by default, which means that the index level should be calculated automatically.
 String label
          The displayed label for the MenuItem.
 int modifiers
          Modifiers for the MenuItem.
static int Selected
          A MenuItem modifier.
static int Separator
          A MenuItem modifier.
 Menu subMenu
          This can be set to be a sub-menu for this item.
 
Constructor Summary
MenuItem()
           
MenuItem(String text)
          This creates the menu item with the action and label being equal to text.
MenuItem(String text, IImage image)
          This creates the menu item with the action and label being equal to text.
MenuItem(String text, int mods, Menu sub)
          This creates the menu item with the action and label being equal to text.
MenuItem(String label, String action)
           
MenuItem(String text, String imageName, Object maskOrColor)
          This creates a MenuItem using the ImageCache to load an icon for the item to be associated with the text label.
 
Method Summary
 boolean equals(Object what)
          Returns if this object is considered equal to the other object.
 MenuItem iconize(String text, IImage image, boolean leaveText)
          Set the label, hotkey and image for the item.
 MenuItem set(String labelAndAction)
          Set the action, label and hotkey of the MenuItem to be the specified parameter, allowing the parameter to have a Hot Key encoded in it.
 MenuItem setText(String labelAndAction)
          Set the action and label of the MenuItem to be the specified parameter, assuming that the parameter is pure text only with no Hot Key encoded in it.
 String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode
 

Field Detail

label

public String label
The displayed label for the MenuItem.


action

public String action
The action String for the MenuItem. Unless you set it to be something different it is usually set to be the same as the label.


modifiers

public int modifiers
Modifiers for the MenuItem.


subMenu

public Menu subMenu
This can be set to be a sub-menu for this item.


id

public int id
An optional ID for the item.


image

public IImage image
If this is not null then this will be displayed instead of the label. If you want to display text with an icon, use an IconAndText image.


hotkey

public int hotkey
An optional hotkey for the MenuItem.


data

public Object data
Optional data to associate with the MenuItem.


indentLevel

public int indentLevel
This is -1 by default, which means that the index level should be calculated automatically. In order for this to have any effect the ChoiceControl using it must have indentDropItems true.


Disabled

public static int Disabled
A MenuItem modifier.


Separator

public static int Separator
A MenuItem modifier.


Checked

public static int Checked
A MenuItem modifier.


Selected

public static int Selected
A MenuItem modifier.

Constructor Detail

MenuItem

public MenuItem()

MenuItem

public MenuItem(String text,
                int mods,
                Menu sub)
This creates the menu item with the action and label being equal to text. The text may have a hot key encoded within it.

Parameters:
text - The action and label for the menu item. This may have a hotkey embedded in it.
mods - Optional modifiers for the item.
sub - An optional sub-menu for the item.

MenuItem

public MenuItem(String text)
This creates the menu item with the action and label being equal to text.

Parameters:
text - The action and label for the menu item. This may have a hotkey embedded in it.

MenuItem

public MenuItem(String text,
                IImage image)
This creates the menu item with the action and label being equal to text. However the label will not be displayed if the image is not null. Use an IconAndText image to display an icon along with text.

Parameters:
text - The action and label for the menu item. This may have a hotkey embedded in it.
image - An image to use as the display for the item.

MenuItem

public MenuItem(String text,
                String imageName,
                Object maskOrColor)
This creates a MenuItem using the ImageCache to load an icon for the item to be associated with the text label.

Parameters:
text - The action and label for the menu item. This may have a hotkey embedded in it.
imageName - The name of an image.
maskOrColor - An optional mask or transparent color for the image.

MenuItem

public MenuItem(String label,
                String action)
Method Detail

set

public MenuItem set(String labelAndAction)
Set the action, label and hotkey of the MenuItem to be the specified parameter, allowing the parameter to have a Hot Key encoded in it.

Parameters:
labelAndAction - The action and label for the menu item. This may have a hotkey embedded in it.
Returns:
this MenuItem

setText

public MenuItem setText(String labelAndAction)
Set the action and label of the MenuItem to be the specified parameter, assuming that the parameter is pure text only with no Hot Key encoded in it.

Parameters:
labelAndAction - The action and label for the menu item. This may have a hotkey embedded in it.
Returns:
this MenuItem

iconize

public MenuItem iconize(String text,
                        IImage image,
                        boolean leaveText)
Set the label, hotkey and image for the item.

Parameters:
text - The text for the label which may have a hotkey encoded within it. If the action field is null when this is called it will also be set to the label.
image - The image which may be a small icon to be associated with the text or it may be the entire display line.
leaveText - If this is true then it is assumed that the image is meant to be an icon to be associated with the item.
Returns:
this MenuItem.

toString

public String toString()
Description copied from class: Object
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representing this object.

equals

public boolean equals(Object what)
Description copied from class: Object
Returns if this object is considered equal to the other object.

Overrides:
equals in class Object
Parameters:
what - Another object to compare to.
Returns:
true if this object is considered equal to the other object.