コード例 #1
0
  // javadoc inherited.
  protected void layout(Composite composite, boolean flushCache) {
    Control[] children = composite.getChildren();

    if (flushCache || sizes == null || sizes.length != children.length) {
      initialize(children);
    }
    int x = marginWidth;
    int y = marginHeight;

    // Get the maximum width of the composite's client area (used to allow
    // the control in the last column to fill the rest of the space).
    final int width = getWidth(composite, SWT.DEFAULT);

    for (int i = 0; i < children.length; i++) {
      final Control child = children[i];
      if (child.getVisible()) {
        int labelVOffset = 0;
        boolean span = getColumnSpan(child) > 1;

        int col = getColumnIndex(child, span);
        if (child instanceof Label) {
          // Non-label control should be next in the sizes array.
          int index = i >= sizes.length ? i : i + 1;
          labelVOffset = (sizes[index].y - sizes[i].y) / 2;
        }

        // Determine if we need to move to the next row, handle spanning
        // and fill in space for the last column.
        if (col == (numberOfColumns - 1)) {
          int fillWidth = width - getOtherColumnsWidth(numberOfColumns - 1);
          fillWidth = fillWidth < 0 ? columnWidth[col] : fillWidth;
          child.setBounds(x, y + labelVOffset, fillWidth, sizes[i].y);

          // Bump up the row offset and reset the column offset.
          y += getControlHeight(child, sizes[i].y);
          x = marginWidth;
        } else {
          // If we span then this control takes up all the rest of the
          // columns horizontal real estate.
          int otherColumnsWidth = getOtherColumnsWidth(col - 1);
          int colWidth = span ? width - otherColumnsWidth : columnWidth[col];

          child.setBounds(x, y + labelVOffset, colWidth, sizes[i].y);

          if (span) {
            y += getControlHeight(child, sizes[i].y);
          } else {
            x += colWidth;
          }
        }
      }
    }
  }
コード例 #2
0
ファイル: FocusUtility.java プロジェクト: judithgull/scout.rt
  public static boolean isFocusable(Control control) {
    if (control == null) {
      return false;
    }

    boolean takesFocus = (control.getStyle() & SWT.NO_FOCUS) == 0;
    if (!takesFocus) {
      return false;
    }

    boolean visible = control.getVisible();
    IPropertyObserver model = RwtScoutComposite.getScoutModelOnWidget(control);
    if (model instanceof IFormField) {
      IFormField field = ((IFormField) model);
      visible &= field.isVisible() && areParentsVisible(field);
    }

    return visible;
  }