1 package org.splat.wapp;
6 * Base popup menu class.
8 public class PopupMenu extends ContextualMenu {
10 // ==============================================================================================================================
12 // ==============================================================================================================================
15 * Default constructor.
19 _width = 186; // Includes borders (2px) and shadow (4px)
20 _height = 2; // Top and bottom border
23 // ==============================================================================================================================
25 // ==============================================================================================================================
35 public void addItem(final String name, final PopupItem item) {
37 item._height = 22; // Height of image.selected.png background image
38 this._height += item._height;
39 super.addItem(name, item);
43 * Insert an items separator into the menu.
45 public void addSeparator() {
46 PopupItem item = new PopupItem();
49 this._height += item._height;
50 super.addItem("", item);
54 * Get the menu as a list of menu items.
56 * @return the list of menu items
58 @SuppressWarnings(Constants.UNCHECKED)
59 public List<PopupItem> asList() {
64 * Get menu item by name.
68 * @return the menu item
70 public PopupItem item(final String name) {
71 return (PopupItem) _items.get(_indices.get(name));
75 * Check if this menu contains the given item.
79 * @return true if this menu contains the given item.
81 public boolean hasItem(final String name) {
82 return _indices.containsKey(name);