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() . 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
Source File: AbstractShape.java    From document-management-software with 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
Source File: UiHelper.java    From gwt-material with 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
Source File: DragSourceSupport.java    From appinventor-extensions with 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);
}