Example #1
0
 /**
  * Show on the right of the provided widget
  *
  * @param widget
  */
 public void showEastOf(Widget widget, String text) {
   init(text);
   clearStyleDependentName();
   addStyleDependentName(WEST);
   show();
   if (this.getOffsetWidth() + widget.getOffsetWidth() + widget.getAbsoluteLeft()
       > Window.getClientWidth()) {
     showNorthOf(widget, text);
     return;
   }
   int top = widget.getAbsoluteTop() - ((this.getOffsetHeight() - widget.getOffsetHeight()) / 2);
   int left = widget.getAbsoluteLeft() + widget.getOffsetWidth() + 1;
   moveTo(top, left);
 }
  @Override
  protected Widget newPositioner(DragContext context) {
    // Use two widgets so that setPixelSize() consistently affects dimensions
    // excluding positioner border in quirks and strict modes
    SimplePanel outer = new SimplePanel();
    outer.addStyleName(DragClientBundle.INSTANCE.css().positioner());

    // place off screen for border calculation
    RootPanel.get().add(outer, -500, -500);

    // Ensure IE quirks mode returns valid outer.offsetHeight, and thus valid
    // DOMUtil.getVerticalBorders(outer)
    outer.setWidget(DUMMY_LABEL_IE_QUIRKS_MODE_OFFSET_HEIGHT);

    int width = 0;
    int height = 0;
    for (Widget widget : context.selectedWidgets) {
      width = Math.max(width, widget.getOffsetWidth());
      height += widget.getOffsetHeight();
    }

    SimplePanel inner = new SimplePanel();
    inner.setPixelSize(
        width - DOMUtil.getHorizontalBorders(outer), height - DOMUtil.getVerticalBorders(outer));

    outer.setWidget(inner);

    return outer;
  }
 @Override
 public void onResize() {
   // It is possible that the SplitterPanel is removed from the DOM before the resize is called
   if (isAttached()) {
     final Widget parent = getParent();
     setPixelSize(parent.getOffsetWidth(), parent.getOffsetHeight());
     super.onResize();
   }
 }
Example #4
0
 /**
  * Show bellow the provided widget
  *
  * @param widget
  */
 public void showSouthOf(Widget widget, String text) {
   init(text);
   clearStyleDependentName();
   addStyleDependentName(NORTH);
   show();
   int top = widget.getAbsoluteTop() + widget.getOffsetHeight();
   int left = widget.getAbsoluteLeft() - ((this.getOffsetWidth() - widget.getOffsetWidth()) / 2);
   moveTo(top, left);
 }
 @Override
 public void onResize() {
   final Widget parent = getParent();
   if (parent != null) {
     final int width = parent.getOffsetWidth();
     final int height = parent.getOffsetHeight();
     setPixelSize(width, height);
     presenter.onResize(width, height);
     panel.setPixelSize(width, height);
     super.onResize();
   }
 }
Example #6
0
  /**
   * Determine if the given click was inside the boundaries of the given widget.
   *
   * @param pWidget the widget
   * @param pClickEvent the click
   * @return <code>true</code> if yes
   */
  public static boolean isInside(final Widget pWidget, final ClickEvent pClickEvent) {
    LOG.enter("isInside"); // $NON-NLS-1$

    boolean result = false;
    final int cx = pClickEvent.getClientX();
    final int cy = pClickEvent.getClientY();
    final int wleft = pWidget.getAbsoluteLeft();
    final int wtop = pWidget.getAbsoluteTop();

    if (LOG.isDetailEnabled()) {
      LOG.detail(
          "isInside", //$NON-NLS-1$
          "Click at ("
              + cx
              + ','
              + cy //$NON-NLS-1$
              + "), widget pos ("
              + wleft
              + ','
              + wtop //$NON-NLS-1$
              + "), widget dims ["
              + pWidget.getOffsetWidth()
              + ',' //$NON-NLS-1$
              + pWidget.getOffsetHeight()
              + ']');
    }
    if (cx >= wleft
        && cy >= wtop
        && cx < wleft + pWidget.getOffsetWidth()
        && cy < wtop + pWidget.getOffsetHeight()) {
      result = true;
    }

    LOG.exit("isInside", Boolean.valueOf(result)); // $NON-NLS-1$
    return result;
  }
