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

The following examples show how to use com.google.gwt.user.client.ui.Widget#getOffsetHeight() .
Example 1
Project: appinventor-extensions   File: MockComponentsUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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() + 6;
  if (height < 26) {          // Do not make the button smaller
    height = 26;              // then 26, as this mimicks what happens
  }                           // on the real device
  restoreSizeStyle(w, style);

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

  return new int[] { width, height };
}
 
Example 2
Project: djvu-html5   File: Djvu_html5.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void resizeCanvas() {
	Widget panel = canvas.getParent();
	int width = panel.getOffsetWidth();
	int height = panel.getOffsetHeight();
	canvas.setWidth(width + "px");
	canvas.setCoordinateSpaceWidth(width);
	canvas.setHeight(height + "px");
	canvas.setCoordinateSpaceHeight(height);
	if (pageLayout != null)
		pageLayout.canvasResized();
}
 
Example 3
Project: consulo   File: GwtVerticalSplitLayoutImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected int getElementSize(Widget widget) {
  int offsetHeight = widget.getOffsetHeight();
  if(offsetHeight == 0) {
    offsetHeight = Window.getClientHeight();
  }
  return offsetHeight;
}
 
Example 4
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 5
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);
}