Ejemplo n.º 1
0
  /** Lays out this MenuItem and all of its sub-items. */
  public synchronized void layout() {
    setEnabled(checkCondition());

    for (int i = 0; i < items.size(); i++) {
      MenuItem seg = (MenuItem) items.get(i);
      if (seg.isHidden()) continue;
      seg.layout();
    }
  }
Ejemplo n.º 2
0
  public synchronized void layout() {
    if (menu == null) return;

    float px = getPadX();
    float py = getPadY();

    float curX = 0, curY = 0;
    switch (layoutMode) {
      case (LAYOUT_BELOW):
        curX = x - py;
        curY = y + height;
        break;
      case (LAYOUT_RIGHT):
      default:
        curX = x + width;
        curY = y - px;
        break;
    }
    subItemRect.x = curX;
    subItemRect.y = curY;
    curX += px;
    curY += py;
    for (int i = 0; i < items.size(); i++) {
      MenuItem item = (MenuItem) items.get(i);
      item.calcPreferredSize();
    }
    float maxWidth = getMaxWidth();
    float maxHeight = getMaxHeight();
    for (int i = 0; i < items.size(); i++) {
      MenuItem item = (MenuItem) items.get(i);
      if (item.isHidden()) continue;
      item.setPosition(curX, curY);
      //			if (layoutMode == LAYOUT_BELOW)
      //				item.setWidth(maxWidth);
      //			else
      //				item.setHeight(maxHeight);
      item.setSize(maxWidth, maxHeight);
      curY += item.getHeight();
    }
    curY += py;

    subItemRect.width = maxWidth + px * 2;
    subItemRect.height = curY - subItemRect.y;

    /*
     * Trigger the recursive layout.
     */
    super.layout();
  }