Exemplo n.º 1
0
 public void removeMenuItemByLabel(String text) {
   for (int i = 0; i < m_menuItems.size(); i++) {
     MenuItem m = (MenuItem) m_menuItems.elementAt(i);
     if (text.compareTo(m.toString()) == 0) {
       m_menuItems.removeElementAt(i);
     }
   }
 }
Exemplo n.º 2
0
  public void fillMenuOptions(Menu menu, int instance) {
    boolean haveContext = false;
    boolean hasMiniMenu = false;

    if ((instance == Menu.INSTANCE_CONTEXT) || (pushMiniMenu)) {
      for (int i = 0; i < m_MiniMenuItems.size(); ++i) {
        MenuItem item = (MenuItem) m_MiniMenuItems.elementAt(i);
        if (item != null) {
          menu.add(item);
          hasMiniMenu = true;
        }
      }
    }

    if (!hasMiniMenu) {
      for (int i = 0; i < m_contextMenuItems.size(); ++i) {
        MenuItem item = (MenuItem) m_contextMenuItems.elementAt(i);
        if (item != null) {
          menu.add(item);
          haveContext = true;
        }
      }
    }

    if (((!haveContext) && (!hasMiniMenu))) {
      for (int i = 0; i < m_menuItems.size(); ++i) {
        menu.add((MenuItem) m_menuItems.elementAt(i));
      }
    }
  }
Exemplo n.º 3
0
  public FreemapMainScreen() {
    super(DEFAULT_MENU);

    m_this = this;
    int size = 20;
    m_contextMenuItems = new Vector(size);
    m_MiniMenuItems = new Vector(size);
    for (int i = 0; i < size; ++i) {
      m_contextMenuItems.addElement(null);
      m_MiniMenuItems.addElement(null);
    }
    m_initial_locale = Locale.getDefaultInputForSystem();

    waiting_dialog =
        new Dialog(
            "please wait...",
            new String[] {"Hide"},
            null,
            Dialog.OK,
            Bitmap.getPredefinedBitmap(Bitmap.HOURGLASS));

    isLandscapeScreen = getVisibleWidth() > getVisibleHeight() ? 1 : 0;
  }
Exemplo n.º 4
0
  public void setMiniMenuItem(
      String text, int ordinal, final int wrapper_callback, final int callback) {
    if (callback != 0) {
      MenuItem menu_item = null;
      menu_item =
          new MenuItem(text, ordinal, 1) {
            public void run() {
              try {
                int c_on_menuItem = CibylCallTable.getAddressByName("rim_on_menuItem");
                if (c_on_menuItem != 0) {
                  UIWorker.addUIEvent(c_on_menuItem, wrapper_callback, callback, 0, 0, true);
                }
              } catch (Exception ex) {
                UIWorker.addUIEventLog("Exception run (menuMiniItem): " + ex.toString());
              }
            }
          };

      m_MiniMenuItems.setElementAt(menu_item, ordinal - 1);
    } else {
      m_menuItems.setElementAt(MenuItem.separator(ordinal - 1), ordinal - 1);
    }
  }
Exemplo n.º 5
0
  public void addMenuItem(
      String text,
      int ordinal,
      int priority,
      final int wrapper_callback,
      final int callback,
      int push_at_start) {
    for (int i = 0; i < m_menuItems.size(); i++) {
      MenuItem m = (MenuItem) m_menuItems.elementAt(i);
      if (text.compareTo(m.toString()) == 0) {
        return; // item already exists, don't add.
      }
    }

    // System.out.println("***** addMenuItem *****");
    // System.out.println("text=" + text);

    MenuItem m =
        new MenuItem(text, ordinal, priority) {
          public void run() {
            try {
              int c_on_menuItem = CibylCallTable.getAddressByName("rim_on_menuItem");
              if (c_on_menuItem != 0) {
                UIWorker.addUIEvent(c_on_menuItem, wrapper_callback, callback, 0, 0, true);
              }
            } catch (Exception ex) {
              System.out.println("run (menuItem): " + ex);
            }
          }
        };

    // System.out.println("added item " + m.toString());

    if (push_at_start == 1) {
      m_menuItems.insertElementAt(m, 0);
    } else m_menuItems.addElement(m);
  }
Exemplo n.º 6
0
  public void setContextMenuItem(String text, final int ordinal, final int callback) {
    // System.out.println("***** setContextMenuItem *****");
    // System.out.println("text=" + text+text.length());

    MenuItem menu = null;

    if (text.length() > 0) {
      menu =
          new MenuItem(text, ordinal, 1) {
            public void run() {
              try {
                int c_on_menuItem = CibylCallTable.getAddressByName("rim_on_menuItem");
                if (c_on_menuItem != 0) {
                  UIWorker.addUIEvent(c_on_menuItem, callback, ordinal, 0, 0, true);
                }
              } catch (Exception ex) {
                UIWorker.addUIEventLog("Exception run (contextMiniItem): " + ex.toString());
              }
            }
          };
    }

    m_contextMenuItems.setElementAt(menu, ordinal - 1);
  }
Exemplo n.º 7
0
 protected void onMenuDismissed(Menu menu) {
   menu_open = false;
   for (int i = 0; i < m_contextMenuItems.size(); ++i) {
     m_MiniMenuItems.setElementAt(null, i);
   }
 }
Exemplo n.º 8
0
 public void addMenuItemSeparator(int ordinal) {
   m_menuItems.addElement(MenuItem.separator(ordinal));
 }
Exemplo n.º 9
0
 public void resetContextMenu(int starting_from) {
   for (int i = starting_from; i < m_contextMenuItems.size(); ++i) {
     setContextMenuItem("", i + 1, 0);
   }
 }