Java Code Examples for com.google.gwt.user.client.Window.getClientHeight()

The following are Jave code examples for showing how to use getClientHeight() of the com.google.gwt.user.client.Window class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: unitimes   File: FilterBox.java   View Source Code Vote up 6 votes
private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) {
	int textBoxOffsetWidth = relativeObject.getOffsetWidth();
	int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;
	int left = relativeObject.getAbsoluteLeft();
	if (offsetWidthDiff > 0) {
		int windowRight = Window.getClientWidth() + Window.getScrollLeft();
		int windowLeft = Window.getScrollLeft();
		int distanceToWindowRight = windowRight - left;
		int distanceFromWindowLeft = left - windowLeft;
		if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
			left -= offsetWidthDiff;
		}
	}
	int top = relativeObject.getAbsoluteTop();
	int windowTop = Window.getScrollTop();
	int windowBottom = Window.getScrollTop() + Window.getClientHeight();
	int distanceFromWindowTop = top - windowTop;
	int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight());
	if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) {
		top -= offsetHeight;
	} else {
		top += relativeObject.getOffsetHeight();
	}
	setPopupPosition(left, top);
}
 
Example 2
Project: unitimes   File: AddMeetingsDialog.java   View Source Code Vote up 6 votes
public void recenter() {
	GwtHint.getInstance().hide();
	
	iScrollRooms.getElement().getStyle().clearHeight();
	if (getElement().getClientHeight() > Window.getClientHeight() - 100)
		iScrollRooms.getElement().getStyle().setHeight(Window.getClientHeight() - 200, Unit.PX);
	
	iScrollDates.getElement().getStyle().clearHeight();
	if (getElement().getClientHeight() > Window.getClientHeight() - 100) {
		iScrollDates.getElement().getStyle().setHeight(Window.getClientHeight() - 200, Unit.PX);
	}

	int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
    int top = (Window.getClientHeight() - getOffsetHeight()) >> 1;
	setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max( Window.getScrollTop() + top, 0));
}
 
Example 3
Project: empiria.player   File: OperationMessageManager.java   View Source Code Vote up 5 votes
public int findNextMessageYPosition() {
    int y = Window.getClientHeight();
    for (OperationMessage currMsg : messages) {
        if (currMsg.isAttached()) {
            if (currMsg.getAbsoluteTop() < y)
                y = currMsg.getAbsoluteTop();
        }
    }
    return y;
}
 
Example 4
Project: empiria.player   File: ViewportHelper.java   View Source Code Vote up 4 votes
Rectangle getViewport() {
    return new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
}
 
Example 5
Project: unitimes   File: AddMeetingsDialog.java   View Source Code Vote up 4 votes
@Override
public void setVisible(boolean visible) {
	super.setVisible(visible);
	if (visible && getElement().getClientHeight() > Window.getClientHeight() - 100)
		recenter();
}
 
Example 6
Project: appinventor-extensions   File: DropDownButton.java   View Source Code Vote up 4 votes
/**
 * @param offsetWidth width of the ContextMenu being positioned on the parent element
 * @param offsetHeight height of the ContextMenu being positioned on the parent element
 * Sets the position of the ContextMenu on the screen given it's dimensions
 */
@Override
public void setPosition(int offsetWidth, int offsetHeight) {

  // getAbsoluteLeft/Right() gives the top coordinate of the parent element
  // getOffsetWidth/Height() gives the width/height of the parent element
  int left = Window.Navigator.getUserAgent().contains("Chrome") && isPinchZoomed()
          ? getTrueAbsoluteLeft() : getAbsoluteLeft();

  if (rightAlign) {
    left += getOffsetWidth() - offsetWidth;
  }

  int top = Window.Navigator.getUserAgent().contains("Chrome") && isPinchZoomed()
          ? getTrueAbsoluteTop() + getOffsetHeight()
          : getAbsoluteTop() + getOffsetHeight();

  // Values to determine how to display the ContextMenu - above or below

  int dropDownBottom = top + offsetHeight;
  int screenBottom  = Window.getScrollTop()+Window.getClientHeight();

  // if the bottom will go off the current browser screen, display
  // the dropdown as a 'dropup' where the ContextMenu appears
  // above instead

  if(dropDownBottom > screenBottom) {
      int newTop = Window.Navigator.getUserAgent().contains("Chrome") && isPinchZoomed()
        ? getTrueAbsoluteTop() -offsetHeight
        : getAbsoluteTop() - offsetHeight;

      // account for the extreeeemely unlikely case where newTop
      // also goes off the screen in this case, it makes more
      // sense to just go off the bottom of the screen (the screen
      // won't grow up, and so the menu would get completely cut
      // off at the top

      if(newTop >= 0) {
          top = newTop;
      }
  }

  menu.setPopupPosition(left, top);

}