Package org.gwt.mosaic.core.client

Examples of org.gwt.mosaic.core.client.Dimension


        + getDataTable().getOffsetHeight();
    if (getFooterTable() != null) {
      height += getFooterTable().getOffsetHeight();
    }
    final int[] m = DOM.getMarginSizes(getElement());
    return new Dimension(width + m[1] + m[3], height + m[0] + m[2]);
  }
View Full Code Here


     *
     * @param widget the widget to compute the minimum size
     * @return the widget's minimum size
     */
    Dimension getMinimumSize(Widget widget) {
      Dimension size = minimumSizes.get(widget);
      if (size == null) {
        final String minWidth = DOM.getComputedStyleAttribute(
            widget.getElement(), "minWidth");
        final String minHeight = DOM.getComputedStyleAttribute(
            widget.getElement(), "minHeight");
        size = new Dimension(minWidth == null ? 1 : DOM.toPixelSize(minWidth,
            true), minHeight == null ? 1 : DOM.toPixelSize(minHeight, false));
        minimumSizes.put(widget, size);
      }
      return size;
    }
View Full Code Here

     *
     * @param widget the widget to compute the preferred size
     * @return the widget's preferred size
     */
    Dimension getPreferredSize(Widget widget) {
      Dimension size = preferredSizes.get(widget);
      if (size == null) {
        LayoutData layoutData = (LayoutData) widget.getLayoutData();
        size = BaseLayout.this.getPreferredSize(
            (LayoutPanel) WidgetHelper.getParent(widget), widget, layoutData);
        // don't cache percentage units
View Full Code Here

   * {@inheritDoc}
   *
   * @see org.gwt.mosaic.ui.client.layout.LayoutManager#getPreferredSize(org.gwt.mosaic.ui.client.layout.LayoutPanel)
   */
  public Dimension getPreferredSize(LayoutPanel layoutPanel) {
    final Dimension result = new Dimension(0, 0);

    try {

      if (layoutPanel == null || !init(layoutPanel)) {
        return result;
      }

      int width = marginLeftMeasure.sizeOf(layoutPanel)
          + marginRightMeasure.sizeOf(layoutPanel)
          + borderLeftMeasure.sizeOf(layoutPanel)
          + borderRightMeasure.sizeOf(layoutPanel)
          + paddingLeftMeasure.sizeOf(layoutPanel)
          + paddingRightMeasure.sizeOf(layoutPanel);

      int height = marginTopMeasure.sizeOf(layoutPanel)
          + marginBottomMeasure.sizeOf(layoutPanel)
          + borderTopMeasure.sizeOf(layoutPanel)
          + borderBottomMeasure.sizeOf(layoutPanel)
          + paddingTopMeasure.sizeOf(layoutPanel)
          + paddingBottomMeasure.sizeOf(layoutPanel);

      final int spacing = layoutPanel.getWidgetSpacing();

      if (north != null) {
        height += preferredHeightMeasure.sizeOf(north);
        final Widget parent = north.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          height += (borderSizes[0] + borderSizes[2]);
        }
        height += spacing;
      }

      if (south != null) {
        height += preferredHeightMeasure.sizeOf(south);
        final Widget parent = south.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          height += (borderSizes[0] + borderSizes[2]);
        }
        height += spacing;
      }

      Dimension westSize = null;

      if (west != null) {
        width += preferredWidthMeasure.sizeOf(west);
        final Widget parent = west.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          width += (borderSizes[1] + borderSizes[3]);
        }
        width += spacing;
      }

      Dimension eastSize = null;

      if (east != null) {
        width += preferredWidthMeasure.sizeOf(east);
        final Widget parent = east.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          width += (borderSizes[1] + borderSizes[3]);
        }
        width += spacing;
      }

      Dimension centerSize = new Dimension(
          preferredWidthMeasure.sizeOf(center),
          preferredHeightMeasure.sizeOf(center));
      width += centerSize.width;

      if (west != null && westSize == null) {
View Full Code Here

      // ---
      int left = paddingLeftMeasure.sizeOf(layoutPanel);
      int top = paddingTopMeasure.sizeOf(layoutPanel);

      final Dimension box = DOM.getClientSize(layoutPanel.getElement());
      final int width = box.width
          - (left + paddingRightMeasure.sizeOf(layoutPanel));
      final int height = box.height
          - (top + paddingBottomMeasure.sizeOf(layoutPanel));
      // ---

      final int spacing = layoutPanel.getWidgetSpacing();

      int right = left + width;
      int bottom = top + height;

      if (north != null) {
        final BorderLayoutData layoutData = getLayoutData(north);

        if (layoutData.resizable && !layoutData.collapsed) {
          if (northSplitBar == null) {
            northSplitBar = new BorderLayoutSplitBar(layoutPanel, north);
            northSplitBar.setStyleName("NorthSplitBar");
            layoutPanel.add(northSplitBar);
          }
        } else {
          if (northSplitBar != null) {
            layoutPanel.removeImpl(northSplitBar);
            northSplitBar = null;
          }
        }

        int h = preferredHeightMeasure.sizeOf(north);

        layoutData.targetLeft = left;
        layoutData.targetTop = top;
        layoutData.targetWidth = Math.max(0, right - left);
        layoutData.targetHeight = h;

        final Widget parent = north.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          final Dimension decPanelBorderSize = new Dimension(borderSizes[1]
              + borderSizes[3], borderSizes[0] + borderSizes[0]);
          layoutData.targetWidth -= decPanelBorderSize.width;
          h += decPanelBorderSize.height;
        }

        if (layoutPanel.isAnimationEnabled()) {
          layoutData.setSourceLeft(layoutData.targetLeft);
          layoutData.setSourceTop(layoutData.targetTop);
          layoutData.setSourceWidth(north.getOffsetWidth());
          layoutData.setSourceHeight(north.getOffsetHeight());
        }

        // split bar
        if (layoutData.resizable && northSplitBar.isAttached()) {
          WidgetHelper.setBounds(layoutPanel, northSplitBar, left, top + h,
              Math.max(0, right - left), spacing);
        }

        top += (h + spacing);
      }

      if (south != null) {
        final BorderLayoutData layoutData = getLayoutData(south);

        if (layoutData.resizable && !layoutData.collapsed) {
          if (southSplitBar == null) {
            southSplitBar = new BorderLayoutSplitBar(layoutPanel, south);
            southSplitBar.setStyleName("SouthSplitBar");
            layoutPanel.add(southSplitBar);
          }
        } else {
          if (southSplitBar != null) {
            layoutPanel.removeImpl(southSplitBar);
            southSplitBar = null;
          }
        }

        int h = preferredHeightMeasure.sizeOf(south);

        layoutData.targetLeft = left;
        layoutData.targetTop = Math.max(0, bottom - h);
        layoutData.targetWidth = Math.max(0, right - left);
        layoutData.targetHeight = h;

        final Widget parent = south.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          final Dimension decPanelBorderSize = new Dimension(borderSizes[1]
              + borderSizes[3], borderSizes[0] + borderSizes[0]);
          layoutData.targetWidth -= decPanelBorderSize.width;
          layoutData.targetTop -= decPanelBorderSize.height;
          h += decPanelBorderSize.height;
        }

        if (layoutPanel.isAnimationEnabled()) {
          layoutData.setSourceLeft(layoutData.targetLeft);
          layoutData.setSourceTop(south.getAbsoluteTop()
              - layoutPanel.getAbsoluteTop()
              - paddingBottomMeasure.sizeOf(layoutPanel));
          layoutData.setSourceWidth(south.getOffsetWidth());
          layoutData.setSourceHeight(south.getOffsetHeight());
        }

        // split bar
        if (layoutData.resizable && southSplitBar.isAttached()) {
          WidgetHelper.setBounds(layoutPanel, southSplitBar, left, Math.max(0,
              bottom - h)
              - spacing, Math.max(0, right - left), spacing);
        }

        bottom -= (h + spacing);
      }

      if (west != null) {
        final BorderLayoutData layoutData = getLayoutData(west);

        if (layoutData.resizable && !layoutData.collapsed) {
          if (westSplitBar == null) {
            westSplitBar = new BorderLayoutSplitBar(layoutPanel, west);
            westSplitBar.setStyleName("WestSplitBar");
            layoutPanel.add(westSplitBar);
          }
        } else {
          if (westSplitBar != null) {
            layoutPanel.removeImpl(westSplitBar);
            westSplitBar = null;
          }
        }

        int w = preferredWidthMeasure.sizeOf(west);

        layoutData.targetLeft = left;
        layoutData.targetTop = top;
        layoutData.targetWidth = w;
        layoutData.targetHeight = Math.max(0, bottom - top);

        final Widget parent = west.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          final Dimension decPanelBorderSize = new Dimension(borderSizes[1]
              + borderSizes[3], borderSizes[0] + borderSizes[0]);
          layoutData.targetHeight -= decPanelBorderSize.height;
          w += decPanelBorderSize.width;
        }

        if (layoutPanel.isAnimationEnabled()) {
          layoutData.setSourceLeft(west.getAbsoluteLeft()
              - layoutPanel.getAbsoluteLeft()
              - paddingLeftMeasure.sizeOf(layoutPanel));
          layoutData.setSourceTop(west.getAbsoluteTop()
              - layoutPanel.getAbsoluteTop()
              - paddingTopMeasure.sizeOf(layoutPanel));
          layoutData.setSourceWidth(west.getOffsetWidth());
          layoutData.setSourceHeight(west.getOffsetHeight());
        }

        // split bar
        if (layoutData.resizable && westSplitBar.isAttached()) {
          WidgetHelper.setBounds(layoutPanel, westSplitBar, left + w, top,
              spacing, Math.max(0, bottom - top));
        }

        left += (w + spacing);
      }

      if (east != null) {
        final BorderLayoutData layoutData = getLayoutData(east);

        if (layoutData.resizable && !layoutData.collapsed) {
          if (eastSplitBar == null) {
            eastSplitBar = new BorderLayoutSplitBar(layoutPanel, east);
            eastSplitBar.setStyleName("EastSplitBar");
            layoutPanel.add(eastSplitBar);
          }
        } else {
          if (eastSplitBar != null) {
            layoutPanel.removeImpl(eastSplitBar);
            eastSplitBar = null;
          }
        }

        int w = preferredWidthMeasure.sizeOf(east);

        layoutData.targetLeft = Math.max(0, right - w);
        layoutData.targetTop = top;
        layoutData.targetWidth = w;
        layoutData.targetHeight = Math.max(0, bottom - top);

        final Widget parent = east.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          final Dimension decPanelBorderSize = new Dimension(borderSizes[1]
              + borderSizes[3], borderSizes[0] + borderSizes[0]);
          layoutData.targetLeft -= decPanelBorderSize.width;
          layoutData.targetHeight -= decPanelBorderSize.height;
          w += decPanelBorderSize.width;
        }

        if (layoutPanel.isAnimationEnabled()) {
          layoutData.setSourceLeft(east.getAbsoluteLeft()
              - layoutPanel.getAbsoluteLeft()
              - paddingRightMeasure.sizeOf(layoutPanel));
          layoutData.setSourceTop(east.getAbsoluteTop()
              - layoutPanel.getAbsoluteTop()
              - paddingTopMeasure.sizeOf(layoutPanel));
          layoutData.setSourceWidth(east.getOffsetWidth());
          layoutData.setSourceHeight(east.getOffsetHeight());
        }

        // split bar
        if (layoutData.resizable && eastSplitBar.isAttached()) {
          WidgetHelper.setBounds(layoutPanel, eastSplitBar, Math.max(0, right
              - w)
              - spacing, top, spacing, Math.max(0, bottom - top));
        }

        right -= (w + spacing);
      }

      if (center != null) {
        BorderLayoutData layoutData = getLayoutData(center);

        layoutData.targetLeft = left;
        layoutData.targetTop = top;
        layoutData.targetWidth = Math.max(1, right - left);
        layoutData.targetHeight = Math.max(1, bottom - top);

        final Widget parent = center.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          final Dimension decPanelBorderSize = new Dimension(borderSizes[1]
              + borderSizes[3], borderSizes[0] + borderSizes[0]);
          layoutData.targetWidth -= decPanelBorderSize.width;
          layoutData.targetHeight -= decPanelBorderSize.height;
        }
