Пример #1
0
 private void updatePreviewSize() {
   Point minSize;
   Rectangle bounds = scroll.getClientArea();
   if (preview.isFitHorizontal()) {
     if (preview.isFitVertical()) minSize = new Point(0, 0); // Best fit
     else minSize = new Point(0, preview.computeSize(bounds.width, SWT.DEFAULT).y); // Fit to width
   } else {
     if (preview.isFitVertical())
       minSize = new Point(preview.computeSize(SWT.DEFAULT, bounds.height).x, 0); // Fit to height
     else minSize = preview.computeSize(SWT.DEFAULT, SWT.DEFAULT); // Custom
     // scale
   }
   scroll.setMinSize(minSize);
 }
  /**
   * Resizes the Section's client and updates the Property Viewer's {@link ScrolledComposite} to
   * account for GridLayouts in the client.
   */
  private void resizePropertyView() {
    // Disable re-drawing for the ScrolledComposite.
    scrollComposite.setRedraw(false);

    int verticalPadding = scrollComposite.getHorizontalBar().getSize().y;
    int horizontalPadding = scrollComposite.getVerticalBar().getSize().x;
    Rectangle clientArea = scrollComposite.getClientArea();
    Point clientAreaSize =
        new Point(clientArea.width - horizontalPadding, clientArea.height - verticalPadding);

    // Recompute the size of the first Composite in the ScrolledComposite
    // based on the width of the ScrolledComposite's client area.
    Point size = scrollCompositeClient.computeSize(clientAreaSize.x, clientAreaSize.y);

    // Update the size of the ScrolledComposite's client.
    scrollCompositeClient.setSize(size);

    // Set the minimum size at which the ScrolledComposite will start
    // drawing scroll bars. This should be the size of its client area minus
    // the spaces the scroll bars would consume.
    scrollComposite.setMinSize(clientAreaSize.x + 1, clientAreaSize.y + 1);

    // We need to call layout() so the ScrolledComposite will update.
    scrollComposite.layout();

    // Set the height hint for the Section's parent Composite. This keeps
    // the TableViewer from going beyond the bottom edge of the Properties
    // Viewer. We want to keep the add and delete buttons visible, and the
    // TableViewer already has its own scroll bars!
    Composite sectionParent = section.getParent();
    GridData gridData = (GridData) sectionParent.getLayoutData();
    GridLayout gridLayout = (GridLayout) sectionParent.getParent().getLayout();
    gridData.heightHint = sectionParent.getParent().getSize().y - gridLayout.marginTop;

    // The parent of the Section has a FillLayout. Its parent has a
    // GridLayout, but sometimes it does not update. Tell it to layout so
    // the Section's parent will update its size.
    section.getParent().getParent().layout();

    // Enable re-drawing for the ScrolledComposite.
    scrollComposite.setRedraw(true);

    return;
  }
  /**
   * When any <code>ProgressReporterPanel</code> in this window is expanded or collapsed re-layout
   * the controls and window appropriately
   */
  public void isCollapsed(boolean value) {
    if (null != shell && false == shell.isDisposed()) {
      scrollable.setRedraw(false);
      Rectangle r = scrollable.getClientArea();
      scrollable.setMinSize(scrollChild.computeSize(r.width, SWT.DEFAULT));

      /*
       * Resizing to fit the panel if there is only one
       */
      if (pReporters.length == 1) {
        Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);
        if (shell.getSize().y != p.y) {
          p.x = shell.getSize().x;
          shell.setSize(p);
        }
      }

      scrollable.layout();
      scrollable.setRedraw(true);
    }
  }
Пример #4
0
 private static void layout(Emoticon emo) {
   emo.frames.layout();
   Rectangle r = emoticonsScroll.getClientArea();
   emoticonsScroll.setMinSize(emoticonsComposite.computeSize(r.width, SWT.DEFAULT));
 }