Example usage for com.google.gwt.user.client.ui Widget getAbsoluteTop

List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteTop

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getAbsoluteTop.

Prototype

public int getAbsoluteTop() 

Source Link

Document

Gets the object's absolute top position in pixels, as measured from the browser window's client area.

Usage

From source file:com.seanchenxi.gwt.serenity.client.widget.PopupLabelBox.java

License:Apache License

public void showRelativeTo(Widget w) {
    show();// w  ww.ja v a2s .c om
    int top = w.getAbsoluteTop() - 20;
    int left = w.getAbsoluteLeft() + w.getOffsetWidth();
    setPopupPosition(left, top);
}

From source file:com.sencha.gxt.widget.core.client.container.PortalLayoutContainer.java

License:sencha.com license

private int getRow(int col, int y) {
    y += XDOM.getBodyScrollTop();/*  w ww  .ja  v  a 2s  . c o  m*/
    CssFloatLayoutContainer con = getWidget(col);
    int count = con.getWidgetCount();

    for (int i = 0; i < count; i++) {
        Widget c = con.getWidget(i);
        int b = c.getAbsoluteTop();
        int t = b + c.getOffsetHeight();

        if (y < t) {
            return i;
        }
    }

    return 0;
}

From source file:com.sencha.gxt.widget.core.client.container.PortalLayoutContainer.java

License:sencha.com license

private int getRowPosition(int col, int y) {
    y += XDOM.getBodyScrollTop();//w  w w  . j  a v a2  s . c o  m
    CssFloatLayoutContainer con = getWidget(col);
    List<Widget> list = new ArrayList<Widget>();
    for (int i = 0; i < con.getWidgetCount(); i++) {
        list.add(con.getWidget(i));
    }
    int count = list.size();

    for (int i = 0; i < count; i++) {
        Widget c = list.get(i);

        int b = c.getAbsoluteTop();
        int t = b + c.getOffsetHeight();
        int m = b + (c.getOffsetHeight() / 2);
        if (y < t) {
            if (y < m) {
                return i;
            } else {
                return i + 1;
            }
        }
    }
    return count;
}

From source file:com.threerings.gwt.ui.fx.MoveAnimation.java

License:Open Source License

protected MoveAnimation(Widget target) {
    _fromLeft = _toLeft = target.getAbsoluteLeft();
    _fromTop = _toTop = target.getAbsoluteTop();
}

From source file:com.threerings.gwt.ui.Popups.java

License:Open Source License

/**
 * Shows the supplied popup in the specified position relative to the specified target widget.
 *///from w  w w . ja  v  a  2  s .  c om
public static <T extends PopupPanel> T show(T popup, Position pos, Widget target) {
    popup.setVisible(false);
    popup.show();

    int left, top;
    switch (pos) {
    case RIGHT:
        left = target.getAbsoluteLeft() + target.getOffsetWidth() + NEAR_GAP;
        break;
    default:
        left = target.getAbsoluteLeft();
        break;
    }
    if (left + popup.getOffsetWidth() > Window.getClientWidth()) {
        left = Math.max(0, Window.getClientWidth() - popup.getOffsetWidth());
    }

    switch (pos) {
    case ABOVE:
        top = target.getAbsoluteTop() - popup.getOffsetHeight() - NEAR_GAP;
        break;
    case OVER:
        top = target.getAbsoluteTop();
        break;
    case RIGHT:
        top = target.getAbsoluteTop() + (target.getOffsetHeight() - popup.getOffsetHeight()) / 2;
        break;
    default:
    case BELOW:
        top = target.getAbsoluteTop() + target.getOffsetHeight() + NEAR_GAP;
        break;
    }

    popup.setPopupPosition(left, top);
    popup.setVisible(true);
    return popup;
}

From source file:com.threerings.gwt.ui.Popups.java

License:Open Source License

/**
 * Centers the supplied vertically on the supplied trigger widget. The popup's showing state
 * will be preserved.// ww  w . j av  a  2 s  .  c  o  m
 */
public static <T extends PopupPanel> T centerOn(T popup, Widget centerOn) {
    return centerOn(popup, centerOn.getAbsoluteTop() + centerOn.getOffsetHeight() / 2);
}

From source file:com.threerings.gwt.util.PopupStack.java

License:Open Source License

/**
 * Pushes any currently showing popup onto the stack and displays the supplied popup. The popup
 * will centered horizontally in the page and centered vertically around the supplied widget.
 *//* www.j a  va  2s. com*/
public void show(PopupPanel popup, Widget onCenter) {
    // determine the ypos of our onCenter target in case it's in the currently popped up popup,
    // because after we hide that popup we won't be able to compute it
    int ypos = (onCenter == null) ? 0 : (onCenter.getAbsoluteTop() + onCenter.getOffsetHeight() / 2);

    PopupPanel showing = _showingPopup.get();
    if (showing != null) {
        // null _showingPopup before hiding to avoid triggering the close handler logic
        _popups.add(showing);
        _showingPopup.update(null);
        showing.hide(true);
    }

    if (onCenter == null) {
        popup.center(); // this will show the popup
    } else {
        Popups.centerOn(popup, ypos).show();
    }

    // now that we've centered and shown our popup (which may have involved showing, hiding and
    // showing it again), we can add a close handler and listen for it to actually close
    popup.addCloseHandler(new CloseHandler<PopupPanel>() {
        public void onClose(CloseEvent<PopupPanel> event) {
            if (_showingPopup.get() == event.getTarget()) {
                if (_popups.size() > 0) {
                    _showingPopup.update(_popups.remove(_popups.size() - 1));
                    _showingPopup.get().show();
                } else {
                    _showingPopup.update(null);
                }
            }
        }
    });
    _showingPopup.update(popup);
}

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Scrolls the window to place the specified target widget at the top (or as close as possible
 * given the height of the browser)./*w  w  w.  j ava2 s.  c o m*/
 */
public static void scrollTo(Widget target) {
    Window.scrollTo(Window.getScrollLeft(), target.getAbsoluteTop());
}

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Returns the vertical scroll position needed to place the specified target widget in view,
 * while trying to minimize scrolling./*from  w w  w.  ja  v a 2s  .c o m*/
 */
public static int getScrollIntoView(Widget target) {
    int top = Window.getScrollTop(), height = Window.getClientHeight();
    int ttop = target.getAbsoluteTop(), theight = target.getOffsetHeight();
    // if the target widget is taller than the browser window, or is above the current scroll
    // position of the browser window, scroll the top of the widget to the top of the window
    if (theight > height || ttop < top) {
        return ttop;
        // otherwise scroll the bottom of the widget to the bottom of the window
    } else if (ttop + theight > top + height) {
        return ttop - (height - theight);
    } else {
        return top; // no scrolling needed
    }
}

From source file:com.threerings.gwt.util.WindowUtil.java

License:Open Source License

/**
 * Returns the vertical scroll position needed to center the target widget vertically in the
 * browser viewport. If the widget is taller than the viewport, its top is returned.
 *///w w  w  . ja v a2  s .c o m
public static int getScrollToMiddle(Widget target) {
    int wheight = Window.getClientHeight(), theight = target.getOffsetHeight();
    int ttop = target.getAbsoluteTop();
    return Math.max(ttop, ttop + (wheight - theight));
}