View Full Code Here

      // dragging
      Location widgetLocation = new WidgetLocation(context.boundaryPanel, null);
      final int[] border = DOM.getBorderSizes(context.boundaryPanel.getElement());
      boundaryOffsetX = widgetLocation.getLeft() + border[3];
      boundaryOffsetY = widgetLocation.getTop() + border[0];
      final Dimension box = DOM.getClientSize(context.boundaryPanel.getElement());
      dropTargetClientWidth = box.width;

      draggableOldAbsoluteLeft = context.draggable.getAbsoluteLeft();
    }
View Full Code Here

   * @see org.mosaic.ui.client.layout.LayoutManager#getPreferredSize(org.mosaic.ui.client.layout.LayoutPanel)
   */
  public Dimension getPreferredSize(LayoutPanel layoutPanel) {
    assert layoutPanel != null;

    final Dimension result = new Dimension();

    init(layoutPanel);

    int width = marginLeftMeasure.sizeOf(layoutPanel)
        + marginRightMeasure.sizeOf(layoutPanel)
        + borderLeftMeasure.sizeOf(layoutPanel)
        + borderRightMeasure.sizeOf(layoutPanel)
        + paddingLeftMeasure.sizeOf(layoutPanel)
        + paddingRightMeasure.sizeOf(layoutPanel);

    int height = marginTopMeasure.sizeOf(layoutPanel)
        + marginBottomMeasure.sizeOf(layoutPanel)
        + borderTopMeasure.sizeOf(layoutPanel)
        + borderBottomMeasure.sizeOf(layoutPanel)
        + paddingTopMeasure.sizeOf(layoutPanel)
        + paddingBottomMeasure.sizeOf(layoutPanel);

    final int size = visibleChildList.size();
    if (size == 0) {
      result.width = width;
      result.height = height;
      return result;
    }

    final int spacing = layoutPanel.getWidgetSpacing();

    // adjust for spacing
    if (orientation == Orientation.HORIZONTAL) {
      width += ((size - 1) * spacing);
    } else { // Orientation.VERTICAL
      height += ((size - 1) * spacing);
    }

    int maxWidth = 0;
    int maxHeight = 0;

    for (Widget child : visibleChildList) {
      final BoxLayoutData layoutData = getLayoutData(child);

      Dimension decPanelFrameSize = null;

      final Widget parent = child.getParent();
      if (parent instanceof InternalDecoratorPanel) {
        final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
        final int borderSizes[] = decPanel.getBorderSizes();
        decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3],
            borderSizes[0] + borderSizes[0]);
      }

      if (orientation == Orientation.HORIZONTAL) {

View Full Code Here

    final int spacing = layoutPanel.getWidgetSpacing();

    int left = paddingLeftMeasure.sizeOf(layoutPanel);
    int top = paddingTopMeasure.sizeOf(layoutPanel);
   
    final Dimension box = DOM.getClientSize(layoutPanel.getElement());
    final int width = box.width
        - (left + paddingRightMeasure.sizeOf(layoutPanel));
    final int height = box.height
        - (top + paddingBottomMeasure.sizeOf(layoutPanel));

    int fillWidth = width;
    int fillHeight = height;

    // adjust for spacing
    if (orientation == Orientation.HORIZONTAL) {
      fillWidth -= ((size - 1) * spacing);
    } else { // Orientation.VERTICAL
      fillHeight -= ((size - 1) * spacing);
    }

    int fillingWidth = 0;
    int fillingHeight = 0;

    // 1st pass
    for (Widget child : visibleChildList) {
      Dimension decPanelFrameSize = null;

      BoxLayoutData layoutData = getLayoutData(child);

      final Widget parent = child.getParent();
      if (parent instanceof InternalDecoratorPanel) {
        final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
        final int borderSizes[] = decPanel.getBorderSizes();
        decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3],
            borderSizes[0] + borderSizes[0]);
      }

      if (orientation == Orientation.HORIZONTAL) {
        if (layoutData.fillWidth) {
          fillingWidth++;
        } else {
          layoutData.calcWidth = preferredWidthMeasure.sizeOf(child);
          if (parent instanceof InternalDecoratorPanel) {
            layoutData.calcWidth += decPanelFrameSize.width;
          }
          fillWidth -= layoutData.calcWidth;
        }
        if (layoutData.fillHeight) {
          layoutData.calcHeight = height;
        } else {
          layoutData.calcHeight = preferredHeightMeasure.sizeOf(child);
          if (parent instanceof InternalDecoratorPanel) {
            layoutData.calcHeight += decPanelFrameSize.height;
          }
        }
      } else { // Orientation.VERTICAL
        if (layoutData.fillHeight) {
          fillingHeight++;
        } else {
          layoutData.calcHeight = preferredHeightMeasure.sizeOf(child);
          if (parent instanceof InternalDecoratorPanel) {
            layoutData.calcHeight += decPanelFrameSize.height;
          }
          fillHeight -= layoutData.calcHeight;
        }
        if (layoutData.fillWidth) {
          layoutData.calcWidth = width;
        } else {
          layoutData.calcWidth = preferredWidthMeasure.sizeOf(child);
          if (parent instanceof InternalDecoratorPanel) {
            layoutData.calcWidth += decPanelFrameSize.width;
          }
        }
      }
    }

    // 2nd pass
    for (Widget child : visibleChildList) {
      Dimension decPanelFrameSize = null;

      final BoxLayoutData layoutData = (BoxLayoutData) child.getLayoutData();
     
      final Widget parent = child.getParent();
      if (parent instanceof InternalDecoratorPanel) {
        final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
        final int borderSizes[] = decPanel.getBorderSizes();
        decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3],
            borderSizes[0] + borderSizes[0]);
      }

      int w = layoutData.calcWidth;
      int h = layoutData.calcHeight;
