Package com.sencha.gxt.core.client.util

Examples of com.sencha.gxt.core.client.util.Margins


      cp = createCollapsePanel(panel, data, region);

      BorderLayoutData collapseData = new BorderLayoutData();
      collapseData.setSize(data.isCollapseHidden() ? 0 : 24);

      Margins m = data.getMargins();
      if (m == null) {
        m = new Margins();
        data.setMargins(m);
      }
      collapseData.setMargins(new Margins(m.getTop(), m.getRight(), m.getBottom(), m.getLeft()));

      if (data.isCollapseHidden()) {
        cp.collapseHidden();
        collapseData.setSize(0);
        switch (region) {
View Full Code Here


        ColumnConfig<M, ?> c = columnModel.getColumn(i);

        final Widget w = doStartEditing(c, value);
        if (w != null) {
          BoxLayoutData ld = new BoxLayoutData();
          ld.setMargins(new Margins(1, 2, 2, 2 + adj));
          w.setLayoutData(ld);
          con.add(w);
          adj = 0;
        }
      }
View Full Code Here

        Widget w = rowEditor.getFieldContainer().getWidget(j++);
        int width = c.getWidth();

        Object layoutData = w.getLayoutData();
        if (layoutData instanceof MarginData) {
          Margins m = ((MarginData) layoutData).getMargins();
          if (m != null) {
            width -= m.getLeft();
            width -= m.getRight();
          }
        }
        if (w instanceof Field<?>) {

          ((Field<?>) w).setWidth(width);
View Full Code Here

      child.setLayoutData(hasMargins);
    } else {
      hasMargins = (HasMargins) data;
    }

    Margins m = hasMargins.getMargins();

    if (m == null) {
      m = new Margins();
      hasMargins.setMargins(m);
    }

    if (verticalSpacing != -1) {
      int vs = (int) Math.round(verticalSpacing / 2d);
      m.setTop(vs);
      m.setBottom(vs);
    }

    if (horizontalSpacing != -1) {
      int hs = (int) Math.round(horizontalSpacing / 2d);
      m.setLeft(hs);
      m.setRight(hs);
    }

  }
