Package org.gwt.mosaic.core.client

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


   * @see #minimumLayoutSize(Container)
   * @see #preferredLayoutSize(Container)
   * @return the maximum dimensions for this layout
   */
  public Dimension maximumLayoutSize(Widget target) {
    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  }
View Full Code Here


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

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

      final int left = paddings[3];
      final int top = paddings[0];
      int width = box.width - (paddings[1] + paddings[3]);
      int height = box.height - (paddings[0] + paddings[2]);
View Full Code Here

    maxHeight += (margins[0] + margins[2]);

    maxWidth += paddings[1] + paddings[3];
    maxHeight += paddings[0] + paddings[2];

    return new Dimension(maxWidth, maxHeight);
  }
View Full Code Here

   * @param parent the <code>Container</code> to inspect
   * @return an object that comprises the grid x and y origins
   */
  public LayoutInfo getLayoutInfo(LayoutPanel parent) {
    initializeColAndRowWidgetLists();
    final Dimension size = WidgetHelper.getOffsetSize(parent);

    // FIXME
    // Insets insets = parent.getInsets();
    int totalWidth = size.width;// - insets.left - insets.right;
    int totalHeight = size.height;// - insets.top - insets.bottom;
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),
            minHeight == null ? 1 : DOM.toPixelSize(minHeight));
        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) {
        size = WidgetHelper.getPreferredSize(widget);// widget.getPreferredSize();
        preferredSizes.put(widget, size);
      }
      return size;
View Full Code Here

   * @see
   * org.mosaic.ui.client.layout.LayoutManager#getPreferredSize(org.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 = (margins[1] + margins[3]) + (paddings[1] + paddings[3])
          + (borders[1] + borders[3]);
      int height = (margins[0] + margins[2]) + (paddings[0] + paddings[2])
          + (borders[0] + borders[2]);

      final int spacing = layoutPanel.getWidgetSpacing();

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

        if (layoutData.collapse) {
          height += WidgetHelper.getPreferredSize(northCollapsedImageButton).height;
        } else {
          int northHeight = (int) layoutData.preferredSize;
          if (layoutData.preferredSize == -1.0) {
            northHeight = WidgetHelper.getPreferredSize(north).height;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            northHeight = (int) (height * layoutData.preferredSize);
          }
          height += northHeight;
          if (layoutData.hasDecoratorPanel()) {
            final DecoratorPanel decPanel = layoutData.decoratorPanel;
            height += (decPanel.getOffsetHeight() - north.getOffsetHeight());
          }
        }

        height += spacing;
      }

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

        if (layoutData.collapse) {
          height += WidgetHelper.getPreferredSize(southCollapsedImageButton).height;
        } else {
          int southHeight = (int) layoutData.preferredSize;
          if (layoutData.preferredSize == -1.0) {
            southHeight = WidgetHelper.getPreferredSize(south).height;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            southHeight = (int) (height * layoutData.preferredSize);
          }
          height += southHeight;
          if (layoutData.hasDecoratorPanel()) {
            final DecoratorPanel decPanel = layoutData.decoratorPanel;
            height += (decPanel.getOffsetHeight() - south.getOffsetHeight());
          }
        }

        height += spacing;
      }

      Dimension westSize = null;

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

        if (layoutData.collapse) {
          width += WidgetHelper.getPreferredSize(westCollapsedImageButton).width;
        } else {
          int westWidth = (int) layoutData.preferredSize;
          if (layoutData.preferredSize == -1.0) {
            westWidth = WidgetHelper.getPreferredSize(west).width;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            westWidth = (int) (width * layoutData.preferredSize);
          }
          width += (int) Math.round(westWidth);
          if (layoutData.hasDecoratorPanel()) {
            final DecoratorPanel decPanel = layoutData.decoratorPanel;
            width += (decPanel.getOffsetWidth() - west.getOffsetWidth());
          }
        }

        width += spacing;
      }

      Dimension eastSize = null;

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

        if (layoutData.collapse) {
          width += WidgetHelper.getPreferredSize(eastCollapsedImageButton).width;
        } else {
          int eastWidth = (int) layoutData.preferredSize;
          if (layoutData.preferredSize == -1.0) {
            eastWidth = WidgetHelper.getPreferredSize(east).width;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            eastWidth = (int) (width * layoutData.preferredSize);
          }
          width += (int) Math.round(eastWidth);
          if (layoutData.hasDecoratorPanel()) {
            final DecoratorPanel decPanel = layoutData.decoratorPanel;
            width += (decPanel.getOffsetWidth() - east.getOffsetWidth());
          }
        }

        width += spacing;
      }

      Dimension centerSize = WidgetHelper.getPreferredSize(center);
      width += centerSize.width;

      if (west != null && westSize == null) {
        westSize = WidgetHelper.getPreferredSize(west);
      }