View Full Code Here

      // dragging
      Location widgetLocation = new WidgetLocation(context.boundaryPanel, null);
      final int[] border = DOM.getBorderSizes(context.boundaryPanel.getElement());
      boundaryOffsetX = widgetLocation.getLeft() + border[3];
      boundaryOffsetY = widgetLocation.getTop() + border[0];
      final Dimension box = DOM.getClientSize(context.boundaryPanel.getElement());
      dropTargetClientWidth = box.width;
      dropTargetClientHeight = box.height;

      layoutData = (BorderLayoutData) widget.getLayoutData();
View Full Code Here

   * {@inheritDoc}
   *
   * @see org.gwt.mosaic.ui.client.layout.LayoutManager#getPreferredSize(org.gwt.mosaic.ui.client.layout.LayoutPanel)
   */
  public Dimension getPreferredSize(LayoutPanel layoutPanel) {
    final Dimension result = new Dimension();
    try {
      if (layoutPanel == null || !init(layoutPanel)) {
        return result;
      }

      int width = marginLeftMeasure.sizeOf(layoutPanel)
          + marginRightMeasure.sizeOf(layoutPanel)
          + borderLeftMeasure.sizeOf(layoutPanel)
          + borderRightMeasure.sizeOf(layoutPanel)
          + paddingLeftMeasure.sizeOf(layoutPanel)
          + paddingRightMeasure.sizeOf(layoutPanel);

      int height = marginTopMeasure.sizeOf(layoutPanel)
          + marginBottomMeasure.sizeOf(layoutPanel)
          + borderTopMeasure.sizeOf(layoutPanel)
          + borderBottomMeasure.sizeOf(layoutPanel)
          + paddingTopMeasure.sizeOf(layoutPanel)
          + paddingBottomMeasure.sizeOf(layoutPanel);

      final int size = visibleChildList.size();
      if (size == 0) {
        result.width = width;
        result.height = height;
        return result;
      }

      final int spacing = layoutPanel.getWidgetSpacing();
      width += ((size - 1) * spacing);

      Dimension decPanelFrameSize = null;

      int maxHeight = 0;

      for (Widget child : visibleChildList) {

        if (child instanceof InternalDecoratorPanel) {
          child = ((InternalDecoratorPanel) child).getWidget();
        }

        final Widget parent = child.getParent();
        if (parent instanceof InternalDecoratorPanel) {
          final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
          final int borderSizes[] = decPanel.getBorderSizes();
          decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3],
              borderSizes[0] + borderSizes[0]);
        }

        width += preferredWidthMeasure.sizeOf(child);
        int h = preferredHeightMeasure.sizeOf(child);
View Full Code Here

TOP

Related Classes of org.gwt.mosaic.core.client.Dimension

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.