View Full Code Here

      } else {
        layoutData = new BoxLayoutData();
        widget.setLayoutData(layoutData);
      }

      Margins cm = layoutData.getMargins();
      if (cm == null) {
        cm = new Margins(0);
        layoutData.setMargins(cm);
      }
    }

    if (findWidth || findHeight) {
      for (int i = 0, len = getWidgetCount(); i < len; i++) {
        Widget widget = getWidget(i);

        if (!widget.isVisible()) {
          continue;
        }

        BoxLayoutData layoutData = (BoxLayoutData) widget.getLayoutData();
        Margins cm = layoutData.getMargins();

        calculateWidth += widget.getOffsetWidth();
        maxWidgetHeight = Math.max(maxWidgetHeight, widget.getOffsetHeight());

        calculateWidth += (cm.getLeft() + cm.getRight());
        maxMarginTop = Math.max(maxMarginTop, cm.getTop());
        maxMarginBottom = Math.max(maxMarginBottom, cm.getBottom());
      }
      maxWidgetHeight += (maxMarginTop + maxMarginBottom);

      if (findWidth) {
        w = calculateWidth;
      }

      if (findHeight) {
        h = maxWidgetHeight;
      }
    }

    int pl = 0;
    int pt = 0;
    int pb = 0;
    int pr = 0;
    if (getPadding() != null) {
      pl = getPadding().getLeft();
      pt = getPadding().getTop();
      pb = getPadding().getBottom();
      pr = getPadding().getRight();
    }

    if (findHeight) {
      h += pt + pb;
    }
    if (findWidth) {
      w += pl + pr;
    }

    int stretchHeight = h - pt - pb;
    int totalFlex = 0;
    int totalWidth = 0;
    int maxHeight = 0;

    for (int i = 0, len = getWidgetCount(); i < len; i++) {
      Widget widget = getWidget(i);

      widget.addStyleName(CommonStyles.get().positionable());

      // very strange behavior where clearing the margins in causing
      // widget.getOffsetWidth to return an invalid result (for buttons -5 px
      // actual width)
      // which is corrected by the time enable overflow code runs
      if (!GXT.isIE7()) {
        widget.getElement().getStyle().setMargin(0, Unit.PX);
      }

      if (!widget.isVisible()) {
        continue;
      }

      if (widget == more) {
        triggerWidth = widget.getOffsetWidth() + 10;
      }

      BoxLayoutData layoutData = (BoxLayoutData) widget.getLayoutData();
      Margins cm = layoutData.getMargins();

      // TODO strange issue where getOffsetWidth call in 2nd loop is returning smaller number than acutal offset
      // when packing CENTER or END so we cache the offsetWidth for use in 2nd loop
      int ww = widget.getOffsetWidth();
      loopWidthMap.put(widget, ww);

      totalFlex += layoutData.getFlex();
      totalWidth += (ww + cm.getLeft() + cm.getRight());
      maxHeight = Math.max(maxHeight, widget.getOffsetHeight() + cm.getTop() + cm.getBottom());
    }

    int innerCtHeight = maxHeight + pt + pb;

    if (hBoxLayoutAlign.equals(HBoxLayoutAlign.STRETCH)) {
      getContainerTarget().setSize(w, h, true);
    } else if (hBoxLayoutAlign.equals(HBoxLayoutAlign.MIDDLE) || hBoxLayoutAlign.equals(HBoxLayoutAlign.BOTTOM)) {
      getContainerTarget().setSize(w, h = Math.max(h, innerCtHeight), true);
    } else {
      getContainerTarget().setSize(w, innerCtHeight, true);
    }

    int extraWidth = w - totalWidth - pl - pr;
    int allocated = 0;
    int cw, ch, ct;
    int availableHeight = h - pt - pb;

    if (getPack().equals(BoxLayoutPack.CENTER)) {
      pl += extraWidth / 2;
    } else if (getPack().equals(BoxLayoutPack.END)) {
      pl += extraWidth;
    }

    for (int i = 0, len = getWidgetCount(); i < len; i++) {
      Widget widget = getWidget(i);

      if (!widget.isVisible()) {
        continue;
      }

      BoxLayoutData layoutData = (BoxLayoutData) widget.getLayoutData();
      Margins cm = layoutData.getMargins();

      cw = loopWidthMap.remove(widget);
      ch = widget.getOffsetHeight();
      pl += cm.getLeft();

      pl = Math.max(0, pl);
      if (hBoxLayoutAlign.equals(HBoxLayoutAlign.MIDDLE)) {
        int diff = availableHeight - (ch + cm.getTop() + cm.getBottom());
        if (diff == 0) {
          ct = pt + cm.getTop();
        } else {
          ct = pt + cm.getTop() + (diff / 2);
        }
      } else {
        if (hBoxLayoutAlign.equals(HBoxLayoutAlign.BOTTOM)) {
          ct = h - (pb + cm.getBottom() + ch);
        } else {
          ct = pt + cm.getTop();
        }

      }

      boolean component = widget instanceof Component;
      Component c = null;
      if (component) {
        c = (Component) widget;
      }

      int width = -1;
      if (component) {
        c.setPosition(pl, ct);
      } else {
        XElement.as(widget.getElement()).setLeftTop(pl, ct);
      }

      if (getPack().equals(BoxLayoutPack.START) && layoutData.getFlex() > 0) {
        int add = (int) Math.floor(extraWidth * (layoutData.getFlex() / totalFlex));
        allocated += add;
        if (isAdjustForFlexRemainder() && i == getWidgetCount() - 1) {
          add += (extraWidth - allocated);
        }

        cw += add;
        width = cw;
      }
      if (hBoxLayoutAlign.equals(HBoxLayoutAlign.STRETCH)) {
        applyLayout(
            widget,
            width,
            Util.constrain(stretchHeight - cm.getTop() - cm.getBottom(), layoutData.getMinSize(),
                layoutData.getMaxSize()));
      } else if (hBoxLayoutAlign.equals(HBoxLayoutAlign.STRETCHMAX)) {
        applyLayout(widget, width,
            Util.constrain(maxHeight - cm.getTop() - cm.getBottom(), layoutData.getMinSize(), layoutData.getMaxSize()));
      } else if (width > 0) {
        applyLayout(widget, width, -1);
      }
      pl += cw + cm.getRight();
    }

    // do we need overflow
    if (enableOverflow) {
      int runningWidth = 0;
      for (int i = 0, len = getWidgetCount(); i < len; i++) {
        Widget widget = getWidget(i);

        if (widget == more) {
          continue;
        }

        BoxLayoutData layoutData = null;
        Object d = widget.getLayoutData();
        if (d instanceof BoxLayoutData) {
          layoutData = (BoxLayoutData) d;
        } else {
          layoutData = new BoxLayoutData();
        }
        Margins cm = layoutData.getMargins();
        if (cm == null) {
          cm = new Margins(0);
        }
        runningWidth += getWidgetWidth(widget);
        runningWidth += cm.getLeft();
        runningWidth += cm.getRight();
      }

      if (runningWidth > w) {
        hasOverflow = true;
        onOverflow();
View Full Code Here

   * Sets the elements's margin.
   *
   * @param margin the margin
   */
  public final void setMargins(int margin) {
    setMargins(new Margins(margin));
  }
View Full Code Here

   * Sets the elements's margin.
   *
   * @param margin the margin
   */
  public final void setMargins(int margin) {
    setMargins(new Margins(margin));
  }
View Full Code Here

    };

    BorderLayoutData collapseData = new BorderLayoutData();
    collapseData.setSize(data.isCollapseHidden() ? 0 : 24);

    Margins m = data.getMargins();
    if (m == null) {
      m = new Margins();
      data.setMargins(m);
    }
    collapseData.setMargins(new Margins(m.getTop(), m.getRight(), m.getBottom(), m.getLeft()));

    if (data.isCollapseHidden()) {
      cp.collapseHidden();
      collapseData.setSize(0);
      switch (region) {
View Full Code Here

      BorderLayoutData data = getLayoutData(north);
      north.setVisible(!data.isHidden());

      if (north.isVisible()) {
        Rectangle b = new Rectangle();
        Margins m = data.getMargins() != null ? data.getMargins() : new Margins();
        double s = data.getSize() <= 1 ? data.getSize() * size.getHeight() : data.getSize();
        b.setHeight((int) s);
        b.setWidth(w - (m.getLeft() + m.getRight()));
        b.setX(m.getLeft());
        b.setY(m.getTop());
        centerY = b.getHeight() + b.getY() + m.getBottom();
        centerH -= centerY;
        b.setX(b.getX() + sLeft);
        b.setY(b.getY() + sTop);
        applyLayout(north, b);
      }
    }
    if (south != null) {
      BorderLayoutData data = getLayoutData(south);
      south.setVisible(!data.isHidden());
      if (south.isVisible()) {
        Rectangle b = new Rectangle();
        Margins m = data.getMargins() != null ? data.getMargins() : new Margins();
        double s = data.getSize() <= 1 ? data.getSize() * size.getHeight() : data.getSize();
        b.setHeight((int) s);
        b.setWidth(w - (m.getLeft() + m.getRight()));
        b.setX(m.getLeft());
        int totalHeight = (b.getHeight() + m.getTop() + m.getBottom());
        b.setY(h - totalHeight + m.getTop());
        centerH -= totalHeight;
        b.setX(b.getX() + sLeft);
        b.setY(b.getY() + sTop);
        applyLayout(south, b);
      }
    }

    if (west != null) {
      BorderLayoutData data = getLayoutData(west);
      west.setVisible(!data.isHidden());
      if (west.isVisible()) {
        Rectangle box = new Rectangle();
        Margins m = data.getMargins() != null ? data.getMargins() : new Margins();
        double s = data.getSize() <= 1 ? data.getSize() * size.getWidth() : data.getSize();
        box.setWidth((int) s);
        box.setHeight(centerH - (m.getTop() + m.getBottom()));
        box.setX(m.getLeft());
        box.setY(centerY + m.getTop());
        int totalWidth = (box.getWidth() + m.getLeft() + m.getRight());
        centerX += totalWidth;
        centerW -= totalWidth;
        box.setX(box.getX() + sLeft);
        box.setY(box.getY() + sTop);
        applyLayout(west, box);
      }

    }
    if (east != null) {
      BorderLayoutData data = getLayoutData(east);
      east.setVisible(!data.isHidden());
      if (east.isVisible()) {
        Rectangle b = new Rectangle();
        Margins m = data.getMargins() != null ? data.getMargins() : new Margins();
        double s = data.getSize() <= 1 ? data.getSize() * size.getWidth() : data.getSize();
        b.setWidth((int) s);
        b.setHeight(centerH - (m.getTop() + m.getBottom()));
        int totalWidth = (b.getWidth() + m.getLeft() + m.getRight());
        b.setX(w - totalWidth + m.getLeft());
        b.setY(centerY + m.getTop());
        centerW -= totalWidth;
        b.setX(b.getX() + sLeft);
        b.setY(b.getY() + sTop);
        applyLayout(east, b);
      }
    }

    if (widget != null) {
      Object data = widget.getLayoutData();
      Margins m = null;
      if (data instanceof HasMargins) {
        m = ((HasMargins) data).getMargins();
      }
      if (m == null) {
        m = new Margins(0);
      }
      lastCenter = new Rectangle(centerX, centerY, centerW, centerH);
      lastCenter.setX(centerX + (m.getLeft() + sLeft));
      lastCenter.setY(centerY + (m.getTop() + sTop));
      lastCenter.setWidth(centerW - (m.getLeft() + m.getRight()));
      lastCenter.setHeight(centerH - (m.getTop() + m.getBottom()));
      applyLayout(widget, lastCenter);
    }
  }
View Full Code Here

    d.setMoveAfterProxyDrag(false);
    d.setSizeProxyToSource(true);
    d.setEnabled(!portlet.isPinned());

    getWidget(column).insert(portlet, index, new VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
    getWidget(column).forceLayout();
  }
View Full Code Here

TOP

Related Classes of com.sencha.gxt.core.client.util.Margins

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.