View Full Code Here

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

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

      final int width = box.width - (paddings[1] + paddings[3]);
      final int height = box.height - (paddings[0] + paddings[2]);

      final int spacing = layoutPanel.getWidgetSpacing();

      int left = paddings[3];
      int right = left + width;

      int top = paddings[0];
      int bottom = top + height;

      runTwiceFlag = false;

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

        if (layoutData.resizable && !layoutData.collapse) {
          if (northSplitBar == null) {
            northSplitBar = new SplitBar(layoutPanel, north, SplitBar.NORTH);
            northSplitBar.setStyleName("NorthSplitBar");
            layoutPanel.addImpl(northSplitBar);
          }
        } else {
          if (northSplitBar != null) {
            layoutPanel.removeImpl(northSplitBar);
            northSplitBar = null;
          }
        }

        int h = 0;

        if (layoutData.collapse) {
          if (northCollapsedImageButton == null) {
            northCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseDown());
            northCollapsedImageButton.addStyleName("NorthCollapsedImageButton");
            northCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(northCollapsed, false);
                layoutPanel.removeImpl(northCollapsedImageButton);
                northCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                northCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(northCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            northCollapsed = north;
            north.setVisible(false);
          }
          h = WidgetHelper.getPreferredSize(northCollapsedImageButton).height;
          WidgetHelper.setBounds(layoutPanel, northCollapsedImageButton, left,
              top, Math.max(0, right - left), h);
        } else {

          if (layoutData.preferredSize == -1.0) {
            h = WidgetHelper.getPreferredSize(north).height;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            h = (int) (height * layoutData.preferredSize);
          } else {
            h = (int) layoutData.preferredSize;
          }

          int _width = Math.max(0, right - left);
          int _height = -1;
          if (layoutData.preferredSize != -1.0) {
            _height = h;
          }

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, north);

            _width -= decPanelBorderSize.width;

            // increase 'h'
            h += decPanelBorderSize.height;
          }
          WidgetHelper.setBounds(layoutPanel, north, left, top, _width, _height);

          // 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 = (BorderLayoutData) getLayoutData(south);

        if (layoutData.resizable && !layoutData.collapse) {
          if (southSplitBar == null) {
            southSplitBar = new SplitBar(layoutPanel, south, SplitBar.SOUTH);
            southSplitBar.setStyleName("SouthSplitBar");
            layoutPanel.addImpl(southSplitBar);
          }
        } else {
          if (southSplitBar != null) {
            layoutPanel.removeImpl(southSplitBar);
            southSplitBar = null;
          }
        }

        int h = 0;

        if (layoutData.collapse) {
          if (southCollapsedImageButton == null) {
            southCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseUp());
            southCollapsedImageButton.addStyleName("SouthCollapsedImageButton");
            southCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(southCollapsed, false);
                layoutPanel.removeImpl(southCollapsedImageButton);
                southCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                southCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(southCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            southCollapsed = south;
            south.setVisible(false);
          }
          h = WidgetHelper.getPreferredSize(southCollapsedImageButton).height;
          WidgetHelper.setBounds(layoutPanel, southCollapsedImageButton, left,
              Math.max(0, bottom - h), Math.max(0, right - left), h);
        } else {
          if (layoutData.preferredSize == -1.0) {
            h = WidgetHelper.getPreferredSize(south).height;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            h = (int) (height * layoutData.preferredSize);
          } else {
            h = (int) layoutData.preferredSize;
          }

          int _width = Math.max(0, right - left);
          int _top = Math.max(0, bottom - h);
          int _height = -1;
          if (layoutData.preferredSize != -1.0) {
            _height = h;
          }

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, south);

            _width -= decPanelBorderSize.width;
            _top -= decPanelBorderSize.height;

            // increase 'h'
            h += decPanelBorderSize.height;
          }

          WidgetHelper.setBounds(layoutPanel, south, left, _top, _width,
              _height);

          // 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 = (BorderLayoutData) getLayoutData(west);

        if (layoutData.resizable && !layoutData.collapse) {
          if (westSplitBar == null) {
            westSplitBar = new SplitBar(layoutPanel, west, SplitBar.WEST);
            westSplitBar.setStyleName("WestSplitBar");
            layoutPanel.addImpl(westSplitBar);
          }
        } else {
          if (westSplitBar != null) {
            layoutPanel.removeImpl(westSplitBar);
            westSplitBar = null;
          }
        }

        int w = 0;

        if (layoutData.collapse) {
          if (westCollapsedImageButton == null) {
            westCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseRight());
            westCollapsedImageButton.addStyleName("WestCollapsedImageButton");
            westCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(westCollapsed, false);
                layoutPanel.removeImpl(westCollapsedImageButton);
                westCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                westCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(westCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            westCollapsed = west;
            west.setVisible(false);
          }
          w = WidgetHelper.getPreferredSize(westCollapsedImageButton).width;
          WidgetHelper.setBounds(layoutPanel, westCollapsedImageButton, left,
              top, w, Math.max(0, bottom - top));
        } else {
          if (layoutData.preferredSize == -1.0) {
            w = WidgetHelper.getPreferredSize(west).width;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            w = (int) (width * layoutData.preferredSize);
          } else {
            w = (int) layoutData.preferredSize;
          }

          int _width = -1;
          if (layoutData.preferredSize != -1.0) {
            _width = w;
          }
          int _height = Math.max(0, bottom - top);

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, west);

            _height -= decPanelBorderSize.height;

            // increase 'w'
            w += decPanelBorderSize.width;
          }

          WidgetHelper.setBounds(layoutPanel, west, left, top, _width, _height);

          // 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 = (BorderLayoutData) getLayoutData(east);

        if (layoutData.resizable && !layoutData.collapse) {
          if (eastSplitBar == null) {
            eastSplitBar = new SplitBar(layoutPanel, east, SplitBar.EAST);
            eastSplitBar.setStyleName("EastSplitBar");
            layoutPanel.addImpl(eastSplitBar);
          }
        } else {
          if (eastSplitBar != null) {
            layoutPanel.removeImpl(eastSplitBar);
            eastSplitBar = null;
          }
        }

        int w = 0;

        if (layoutData.collapse) {
          if (eastCollapsedImageButton == null) {
            eastCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseLeft());
            eastCollapsedImageButton.addStyleName("EastCollapsedImageButton");
            eastCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(eastCollapsed, false);
                layoutPanel.removeImpl(eastCollapsedImageButton);
                eastCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                eastCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(eastCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            eastCollapsed = east;
            east.setVisible(false);
          }
          w = WidgetHelper.getPreferredSize(eastCollapsedImageButton).width;
          WidgetHelper.setBounds(layoutPanel, eastCollapsedImageButton,
              Math.max(0, right - w), top, w, Math.max(0, bottom - top));
        } else {
          if (layoutData.preferredSize == -1.0) {
            w = WidgetHelper.getPreferredSize(east).width;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            w = (int) (width * layoutData.preferredSize);
          } else {
            w = (int) layoutData.preferredSize;
          }

          int _left = Math.max(0, right - w);
          int _width = -1;
          if (layoutData.preferredSize != -1.0) {
            _width = w;
          }
          int _height = Math.max(0, bottom - top);

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, east);

            _left -= decPanelBorderSize.width;
            _height -= decPanelBorderSize.height;

            // increase 'h'
            w += decPanelBorderSize.width;
          }
          WidgetHelper.setBounds(layoutPanel, east, _left, top, _width, _height);

          // 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);
      }

      int _width = Math.max(0, right - left);
      int _height = Math.max(0, bottom - top);

      BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(center);
      if (layoutData != null && layoutData.hasDecoratorPanel()) {
        final Dimension decPanelBorderSize = getDecoratorFrameSize(
            layoutData.decoratorPanel, center);
        _width -= decPanelBorderSize.width;
        _height -= decPanelBorderSize.height;
      }

