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

The following are Jave code examples for showing how to use getOffsetHeight() of the com.google.gwt.user.client.ui.Widget class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: appinventor-extensions   File: MockComponentsUtil.java   Source Code and License Vote up 5 votes
/**
 * Returns the preferred size of the specified widget,
 * in an array of the form {@code [width, height]}.
 * <p>
 * It is assumed that:
 * <ul>
 *   <li>{@code w} has no parent</li>
 *   <li>{@code w} has not been configured to be invisible</li>
 * </ul>
 */
public static int[] getPreferredSizeOfDetachedWidget(Widget w) {
  // Attach the widget to the DOM, so that its preferred size is calculated correctly
  RootPanel.get().add(w);

  String[] style = clearSizeStyle(w);
  int width = w.getOffsetWidth() + 4;
  int height = w.getOffsetHeight();
  restoreSizeStyle(w, style);

  // Detach the widget from the DOM before returning
  RootPanel.get().remove(w);

  return new int[] { width, height };
}
 
Example 2
Project: empiria.player   File: WidgetSizeHelper.java   Source Code and License Vote up 4 votes
private Rectangle toRectangle(Widget widget) {
    return new Rectangle(widget.getAbsoluteLeft(), widget.getAbsoluteTop(), widget.getOffsetWidth(), widget.getOffsetHeight());
}
 
Example 3
Project: appinventor-extensions   File: DragSourceSupport.java   Source Code and License Vote up 3 votes
/**
 * 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);
}