Java Code Examples for com.google.gwt.user.client.ui.Widget#getAbsoluteTop()

The following examples show how to use com.google.gwt.user.client.ui.Widget#getAbsoluteTop() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected int getContainerOffsetTop() {
	// if (containerOffsetTop < 0 || !sync) {
	// int scrollTop = 0;
	// Element parent = DOM.getParent(widget.getElement());
	// while (parent != null) {
	// if (getScrollTop(parent) > 0) {
	// scrollTop += getScrollTop(parent);
	// GWT.log("Scroll Top detected : " + scrollTop);
	// }
	// if ("relative".equals(DOM.getStyleAttribute(parent, "position"))) {
	// containerOffsetTop = DOM.getAbsoluteTop(parent) - scrollTop;
	// }
	// parent = DOM.getParent(parent);
	// }
	// }
	if (containerOffsetTop < 0 || !sync) {
		int top = 0;
		Widget parent = widget.getParent();
		while (parent != null && top == 0) {
			parent = parent.getParent();
			if (parent != null)
				top = parent.getAbsoluteTop();
		}
		containerOffsetTop = top;

		//containerOffsetTop = AdminPanel.get().getContent().getAbsoluteTop();
	}
	return containerOffsetTop;
}
 
Example 2
Source Project: gwt-material   File: UiHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static int calculateSpaceToBottom(Widget widget) {
    return Window.getClientHeight() - widget.getAbsoluteTop() - widget.getOffsetHeight();
}
 
Example 3
/**
 * Returns whether the specified widget contains a position given
 * by the absolute coordinates.
 *
 * @param w  widget to test
 * @param absX  absolute x coordinate of position
 * @param absY  absolute y coordinate of position
 * @return  {@code true} if the position is within the widget, {@code false}
 *          otherwise
 */
private static boolean isInside(Widget w, int absX, int absY) {
  int wx = w.getAbsoluteLeft();
  int wy = w.getAbsoluteTop();
  int ww = w.getOffsetWidth();
  int wh = w.getOffsetHeight();

  return (wx <= absX) && (absX < wx + ww) && (wy <= absY) && (absY < wy + wh);
}