Example usage for com.google.gwt.dom.client Document getBodyOffsetLeft

List of usage examples for com.google.gwt.dom.client Document getBodyOffsetLeft

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Document getBodyOffsetLeft.

Prototype

public int getBodyOffsetLeft() 

Source Link

Usage

From source file:com.bfr.client.selection.RangeEndPoint.java

License:Apache License

public static RangeEndPoint findLocation(Element element, int absX, int absY) {
    // Convert to document-relative coordinates
    Document doc = element.getOwnerDocument();
    int relX = absX - doc.getBodyOffsetLeft();
    int offY = getTotalOffsetY(doc);
    int relY = absY + offY;

    if (spn == null) {
        spn = doc.createSpanElement();//  www  .  ja v a2 s. c  om
        spn.setInnerText("X");
    }
    Element body = doc.getBody();
    body.appendChild(spn);
    spn.getStyle().setPosition(Position.ABSOLUTE);
    spn.getStyle().setTop(relY, Unit.PX);
    spn.getStyle().setLeft(relX, Unit.PX);

    FindLocRes locRes = findLocation(doc, element, relX, relY);

    return (locRes == null) ? null : locRes.ep;
}

From source file:org.cruxframework.crux.smartfaces.client.dialog.PopupPanel.java

License:Apache License

/**
 * Sets the popup's position relative to the browser's client area. The
 * popup's position may be set before calling {@link #show()}.
 * /*from w  ww . jav a2  s.  c om*/
 * @param left
 *            the left position, in pixels
 * @param top
 *            the top position, in pixels
 */
public void setPosition(int left, int top) {
    if (centered) {
        uncentralizeMe();
    }

    // Account for the difference between absolute position and the
    // body's positioning context.
    Document document = Document.get();
    left -= document.getBodyOffsetLeft();
    top -= document.getBodyOffsetTop();

    this.left = left;
    this.top = top;
    setPopupPositionStyle(left, top);
}