Example #7
0
 @Override
 public void onResize(ResizeEvent event) {
   if (receptor != null) {
     Element elem = simplePanel.getElement();
     DOM.setStyleAttribute(
         elem, "left", receptor.getAbsoluteLeft() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(
         elem, "top", receptor.getAbsoluteTop() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(
         elem, "width", receptor.getOffsetWidth() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(
         elem, "height", receptor.getOffsetHeight() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(elem, "position", "absolute"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(elem, "zIndex", "1005"); // $NON-NLS-1$ //$NON-NLS-2$
   }
 }
  public FirstPersonControls(Object3D object, Widget widget) {
    super(object, widget);

    this.viewHalfX = widget.getOffsetWidth() / 2;
    this.viewHalfY = widget.getOffsetHeight() / 2;

    if (getWidget().getClass() != RootPanel.class)
      getWidget().getElement().setAttribute("tabindex", "-1");

    this.target = new Vector3();

    getWidget().addDomHandler(this, ContextMenuEvent.getType());

    getWidget().addDomHandler(this, MouseMoveEvent.getType());
    getWidget().addDomHandler(this, MouseDownEvent.getType());
    getWidget().addDomHandler(this, MouseUpEvent.getType());
    RootPanel.get().addDomHandler(this, KeyDownEvent.getType());
    RootPanel.get().addDomHandler(this, KeyUpEvent.getType());
  }
Example #9
0
  public WidgetArea(Widget widget, Widget reference) {
    setLeft(widget.getAbsoluteLeft());
    setTop(widget.getAbsoluteTop());

    if (reference != null) {
      setLeft(
          getLeft() - reference.getAbsoluteLeft() - DOMUtil.getBorderLeft(reference.getElement()));
      setTop(getTop() - reference.getAbsoluteTop() - DOMUtil.getBorderTop(reference.getElement()));
    }
    setRight(getLeft() + widget.getOffsetWidth());
    setBottom(getTop() + widget.getOffsetHeight());

    Element elem = widget.getElement().getOffsetParent();
    Element p;

    while (elem != null && (p = elem.getOffsetParent()) != null) {
      int left = elem.getAbsoluteLeft();

      if (getLeft() < left) {
        setLeft(left);
      }

      int top = elem.getAbsoluteTop();
      if (getTop() < top) {
        setTop(top);
      }

      int bottom = top + elem.getOffsetHeight();
      if (getBottom() > bottom) {
        setBottom(bottom);
      }

      int right = left + elem.getOffsetWidth();
      if (getRight() > right) {
        setRight(right);
      }

      elem = p;
    }
  }
Example #10
0
  public void attachWidgetToMouse(
      MouseDownEvent event,
      Widget w,
      MouseMoveHandler mouseMoveHandler,
      MouseUpHandler mouseUpHandler) {
    this.mouseMoveHandler = mouseMoveHandler;
    this.mouseUpHandler = mouseUpHandler;
    if (widget == w) return;

    clearWidgetFromMouse();
    widget = w;

    if (widget != null) {
      height = w.getOffsetHeight();
      width = w.getOffsetWidth();
      offsetX = event.getRelativeX(w.getElement());
      offsetY = event.getRelativeY(w.getElement());
      parent.add(widget);
      parent.setWidgetTopHeight(widget, event.getClientY() - offsetY, Unit.PX, height, Unit.PX);
      parent.setWidgetLeftWidth(widget, event.getClientX() - offsetX, Unit.PX, width, Unit.PX);
      attachHandlers();
    }
  }
Example #11
0
 public void showAndAdapt(Widget w) {
   receptor = w;
   show(w.getAbsoluteLeft(), w.getAbsoluteTop(), w.getOffsetWidth(), w.getOffsetHeight());
 }
Example #12
0
 public void show(Widget w) {
   show(w.getAbsoluteLeft(), w.getAbsoluteTop(), w.getOffsetWidth(), w.getOffsetHeight());
 }
 @Override
 public Point2D getTopRightLocation() {
   Widget w = rootPanel;
   return new Point2D(w.getAbsoluteLeft() + w.getOffsetWidth(), w.getAbsoluteTop());
 }