View Full Code Here

   * @see
   * org.mosaic.ui.client.layout.LayoutManager#getPreferredSize(org.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 = (margins[1] + margins[3]) + (paddings[1] + paddings[3])
          + (borders[1] + borders[3]);
      int height = (margins[0] + margins[2]) + (paddings[0] + paddings[2])
          + (borders[0] + borders[2]);

      final int size = visibleWidgetCount;
      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;

      Dimension decPanelFrameSize = null;

      for (Iterator<Widget> iter = layoutPanel.iterator(); iter.hasNext();) {
        Widget child = iter.next();
        if (child instanceof DecoratorPanel) {
          child = ((DecoratorPanel) child).getWidget();
View Full Code Here

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

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

      final int spacing = layoutPanel.getWidgetSpacing();

      int width = box.width - (paddings[1] + paddings[3]);
      int height = box.height - (paddings[0] + paddings[2]);
      int left = paddings[3];
      int top = paddings[0];

      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;

      runTwiceFlag = false;

      final List<Widget> visibleChildList = new ArrayList<Widget>();

      Dimension decPanelFrameSize = null;

      // 1st pass
      for (Iterator<Widget> iter = layoutPanel.iterator(); iter.hasNext();) {
        Widget child = iter.next();
        if (child instanceof DecoratorPanel) {
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.