Package org.gwt.mosaic.core.client

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


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

      final Dimension box = DOM.getClientSize(layoutPanel.getElement());
      final int spacing = layoutPanel.getWidgetSpacing();

      int left = paddingLeftMeasure.sizeOf(layoutPanel);
      int top = paddingTopMeasure.sizeOf(layoutPanel);
      int width = box.width - (left + paddingRightMeasure.sizeOf(layoutPanel));
      // int height = box.height - (top +
      // paddingBottomMeasure.sizeOf(layoutPanel));

      Dimension decPanelFrameSize = null;

      int maxHeight = 0;

      for (Widget child : visibleChildList) {

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

        final FlowLayoutData 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]);
        }

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


      if (onLoadWidth != null && onLoadHeight != null) {
        setSize(onLoadWidth, onLoadHeight);
        onLoadWidth = onLoadHeight = null;
      } else {
        final Dimension d = getPreferredSize();
        if (onLoadWidth != null) {
          setSize(onLoadWidth, d.height + "px");
          onLoadWidth = null;
        } else if (onLoadHeight != null) {
          setSize(d.width + "px", onLoadHeight);
View Full Code Here

   *
   * @see org.mosaic.ui.client.layout.HasLayout#getPreferredSize()
   */
  public Dimension getPreferredSize() {
    if (!isAttached()) {
      return new Dimension();
    }

    if (preferredSizeCache.width == -1 || preferredSizeCache.height == -1) {
      preferredSizeCache = layout.getPreferredSize(this);

View Full Code Here

      // DOM.setStyleAttribute(toPixelSizeTestElem, "background", "red");
    }
    DOM.setStyleAttribute(toPixelSizeTestElem, "width", value);
    DOM.setStyleAttribute(toPixelSizeTestElem, "height", value);

    Dimension size = DOM.getBoxSize(toPixelSizeTestElem);

    return (useWidthAttribute) ? size.width : size.height;
  }
View Full Code Here

   * margins.
   *
   * @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;
      }

      for (int r = 0; r < rows; r++) {
        int cellWidth = 0;
        int cellHeight = 0;
        for (int c = 0; c < cols; c++) {
          Widget widget = widgetMatrix[c][r];
          if (widget == null || widget == SPAN) {
            continue;
          }
          if (widget instanceof InternalDecoratorPanel) {
            widget = ((InternalDecoratorPanel) widget).getWidget();
          }

          GridLayoutData layoutData = (GridLayoutData) widget.getLayoutData();

          final Dimension dim = new Dimension(
              preferredWidthMeasure.sizeOf(widget),
              preferredHeightMeasure.sizeOf(widget));

          int flowWidth, flowHeight;

          flowWidth = dim.getWidth();
          flowHeight = dim.getHeight();

          cellWidth = Math.max(cellWidth, (int) Math.ceil((double) flowWidth
              / (double) layoutData.colspan));

          cellHeight = Math.max(cellHeight, (int) Math.ceil((double) flowHeight
View Full Code Here

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

      final Dimension box = DOM.getClientSize(layoutPanel.getElement());

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

      final int spacing = layoutPanel.getWidgetSpacing();

      // adjust for spacing
      width -= ((cols - 1) * spacing);
      height -= ((rows - 1) * spacing);

      final int colWidth = width / cols;
      final int rowHeight = height / rows;

      for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {
          Widget widget = widgetMatrix[c][r];
          if (widget == null || widget == SPAN) {
            continue;
          }
          if (widget instanceof InternalDecoratorPanel) {
            widget = ((InternalDecoratorPanel) widget).getWidget();
          }

          int cellWidth;
          int cellHeight;

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

            cellWidth = colWidth * layoutData.colspan - decPanelFrameSize.width
                + spacing * (layoutData.colspan - 1);
            cellHeight = rowHeight * layoutData.rowspan
                - decPanelFrameSize.height + spacing * (layoutData.rowspan - 1);
          } else {
            cellWidth = colWidth * layoutData.colspan + spacing
                * (layoutData.colspan - 1);
            cellHeight = rowHeight * layoutData.rowspan + spacing
                * (layoutData.rowspan - 1);
          }

          HorizontalAlignmentConstant hAlignment = layoutData.getHorizontalAlignment();
          if (hAlignment == null) {
            hAlignment = getHorizontalAlignment();
          }

          Dimension prefSize = null;

          if (hAlignment == null) {
            layoutData.targetLeft = left + (spacing + colWidth) * c;
            layoutData.targetWidth = cellWidth;
          } else {
            // (ggeorg) this call to WidgetHelper.getPreferredSize() is
            // required even for ALIGN_LEFT
            prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget),
                preferredHeightMeasure.sizeOf(widget));

            if (HasHorizontalAlignment.ALIGN_LEFT == hAlignment) {
              layoutData.targetLeft = left + (spacing + colWidth) * c;
            } else if (HasHorizontalAlignment.ALIGN_CENTER == hAlignment) {
              layoutData.targetLeft = left + (spacing + colWidth) * c
                  + (cellWidth / 2) - prefSize.width / 2;
            } else {
              layoutData.targetLeft = left + (spacing + colWidth) * c
                  + cellWidth - prefSize.width;
            }
            layoutData.targetWidth = prefSize.width;
          }

          VerticalAlignmentConstant vAlignment = layoutData.getVerticalAlignment();
          if (vAlignment == null) {
            vAlignment = getVerticalAlignment();
          }

          if (vAlignment == null) {
            layoutData.targetTop = top + (spacing + rowHeight) * r;
            layoutData.targetHeight = cellHeight;
          } else {
            if (prefSize == null) {
              // (ggeorg) this call to WidgetHelper.getPreferredSize() is
              // required even for ALIGN_TOP
              prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget),
                  preferredHeightMeasure.sizeOf(widget));
            }
            if (HasVerticalAlignment.ALIGN_TOP == vAlignment) {
              layoutData.targetTop = top + (spacing + rowHeight) * r;
            } else if (HasVerticalAlignment.ALIGN_MIDDLE == vAlignment) {
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

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

      final Dimension box = DOM.getClientSize(layoutPanel.getElement());
      final int spacing = layoutPanel.getWidgetSpacing();

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

      int fillWidth = width;

      fillWidth -= ((size - 1) * spacing);

      int fillingWidth = 0;

      Dimension decPanelFrameSize = null;

      // 1st pass
      for (Widget child : visibleChildList) {
        if (child instanceof InternalDecoratorPanel) {
          child = ((InternalDecoratorPanel) child).getWidget();
        }

        ColumnLayoutData 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 (layoutData.getPreferredWidth() == null) {
          fillingWidth += layoutData.getFlexibility();
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());
      dropTargetClientHeight = box.height;

      draggableOldAbsoluteTop = context.draggable.getAbsoluteTop();
    }
View Full Code Here

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

    final Dimension result = new Dimension();

    init(layoutPanel);

    if (child != null) {
      result.setSize(preferredWidthMeasure.sizeOf(child),
          preferredHeightMeasure.sizeOf(child));

      final Widget parent = child.getParent();
      if (parent instanceof InternalDecoratorPanel) {
        final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent;
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.