Examples of BoxModel


Examples of gwt.mosaic.client.style.BoxModel

    int columnCount = columns.size();

    int width = getElement().getClientWidth();
    int height = getElement().getClientHeight();

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    // NOTE We cache column widths and row heights to make getColumnAt()
    // and getRowAt() more efficient
    columnWidths = getColumnWidths(width);
    rowHeights = getRowHeights(height, columnWidths);

    // Determine which rows and column should be visible so we know which
    // ones should be collapsed
    boolean[] visibleRows = new boolean[rowCount];
    boolean[] visibleColumns = new boolean[columnCount];

    boolean[][] occupiedCells = getOccupiedCells();
    for (int i = 0; i < rowCount; i++) {
      for (int j = 0; j < columnCount; j++) {
        if (occupiedCells[i][j]) {
          visibleRows[i] = true;
          visibleColumns[j] = true;
        }
      }
    }

    int widgetY = boxModel.getPadding().top;
    for (int i = 0; i < rowCount; i++) {
      Grid.Row row = rows.get(i);

      int widgetX = boxModel.getPadding().left;

      WidgetHelper.setLocation(row, 0, 0);
      WidgetHelper.setSize(row, width, 1);

      for (int j = 0, n = row.getWidgetCount(); j < n && j < columnCount; j++) {
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

    boolean[] defaultWidthColumns = new boolean[columnCount];
    int totalRelativeWeight = 0;
    int visibleColumnCount = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    int reservedWidth = boxModel.getPaddingWidthContribution();

    // First, we allocate the widths of non-relative columns. We store the
    // widths of relative columns as negative values for later processing

    for (int j = 0; j < columnCount; j++) {
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

    boolean[] defaultHeightRows = new boolean[rowCount];
    int totalRelativeWeight = 0;
    int visibleRowCount = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    int reservedHeight = boxModel.getPaddingHeightContribution();

    // First, we allocate the heights of non-relative rows. We store the
    // heights of relative rows as negative values for later processing

    for (int i = 0; i < rowCount; i++) {
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

        preferredHeight = Math.max(preferredHeight,
            preferredCardSize.height);
      }
    }

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    preferredWidth += boxModel.getWidthContribution();
    preferredHeight += boxModel.getHeightContribution();

    return (this.preferredSize = new Dimensions(preferredWidth,
        preferredHeight));
  }
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

  @Override
  protected void doLayout() {
    // Set the size of all widgets to match the size of the stack pane,
    // minus padding

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    int width = Math.max(
        getElement().getOffsetWidth()
            - boxModel.getPaddingWidthContribution(), 0);
    int height = Math.max(
        getElement().getClientHeight()
            - boxModel.getPaddingHeightContribution(), 0);

    int left = boxModel.getPadding().left;
    int top = boxModel.getPadding().top;
    for (Widget component : getChildren()) {
      if (component.isVisible()) {
        WidgetHelper.setLocation(component, left, top);
        WidgetHelper.setSize(component, width, height);
      }
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

    int maximumLabelWidth = 0;
    int maximumFieldWidth = 0;
    int maximumSeparatorWidth = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    for (int sectionIndex = 0, sectionCount = getWidgetCount(); sectionIndex < sectionCount; sectionIndex++) {
      Form.Section section = (Form.Section) getWidget(sectionIndex);

      if (sectionIndex > 0 || section.getHeading() != null) {
        Separator separator = section.separator;
        maximumSeparatorWidth = Math.max(maximumSeparatorWidth,
            WidgetHelper.getPreferredWidth(separator));
      }

      for (int fieldIndex = 0, fieldCount = section.getWidgetCount(); fieldIndex < fieldCount; fieldIndex++) {
        Form.Field fieldWidget = (Form.Field) section
            .getWidget(fieldIndex);
        Widget field = fieldWidget.getWidget(0);

        if (fieldWidget.isVisible()) {
          InlineLabel label = fieldWidget.labelWidget;
          maximumLabelWidth = Math.max(maximumLabelWidth,
              WidgetHelper.getPreferredWidth(label));

          int fieldWidth = WidgetHelper.getPreferredWidth(field, -1);

          // TODO if(showFlagMessagesInline) {}

          maximumFieldWidth = Math.max(maximumFieldWidth, fieldWidth);
        }
      }
    }

    preferredWidth = maximumLabelWidth + horizontalSpacing
        + maximumFieldWidth;

    // TODO if(showFlagIcons) {}

    preferredWidth = Math.max(maximumSeparatorWidth, preferredWidth
        + boxModel.getWidthContribution());

    return preferredWidth;
  }
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

  @Override
  public int getPreferredHeight(int width) {
    int preferredHeight = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    // Determine the field width constraint
    int fieldWidth = (fill && width != -1) ? getFieldWidth(width) : -1;

    for (int sectionIndex = 0, sectionCount = getWidgetCount(); sectionIndex < sectionCount; sectionIndex++) {
      Form.Section section = (Form.Section) getWidget(sectionIndex);

      if (sectionIndex > 0 || section.getHeading() != null) {
        Separator separator = section.separator;
        preferredHeight += WidgetHelper.getPreferredHeight(separator,
            width);
        preferredHeight += verticalSpacing;
      }

      for (int fieldIndex = 0, fieldCount = section.getWidgetCount(); fieldIndex < fieldCount; fieldIndex++) {
        Form.Field fieldWidget = (Form.Field) section
            .getWidget(fieldIndex);
        Widget field = fieldWidget.getWidget(0);

        if (fieldWidget.isVisible()) {
          // Determine the label size and baseline
          InlineLabel label = fieldWidget.labelWidget;
          Dimensions labelSize = WidgetHelper.getPreferredSize(label);
          int labelAscent = WidgetHelper.getBaseline(label,
              labelSize.width, labelSize.height);
          int labelDescent = labelSize.height - labelAscent;

          // Determine the field size and baseline
          Dimensions fieldSize;
          if (fill && fieldWidth != -1) {
            fieldSize = new Dimensions(fieldWidth,
                WidgetHelper.getPreferredHeight(field,
                    fieldWidth));
          } else {
            fieldSize = WidgetHelper.getPreferredSize(field);
          }

          int fieldAscent = WidgetHelper.getBaseline(field,
              fieldSize.width, fieldSize.height);
          if (fieldAscent == -1) {
            fieldAscent = fieldSize.height;
          }

          int fieldDescent = fieldSize.height - fieldAscent;

          // Determine the row height
          int maximumAscent = Math.max(labelAscent, fieldAscent);
          int maximumDescent = Math.max(labelDescent, fieldDescent);
          int rowHeight = maximumAscent + maximumDescent;

          preferredHeight += rowHeight;

          if (fieldIndex > 0) {
            preferredHeight += verticalSpacing;
          }
        }
      }
    }

    preferredHeight += boxModel.getHeightContribution();

    return preferredHeight;
  }
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

    int fieldWidth = (fill) ? getFieldWidth(width) : -1;

    int sectionCount = getWidgetCount();
    int sectionIndex = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    int rowY = 0;
    while (sectionIndex < sectionCount && baseline == -1) {
      Form.Section section = (Section) getWidget(sectionIndex);

      if (sectionIndex > 0 || section.getHeading() != null) {
        Separator separator = section.separator;
        rowY += WidgetHelper.getPreferredHeight(separator, width);
        rowY += verticalSpacing;
      }

      int fieldCount = section.getWidgetCount();
      int fieldIndex = 0;

      while (fieldIndex < fieldCount && baseline == -1) {
        Form.Field fieldWidget = (Form.Field) section
            .getWidget(fieldIndex);
        Widget field = fieldWidget.getWidget(0);

        if (fieldWidget.isVisible()) {
          // Determine the label size and baseline
          InlineLabel label = fieldWidget.labelWidget;
          Dimensions labelSize = WidgetHelper.getPreferredSize(label);
          int labelAscent = WidgetHelper.getBaseline(label,
              labelSize.width, labelSize.height);

          // Determine the field size and baseline
          Dimensions fieldSize;
          if (fill && fieldWidth != -1) {
            fieldSize = new Dimensions(fieldWidth,
                WidgetHelper.getPreferredHeight(field,
                    fieldWidth));
          } else {
            fieldSize = WidgetHelper.getPreferredSize(field);
          }

          int fieldAscent = WidgetHelper.getBaseline(field,
              fieldSize.width, fieldSize.height);
          if (fieldAscent == -1) {
            fieldAscent = labelAscent;
          }

          // Determine the baseline
          int maximumAscent = Math.max(labelAscent, fieldAscent);
          baseline = rowY + maximumAscent;
        }

        fieldIndex++;
      }

      sectionIndex++;
    }

    baseline += boxModel.getPadding().top;

    return baseline;
  }
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

  private int getFieldWidth(int width) {
    int maximumLabelWidth = 0;
    int maximumFlagMessageWidth = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    for (int sectionIndex = 0, sectionCount = getWidgetCount(); sectionIndex < sectionCount; sectionIndex++) {
      Form.Section section = (Form.Section) getWidget(sectionIndex);

      for (int fieldIndex = 0, fieldCount = section.getWidgetCount(); fieldIndex < fieldCount; fieldIndex++) {
        Form.Field fieldWidget = (Form.Field) section
            .getWidget(fieldIndex);
        // Widget field = fieldWidget.getWidget(0);

        if (fieldWidget.isVisible()) {
          InlineLabel label = fieldWidget.labelWidget;
          maximumLabelWidth = Math.max(maximumLabelWidth,
              WidgetHelper.getPreferredWidth(label));

          // TODO if (showFlagMessagesInline) {}
        }
      }
    }

    int fieldWidth = Math.max(0, width
        - (maximumLabelWidth + horizontalSpacing));

    // TODO if (showFlagIcons) {}

    // TODO if (showFlagMessagesInline) {}

    fieldWidth = Math.max(0,
        fieldWidth - boxModel.getPaddingWidthContribution());

    return fieldWidth;
  }
View Full Code Here

Examples of gwt.mosaic.client.style.BoxModel

  protected void doLayout() {
    // Determine the maximum label and flag message width
    int maximumLabelWidth = 0;
    int maximumFlagMessageWidth = 0;

    BoxModel boxModel = WidgetHelper.getBoxModel(this);

    for (int sectionIndex = 0, sectionCount = getWidgetCount(); sectionIndex < sectionCount; sectionIndex++) {
      Form.Section section = (Form.Section) getWidget(sectionIndex);

      for (int fieldIndex = 0, fieldCount = section.getWidgetCount(); fieldIndex < fieldCount; fieldIndex++) {
        Form.Field fieldWidget = (Form.Field) section
            .getWidget(fieldIndex);
        // Widget field = fieldWidget.getWidget(0);

        if (fieldWidget.isVisible()) {
          InlineLabel label = fieldWidget.labelWidget;
          maximumLabelWidth = Math.max(maximumLabelWidth,
              WidgetHelper.getPreferredWidth(label));

          // TODO if (showFlagMessagesInline) {}
        }
      }
    }

    // Determine the field width
    int width = getElement().getClientWidth();
    int fieldWidth = Math.max(0, width
        - (maximumLabelWidth + horizontalSpacing));

    // TODO if (showFlagIcons) {}

    // TODO if (showFlagMessagesInline) {}

    fieldWidth = Math.max(0,
        fieldWidth - boxModel.getPaddingWidthContribution());

    // Lay out the components
    int rowY = boxModel.getPadding().top;

    for (int sectionIndex = 0, sectionCount = getWidgetCount(); sectionIndex < sectionCount; sectionIndex++) {
      Form.Section section = (Form.Section) getWidget(sectionIndex);

      WidgetHelper.setSize(section, width, 1);
      WidgetHelper.setLocation(section, 0, 0);

      Separator separator = section.separator;
      if (sectionIndex > 0 || section.getHeading() != null) {
        int separatorWidth = Math.max(
            width - boxModel.getPaddingWidthContribution(), 0);
        separator.setVisible(true);
        int separatorHeight = WidgetHelper.getPreferredHeight(
            separator, separatorWidth);
        WidgetHelper
            .setSize(separator, separatorWidth, separatorHeight);
        WidgetHelper.setLocation(separator, boxModel.getPadding().left,
            rowY);
        rowY += separatorHeight;
      } else {
        separator.setVisible(false);
      }

      for (int fieldIndex = 0, fieldCount = section.getWidgetCount(); fieldIndex < fieldCount; fieldIndex++) {
        Form.Field fieldWidget = (Form.Field) section
            .getWidget(fieldIndex);
        Widget field = fieldWidget.getWidget(0);

        InlineLabel label = fieldWidget.labelWidget;

        WidgetHelper.setSize(fieldWidget, width, 1);
        WidgetHelper.setLocation(fieldWidget, 0, 0);

        if (fieldWidget.isVisible()) {
          // Show the label
          label.setVisible(true);

          // Determine the label size and baseline
          Dimensions labelSize = WidgetHelper.getPreferredSize(label);

          WidgetHelper.setSize(label, labelSize.width,
              labelSize.height);
          int labelAscent = WidgetHelper.getBaseline(label,
              labelSize.width, labelSize.height);
          int labelDescent = labelSize.height - labelAscent;

          // Determine the field size and baseline
          Dimensions fieldSize;
          if (fill) {
            fieldSize = new Dimensions(fieldWidth,
                WidgetHelper.getPreferredHeight(field,
                    fieldWidth));
          } else {
            fieldSize = WidgetHelper.getPreferredSize(field);
          }

          WidgetHelper.setSize(field, fieldSize.width,
              fieldSize.height);

          int fieldAscent = WidgetHelper.getBaseline(field,
              fieldSize.width, fieldSize.height);
          if (fieldAscent == -1) {
            fieldAscent = labelAscent;
          }

          int fieldDescent = fieldSize.height - fieldAscent;

          // Determine the baseline and row height
          int maximumAscent = Math.max(labelAscent, fieldAscent);
          int maximumDescent = Math.max(labelDescent, fieldDescent);

          int baseline = maximumAscent;
          int rowHeight = maximumAscent + maximumDescent;

          // Position the label
          int labelX = boxModel.getPadding().left;
          if (!leftAlignLabels) {
            labelX += maximumLabelWidth - labelSize.width;
          }

          // TODO if (showFlagIcons) {}

          int labelY = rowY + (baseline - labelAscent);
          WidgetHelper.setLocation(label, labelX, labelY);

          // Position the field
          int fieldX = boxModel.getPadding().left + maximumLabelWidth
              + horizontalSpacing;
          // TODO if (showFlagIcons) {}

          int fieldY = rowY + (baseline - fieldAscent);
          WidgetHelper.setLocation(field, fieldX, fieldY);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.