List of usage examples for com.google.gwt.user.client.ui UIObject getOffsetHeight
public int getOffsetHeight()
From source file:org.openremote.app.client.widget.PopupPanel.java
License:Apache License
/** * Positions the popup, called after the offset width and height of the popup * are known./* w w w.j ava2 s . c om*/ * * @param relativeObject the ui object to position relative to * @param offsetWidth the drop down's offset width * @param offsetHeight the drop down's offset height */ private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) { // Calculate left position for the popup. The computation for // the left position is bidi-sensitive. int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left; if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft(); // Right-align the popup. Note that this computation is // valid in the case where offsetWidthDiff is negative. left = textBoxAbsoluteLeft - offsetWidthDiff; // If the suggestion popup is not as wide as the text box, always // align to the right edge of the text box. Otherwise, figure out whether // to right-align or left-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Compute the left value for the right edge of the textbox int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth; // Distance from the right edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge; // Distance from the right edge of the text box to the left edge of the // window int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of the text box and there IS enough space for the // overflow to the right of the text box, then left-align the popup. // However, if there is not enough space on either side, stick with // right-alignment. if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) { // Align with the left edge of the text box. left = textBoxAbsoluteLeft; } } } else { // LTR case // Left-align the popup. left = relativeObject.getAbsoluteLeft(); // If the suggestion popup is not as wide as the text box, always align to // the left edge of the text box. Otherwise, figure out whether to // left-align or right-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Distance from the left edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge of the // window int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of hte text box, and there IS enough space for the // overflow to the left of the text box, then right-align the popup. // However, if there is not enough space on either side, then stick with // left-alignment. if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { // Align with the right edge of the text box. left -= offsetWidthDiff; } } } // Calculate top position for the popup int top = relativeObject.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); // If there is not enough space for the popup's height below the text // box and there IS enough space for the popup's height above the text // box, then position the popup above the text box. However, if there // is not enough space on either side, then stick with displaying the // popup below the text box. if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { // Position above the text box top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }
From source file:org.openremote.manager.client.widget.AbstractAppPanel.java
License:Open Source License
public void showBottomRightOf(UIObject bottomRightTarget, int marginRight, int marginBottom) { this.bottomRightTarget = bottomRightTarget; this.marginRight = marginRight; this.marginBottom = marginBottom; getPopupPanel().setPopupPositionAndShow((offsetWidth, offsetHeight) -> { int bottom = bottomRightTarget.getAbsoluteTop() + bottomRightTarget.getOffsetHeight(); int right = bottomRightTarget.getAbsoluteLeft() + bottomRightTarget.getOffsetWidth(); int top = bottom - offsetHeight - marginBottom; int left = right - offsetWidth - marginRight; getPopupPanel().setPopupPosition(left, top); });/*from www. j ava2 s . com*/ }
From source file:org.pepstock.jem.gwt.client.commons.UITools.java
License:Open Source License
/** * Simple tool to used to know if a Widget is visible, and if it is in foreground * @param object/* ww w . jav a2s . c o m*/ * @return <code>true</code> if the parameter is visible and in foreground */ public static boolean isInForegroundVisible(UIObject object) { return object.isVisible() && object.getOffsetWidth() > 0 && object.getOffsetHeight() > 0; }
From source file:org.roda.wui.client.common.popup.CalloutPopup.java
private Pair<Integer, Integer> getBottomRight(UIObject target, int offsetWidth, int offsetHeight) { int left = target.getAbsoluteLeft() + target.getOffsetWidth() / 2 - offsetWidth + ARROW_OFFSET_PX; int top = target.getAbsoluteTop() - offsetHeight - MARGIN_FROM_TARGET_PX; // change top value if popup top disappears of the page (goes to bottom) if (top < 0) { top = target.getAbsoluteTop() + target.getOffsetHeight() + MARGIN_FROM_TARGET_PX; addStyleDependentName(CalloutPosition.TOP_RIGHT.name().toLowerCase()); } else {//from w w w . j a v a 2 s . c o m addStyleDependentName(CalloutPosition.BOTTOM_RIGHT.name().toLowerCase()); } return Pair.of(left, top); }
From source file:org.roda.wui.client.common.popup.CalloutPopup.java
private Pair<Integer, Integer> getTopRight(UIObject target, int offsetWidth, int offsetHeight) { int left = target.getAbsoluteLeft() + target.getOffsetWidth() / 2 - offsetWidth + ARROW_OFFSET_PX; int top = target.getAbsoluteTop() + target.getOffsetHeight() + MARGIN_FROM_TARGET_PX; addStyleDependentName(CalloutPosition.TOP_RIGHT.name().toLowerCase()); return Pair.of(left, top); }