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() .
Example 1
Project: document-management-software   File: AbstractShape.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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
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
Project: appinventor-extensions   File: DragSourceSupport.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}