Пример #1
0
  /**
   * Returns the window's resizable instance.
   *
   * @return the resizable
   */
  public Resizable getResizable() {
    if (resizer == null && resizable) {
      resizer = new Resizable(this);
      resizer.setMinWidth(getMinWidth());
      resizer.setMinHeight(getMinHeight());
      resizer.addResizeListener(
          new ResizeListener() {

            @Override
            public void resizeEnd(final ResizeEvent re) {
              // end resize after event preview
              DeferredCommand.addCommand(
                  new Command() {
                    public void execute() {
                      onEndResize(re);
                    }
                  });
            }

            @Override
            public void resizeStart(ResizeEvent re) {
              onStartResize(re);
            }
          });
    }
    return resizer;
  }
Пример #2
0
  /**
   * Restores a maximized window back to its original size and position prior to being maximized and
   * also replaces the 'restore' tool button with the 'maximize' tool button.
   */
  public void restore() {
    if (maximized) {
      el().removeStyleName("x-window-maximized");
      if (maximizable) {
        restoreBtn.setVisible(false);
        maxBtn.setVisible(true);
      }
      if (restoreShadow != null && restoreShadow.booleanValue() && layer != null) {
        layer.enableShadow();
        restoreShadow = null;
      }
      if (draggable) {
        dragger.setEnabled(true);
      }
      if (resizable) {
        resizer.setEnabled(true);
      }
      head.addStyleName("x-window-draggable");
      if (restorePos != null) {
        setPosition(restorePos.x, restorePos.y);

        boolean cacheSizesRestore = cacheSizes;
        cacheSizes = false;
        setSize(restoreSize.width, restoreSize.height);
        cacheSizes = cacheSizesRestore;
      }
      if (container == null && restoreWindowScrolling != null) {
        com.google.gwt.dom.client.Document.get()
            .enableScrolling(restoreWindowScrolling.booleanValue());
        restoreWindowScrolling = null;
      }
      maximized = false;
      fireEvent(Events.Restore, new WindowEvent(this));
    }
  }
Пример #3
0
 /**
  * True to allow user resizing at each edge and corner of the window, false to disable resizing
  * (defaults to true).
  *
  * @param resizable true to enabled resizing
  */
 public void setResizable(boolean resizable) {
   this.resizable = resizable;
   if (resizable) {
     getResizable();
   } else if (resizer != null) {
     resizer.release();
     resizer = null;
   }
 }
Пример #4
0
  /**
   * Fits the window within its current container and automatically replaces the 'maximize' tool
   * button with the 'restore' tool button.
   */
  public void maximize() {
    if (!maximized) {
      restoreSize = getSize();
      restorePos = getPosition(true);
      restoreShadow = getShadow();
      if (container == null) {
        String bodyOverflow =
            com.google.gwt.dom.client.Document.get().isCSS1Compat()
                ? com.google.gwt.dom.client.Document.get()
                    .getDocumentElement()
                    .getStyle()
                    .getProperty("overflow")
                : com.google.gwt.dom.client.Document.get()
                    .getBody()
                    .getStyle()
                    .getProperty("overflow");
        if (!"hidden".equals(bodyOverflow)) {
          restoreWindowScrolling = true;
        }
        com.google.gwt.dom.client.Document.get().enableScrolling(false);
      }
      maximized = true;
      addStyleName("x-window-maximized");
      head.removeStyleName("x-window-draggable");
      if (layer != null) {
        layer.disableShadow();
      }

      boolean cacheSizesRestore = cacheSizes;
      cacheSizes = false;
      fitContainer();
      cacheSizes = cacheSizesRestore;

      if (maximizable) {
        maxBtn.setVisible(false);
        restoreBtn.setVisible(true);
      }
      if (draggable) {
        dragger.setEnabled(false);
      }
      if (resizable) {
        resizer.setEnabled(false);
      }

      fireEvent(Events.Maximize, new WindowEvent(this));
    } else {
      fitContainer();
    }
  }
Пример #5
0
 /**
  * The minimum width in pixels allowed for this window (defaults to 200). Only applies when
  * resizable = true.
  *
  * @param minWidth the minimum height
  */
 public void setMinWidth(int minWidth) {
   this.minWidth = minWidth;
   if (resizer != null) {
     resizer.setMinWidth(minWidth);
   }
 }
Пример #6
0
 /**
  * The minimum height in pixels allowed for this window (defaults to 100). Only applies when
  * resizable = true.
  *
  * @param minHeight the min height
  */
 public void setMinHeight(int minHeight) {
   this.minHeight = minHeight;
   if (resizer != null) {
     resizer.setMinHeight(minHeight);
   }
 }