Ejemplo n.º 1
0
 /**
  * ------------------------------------------------------ Specifies whether the focus border
  * (hilite border) is to be enabled for this container.
  *
  * @param flag true if enabled ------------------------------------------------------
  */
 public void setDisplaysFocusBorder(boolean flag) {
   displaysFocusBorder = flag;
   if (displaysFocusBorder) {
     tmpMargins.setMargins(getBorderHiliteWidth());
     if (preferredMargins != null) tmpMargins.union(preferredMargins);
   } else {
     if (preferredMargins != null) tmpMargins.copy(preferredMargins);
     else tmpMargins.setMargins(0, 0, 0, 0);
   }
   super.setMargins(tmpMargins);
   invalidateLayout();
 }
Ejemplo n.º 2
0
  /**
   * ------------------------------------------------------ Sets the margins of this MiPart.
   *
   * @param m the margins or null
   * @overrides MiPart#setMargins ------------------------------------------------------
   */
  public void setMargins(MiMargins m) {
    if (preferredMargins != null) preferredMargins.copy(m);
    else preferredMargins = new MiMargins(m);

    MiMargins currentMargins = getMargins(tmpMargins);

    if (displaysFocusBorder) {
      currentMargins.setMargins(getBorderHiliteWidth());
      currentMargins.union(preferredMargins);
    } else {
      currentMargins.copy(preferredMargins);
    }
    super.setMargins(currentMargins);
    refreshBounds();
  }
Ejemplo n.º 3
0
 /**
  * ------------------------------------------------------ Gets the total margins (inset margins
  * plus margins).
  *
  * @return the total margins ------------------------------------------------------
  */
 public MiMargins getTotalMargins() {
   MiMargins m = getCellMargins();
   m.addMargins(getInsetMargins(tmpMargins));
   m.addMargins(getMargins(tmpMargins));
   return (m);
 }
Ejemplo n.º 4
0
  /**
   * ------------------------------------------------------ Realculates the outer bounds of this
   * container.
   *
   * @param bounds the (returned) outer bounds
   *     ------------------------------------------------------
   */
  protected void reCalcBounds(MiBounds bounds) {
    getBounds(bounds);

    if (!autoLayoutEnabled) {
      return;
    }

    MiBounds contents = MiBounds.newBounds();
    MiMargins insetMargins = getInsetMargins();
    MiMargins cellMargins = getCellMargins();

    super.reCalcBounds(contents);
    if (contents.isReversed()) {
      contents.copy(bounds);
      if (contents.isReversed()) {
        contents.setBounds(0, 0, 0, 0);
        contents.addMargins(insetMargins);
        contents.addMargins(cellMargins);
        contents.addMargins(getMargins(tmpMargins));
      } else if ((contents.getWidth()
              < insetMargins.getWidth()
                  + getMargins(tmpMargins).getWidth()
                  + cellMargins.getWidth())
          || (contents.getHeight()
              < insetMargins.getHeight()
                  + getMargins(tmpMargins).getHeight()
                  + cellMargins.getHeight())) {
        contents.setWidth(
            insetMargins.getWidth() + getMargins(tmpMargins).getWidth() + cellMargins.getWidth());
        contents.setHeight(
            insetMargins.getHeight()
                + getMargins(tmpMargins).getHeight()
                + cellMargins.getHeight());
      }
      bounds.copy(contents);
    } else {
      // SUPER CLASS DOES THIS contents.addMargins(insetMargins);
      contents.addMargins(cellMargins);
      // SUPER CLASS DOES THIS contents.addMargins(getMargins(tmpMargins));
    }

    if ((autoLayoutRule == MAKE_CONTAINER_SAME_SIZE_AS_CONTENTS)) {
      bounds.copy(contents);
    } else if ((autoLayoutRule == MAKE_CONTAINER_SAME_SIZE_OR_BIGGER_THAN_CONTENTS)) {
      if (!contents.isContainedIn(bounds)) bounds.copy(contents);
    } else if ((autoLayoutRule
        == MAKE_CONTAINER_SAME_SIZE_AS_CONTENTS_OR_OVERRIDDEN_PREFERRED_SIZE)) {
      bounds.copy(contents);
      if (hasOverriddenPreferredSize()) {
        bounds.setSize(getPreferredSize(new MiSize()));
      }
    }

    if (hasFixedWidthOrHeight) {
      getBounds(contents);

      if (hasFixedWidth()) {
        bounds.xmin = contents.xmin;
        bounds.xmax = contents.xmax;
      }
      if (hasFixedHeight()) {
        bounds.ymin = contents.ymin;
        bounds.ymax = contents.ymax;
      }
    }
    MiBounds.freeBounds(contents);
  }